-
Notifications
You must be signed in to change notification settings - Fork 5
/
install.sh
79 lines (62 loc) · 2.44 KB
/
install.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
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SERVICE_NAME=$(basename $SCRIPT_DIR)
GUI_DIR=/opt/victronenergy/gui/qml
# set permissions for script files
chmod a+x $SCRIPT_DIR/restart.sh
chmod 744 $SCRIPT_DIR/restart.sh
chmod a+x $SCRIPT_DIR/uninstall.sh
chmod 744 $SCRIPT_DIR/uninstall.sh
chmod a+x $SCRIPT_DIR/service/run
chmod 755 $SCRIPT_DIR/service/run
# create sym-link to run script in deamon
ln -s $SCRIPT_DIR/service /service/$SERVICE_NAME
# add install-script to rc.local to be ready for firmware update
filename=/data/rc.local
if [ ! -f $filename ]
then
touch $filename
chmod 755 $filename
echo "#!/bin/bash" >> $filename
echo >> $filename
fi
grep -qxF "$SCRIPT_DIR/install.sh" $filename || echo "$SCRIPT_DIR/install.sh" >> $filename
# Backup GUI
if ! [ -e $GUI_DIR/PageAcInSetup._qml ]
then
cp $GUI_DIR/PageAcInSetup.qml $GUI_DIR/PageAcInSetup._qml
fi
if ! [ -e $GUI_DIR/OverviewGridParallel._qml ]
then
mv $GUI_DIR/OverviewGridParallel.qml $GUI_DIR/OverviewGridParallel._qml
fi
if ! [ -e /opt/victronenergy/gui/qml/PageMain._qml ]
then
mv $GUI_DIR/PageMain.qml $GUI_DIR/PageMain._qml
fi
# Patch GUI
patch=$SCRIPT_DIR/qml/PageAcInSetup_patch.qml
file=$GUI_DIR/PageAcInSetup.qml
if [ "$(cat $patch)" != "$(sed -n '/\/\* HM settings \*\//,/\/\* HM settings end \*\//p' $file )" ]; then
sed -i '/\/\* HM settings \*\//,/\/\* HM settings end \*\//d' $file
line_number=$(grep -n "\/\* EM24 settings \*\/" $file | cut -d ":" -f 1)
if ! [ -z "$line_number" ]; then
line_number=$((line_number - 1))r
echo "patching file $file"
sed -i "$line_number $patch" $file
else
echo "Error patching file $file"
fi
fi
cp $GUI_DIR/OverviewGridParallel._qml $GUI_DIR/OverviewGridParallel.qml
cp $GUI_DIR/PageMain._qml $GUI_DIR/PageMain.qml
patch -p0 < $SCRIPT_DIR/qml/PageMain.diff
patch -p0 < $SCRIPT_DIR/qml/OverviewGridParallel.diff
ln -s -f $SCRIPT_DIR/qml/MultiHm.qml /opt/victronenergy/gui/qml/MultiHm.qml
ln -s -f $SCRIPT_DIR/qml/PageHmSetup.qml /opt/victronenergy/gui/qml/PageHmSetup.qml
ln -s -f $SCRIPT_DIR/qml/PageVebusHm.qml /opt/victronenergy/gui/qml/PageVebusHm.qml
ln -s -f $SCRIPT_DIR/qml/overview-inverter-Hm.svg /opt/victronenergy/themes/ccgx/images/overview-inverter-Hm.svg
ln -s -f $SCRIPT_DIR/qml/overview-inverter-short-Hm.svg /opt/victronenergy/themes/ccgx/images/overview-inverter-short-Hm.svg
svc -d /service/gui
sleep 1
svc -u /service/gui