From d99fb40baf87b484b25311b2c5e8170bd2224a7b Mon Sep 17 00:00:00 2001 From: pks Date: Sat, 1 May 2021 06:18:12 +0200 Subject: v1 --- v1/weather-logger | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 v1/weather-logger (limited to 'v1') diff --git a/v1/weather-logger b/v1/weather-logger new file mode 100755 index 0000000..84be622 --- /dev/null +++ b/v1/weather-logger @@ -0,0 +1,33 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: weather-logger +# Required-Start: $all +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: +# Short-Description: weather-logger +### END INIT INFO + +export SUFFIX=$(date +'%Y-%m-%d-%H:%M:%S') +export USER=pks +export DIR=/home/$USER/weather_logger/ +export PYTHONPATH=/home/$USER/.local/lib/python3.7/site-packages/ + +case "$1" in + start) + echo "Starting weather-logger" + rm -f $DIR/stop + #runuser -l $USER -c "source $DIR/env/bin/activate && python $DIR/receive.py 2>$DIR/weather.$SUFFIX.err > $DIR/weather.$SUFFIX.out" & + runuser -l $USER -c "python3.7 $DIR/receive.py 2>$DIR/log/weather.$SUFFIX.err > $DIR/log/weather.$SUFFIX.out" & + ;; + stop) + echo "Stopping weather-logger" + runuser -l $USER -c "touch $DIR/stop" + ;; + *) + echo "Usage: /etc/init.d/weather-logger {start|stop}" + exit 1 + ;; +esac + +exit 0 -- cgit v1.2.3