view 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
line wrap: on
line source

#!/bin/sh

root=$(cd $(dirname $0); pwd)

# Set VE_SERVICE for our serial cable to inform serial-starter about it
mkdir -p /etc/udev/rules.d
cat >/etc/udev/rules.d/eprodbus.rules <<EOF
ACTION=="add", ENV{ID_BUS}=="usb", ENV{ID_MODEL}=="FT232_epro", ENV{VE_SERVICE}="eprodbus"
EOF

# Tell serial starter to run our service
mkdir -p /data/conf/serial-starter.d
cat >/data/conf/serial-starter.d/eprodbus.conf <<EOF
service	eprodbus	eprodbus
EOF

# Create service template for running and logging
# Serial starter copies this to /service and pattern-replaces TTY
mkdir -p /opt/victronenergy/eprodbus/service/log /var/log/eprodbus
cat >/opt/victronenergy/eprodbus/service/run <<EOF
#!/bin/sh
exec 2>&1
exec /usr/bin/python $root/eprodbus.py TTY
EOF
cat <<EOF >/opt/victronenergy/eprodbus/service/log/run
#!/bin/sh
exec 2>&1
exec multilog t s25000 n4 /var/log/eprodbus.TTY
EOF
chmod 755 /opt/victronenergy/eprodbus/service/run /opt/victronenergy/eprodbus/service/log/run