Line matching
This commit is contained in:
parent
5ca98a2050
commit
a9efd5bcb3
|
@ -45,7 +45,7 @@ function show_help {
|
|||
function sip_user_exists {
|
||||
IFS=''
|
||||
while read line; do
|
||||
if [[ "$line" == "<user id=\"$MY_USERNAME\">" ]]; then
|
||||
if [[ "$line" == *"<user id=\"$MY_USERNAME\">" ]]; then
|
||||
USER_EXISTS="yes"
|
||||
return
|
||||
fi
|
||||
|
@ -62,17 +62,17 @@ function update_sip_user {
|
|||
IFS=''
|
||||
while read line; do
|
||||
if [ ! $USER_FOUND ]; then
|
||||
if [[ "$line" == "<user id=\"$MY_USERNAME\">" ]]; then
|
||||
if [[ "$line" == *"<user id=\"$MY_USERNAME\">" ]]; then
|
||||
USER_FOUND="yes"
|
||||
fi
|
||||
else
|
||||
if [[ "$line" == "<extension>"* ]]; then
|
||||
if [[ "$line" == *"<extension>"* ]]; then
|
||||
line="<extension>$EXTENSION</extension>"
|
||||
fi
|
||||
if [[ "$line" == "<secret>"* ]]; then
|
||||
if [[ "$line" == *"<secret>"* ]]; then
|
||||
line="<secret>$PASSWORD</secret>"
|
||||
fi
|
||||
if [[ "$line" == "<display>"* ]]; then
|
||||
if [[ "$line" == *"<display>"* ]]; then
|
||||
line="<display>$MY_USERNAME $EXTENSION</display>"
|
||||
USER_FOUND=
|
||||
fi
|
||||
|
@ -90,7 +90,7 @@ function add_sip_user {
|
|||
touch $NEW_CONFIG_FILE
|
||||
IFS=''
|
||||
while read line; do
|
||||
if [[ "$line" == '</provision>' ]]; then
|
||||
if [[ "$line" == *'</provision>' ]]; then
|
||||
echo "<user id=\"$MY_USERNAME\">" >> $NEW_CONFIG_FILE
|
||||
echo "<extension>$EXTENSION</extension>" >> $NEW_CONFIG_FILE
|
||||
echo "<secret>$PASSWORD</secret>" >> $NEW_CONFIG_FILE
|
||||
|
|
|
@ -43,7 +43,7 @@ function show_help {
|
|||
function sip_user_exists {
|
||||
IFS=''
|
||||
while read line; do
|
||||
if [[ "$line" == "<user id=\"$MY_USERNAME\">" ]]; then
|
||||
if [[ "$line" == *"<user id=\"$MY_USERNAME\">" ]]; then
|
||||
USER_EXISTS="yes"
|
||||
return
|
||||
fi
|
||||
|
@ -60,14 +60,14 @@ function remove_sip_user {
|
|||
IFS=''
|
||||
while read line; do
|
||||
if [ ! $USER_FOUND ]; then
|
||||
if [[ "$line" == "<user id=\"$MY_USERNAME\">" ]]; then
|
||||
if [[ "$line" == *"<user id=\"$MY_USERNAME\">" ]]; then
|
||||
USER_FOUND="yes"
|
||||
fi
|
||||
fi
|
||||
if [ ! $USER_FOUND ]; then
|
||||
echo "$line" >> $NEW_CONFIG_FILE
|
||||
else
|
||||
if [[ "$line" == '</user>' ]]; then
|
||||
if [[ "$line" == *'</user>' ]]; then
|
||||
USER_FOUND=
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue