From 843bb50c48a8b11c572c1e64e0237d09d635e1f0 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sun, 27 Jan 2019 00:27:21 +0100 Subject: init --- weather-logger | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 weather-logger (limited to 'weather-logger') diff --git a/weather-logger b/weather-logger new file mode 100755 index 0000000..a2c957b --- /dev/null +++ b/weather-logger @@ -0,0 +1,26 @@ +#! /bin/sh +# /etc/init.d/weather-logger +# + +export SUFFIX=$(date +'%Y-%m-%d-%H:%M:%S') +export DIR=/home/pi/weather/ + +# Carry out specific functions when asked to by the system +case "$1" in + start) + echo "Starting weather-logger" + rm -f $DIR/stop + runuser -l pi -c "source $DIR/env/bin/activate && python $DIR/receive.py 2>$DIR/weather.$SUFFIX.err > $DIR/weather.$SUFFIX.out" + ;; + stop) + echo "Stopping weather-logger" + runuser -l pi -c "touch $DIR/stop" + ;; + *) + echo "Usage: /etc/init.d/weather-logger {start|stop}" + exit 1 + ;; +esac + +exit 0 + -- cgit v1.2.3