Next SIP extension
This commit is contained in:
parent
7100b577f8
commit
31316c3bf5
|
@ -35,35 +35,23 @@ extensions=()
|
|||
|
||||
# get the used extensions
|
||||
IFS=''
|
||||
while read line; 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 < $CONFIG_FILE
|
||||
for line in $(cat $CONFIG_FILE | grep "extension"); do
|
||||
extnum=$(echo "$line" | awk -F '>' '{print $2}' | awk -F '<' '{print $1}')
|
||||
extensions+=($extnum)
|
||||
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;
|
||||
# find the max extension number
|
||||
maxnum=201
|
||||
for i in ${extensions[@]}; do
|
||||
if [ $i -gt $maxnum ]; then
|
||||
maxnum=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $maxnum -gt 299 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo $(($maxnum + 1))
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue