diff --git a/src/freedombone-addsipuser b/src/freedombone-addsipuser index eaa95803..f05338b7 100755 --- a/src/freedombone-addsipuser +++ b/src/freedombone-addsipuser @@ -43,13 +43,13 @@ function show_help { } function sip_user_exists { - for line in $(cat $CONFIG_FILE) - do + IFS='' + while read line; do if [[ "$line" == "" ]]; then USER_EXISTS="yes" return fi - done + done < $CONFIG_FILE } function update_sip_user { @@ -59,8 +59,8 @@ function update_sip_user { rm -f $NEW_CONFIG_FILE fi touch $NEW_CONFIG_FILE - for line in $(cat $CONFIG_FILE) - do + IFS='' + while read line; do if [ ! $USER_FOUND ]; then if [[ "$line" == "" ]]; then USER_FOUND="yes" @@ -78,7 +78,7 @@ function update_sip_user { fi fi echo $line >> $NEW_CONFIG_FILE - done + done < $CONFIG_FILE mv $NEW_CONFIG_FILE $CONFIG_FILE } @@ -88,8 +88,8 @@ function add_sip_user { rm -f $NEW_CONFIG_FILE fi touch $NEW_CONFIG_FILE - for line in $(cat $CONFIG_FILE) - do + IFS='' + while read line; do if [[ "$line" == '' ]]; then echo "" >> $NEW_CONFIG_FILE echo "$EXTENSION" >> $NEW_CONFIG_FILE @@ -98,7 +98,7 @@ function add_sip_user { echo '' >> $NEW_CONFIG_FILE fi echo $line >> $NEW_CONFIG_FILE - done + done < $CONFIG_FILE mv $NEW_CONFIG_FILE $CONFIG_FILE usermod -aG sipwitch $MY_USERNAME } diff --git a/src/freedombone-rmsipuser b/src/freedombone-rmsipuser index 6e02c272..b2951cb8 100755 --- a/src/freedombone-rmsipuser +++ b/src/freedombone-rmsipuser @@ -41,13 +41,13 @@ function show_help { } function sip_user_exists { - for line in $(cat $CONFIG_FILE) - do + IFS='' + while read line; do if [[ "$line" == "" ]]; then USER_EXISTS="yes" return fi - done + done < $CONFIG_FILE } function remove_sip_user { @@ -57,21 +57,21 @@ function remove_sip_user { rm -f $NEW_CONFIG_FILE fi touch $NEW_CONFIG_FILE - for line in $(cat $CONFIG_FILE) - do + IFS='' + while read line; do if [ ! $USER_FOUND ]; then if [[ "$line" == "" ]]; then USER_FOUND="yes" fi fi if [ ! $USER_FOUND ]; then - echo $line >> $NEW_CONFIG_FILE + echo "$line" >> $NEW_CONFIG_FILE else if [[ "$line" == '' ]]; then USER_FOUND= fi fi - done + done < $CONFIG_FILE mv $NEW_CONFIG_FILE $CONFIG_FILE } diff --git a/src/freedombone-sipfreeext b/src/freedombone-sipfreeext index 7a61dab0..fa0060eb 100755 --- a/src/freedombone-sipfreeext +++ b/src/freedombone-sipfreeext @@ -34,8 +34,8 @@ CONFIG_FILE=/etc/sipwitch.conf extensions=() # get the used extensions -for line in $(cat $CONFIG_FILE) -do +IFS='' +while read line; do if [[ "$line" == ""* ]]; then ext=$(echo "$line" | awk -F '>' '{print $2}' | awk -F '<' '{print $1}') extensions+=($ext) @@ -43,7 +43,7 @@ do if [[ "$line" == '' ]]; then break fi -done +done < $CONFIG_FILE #echo "used extensions:" #echo $extensions