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

Line matching

parent 5ca98a20
No related branches found
No related tags found
Loading
......@@ -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
......
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