1
0
Fork 0
Browse Source

refactor timers in scripts.

pull/1/head
rtrp@factory1 4 years ago
parent
commit
0eaea3b798
  1. 3
      cli_meter.py
  2. 2
      make-log-files.sh
  3. 17
      shutdown.sh
  4. 21
      startup.sh

3
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()

2
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

17
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
}

21
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