forked from domoticz/domoticz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updaterelease
executable file
·59 lines (53 loc) · 1.79 KB
/
updaterelease
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
#!/bin/sh
# This script can be used to upgrade to the latest release version
# To skip making a backup, use -nobackup as commandline argument
lowercase(){
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
}
OS=`lowercase \`uname -s\``
MACH=`uname -m`
ARCH=`dpkg --print-architecture`
if [ ${MACH} = "armv6l" ]
then
echo "ARMv6 is not supported anymore... Please upgrade your hardware"
exit 1
fi
if [ ${ARCH} = "armhf" ]
then
MACH="armv7l"
fi
echo "Stopping Domoticz..."
sudo service domoticz.sh stop
if [ "$1" != "-nobackup" ]; then
echo "Making backup of current installation..."
# first remove oldest files (we keep 5 backups)
ls -t backups/domoticz_backup_* | tail -n +5 | xargs --no-run-if-empty -I {} rm -- {}
# create backup in parent folder (mostly home)
timestamp=$(date +%Y%m%d_%H%M%S)
echo "Output file: backups/domoticz_backup_$timestamp.tar.gz"
mkdir -p backups
sudo tar --exclude backups -czf backups/domoticz_backup_$timestamp.tar.gz .
echo "Backup finished..."
fi
echo "Downloading latest release version..."
wget -4 -q -O domoticz_release.tgz --no-check-certificate "https://www.domoticz.com/download.php?channel=stable&type=release&system=${OS}&machine=${MACH}"
if [ $? -ne 0 ]
then
echo "Problem downloading new Domoticz version!!. Restarting current version..."
sudo service domoticz.sh start
exit 1
fi
echo "Checking file integrity..."
tar tzf domoticz_release.tgz >/dev/null
if [ $? -ne 0 ]
then
echo "Problem in downloaded Domoticz archive!!. Stopping and restarting current version..."
sudo service domoticz.sh start
exit 1
fi
echo "Installing new version..."
tar xfz domoticz_release.tgz --checkpoint=.100
rm domoticz_release.tgz
echo "\nStarting Domoticz... (please standby...)"
sudo service domoticz.sh start
echo "Done..."