-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
58 lines (49 loc) · 1.49 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
#!/bin/sh
SOURCE=$0
while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
SOURCE=$(readlink "$SOURCE")
[[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
PATH=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
DIR=`/usr/bin/basename $PATH`
if [ ! -L /opt/victronenergy/$DIR ]
then
/bin/ln -s $PATH to /opt/victronenergy/$DIR
else
echo Service exists already
fi
if [ -L /opt/victronenergy/service-templates/$DIR ]
then
/bin/rm /opt/victronenergy/service-templates/$DIR
fi
if [ ! -e /opt/victronenergy/service-templates/$DIR ]
then
/bin/mkdir /opt/victronenergy/service-templates/$DIR
/bin/cp -r $PATH/service/* /opt/victronenergy/service-templates/$DIR/
else
echo Service-template exists already
fi
if [ ! -e /data/conf/serial-starter.d ]
then
/bin/mkdir /data/conf/serial-starter.d
fi
if [ ! -e /data/conf/serial-starter.d/suninv.conf ]
then
/bin/cp $PATH/conf/serial-starter.d/suninv.conf /data/conf/serial-starter.d/suninv.conf
else
echo serial-starter conf file already exists
fi
if [ ! "$1" == "NORC" ]
then
echo Looking for rc.local
if [ ! -e /data/rc.local ]
then
echo No rc.local found
echo '#!/bin/sh' > /data/rc.local
/bin/chmod u+x /data/rc.local
fi
echo $PATH/install.sh NORC >> /data/rc.local
else
echo skipping rc.local test
fi