changeset 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 64d0d5aaf329
files README install.sh
diffstat 2 files changed, 27 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/README	Mon Dec 13 15:51:41 2021 +1030
+++ b/README	Mon Dec 13 23:04:37 2021 +1030
@@ -1,3 +1,4 @@
 Python to read status from am Enerdrive ePro battery monitor.
 
 http://enerdrive.com.au/product/epro-elite-battery-monitors/
+https://github.com/victronenergy/venus/wiki/howto-add-a-driver-to-Venus
\ No newline at end of file
--- a/install.sh	Mon Dec 13 15:51:41 2021 +1030
+++ b/install.sh	Mon Dec 13 23:04:37 2021 +1030
@@ -3,20 +3,20 @@
 root=$(cd $(dirname $0); pwd)
 
 # Set VE_SERVICE for our serial cable to inform serial-starter about it
-mkdir -p /etc/udev/rules.d
+mkdir -p /etc/udev/rules.d >/dev/null 2>&1
 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
+mkdir -p /data/conf/serial-starter.d >/dev/null 2>&1
 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
+mkdir -p /opt/victronenergy/eprodbus/service/log >/dev/null 2>&1
 cat >/opt/victronenergy/eprodbus/service/run <<EOF
 #!/bin/sh
 exec 2>&1
@@ -28,3 +28,26 @@
 exec multilog t s25000 n4 /var/log/eprodbus.TTY
 EOF
 chmod 755 /opt/victronenergy/eprodbus/service/run /opt/victronenergy/eprodbus/service/log/run
+
+# Create rc.local hooks for reinstallation
+mkdir /data/rc.local.d /data/rcS.local.d >/dev/null 2>&1
+cat >/data/rc.local.d/eprodbus <<EOF
+#!/bin/sh
+sh $root/install.sh
+EOF
+
+cat >/data/rc.local <<EOF
+#!/bin/sh
+for s in /data/rc.local.d/*; do
+  \$s
+done
+EOF
+
+cat >/data/rcS.local <<EOF
+#!/bin/sh
+for s in /data/rcS.local.d/*; do
+  \$s
+done
+EOF
+
+chmod 755 /data/rc.local.d/eprodbus /data/rc.local /data/rcS.local