comparison install.sh @ 24:41eba85c0c84

Hide complaints from mkdir. Create reinstallation hooks.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 13 Dec 2021 23:04:37 +1030
parents 7bca87ca06e4
children
comparison
equal deleted inserted replaced
23:7bca87ca06e4 24:41eba85c0c84
1 #!/bin/sh 1 #!/bin/sh
2 2
3 root=$(cd $(dirname $0); pwd) 3 root=$(cd $(dirname $0); pwd)
4 4
5 # Set VE_SERVICE for our serial cable to inform serial-starter about it 5 # Set VE_SERVICE for our serial cable to inform serial-starter about it
6 mkdir -p /etc/udev/rules.d 6 mkdir -p /etc/udev/rules.d >/dev/null 2>&1
7 cat >/etc/udev/rules.d/eprodbus.rules <<EOF 7 cat >/etc/udev/rules.d/eprodbus.rules <<EOF
8 ACTION=="add", ENV{ID_BUS}=="usb", ENV{ID_MODEL}=="FT232_epro", ENV{VE_SERVICE}="eprodbus" 8 ACTION=="add", ENV{ID_BUS}=="usb", ENV{ID_MODEL}=="FT232_epro", ENV{VE_SERVICE}="eprodbus"
9 EOF 9 EOF
10 10
11 # Tell serial starter to run our service 11 # Tell serial starter to run our service
12 mkdir -p /data/conf/serial-starter.d 12 mkdir -p /data/conf/serial-starter.d >/dev/null 2>&1
13 cat >/data/conf/serial-starter.d/eprodbus.conf <<EOF 13 cat >/data/conf/serial-starter.d/eprodbus.conf <<EOF
14 service eprodbus eprodbus 14 service eprodbus eprodbus
15 EOF 15 EOF
16 16
17 # Create service template for running and logging 17 # Create service template for running and logging
18 # Serial starter copies this to /service and pattern-replaces TTY 18 # Serial starter copies this to /service and pattern-replaces TTY
19 mkdir -p /opt/victronenergy/eprodbus/service/log /var/log/eprodbus 19 mkdir -p /opt/victronenergy/eprodbus/service/log >/dev/null 2>&1
20 cat >/opt/victronenergy/eprodbus/service/run <<EOF 20 cat >/opt/victronenergy/eprodbus/service/run <<EOF
21 #!/bin/sh 21 #!/bin/sh
22 exec 2>&1 22 exec 2>&1
23 exec /usr/bin/python $root/eprodbus.py TTY 23 exec /usr/bin/python $root/eprodbus.py TTY
24 EOF 24 EOF
26 #!/bin/sh 26 #!/bin/sh
27 exec 2>&1 27 exec 2>&1
28 exec multilog t s25000 n4 /var/log/eprodbus.TTY 28 exec multilog t s25000 n4 /var/log/eprodbus.TTY
29 EOF 29 EOF
30 chmod 755 /opt/victronenergy/eprodbus/service/run /opt/victronenergy/eprodbus/service/log/run 30 chmod 755 /opt/victronenergy/eprodbus/service/run /opt/victronenergy/eprodbus/service/log/run
31
32 # Create rc.local hooks for reinstallation
33 mkdir /data/rc.local.d /data/rcS.local.d >/dev/null 2>&1
34 cat >/data/rc.local.d/eprodbus <<EOF
35 #!/bin/sh
36 sh $root/install.sh
37 EOF
38
39 cat >/data/rc.local <<EOF
40 #!/bin/sh
41 for s in /data/rc.local.d/*; do
42 \$s
43 done
44 EOF
45
46 cat >/data/rcS.local <<EOF
47 #!/bin/sh
48 for s in /data/rcS.local.d/*; do
49 \$s
50 done
51 EOF
52
53 chmod 755 /data/rc.local.d/eprodbus /data/rc.local /data/rcS.local