Update 'gammu_receive_sms.sh'
This commit is contained in:
parent
bce17c58c0
commit
a7ef429fe0
@ -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"
|
||||
@ -37,4 +44,5 @@ else
|
||||
REPLY="FROM: $SMS_1_NUMBER TEXT: $SMS_1_TEXT"
|
||||
fi
|
||||
|
||||
/usr/bin/sudo /usr/bin/gammu-smsd-inject TEXT $PHONENUM -len 999 -textutf8 "$REPLY"
|
||||
/usr/bin/sudo /usr/bin/gammu-smsd-inject TEXT $PHONENUM -len 999 -textutf8 "$REPLY"
|
||||
echo "[$DATE] $PHONENUM - $REPLY" >> /var/log/gammu_receive.log
|
Loading…
Reference in New Issue
Block a user