From 0eaea3b7981f162497dc7f1cdb6b5879cc11784c Mon Sep 17 00:00:00 2001 From: "rtrp@factory1" Date: Sat, 11 Jan 2020 01:11:22 +0000 Subject: [PATCH] refactor timers in scripts. --- cli_meter.py | 3 +++ make-log-files.sh | 2 +- shutdown.sh | 17 +++++++++-------- startup.sh | 21 ++++++++++----------- 4 files changed, 23 insertions(+), 20 deletions(-) mode change 100644 => 100755 cli_meter.py diff --git a/cli_meter.py b/cli_meter.py old mode 100644 new mode 100755 index eeb30e9..74476dd --- a/cli_meter.py +++ b/cli_meter.py @@ -1,3 +1,5 @@ +#!/usr/bin/python3 + """ CLI Meter ==================================================================== @@ -86,4 +88,5 @@ def main(): GPIO.cleanup() if __name__ == "__main__": + # time.sleep(60) main() diff --git a/make-log-files.sh b/make-log-files.sh index 4cc056b..a15c828 100644 --- a/make-log-files.sh +++ b/make-log-files.sh @@ -2,7 +2,7 @@ # This script creates the log files and the fold they will reside in. # This script must be executed before you set-up the start-up and -# shutdown cron-jobs on the system. +# shutdown cron-jobs on the system. mkdir ~/logs/ touch ~/logs/startup-logs.txt diff --git a/shutdown.sh b/shutdown.sh index 4423c4c..2675fcb 100755 --- a/shutdown.sh +++ b/shutdown.sh @@ -1,17 +1,18 @@ -#!/bin/bas +#!/bin/bash logDate=$(date '+%Y-%m-%dT%TZ') -logFile="/home/lm-1/logs/shutdown-logs.txt" +logFile="/home/rtrp/logs/shutdown-logs.txt" +mainURL="http://3.9.19.84/api/status/update" getApiUrl () { # Copy and Paste for the win! case $HOSTNAME in - (factory1) apiURL="http://3.9.19.84/api/status/update/1";; - (factory2) apiURL="http://3.9.19.84/api/status/update/2";; - (factory3) apiURL="http://3.9.19.84/api/status/update/3";; - (gallery1) apiURL="http://3.9.19.84/api/status/update/4";; - (gallery2) apiURL="http://3.9.19.84/api/status/update/5";; - (gallery3) apiURL="http://3.9.19.84/api/status/update/6";; + (factory1) apiURL="${mainURL}/1";; + (factory2) apiURL="${mainURL}/2";; + (factory3) apiURL="${mainURL}/3";; + (gallery1) apiURL="${mainURL}/4";; + (gallery2) apiURL="${mainURL}/5";; + (gallery3) apiURL="${mainURL}/6";; esac } diff --git a/startup.sh b/startup.sh index c710e67..6c376ca 100755 --- a/startup.sh +++ b/startup.sh @@ -1,19 +1,19 @@ #!/bin/bash -sleep 40 +sleep 60 logDate=$(date '+%Y-%m-%dT%TZ') -logFile="/home/lm-1/logs/start-logs.txt" +logFile="/home/rtrp/logs/startup-logs.txt" +mainURL="http://3.9.19.84/api/status/update" getApiUrl () { - # Copy and Paste for the win! case $HOSTNAME in - (factory1) apiURL="http://3.9.19.84/api/status/update/1";; - (factory2) apiURL="http://3.9.19.84/api/status/update/2";; - (factory3) apiURL="http://3.9.19.84/api/status/update/3";; - (gallery1) apiURL="http://3.9.19.84/api/status/update/4";; - (gallery2) apiURL="http://3.9.19.84/api/status/update/5";; - (gallery3) apiURL="http://3.9.19.84/api/status/update/6";; + (factory1) apiURL="${mainURL}/1";; + (factory2) apiURL="${mainURL}/2";; + (factory3) apiURL="${mainURL}/3";; + (gallery1) apiURL="${mainURL}/4";; + (gallery2) apiURL="${mainURL}/5";; + (gallery3) apiURL="${mainURL}/6";; esac } @@ -28,5 +28,4 @@ getApiUrl curl -S -X POST --header 'Content-Type: application/json' --header 'Accept: text/html' -d '{"status": "on", "time": "'${logDate}'", "token": "QWERTYuiopasdfghjklzxcvbnm_1234567890"}' "${apiURL}" -sleep 10 -sudo python /home/lm-1/repos/light-meter/cli_meter.py +python3 /home/rtrp/repos/light-meter/cli_meter.py