annotate install.sh @ 23:7bca87ca06e4

Add script to create service, udev and serial-starter entries.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 13 Dec 2021 15:51:41 +1030
parents
children 41eba85c0c84
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
7bca87ca06e4 Add script to create service, udev and serial-starter entries.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
6 mkdir -p /etc/udev/rules.d
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
7bca87ca06e4 Add script to create service, udev and serial-starter entries.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
12 mkdir -p /data/conf/serial-starter.d
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
7bca87ca06e4 Add script to create service, udev and serial-starter entries.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
19 mkdir -p /opt/victronenergy/eprodbus/service/log /var/log/eprodbus
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