|
@@ -43,13 +43,13 @@ function show_help {
|
43
|
43
|
}
|
44
|
44
|
|
45
|
45
|
function sip_user_exists {
|
46
|
|
- for line in $(cat $CONFIG_FILE)
|
47
|
|
- do
|
|
46
|
+ IFS=''
|
|
47
|
+ while read line; do
|
48
|
48
|
if [[ "$line" == "<user id=\"$MY_USERNAME\">" ]]; then
|
49
|
49
|
USER_EXISTS="yes"
|
50
|
50
|
return
|
51
|
51
|
fi
|
52
|
|
- done
|
|
52
|
+ done < $CONFIG_FILE
|
53
|
53
|
}
|
54
|
54
|
|
55
|
55
|
function update_sip_user {
|
|
@@ -59,8 +59,8 @@ function update_sip_user {
|
59
|
59
|
rm -f $NEW_CONFIG_FILE
|
60
|
60
|
fi
|
61
|
61
|
touch $NEW_CONFIG_FILE
|
62
|
|
- for line in $(cat $CONFIG_FILE)
|
63
|
|
- do
|
|
62
|
+ IFS=''
|
|
63
|
+ while read line; do
|
64
|
64
|
if [ ! $USER_FOUND ]; then
|
65
|
65
|
if [[ "$line" == "<user id=\"$MY_USERNAME\">" ]]; then
|
66
|
66
|
USER_FOUND="yes"
|
|
@@ -78,7 +78,7 @@ function update_sip_user {
|
78
|
78
|
fi
|
79
|
79
|
fi
|
80
|
80
|
echo $line >> $NEW_CONFIG_FILE
|
81
|
|
- done
|
|
81
|
+ done < $CONFIG_FILE
|
82
|
82
|
mv $NEW_CONFIG_FILE $CONFIG_FILE
|
83
|
83
|
}
|
84
|
84
|
|
|
@@ -88,8 +88,8 @@ function add_sip_user {
|
88
|
88
|
rm -f $NEW_CONFIG_FILE
|
89
|
89
|
fi
|
90
|
90
|
touch $NEW_CONFIG_FILE
|
91
|
|
- for line in $(cat $CONFIG_FILE)
|
92
|
|
- do
|
|
91
|
+ IFS=''
|
|
92
|
+ while read line; do
|
93
|
93
|
if [[ "$line" == '</provision>' ]]; then
|
94
|
94
|
echo "<user id=\"$MY_USERNAME\">" >> $NEW_CONFIG_FILE
|
95
|
95
|
echo "<extension>$EXTENSION</extension>" >> $NEW_CONFIG_FILE
|
|
@@ -98,7 +98,7 @@ function add_sip_user {
|
98
|
98
|
echo '</user>' >> $NEW_CONFIG_FILE
|
99
|
99
|
fi
|
100
|
100
|
echo $line >> $NEW_CONFIG_FILE
|
101
|
|
- done
|
|
101
|
+ done < $CONFIG_FILE
|
102
|
102
|
mv $NEW_CONFIG_FILE $CONFIG_FILE
|
103
|
103
|
usermod -aG sipwitch $MY_USERNAME
|
104
|
104
|
}
|