Browse Source

Add state change

main
Peter 2 years ago
parent
commit
029397c2d4
Signed by: pludi GPG Key ID: CFBA360E696EDC99
2 changed files with 20 additions and 6 deletions
  1. +1
    -1
      spacestatus.json
  2. +19
    -5
      spacestatus.sh

+ 1
- 1
spacestatus.json View File

@ -1 +1 @@
{"api":"0.13","space":"/usr/space","logo":"","url":"https://usrspace.at","location":{"lat":47.92305,"lon":16.21173,"address":"Mühlgasse 8, 2544 Leobersdorf, Austria"},"state":{"open":%s},"contact":{"twitter":"@usrspace_at","email":"kernel AT usrspace.at","facebook":"https://facebook.com/usrspace.at","keymasters":[{"name":"Peter","twitter":"@pludikovsky"}]},"issue_report_channels":["email","twitter"],"feeds":{"calendar":{"type":"ical","url":"https://usrspace.at/termine.ics"}},"cache":{"schedule":"m.05"},"projects":["https://gitlab.usrspace.at/","https://www.usrspace.at/w/index.php?title=Kategorie:Projekte"]}
{"api":"0.13","space":"/usr/space","logo":"","url":"https://usrspace.at","location":{"lat":47.92305,"lon":16.21173,"address":"Mühlgasse 8, 2544 Leobersdorf, Austria"},"state":{"open":%s,"lastchange":%d},"contact":{"twitter":"@usrspace_at","email":"kernel AT usrspace.at","facebook":"https://facebook.com/usrspace.at","keymasters":[{"name":"Peter","twitter":"@pludikovsky"}]},"issue_report_channels":["email","twitter"],"feeds":{"calendar":{"type":"ical","url":"https://usrspace.at/termine.ics"}},"cache":{"schedule":"m.05"},"projects":["https://gitlab.usrspace.at/","https://www.usrspace.at/w/index.php?title=Kategorie:Projekte"]}

+ 19
- 5
spacestatus.sh View File

@ -2,7 +2,7 @@
[ ! -z "$DEBUG" ] && set -x
set -eu
#set -eu
function write_html {
status=$1
@ -26,11 +26,25 @@ function write_json {
CLOSED_JSON='false'
OPEN_JSON='true'
if [ "$status" -gt 0 ]
# Previous status Open & Open now -> skip
grep -q '"open":true' $STATUS_JSON
if [[ $? -eq 0 && "$status" -gt 0 ]]
then
return
fi
# Previous status Closed & Closed now -> skip
grep -q '"open":false' $STATUS_JSON
if [[ $? -eq 0 && "$status" -eq 0 ]]
then
return
fi
if [ "$status" -eq 0 ]
then
printf "$TEMPLATE_JSON" $OPEN_JSON > $STATUS_JSON
printf "$TEMPLATE_JSON" $OPEN_JSON $( date +%s ) > $STATUS_JSON
else
printf "$TEMPLATE_JSON" $CLOSED_JSON > $STATUS_JSON
printf "$TEMPLATE_JSON" $CLOSED_JSON $( date +%s ) > $STATUS_JSON
fi
}
@ -47,6 +61,6 @@ exec 3>&-
leases=$( cat $tmpcount | wc -l )
write_html $leases
write_json $leases
write_json $leases
rm $tmpcount

Loading…
Cancel
Save