reboot_phones.sh 974 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. #This script will reboot all the phones in a particular domain for a specified model. A pause is optional.
  3. #gather parameters
  4. read -p "Enter the Domain to Reboot (example: abc.net):" domain
  5. read -p "Enter the phone type to reboot (polycom, yealink, cisco):" vendor
  6. read -p "Enter the time in seconds to pause between phones:" pausetime
  7. #create a temp file
  8. NOW=$(date +"%Y%m%d_%H%M%S")
  9. FILE="registrations-$NOW.csv"
  10. #gather the registrations from freeswitch
  11. eval 'fs_cli -x "show registrations" > $FILE'
  12. #create some variables
  13. N=0
  14. ARR=()
  15. #set the internal field separator
  16. IFS=","
  17. INPUT=$FILE
  18. #Loop through the registrations and reboot
  19. [ ! -f $INPUT ] &while read reg_user realm extra
  20. do
  21. if [ ."$realm" = ."$domain" ]; then
  22. eval 'fs_cli -x "luarun app.lua event_notify internal reboot $reg_user@$realm $vendor"'
  23. if [ "$pausetime" > 0 ]; then
  24. sleep $pausetime
  25. fi
  26. fi
  27. done < $INPUT
  28. IFS=$OLDIFS
  29. #remove the file
  30. rm $FILE