Prechádzať zdrojové kódy

Added SMS notification.
Fixes cause of sipsak changes.

Nils Ohlmeier 23 rokov pred
rodič
commit
e71148ce8b
1 zmenil súbory, kde vykonal 20 pridanie a 12 odobranie
  1. 20 12
      etc/serresponse

+ 20 - 12
etc/serresponse

@@ -7,10 +7,7 @@
 
 
 [email protected]
-SERHOME=/home/srouter
-SERDIR=$SERHOME/sip_router
-TESTDIR=$SERDIR/test
-BIN=$TESTDIR/sipsak
+SIPSAK=/home/srouter/sipsak/sipsak
 SIPURI=sip:[email protected]
 LOCKDIR=/var/lock
 LOCKFILE=serresponse
@@ -18,12 +15,18 @@ LOCK_TIMEOUT=240
 TMP=/tmp/serresponse.$$
 MAILCOMMAND=/bin/mail
 HOSTN=`hostname`
+SMSSEND=/home/sms/smstools/bin/putsms
+SMSDEVICE=/dev/ttyS0
+SMSNUMBERS="491795061546"
 
 ############################
 
 LOCKF=$LOCKDIR/$LOCKFILE
 TMP2=$TMP.dns
 TMP3=$TMP.ips
+SIPSAKCMD="$SIPSAK -v -s $SIPURI"
+SIPSAKNCMD="$SIPSAK -v -n -s $SIPURI"
+SMSCMD="$SMSSEND -d$SMSDEVICE -b9600"
 
 if [ -e $LOCKF ] ; then
 	find $LOCKDIR -name $LOCKFILE -amin +$LOCK_TIMEOUT -exec rm {} ';'
@@ -36,17 +39,19 @@ if [ -e $LOCKF ] ; then
 fi
 
 if [ ! -e $LOCKF ] ; then
-	if [ ! -x $BIN ] ; then
-		echo "serresponse did not find the required sipsak executable $BIN" >> $TMP
+	if [ ! -x $SIPSAK ] ; then
+		echo "serresponse did not find the required sipsak executable $SIPSAK" >> $TMP
 	else
-		echo "  $BIN -s $SIPURI" >> $TMP2
+		echo "  $SIPSAKCMD" >> $TMP2
 		echo "produced this output:" >> $TMP2
-		$BIN -s $SIPURI >> $TMP2 2>&1
-		if [ $? -eq 1 ] ; then
-			echo "  $BIN -n -s $SIPURI" >> $TMP3
+		$SIPSAKCMD >> $TMP2 2>&1
+		echo "$SIPSAKCMD = $?"
+		if [ $? -eq 3 ] ; then
+			echo "  $SIPSAKNCMD" >> $TMP3
 			echo "produced this output:" >> $TMP3
-			$BIN -n -s $SIPURI >> $TMP3 2>&1
-			if [ $? -eq 0 ] ; then
+			$SIPSAKNCMD >> $TMP3 2>&1
+			echo "$SIPSAKNCMD = $?"
+			if [ $? -le 1 ] ; then
 				echo "ser did not responses (fast enough) on the sipsak requests with fqdn in Via" >> $TMP
 				echo "but the test with IPs in Via succeeded." >> $TMP
 				echo "  => DNS PROBLEM !?!" >> $TMP
@@ -96,6 +101,9 @@ if [ ! -e $LOCKF ] ; then
 	
 	if [ -e $TMP ] ; then
 		$MAILCOMMAND -s "serresponse failed" $NOTIFY < $TMP
+		for i in $SMSNUMBERS; do
+			$SMSCMD $i "serresponse failed. please check your emails for details"
+		done
 		touch $LOCKF
 		rm -f $TMP
 	fi