Skip to content
Snippets Groups Projects
Commit 7e59a41e authored by Bob Mottram's avatar Bob Mottram
Browse files

Improved way of getting the next SIP extension

parent 07b79522
No related branches found
No related tags found
No related merge requests found
......@@ -31,27 +31,12 @@
CONFIG_FILE=/etc/sipwitch.conf
extensions=()
# get the used extensions
IFS=''
for line in $(cat $CONFIG_FILE | grep "extension"); do
extnum=$(echo "$line" | awk -F '>' '{print $2}' | awk -F '<' '{print $1}')
extensions+=($extnum)
done
# find the max extension number
maxnum=201
for i in ${extensions[@]}; do
if [ $i -gt $maxnum ]; then
maxnum=$i
break
fi
while (( maxnum < 299 )); do
if ! grep -q "extension>$maxnum<" $CONFIG_FILE; then
break;
fi
maxnum=$((maxnum + 1))
done
if [ $maxnum -gt 299 ]; then
exit 1
fi
echo $(($maxnum + 1))
echo $maxnum
exit 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment