Ce commit ajoute un support rudimentaire de space-api: (voir https://spaceapi.io/docs/) Il consiste en deux parties: * un fichier spaceapi/space.json contenant les infos du lol * une mise à jour de status/set-status.sh qui utilise jq pour répercuter les changements de l'état d'ouverture du lolcal TODO: Ajouter nos capteurs (ce n'est pas trivial, amha, il faudra revoir l'architecture du système pour le faire correctement)
24 lines
762 B
Bash
Executable File
24 lines
762 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ "$#" = "0" ]; then
|
|
echo "Usage set-status.sh [new-status]"
|
|
echo ""
|
|
echo "[new-status] can be \"opened\" or \"closed\""
|
|
echo ""
|
|
exit 1
|
|
fi
|
|
|
|
SPACE_JSON=/var/www/html/spaceapi/space.json
|
|
|
|
if [ "$1" = "opened" ]; then
|
|
ln -sf "index.ouvert.html" "/var/www/html/status/index.html"
|
|
jq "setpath([\"state\", \"open\"]; true) | setpath([\"state\", \"lastchange\"]; $(date +%s))" < $SPACE_JSON > $SPACE_JSON.new &&
|
|
mv -f $SPACE_JSON.new $SPACE_JSON
|
|
fi
|
|
|
|
if [ "$1" = "closed" ]; then
|
|
ln -sf "index.fermé.html" "/var/www/html/status/index.html"
|
|
jq "setpath([\"state\", \"open\"]; false) | setpath([\"state\", \"lastchange\"]; $(date +%s))" < $SPACE_JSON > $SPACE_JSON.new &&
|
|
mv -f $SPACE_JSON.new $SPACE_JSON
|
|
fi
|