This repository has been archived by the owner on May 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_setup.sh
53 lines (45 loc) · 1.64 KB
/
docker_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
#!/bin/bash
# Check Docker YAML
sudo -u pi mkdir "simplyprint"
# shellcheck disable=SC2164
cd simplyprint
sudo -u pi mkdir "logs"
sudo -u pi touch logs/log.txt
sudo -u pi touch logs/device.log
sudo -u pi touch logs/scripts.log
sudo -u pi touch logs/docker.log
echo "Log created $(date -u)" >>"$(pwd)"/logs/log.txt
echo "Log created $(date -u)" >>"$(pwd)"/logs/device.log
echo "Log created $(date -u)" >>"$(pwd)"/logs/scripts.log
echo "Log created $(date -u)" >>"$(pwd)"/logs/docker.log
echo "$(date -u) - docker_setup.sh" >>"$(pwd)"/logs/scripts.log
yes | apt-get update
sudo -u pi curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
usermod -aG docker pi
apt-get install libffi-dev libssl-dev
yes | apt install python3-dev
apt-get install -y python3 python3-pip
pip3 install docker-compose
sudo -u pi curl https://raw.githubusercontent.com/SimplyPrint/Multi-Instance-Setup/main/update.sh -o update.sh
sudo -u pi bash update.sh
#Read current crontab
myCron=$(crontab -l)
#Check if the cronjob already exist
if [[ $myCron != *"@reboot cd $(pwd) && bash cron_check.sh"* ]]; then
#echo new cronjob into crontab file
{
echo "@reboot cd $(pwd) && bash cron_check.sh"
echo "* * * * * cd $(pwd) && bash cron_check.sh"
echo "0 0 * * * cd $(pwd) && curl https://raw.githubusercontent.com/SimplyPrint/Multi-Instance-Setup/main/update.sh -o update.sh"
echo "0 0 * * 0 cd $(pwd) && bash log_controller.sh"
} >>myCron
#install new cron file
sudo -u pi crontab myCron
fi
#Remove
rm myCron
chmod -R 775 .* 2>/dev/null
chmod -R 775 . 2>/dev/null
printf "\n\n--- Ready! ---\n\n\nThe raspberry pi will now reboot, press Enter to continue"
read -r