Check dongle status on Chan_dongle and restart asterisk

sezione dedicata ai sistemi operativi alternativi Open Source

Check dongle status on Chan_dongle and restart asterisk

Messaggio da leggereda root » 29/11/2018, 16:20

Install usbreset:
opkg update
opkg install usbreset


launch usbreset to check dongle ID:
usbreset

example:
root@OpenWrt:~# usbreset
Usage:
usbreset PPPP:VVVV - reset by product and vendor id
usbreset BBB/DDD - reset by bus and device number
usbreset "Product" - reset by product name

Devices:
Number 001/002 ID 05e3:0608 USB2.0 Hub
Number 001/005 ID 12d1:1001 HUAWEI Mobile


create script:
nano /root/check-gsm.sh

#!/bin/bash
# check dongle status, reset dongle and restart asterisk if not ready
#
checkifok=`/usr/sbin/asterisk -rx "dongle show devices" | grep -wc Free`
if [[ $checkifok == 0 ]]; then
/bin/echo "Dongle not ready" >/dev/null 2>&1
/bin/sleep 3
/usr/bin/usbreset 12d1:1001
/bin/sleep 2
/etc/init.d/asterisk restart
else
/bin/echo "Dongle OK" >/dev/null 2>&1
fi
# eof


give the right permisisons to the above script:
chmod 755 /root/check-gsm.sh

add this to root crontabs:
# check dongle status every 5 minutes and restart asterisk if not ready
*/5 * * * * /root/check-gsm.sh
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 394
Iscritto il: 10/04/2012, 10:55
Località: Turin

Re: Check dongle status on Chan_dongle and restart asterisk

Messaggio da leggereda root » 30/11/2018, 4:24

SIP checking:

nano /root/check-sip.sh

#!/bin/bash
# controllo trunk SIP asterisk, se non registrato manda una mail di avviso e riavvia asterisk
#
checkifok=`/usr/sbin/asterisk -rx "sip show registry" | grep -wc Registered`
if [[ $checkifok == 0 ]]; then
/bin/echo "SIP trunk(s) not registered" >/dev/null 2>&1
/bin/sleep 3
/etc/init.d/asterisk restart
else
/bin/echo "Trunk(s) OK" > /dev/null 2>&1
fi
# eof
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 394
Iscritto il: 10/04/2012, 10:55
Località: Turin


Torna a OpenWRT

Chi c’è in linea

Visitano il forum: Nessuno e 2 ospiti

cron