diff install.sh @ 32:b6f96e8738ca

Add install script to create service entry and rc.local resurrecter
author Daniel O'Connor <darius@dons.net.au>
date Mon, 13 Dec 2021 18:17:12 +1030
parents
children 7125b13d0528
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/install.sh	Mon Dec 13 18:17:12 2021 +1030
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+root=$(cd $(dirname $0); pwd)
+
+# Create service files for running and logging
+mkdir -p /service/vanlogger/log
+cat >/service/vanlogger/run <<EOF
+#!/bin/sh
+exec 2>&1
+exec /usr/bin/python $root/vanlogger.py
+EOF
+cat <<EOF >/service/vanlogger/log/run
+#!/bin/sh
+exec 2>&1
+exec multilog t s25000 n4 /var/log/vanlogger
+EOF
+chmod 755 /service/vanlogger/run /service/vanlogger/log/run
+
+# Create rc.local hooks for reinstallation
+mkdir /data/rc.local.d /data/rcS.local.d
+cat >/data/rc.local.d/vanlogger <<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/vanlogger /data/rc.local /data/rcS.local