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

Get the next available SIP extension number

parent 932100d8
No related branches found
No related tags found
No related merge requests found
......@@ -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'
......
#!/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
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