summaryrefslogtreecommitdiff
path: root/power-logger
diff options
context:
space:
mode:
authorpks <pks@pks.rocks>2021-05-16 18:22:52 +0200
committerpks <pks@pks.rocks>2021-05-16 18:22:52 +0200
commit899ba88b76a2f01b1bab87fbb960c2277435c521 (patch)
tree206b60e4f9f5351daf6442ab0a23c2b6f2d2d1e4 /power-logger
parent1123b0db81b6057e113f16a1ddea15c36b7b3d79 (diff)
restart
Diffstat (limited to 'power-logger')
-rwxr-xr-xpower-logger44
1 files changed, 0 insertions, 44 deletions
diff --git a/power-logger b/power-logger
deleted file mode 100755
index f1ac7a7..0000000
--- a/power-logger
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-### BEGIN INIT INFO
-# Provides: power-logger
-# Required-Start: $all
-# Required-Stop:
-# Default-Start: 2 3 4 5
-# Default-Stop:
-# Short-Description: power-logger
-### END INIT INFO
-
-export SUFFIX=$(date +'%Y-%m-%d-%H:%M:%S')
-export USER=pks
-export GROUP=pks
-export DIR=/home/$USER/mqtt_client/
-
-case "$1" in
- start)
- echo "Starting power-logger"
- rm -f $DIR/stop
- if [ ! -f $DIR/power.db ]; then
- runuser -l $USER -c "$DIR/db-create.sh $DIR/power.db"
- fi
- mkdir -p $DIR/log
- chown -R $USER:$GROUP $DIR/log
- runuser -l $USER -c "source $DIR/env/bin/activate && python $DIR/mqtt-receiver.py 2> >(cat > $DIR/log/power.$SUFFIX.err) | tee >(cat > $DIR/log/power.$SUFFIX.out) | $DIR/db-from-log.sh $DIR/power.db 2> >(cat > $DIR/log/power.db-from-log.$SUFFIX.err)" &
- echo $! > /run/power-logger.pid2
- ;;
- stop)
- echo "Stopping power-logger"
- runuser -l $USER -c "touch $DIR/stop"
- sleep 3
- if [ -f /run/power-logger.pid2 ]; then
- kill $(cat /run/power-logger.pid2) &>/dev/null
- rm -f /run/power-logger.pid2
- fi
- rm -f $DIR/stop
- ;;
- *)
- echo "Usage: /etc/init.d/power-logger {start|stop}"
- exit 1
- ;;
-esac
-
-exit 0