diff --git a/announce/gatewayrestart.dat b/announce/gatewayrestart.dat new file mode 100644 index 0000000..f21557f Binary files /dev/null and b/announce/gatewayrestart.dat differ diff --git a/announce/rebooting.dat b/announce/rebooting.dat new file mode 100644 index 0000000..8418ddb Binary files /dev/null and b/announce/rebooting.dat differ diff --git a/announce/shutdown.dat b/announce/shutdown.dat new file mode 100644 index 0000000..9a762c7 Binary files /dev/null and b/announce/shutdown.dat differ diff --git a/exec_G.sh b/exec_G.sh index a8e47a5..225d4d2 100755 --- a/exec_G.sh +++ b/exec_G.sh @@ -1,2 +1,4 @@ #!/bin/sh +qnvoice ${2} gatewayrestart.dat 'Gateway Restart' +sleep 5 systemctl restart qngateway diff --git a/exec_H.sh b/exec_H.sh index 40db820..9fc303e 100755 --- a/exec_H.sh +++ b/exec_H.sh @@ -1,2 +1,4 @@ #!/bin/sh +qnvoice ${2} shutdown.dat 'System Shutdown' +sleep 5 shutdown -h now diff --git a/exec_R.sh b/exec_R.sh index 7e4b8af..db73a28 100755 --- a/exec_R.sh +++ b/exec_R.sh @@ -1,2 +1,4 @@ #!/bin/sh +qnvoice ${2} rebooting.dat 'System Reboot' +sleep 5 shutdown -r now diff --git a/qndtmf.sh b/qndtmf.sh index 3e4a15b..8cb15a4 100755 --- a/qndtmf.sh +++ b/qndtmf.sh @@ -12,9 +12,23 @@ # Example: D00617 will link local module to DCS006 Q # Example: *00103 will link local module to REF001 C # Example: 0 or 00 will report status of the link, " I" +# Example: ##08 will execute the exec_H.sh script (shutdown the system) # We set this to spaces, it will be set later + +GetLetter () { + if [[ $1 == ([0-9]) ]]; then + if [ $1 -gt 0 ] && [ $1 -le 26 ]; then + LETTER=${LETTERS[$1-1]} + return + fi + fi + LETTER=$BAD +} + LUSER=" " +LETTERS=( {A..Z} ) +BAD='bad' cd /tmp echo started at `date` @@ -25,101 +39,59 @@ do do echo found file $i at `date` LOCAL_BAND=${i:0:1} - if [[ "$LOCAL_BAND" = "A" ]] || [[ "$LOCAL_BAND" = "B" ]] || [[ "$LOCAL_BAND" = "C" ]] ; then + if [[ "$LOCAL_BAND" == 'A' ]] || [[ "$LOCAL_BAND" == 'B' ]] || [[ "$LOCAL_BAND" == 'C' ]]; then CMD=`head -n 1 $i 2>/dev/null` LUSER=`tail -n 1 $i 2>/dev/null` echo "... with these contents: " $CMD " " $LUSER - if [[ "$CMD" = "#" ]] ; then + if [[ "$CMD" == '#' ]]; then echo Unlinking local band $LOCAL_BAND requested by $LUSER qnremote ${LOCAL_BAND} "$LUSER" U >/dev/null 2>&1 echo - elif [[ "$CMD" = "0" ]] || [[ "$CMD" = "00" ]] ; then + elif [[ "$CMD" == '0' ]] || [[ "$CMD" == '00' ]]; then echo Link Status on local band $LOCAL_BAND requested by $LUSER qnremote ${LOCAL_BAND} "$LUSER" I >/dev/null 2>&1 echo - elif [[ "$CMD" = "**" ]] ; then + elif [[ "$CMD" == '**' ]]; then echo Load Hosts on local band $LOCAL_BAND requested by $LUSER qnremote ${LOCAL_BAND} "$LUSER" F >/dev/null 2>&1 else - LEN=${#CMD} - if [[ "$LEN" = "6" ]] ; then - PFX=${CMD:0:1} - REMOTE_NODE=${CMD:1:3} - REMOTE_BAND=${CMD:4:2} - - if [[ "$REMOTE_BAND" = "01" ]] ; then - REMOTE_BAND=A - elif [[ "$REMOTE_BAND" = "02" ]] ; then - REMOTE_BAND=B - elif [[ "$REMOTE_BAND" = "03" ]] ; then - REMOTE_BAND=C - elif [[ "$REMOTE_BAND" = "04" ]] ; then - REMOTE_BAND=D - elif [[ "$REMOTE_BAND" = "05" ]] ; then - REMOTE_BAND=E - elif [[ "$REMOTE_BAND" = "06" ]] ; then - REMOTE_BAND=F - elif [[ "$REMOTE_BAND" = "07" ]] ; then - REMOTE_BAND=G - elif [[ "$REMOTE_BAND" = "08" ]] ; then - REMOTE_BAND=H - elif [[ "$REMOTE_BAND" = "09" ]] ; then - REMOTE_BAND=I - elif [[ "$REMOTE_BAND" = "10" ]] ; then - REMOTE_BAND=J - elif [[ "$REMOTE_BAND" = "11" ]] ; then - REMOTE_BAND=K - elif [[ "$REMOTE_BAND" = "12" ]] ; then - REMOTE_BAND=L - elif [[ "$REMOTE_BAND" = "13" ]] ; then - REMOTE_BAND=M - elif [[ "$REMOTE_BAND" = "14" ]] ; then - REMOTE_BAND=N - elif [[ "$REMOTE_BAND" = "15" ]] ; then - REMOTE_BAND=O - elif [[ "$REMOTE_BAND" = "16" ]] ; then - REMOTE_BAND=P - elif [[ "$REMOTE_BAND" = "17" ]] ; then - REMOTE_BAND=Q - elif [[ "$REMOTE_BAND" = "18" ]] ; then - REMOTE_BAND=R - elif [[ "$REMOTE_BAND" = "19" ]] ; then - REMOTE_BAND=S - elif [[ "$REMOTE_BAND" = "20" ]] ; then - REMOTE_BAND=T - elif [[ "$REMOTE_BAND" = "21" ]] ; then - REMOTE_BAND=U - elif [[ "$REMOTE_BAND" = "22" ]] ; then - REMOTE_BAND=V - elif [[ "$REMOTE_BAND" = "23" ]] ; then - REMOTE_BAND=W - elif [[ "$REMOTE_BAND" = "24" ]] ; then - REMOTE_BAND=X - elif [[ "$REMOTE_BAND" = "25" ]] ; then - REMOTE_BAND=Y - elif [[ "$REMOTE_BAND" = "26" ]] ; then - REMOTE_BAND=Z + if [ ${#CMD} -eq 4 ] && [[ ${CMD:0:2} == '##' ]]; then + GetLetter ${CMD:2:2} + if [[ "$LETTER" == "$BAD" ]]; then + echo "bad script letter index: '${CMD:2:2}'" else - REMOTE_BAND=Z + exec_${LETTER}.sh fi + elif [ ${#CMD} -eq 6 ]; then - if [[ "$PFX" = "B" ]] ; then + PFX=${CMD:0:1} + if [[ "$PFX" = 'B' ]]; then RMT=XRF - elif [[ "$PFX" = "D" ]] ; then + elif [[ "$PFX" = 'D' ]]; then RMT=DCS - elif [[ "$PFX" = "*" ]] ; then + elif [[ "$PFX" = '*' ]]; then RMT=REF else - RMT=garbage + RMT=$BAD fi - if [[ "$RMT" == "garbage" ]] ; then - echo bad value in prefix + REMOTE_NODE=${CMD:1:3} + if [[ $REMOTE_NODE != ([0-9]) ]]; then + REMOTE_NODE=$BAD + fi + + GetLetter ${CMD:4:2} + REMOTE_BAND=$LETTER + + if [[ "$RMT" == "$BAD" ]] || [[ "$REMOTE_NODE" == "$BAD" ]] || [[ "$REMOTE_BAND" == "$BAD" ]]; then + echo "nonsense link command: '$CMD'" else echo linking local band $LOCAL_BAND to remote node ${RMT}${REMOTE_NODE} $REMOTE_BAND requested by $LUSER qnremote ${LOCAL_BAND} "$LUSER" ${RMT}${REMOTE_NODE}${REMOTE_BAND}L >/dev/null 2>&1 echo fi + else + echo "Bad command: '$CMD'" fi fi else