huawei e1550 + Smstools3

Конфиги

/etc/smsd.conf

# Example smsd.conf. Read the manual for a description

devices = GSM1
logfile = /var/log/smsd.log
loglevel = 3

outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
failed = /var/spool/sms/failed
incoming = /var/spool/sms/incoming
sent = /var/spool/sms/sent

delaytime = 6
errorsleeptime = 12
blocktime = 180
autosplit = 3
receive_before_send = yes
decode_unicode_text = yes
eventhandler = /etc/sms_events.sh

[GSM1]
#device = /dev/gsmmodem
device = /dev/ttyUSB1
baudrate = 115200
report = yes
rtscts = no
#init = AT+CPMS="SM","SM",""
init = AT+CPMS="SM","SM","SM"
#check_memory_metod = 2
check_memory_method = 31
signal_quality_ber_ignore = yes
incoming = yes
incoming = high

 

/etc/sms_events.sh - исполняет команду по смс вида #/etc/now_time_money.sh

#! /bin/bash

COMMAND_CHAR="#"
#INCOMING_DIR=/var/spool/sms/incoming
ALLOW_PHONES="7916xxxxxxx 7965xxxxxxx"
SEND_BACK_REPORT=NO

[ "$1" = "RECEIVED" ] || exit 0

to_log(){
    text=$1
    export LANG=en_EN
    log_date=`date "+%b %d %H:%M:%S "`
    log_host=`hostname -s`
    echo "$log_date $log_host $text" >> /var/log/smsd.log
}

File=$2

Allow=0
for Phone in $ALLOW_PHONES; do
    cat $File | grep "From: $Phone" > /dev/null 2>&1
    [ $? -eq 0 ] && Allow=1
done;

[ $Allow -eq 0 ] && exit 0

cat $INCOMING_DIR/$File | grep "$COMMAND_CHAR"
[ $? -ne 0 ] && exit 0

FromPhone=`cat $File | grep "From:" | cut -d " " -f2`

command=`cat $File | grep "$COMMAND_CHAR" | cut -d "$COMMAND_CHAR" -f2`
to_log "Incoming command: $command from $FromPhone"
out=`$command`

if [ "$SEND_BACK_REPORT" = "YES" ]; then
    smssend $FromPhone "$out"
    to_log "Send sms to $FromPhone: $out"
fi
rm -f $File
to_log "Deleting file $File"

 

/etc/sms3_monitoring —  рестарт при ошибке железа — cron — */5 *   * * *   root    /etc/sms3_monitoring

#!/bin/bash
rm /root/buffer_sms_file
date=`date`
tail -n5 /var/log/smsd.log > /root/buffer_sms_file
cat /root/buffer_sms_file | grep "Error: Modem is not registered to the network"
if [ $? -eq 0 ]; then
        /etc/init.d/sms3 restart
        tar cvfz /var/log/smsd.log /var/log/sms_erlog_$date.log
        shutdown -rf now
fi

cat /root/buffer_sms_file | grep "Error: registration is denied"
if [ $? -eq 0 ]; then
        /etc/init.d/sms3 restart
        tar cvfz /var/log/smsd.log /var/log/sms_erlog_$date.log
        shutdown -rf now
        fi

cat /root/buffer_sms_file | grep "Modem handler 0 terminated abnormally"
if [ $? -eq 0 ]; then
        /etc/init.d/sms3 restart
        tar cvfz /var/log/smsd.log /var/log/sms_erlog_$date.log
        shutdown -rf now
        fi

cat /root/buffer_sms_file | grep "write_to_modem: error 5: Input/output error"
if [ $? -eq 0 ]; then
        /etc/init.d/sms3 restart
        tar cvfz /var/log/smsd.log /var/log/sms_erlog_$date.log
        shutdown -rf now

        fi
cat /root/buffer_sms_file | grep "Couldn't open serial port /dev/ttyUSB"
if [ $? -eq 0 ]; then
        /etc/init.d/sms3 restart
        tar cvfz /var/log/smsd.log /var/log/sms_erlog_$date.log
        shutdown -rf now
        fi

 

 

 

  1. Пока комментариев нет.

  1. Пока что обратных ссылок нет.