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