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