Compare commits

...

1 commit

Author SHA1 Message Date
djerun cc4fdcb231 add support for new spaceapi 2023-11-05 00:44:24 +01:00
4 changed files with 11 additions and 2 deletions

View file

@ -1,2 +1,3 @@
password=sesamaenderdich
spaceapi_password=mekmitasdigoat
tresor=1111

1
lock
View file

@ -6,6 +6,7 @@ echo "Securing Communication to Space Systems..."
echo "Open Communication Channel..."
# Silent, Output to /dev/null, Timeout after 5s and retry 12 times, each doubling the waitingtime until ten minutes.
nohup curl -s -o /dev/null -m 5 --connect-timeout 5 --retry 12 "https://hamburg.ccc.de/dooris/status.php?apikey=${password}&action=close" >/dev/null 2>&1 &
nohup curl -s -o /dev/null -m 5 --connect-timeout 5 --retry 12 -X PUT -d false -u dooris:${spaceapi_password} "https://spaceapi.hamburg.ccc.de/state/open" >/dev/null 2>&1 &
nohup mosquitto_pub -h 'mqtt.z9' -t 'z9/door/status' -r -m 'locked' >/dev/null 2>&1 &
echo "Locking Space..."
echo "1" > /sys/class/gpio/gpio22/value

10
shared
View file

@ -8,13 +8,19 @@ if [ ! -f "${basedir}/${config}" ]; then
fi
# get password config value in a safe way
password="$(grep password ${basedir}/${config} 2>/dev/null|cut -d= -f2|tr -d ' \t')"
password="$(grep '^password' ${basedir}/${config} 2>/dev/null|cut -d= -f2|tr -d ' \t')"
if [ -z "${password}" ]; then
echo "WARNING: password in ${config} is missing!" >&2
fi
# get spaceapi-password config value in a safe way
spaceapi_password="$(grep '^spaceapi_password' ${basedir}/${config} 2>/dev/null|cut -d= -f2|tr -d ' \t')"
if [ -z "${spaceapi_password}" ]; then
echo "WARNING: spaceapi_password in ${config} is missing!" >&2
fi
# get tresor config value in a safe way
tresor="$(grep tresor ${basedir}/${config} 2>/dev/null|cut -d= -f2|tr -d ' \t')"
tresor="$(grep '^tresor' ${basedir}/${config} 2>/dev/null|cut -d= -f2|tr -d ' \t')"
if [ -z "${tresor}" ]; then
echo "WARNING: tresor in ${config} is missing!" >&2
fi

1
unlock
View file

@ -5,6 +5,7 @@ echo "Initializing Space Systems..."
echo "Securing Communication to Space Systems..."
echo "Open Communication Channel..."
nohup curl -s -o /dev/null -m 5 --connect-timeout 5 --retry 12 "https://hamburg.ccc.de/dooris/status.php?apikey=${password}&action=open" >/dev/null 2>&1 &
nohup curl -s -o /dev/null -m 5 --connect-timeout 5 --retry 12 -X PUT -d true -u dooris:${spaceapi_password} "https://spaceapi.hamburg.ccc.de/state/open" >/dev/null 2>&1 &
nohup mosquitto_pub -h 'mqtt.z9' -t 'z9/door/status' -r -m 'unlocked' >/dev/null 2>&1 &
echo "Unlocking Space..."
echo "1" > /sys/class/gpio/gpio27/value