#!/bin/sh # /etc/init.d/weather-logger export SUFFIX=$(date +'%Y-%m-%d-%H:%M:%S') export USER=pks export DIR=/home/$USER/weather/ 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" & ;; 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