-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
44 lines (38 loc) · 1.3 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
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
LIB_DIR=/data/etc/vebus
SERVICE_NAME=$(basename $SCRIPT_DIR)
# set permissions for script files
chmod 744 $SCRIPT_DIR/$SERVICE_NAME.py
chmod 744 $SCRIPT_DIR/install.sh
chmod 744 $SCRIPT_DIR/restart.sh
chmod 744 $SCRIPT_DIR/uninstall.sh
chmod 755 $SCRIPT_DIR/service/run
# check dependencies
if [ ! -f $LIB_DIR/ve_utils.py ]
then
echo "File ve_utils.py does not exist in folder"
wget https://raw.githubusercontent.com/victronenergy/velib_python/master/ve_utils.py -P $LIB_DIR
else
echo "File ve_utils.py already in folder."
fi
if [ ! -f $LIB_DIR/vedbus.py ]
then
echo "File vedbus.py does not exist in folder"
wget https://raw.githubusercontent.com/victronenergy/velib_python/master/vedbus.py -P $LIB_DIR
else
echo "File vedbus.py already in folder."
fi
# 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 777 $filename
echo "#!/bin/bash" >> $filename
echo >> $filename
fi
# if not alreay added, then add to rc.local
grep -qxF "bash $SCRIPT_DIR/install.sh" $filename || echo "bash $SCRIPT_DIR/install.sh" >> $filename