-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall-backup.sh
109 lines (87 loc) · 2.86 KB
/
install-backup.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
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
# script version 0.0.2 (2023.06.07)
# uncomment for debugging
#set -x
echo ""
# check if the system is a Venus OS
if [ -f "/opt/victronenergy/version" ]
then
echo "Recognized OS: \"Venus OS $(head -n 1 /opt/victronenergy/version)\""
INSTALL_DIR=/data/etc
else
echo "Recognized OS: \"$(uname -a)\""
INSTALL_DIR=/opt
fi
echo ""
# check if archive already exists
TMP_FILE=/tmp/master.zip
if [ -f $TMP_FILE ]; then
echo "delete existing $TMP_FILE"
rm -f $TMP_FILE
echo ""
fi
# check if folder already exists
TMP_DIR=/tmp/raspberry-pi-backup-master
if [ -d $TMP_DIR ]; then
echo "delete existing $TMP_DIR"
rm -rf $TMP_DIR
echo ""
fi
# download latest copy of repository
echo "Download latest version..."
wget -P /tmp https://github.com/mr-manuel/raspberry-pi-backup/archive/refs/heads/master.zip
if [ $? -ne 0 ]; then
echo "Error during downloading the file."
exit
else
echo "done."
fi
echo ""
# unzip archive
echo "Extracting archive..."
unzip /tmp/master.zip -d /tmp
if [ $? -ne 0 ]; then
echo "Error during extracting the file."
exit
else
echo "done."
fi
echo ""
# copy archive
cp -rf /tmp/raspberry-pi-backup-master/raspberry-pi-backup/ $INSTALL_DIR
# make file executable
chmod +x $INSTALL_DIR/raspberry-pi-backup/backup.sh
chmod +x $INSTALL_DIR/raspberry-pi-backup/ext/dd
# copy mount.cifs if missing on system (like on Venus OS)
if [ ! -f "/sbin/mount.cifs" ]; then
echo "Copy missing \"mount.cifs\" to \"/sbin/mount.cifs\""
cp $INSTALL_DIR/raspberry-pi-backup/ext/sbin/mount.cifs /sbin
chmod +x /sbin/mount.cifs
chmod u+s /sbin/mount.cifs
fi
# copy mount.nfs if missing on system (like on Venus OS)
if [ ! -f "/sbin/mount.nfs" ]; then
echo "Copy missing \"mount.nfs\" to \"/sbin/mount.nfs\""
cp $INSTALL_DIR/raspberry-pi-backup/ext/sbin/mount.nfs /sbin
chmod +x /sbin/mount.nfs
chmod u+s /sbin/mount.nfs
fi
# copy libcap-ng.so.0.0.0 if missing on system and create symbolic link (like on Venus OS not large)
if [ ! -L "/lib/libcap-ng.so.0.0.0" ]; then
echo "Copy missing \"libcap-ng.so.0.0.0\" to \"/lib/libcap-ng.so.0.0.0\""
cp $INSTALL_DIR/raspberry-pi-backup/ext/lib/libcap-ng.so.0.0.0 /lib
chmod +x /lib/libcap-ng.so.0.0.0
fi
if [ ! -L "/lib/libcap-ng.so.0" ]; then
echo "Creating missing symbolic link \"/lib/libcap-ng.so.0\" to \"/lib/libcap-ng.so.0.0.0\""
ln -s "/lib/libcap-ng.so.0.0.0" "/lib/libcap-ng.so.0"
fi
echo ""
echo ""
if [ -f "$INSTALL_DIR/raspberry-pi-backup/backup.sh" ] && [ -f "/sbin/mount.cifs" ] && [ -f "/sbin/mount.nfs" ]; then
echo "The installation was successful."
echo "Now you have to change the default parameters of the script and setup a cronjob to run automatically \"$INSTALL_DIR/raspberry-pi-backup/backup.sh\" on your desire."
else
echo "Something went wrong with the installation. Try to reboot your system."
fi
echo ""