Diff from version 2 to 10 (current)
@@ -1 +1,42 @@ |
-{attachment id=4652} | +cat addphone.sh | +~pp~ | +#!/bin/bash | +usersconf=/etc/asterisk/users.conf # Asterisk users.conf file | +password=admin # Phone admin password for remote reboot | +vendormac=00:0b # Vendor mac address prefix (00:0b - Grandstream) | +numdigs=2 # Number of digits in internal phone numbers 2 - 00 3 - 000 4 - 0000 | +secret=cnfywbz # sip password | +num=1 # start phone number | + | +cp ${usersconf} ${usersconf}.old | +printf -v numt "%.*u" ${numdigs} ${num} | +while read str ; | +do | +mac=$(echo -n ${str} | grep -o -E '([0-9a-z]{2}:){5}[0-9a-z]{2}' | grep "${vendormac}" | sed 's|:||g' ) | +if [ "${mac}" ] && [ ! "$(grep ${mac} ${usersconf})" ] ; then | + ip=$(echo -n ${str} | grep -o -E '([0-9]{1,3}\.){3}[0-9a-z]{1,3}') | + echo New phone found mac=${mac} ip=${ip} | + while [ "$(grep "\[${numt}\]" ${usersconf} )" ] ; | + do | + echo Number ${numt} already exist. Skipping. | + let num++ | + printf -v numt "%.*u" ${numdigs} ${num} | + done | + echo Assign to internal number ${numt} | + ( echo "[${numt}]" | + echo macaddress = ${mac} | + echo autoprov = yes | + echo secret = ${secret} | + echo fullname = ${numt} | + echo ) >>${usersconf} | + echo Reload asterisk config | + asterisk -rx "config reload ${usersconf}" # Informs asterisk that changed config file | + echo Reboot phone | + gsreboot ${password} ${ip} # Remote reboot phone for autoprovisioning | + let num++ | + printf -v numt "%.*u" ${numdigs} ${num} | + echo --- | +fi | +done | +~/pp~ | +{attachment id=4653} |
|
|
User | Comment | Time | Version |
---|
laigor | | 2014-03-27 20:32 | 10 |
laigor | | 2014-03-27 20:31 | 9 |
laigor | | 2014-03-27 20:30 | 8 |
laigor | | 2014-03-27 20:29 | 6 |
laigor | | 2014-03-27 20:28 | 5 |
laigor | | 2014-03-27 20:27 | 4 |
laigor | | 2014-03-27 20:15 | 3 |
laigor | | 2014-03-27 20:10 | 2 |