-
Notifications
You must be signed in to change notification settings - Fork 5
/
upgrade.sh
executable file
·96 lines (80 loc) · 2.88 KB
/
upgrade.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env bash
repourl=https://github.com/darton/RPiMS/archive/refs/heads/master.zip
downloaddir=/tmp
unpackdir=/tmp/RPiMS-master
installdir=/home/pi/scripts/RPiMS
wwwdir=/var/www/html
_IP=$(ip route get 1.1.1.1 | awk '{print $7}')
echo "Do you want to upgrade the RPiMS ?"
read -r -p "$1 [y/N] " response < /dev/tty
#read -r -p "$1 [y/N] "
if [[ $response =~ ^(yes|y|Y)$ ]]; then
echo "Greats ! The upgrade process has started."
[[ -d $wwwdir ]] || sudo mkdir -p $wwwdir
[[ -d $installdir ]] || mkdir -p $installdir
[[ -d /home/pi/Videos ]] || mkdir -p /home/pi/Videos
[[ ! -d $unpackdir ]] || rm -rf $unpackdir
[[ ! -f $downloaddir/RPiMS.zip ]] || rm $downloaddir/RPiMS.zip
curl -sS $repourl -L -o $downloaddir/RPiMS.zip
unzip $downloaddir/RPiMS.zip -d $downloaddir
sudo rm -rf $installdir/*
sudo cp $unpackdir/RPiMS/* $installdir
sudo chmod u+x $installdir/*.py $installdir/*.sh
for item in api css js setup
do
sudo rm -rf $wwwdir/$item
done
sudo rm $wwwdir/*.*
for item in api css js setup
do
sudo cp -R $unpackdir/www/$item $wwwdir
done
sudo cp $unpackdir/www/*.php $wwwdir
sudo cp $unpackdir/www/favicon.ico $wwwdir
[[ ! -d $unpackdir ]] || rm -rf $unpackdir
[[ ! -f $downloaddir/RPiMS.zip ]] || rm $downloaddir/RPiMS.zip
echo ""
echo "-------------------------------------"
echo "Upgrade successfully completed !"
echo "-------------------------------------"
echo ""
fi
echo "Do you want to upgrade the Python library ?"
read -r -p "$1 [y/N] " response < /dev/tty
if [[ $response =~ ^(yes|y|Y)$ ]]; then
echo "Greats ! The upgrade OS has started."
sudo /usr/bin/python3 -m pip install --upgrade pip
sudo -H pip3 install --upgrade RPi.bme280 smbus2 w1thermsensor redis[hiredis] pid PyYAML luma.oled luma.lcd luma.core adafruit-circuitpython-ads1x15 rshell pyusb
echo ""
echo "-------------------------------------"
echo "Upgrade successfully completed !"
echo "-------------------------------------"
echo ""
fi
echo "Do you want to upgrade the Operating System ?"
read -r -p "$1 [y/N] " response < /dev/tty
if [[ $response =~ ^(yes|y|Y)$ ]]; then
echo "Greats ! The upgrade OS has started."
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y autoremove
echo ""
echo "-------------------------------------"
echo "Upgrade successfully completed !"
echo "-------------------------------------"
echo ""
fi
echo ""
echo "Do you want to reboot RPiMS now ?"
echo ""
echo "After restarting open http://$_IP/setup or http://127.0.0.1 to configure RPiMS"
read -r -p "$1 [y/N] " response < /dev/tty
if [[ $response =~ ^(yes|y|Y)$ ]]; then
sudo reboot
else
echo ""
echo "Run this command manually: sudo reboot"
echo ""
echo "After restarting open http://$_IP/setup or http://127.0.0.1/setup to configure RPiMS"
exit
fi