Reboot phones in domain

Status
Not open for further replies.

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,044
565
113
From KonradSC in IRC:

Code:
#!/bin/bash
read -p "Enter the Domain to Reboot (example: abc.encoretg.net):" domain
read -p "Enter the phone type to reboot (polycom, yealink, cisco):" vendor
read -p "Enter the time in seconds to pause between phones:" pausetime


NOW=$(date +"%Y%m%d_%H%M%S")
FILE="registrations-$NOW.csv"

eval 'fs_cli -x "show registrations" > $FILE'

N=0
ARR=()

IFS=","

INPUT=$FILE
[ ! -f $INPUT ] &while read reg_user realm extra
do
       if [ "$realm" = "$domain" ]; then
                echo "$reg_user@$realm"
                eval 'fs_cli -x "luarun app.lua event_notify internal reboot $reg_user@$realm $vendor"'
                if [ "$pausetime" > 0 ]; then
                        sleep $pausetime
                fi
        fi
done < $INPUT
IFS=$OLDIFS
rm $FILE
 
  • Like
Reactions: yukon

Alfa

New Member
Mar 1, 2017
9
0
1
38
Hi, thanks for your script :)
I have an error on "ARR=()" but as long it not used I simply comment it and it work.
There is a way to send unregister on user after send the reboot to the phone ? Like "eval 'fs_cli -x "luarun app.lua event_notify internal unregister $reg_user@$realm $vendor"' ?
 

djacob

Member
Oct 31, 2016
43
8
8
50
Bensalem PA , USA
Digi, here is how we do it. we have this script in crontab then you just pass in the domain name you want to reboot all the phones for:

#Reboot somedomain Phones at 3am
0 3 * * * /root/scripts/pbx/cli_utils/reboot_phones.sh pbx.somedomain.com > /dev/null

script is :

#!/bin/bash
DOMAIN=$1
for EXT in `psql -U postgres -A -t -c "select sip_user from sip_registrations where sip_host='$DOMAIN';" freeswitch`; do
/usr/local/bin/fs_cli -x 'lua /var/www/fusionpbx/resources/install/scripts/app.lua event_notify internal reboot $EXT@$DOMAIN grandstream'
done

##This is for grandstream phones

just wanted to share this,
Dave
 
Status
Not open for further replies.