diff --git a/dooris.conf.sample b/dooris.conf.sample index 82ed7b1..b28281e 100644 --- a/dooris.conf.sample +++ b/dooris.conf.sample @@ -1,2 +1,3 @@ password=sesamaenderdich +spaceapi_password=mekmitasdigoat tresor=1111 diff --git a/lock b/lock index e37ef9e..9598d1b 100755 --- a/lock +++ b/lock @@ -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 diff --git a/shared b/shared index 9ab918c..d8e82bb 100755 --- a/shared +++ b/shared @@ -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 diff --git a/unlock b/unlock index f355273..4b98877 100755 --- a/unlock +++ b/unlock @@ -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