Update 'gammu_receive_sms.sh'

This commit is contained in:
Beu 2017-11-23 22:34:43 +01:00
parent bce17c58c0
commit a7ef429fe0

View File

@ -4,8 +4,8 @@ SECRETKEY=''
PHONENUM=''
DATE=`date --date="1 minute ago" +'%Y-%m-%d %H:%M:%S'`
OTP=`oathtool -w 3 --now="$DATE" --totp -b $SECRETKEY`
DATE=`date --date="2 minute ago" +'%Y-%m-%d %H:%M:%S'`
OTP=`oathtool -w 4 --now="$DATE" --totp -b $SECRETKEY`
OTPFROMCLIENT=`echo $SMS_1_TEXT | awk '{print $NF}'`
CMD=`echo $SMS_1_TEXT | awk '{print tolower($1)}'`
@ -26,9 +26,16 @@ if [[ $SMS_1_NUMBER -eq $PHONENUM ]]; then
REPLY="Signal reboot envoyé"
;;
cmd)
HOST=`echo $SMS_1_TEXT | awk '{print $2}'`
COMMAND=`echo $SMS_1_TEXT | awk '{for (i=3; i<NF; i++) print $i}'`
HOST=`echo $TEXT | awk '{print $1}'`
COMMAND=`echo $TEXT | awk 'BEGIN {ORS=" "} {for (i=2; i<NF; i++) print $i}'`
REPLY=`ssh -oStrictHostKeyChecking=no root@$HOST $COMMAND`
pxy)
PHONENUM=`echo $TEXT | awk '{print $1}'`
REPLY=`echo $TEXT | awk 'BEGIN {ORS=" "} {for (i=2; i<NF; i++) print $i}'`
;;
*)
REPLY="Commande inconnu"
;;
esac
else
REPLY="Mauvais OTP"
@ -38,3 +45,4 @@ else
fi
/usr/bin/sudo /usr/bin/gammu-smsd-inject TEXT $PHONENUM -len 999 -textutf8 "$REPLY"
echo "[$DATE] $PHONENUM - $REPLY" >> /var/log/gammu_receive.log