-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
73 lines (55 loc) · 2.03 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# Update and upgrade system packages
sudo apt-get update
sudo apt-get upgrade -y
# Prompt the user to choose whether it's for master or slave
read -p "Is this setup for the master or a slave? (master/slave): " target
# Define the source and destination directories based on the user's choice
if [[ "$target" == "master" ]]; then
source_dir="./master-raspberry/config"
echo "Installing Docker and docker-compose..."
# Install Docker
curl -sSL https://get.docker.com | sh
sudo usermod -aG docker pi
# Install docker-compose
sudo apt-get install -y libffi-dev libssl-dev
sudo apt-get install -y python python-pip
sudo apt-get install -y python3 docker-compose
elif [[ "$target" == "slave" ]]; then
source_dir="./slave-raspberry/config"
else
echo "Invalid choice. Exiting."
exit 1
fi
# echo "Changing DNS rules..."
# # Change DNS rules
# sudo sed -i 's/#DNS=/DNS=8.8.8.8 8.8.4.4/' /etc/systemd/resolved.conf
# sudo systemctl restart systemd-resolved.service
echo "Copying service files from $source_dir to /etc/systemd/system/"
# Copy .service files
sudo cp $source_dir/*.service /etc/systemd/system/
# Reload systemd to read the new service files
sudo systemctl daemon-reload
if [[ "$target" == "master" ]]; then
# enable the service to run on boot
sudo systemctl enable docker-compose-app.service
sudo systemctl enable wifi-power-management.service
# start the services
sudo systemctl start docker-compose-app.service
sudo systemctl start wifi-power-management.service
elif [[ "$target" == "slave" ]]; then
# enable the service to run on boot
sudo systemctl enable wifi-power-management.service
# start the services
sudo systemctl start wifi-power-management.service
fi
# Create a Python virtual environment
python -m venv env
# Activate the virtual environment
source env/bin/activate
# Install Python requirements
pip install -r requirements.txt
# Provide instructions to the user
echo "Setup completed successfully! Rebooting..."
# Reboot the system
sudo reboot