Ajout du script
This commit is contained in:
parent
13299a3e26
commit
fbe4db13b5
41
gammu_receive_sms.sh
Normal file
41
gammu_receive_sms.sh
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SECRETKEY=''
|
||||||
|
PHONENUM=''
|
||||||
|
|
||||||
|
DATE=`date --date="1 minute ago" +'%Y-%m-%d %H:%M:%S'`
|
||||||
|
OTP=`oathtool -w 3 --now="$DATE" --totp -b $SECRETKEY`
|
||||||
|
|
||||||
|
OTPFROMCLIENT=`echo $SMS_1_TEXT | awk '{print $NF}'`
|
||||||
|
CMD=`echo $SMS_1_TEXT | awk '{print tolower($1)}'`
|
||||||
|
TEXT=`echo $SMS_1_TEXT | awk '{for (i=2; i<NF; i++) print $i}'`
|
||||||
|
MATCH=`echo $OTP | grep $OTPFROMCLIENT`
|
||||||
|
|
||||||
|
echo $OTP >> /var/log/gammu_receive.log
|
||||||
|
|
||||||
|
if [[ $SMS_1_NUMBER -eq $PHONENUM ]]; then
|
||||||
|
if [[ -n $MATCH ]] ;then
|
||||||
|
case $CMD in
|
||||||
|
allo)
|
||||||
|
REPLY="A l'huile"
|
||||||
|
;;
|
||||||
|
ping)
|
||||||
|
REPLY=`ping -n -c 2 $TEXT`
|
||||||
|
;;
|
||||||
|
reboot)
|
||||||
|
ssh root@"$TEXT" 'sudo reboot'
|
||||||
|
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}'`
|
||||||
|
REPLY=`ssh -oStrictHostKeyChecking=no root@$HOST $COMMAND`
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
REPLY="Mauvais OTP"
|
||||||
|
fi
|
||||||
|
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"
|
Loading…
Reference in New Issue
Block a user