Get the next available SIP extension number
This commit is contained in:
parent
932100d862
commit
2ae3f297e4
2
Makefile
2
Makefile
|
@ -43,6 +43,7 @@ install:
|
|||
install -m 755 src/${APP}-logging ${DESTDIR}${PREFIX}/bin
|
||||
install -m 755 src/${APP}-addsipuser ${DESTDIR}${PREFIX}/bin
|
||||
install -m 755 src/${APP}-rmsipuser ${DESTDIR}${PREFIX}/bin
|
||||
install -m 755 src/${APP}-sipfreeext ${DESTDIR}${PREFIX}/bin
|
||||
mkdir -m 755 -p ${DESTDIR}${PREFIX}/share/man/man1
|
||||
install -m 644 man/${APP}.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
||||
install -m 644 man/${APP}-keydrive.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
||||
|
@ -133,6 +134,7 @@ uninstall:
|
|||
rm -f ${PREFIX}/bin/${APP}-logging
|
||||
rm -f ${PREFIX}/bin/${APP}-addsipuser
|
||||
rm -f ${PREFIX}/bin/${APP}-rmsipuser
|
||||
rm -f ${PREFIX}/bin/${APP}-sipfreeext
|
||||
clean:
|
||||
rm -f \#* \.#* debian/*.substvars debian/*.log
|
||||
rm -fr deb.* debian/${APP}
|
||||
|
|
|
@ -205,6 +205,7 @@ if grep -q "Blog domain" $COMPLETION_FILE; then
|
|||
fi
|
||||
|
||||
if grep -q "install_sip" $COMPLETION_FILE; then
|
||||
SIP_EXTENSION=$(freedombone-sipfreeext)
|
||||
freedombone-addsipuser -u $MY_USERNAME -e $SIP_EXTENSION -p "$NEW_USER_PASSWORD"
|
||||
if [ ! "$?" = "0" ]; then
|
||||
echo 'SIP user could not be added'
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# .---. . .
|
||||
# | | |
|
||||
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
||||
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
||||
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
||||
#
|
||||
# Freedom in the Cloud
|
||||
#
|
||||
|
||||
# Returns the next free SIP extension number
|
||||
|
||||
# License
|
||||
# =======
|
||||
#
|
||||
# Copyright (C) 2015 Bob Mottram <bob@robotics.uk.to>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
CONFIG_FILE=/etc/sipwitch.conf
|
||||
|
||||
extensions=()
|
||||
|
||||
# get the used extensions
|
||||
for line in $ (cat $CONFIG_FILE)
|
||||
do
|
||||
if [[ "$line" == "<extension>"* ]]; then
|
||||
ext=$(echo "$line" | awk -F '>' '{print $2}' | awk -F '<' '{print $1}')
|
||||
extensions+=($ext)
|
||||
fi
|
||||
if [[ "$line" == '</provision>' ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
#echo "used extensions:"
|
||||
#echo $extensions
|
||||
#echo " "
|
||||
|
||||
# which is the first available unused extension ?
|
||||
for ext in $(seq 201 299);
|
||||
do
|
||||
is_used=
|
||||
for i in "${extensions[@]}"
|
||||
do
|
||||
if [[ "$i" == "$ext" ]]; then
|
||||
is_used=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ ! $is_used ]; then
|
||||
echo $ext;
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue