changeset 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 02ba26698696
children 41eba85c0c84
files install.sh
diffstat 1 files changed, 30 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/install.sh	Mon Dec 13 15:51:41 2021 +1030
@@ -0,0 +1,30 @@
+#!/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