Craig Oates
4 years ago
3 changed files with 59 additions and 3 deletions
@ -0,0 +1,29 @@
|
||||
#!/bin/bash |
||||
|
||||
logDate=$(date '+%Y-%m-%dT%TZ') |
||||
logFile="/home/lm-1/logs/shutdown-logs.txt" |
||||
|
||||
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";; |
||||
esac |
||||
} |
||||
|
||||
logStatusChange () { |
||||
cat << EOF >> $logFile |
||||
$logDate |
||||
EOF |
||||
} |
||||
|
||||
logStatusChange |
||||
getApiUrl |
||||
|
||||
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/html' -d '{"status": "off", "time": "'${logDate}'", "token": "QWERTYuiopasdfghjklzxcvbnm_1234567890"}' "${apiURL}" |
||||
|
||||
shutdown now |
@ -0,0 +1,27 @@
|
||||
#!/bin/bash |
||||
|
||||
logDate=$(date '+%Y-%m-%dT%TZ') |
||||
logFile="/home/lm-1/logs/start-logs.txt" |
||||
|
||||
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";; |
||||
esac |
||||
} |
||||
|
||||
logStatusChange () { |
||||
cat << EOF >> $logFile |
||||
$logDate |
||||
EOF |
||||
} |
||||
|
||||
logStatusChange |
||||
getApiUrl |
||||
|
||||
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/html' -d '{"status": "on", "time": "'${logDate}'", "token": "QWERTYuiopasdfghjklzxcvbnm_1234567890"}' "${apiURL}" |
Reference in new issue