#!/bin/bash set -u #old# closed loop (=closed door) is more reliable to detect. #old# so, if there are $CHECKS checks in favour to the door #old# being closed, we might assume that this is the case. # as of 2015-01 things got fishy # so we just look who got the most votes # DEV=/dev/ttyUSB0 if [ ! -e "$DEV" ]; then logger -t "sopen-client" "'$DEV' missing: $( ls -ld /dev )" exit fi CHECKS=20 QUOTA=$(( $CHECKS / 2 )) FLAG=0 for i in $( seq 1 $CHECKS ); do if [ x`/usr/local/app/shackdoor/shackdoor /dev/ttyUSB0` = xDSR ] ; then FLAG=$(( $FLAG + 1 )) fi done echo FLAG=$FLAG if [ "$FLAG" -lt "$QUOTA" ] ; then echo -e -n "GET /sopen/open/************ HTTP/1.0\r\nHost: shackspace.de\r\n\r\n" | nc shackspace.de 80 else echo -e -n "GET /sopen/closed/************ HTTP/1.0\r\nHost: shackspace.de\r\n\r\n" | nc shackspace.de 80 fi