summaryrefslogtreecommitdiff
path: root/weather-logger
blob: a2c957b596356e46861c69cb7e04c6a6144f3126 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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