summaryrefslogtreecommitdiff
path: root/recipes-core/mlinux-scripts
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2017-08-28 14:43:18 -0500
committerJohn Klug <john.klug@multitech.com>2017-09-14 17:31:21 -0500
commit1e07a786112f7217bca318c55a37f4123e9a2b45 (patch)
treea5bed742f5291e6c37fae3f99f8b8d9a7fda02dd /recipes-core/mlinux-scripts
parent08ae15c88a7a0fc94853063bdb5cdf9eb4d7ecb1 (diff)
downloadmeta-mlinux-atmel-1e07a786112f7217bca318c55a37f4123e9a2b45.tar.gz
meta-mlinux-atmel-1e07a786112f7217bca318c55a37f4123e9a2b45.tar.bz2
meta-mlinux-atmel-1e07a786112f7217bca318c55a37f4123e9a2b45.zip
Make sure radio is ready, and do not assume any particular APN
Diffstat (limited to 'recipes-core/mlinux-scripts')
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-set-apn28
1 files changed, 19 insertions, 9 deletions
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-set-apn b/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-set-apn
index 691ecd2..a588587 100755
--- a/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-set-apn
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-set-apn
@@ -24,6 +24,7 @@ function usage {
echo "Usage: $(basename $0) [--] APN"
echo "Or $(basename $0) -c to clear the APN line"
echo "-- is requied if the APN begins with -"
+ echo "Radio must be ready to set the APN"
exit 1
}
@@ -46,22 +47,31 @@ leu1_chat_file=/etc/ppp/peers/leu1_chat
lna3_chat_file=/etc/ppp/peers/lna3_chat
model=$(radio-query --model 2>/dev/null)
+if (($? != 0)) ; then
+ echo "Radio is not ready or not found and cannot determine the type"
+ exit 1
+fi
if [[ $model == "LE910-NA1" ]] ; then
if ((clear != 1)) ; then
- if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=3,\"IPV4V6\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=3,\"IPV4V6\",\"${apn}\"'/" $lna3_chat_file ; then
+ if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=3,\"([^\"]*)\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=3,\"\2\",\"${apn}\"'/" $lna3_chat_file ; then
echo "Set APN to \"${apn}\" in $lna3_chat_file"
else
echo "Failed to set APN in $lna3_chat_file"
fi
- fw=$(radio-query --active-firmware 2>/dev/null) || ((fw=-1))
+ fw=$(radio-query --active-firmware 2>/dev/null)
+ if (($? != 0)) ; then
+ echo "Radio query for active firmware failed, so clear APN"
+ fw=1
+ fi
+
if (( fw == 1 )) ; then
# Verizon is active, so comment out the APN
echo "Temporarily commenting out APN, since Verizon is active and no APN is allowed in a Verizon chat file."
- sed -r -i "s/^(OK\s+'AT\+CGDCONT=3,\"IPV4V6\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $lna3_chat_file
+ sed -r -i "s/^(OK\s+'AT\+CGDCONT=3,\"[^/]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $lna3_chat_file
fi
else
- if sed -r -i "s/^(OK\s+'AT\+CGDCONT=3,\"IPV4V6\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $lna3_chat_file ; then
+ if sed -r -i "s/^(OK\s+'AT\+CGDCONT=3,\"[^/]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $lna3_chat_file ; then
echo "Commented out APN in $lna3_chat_file"
else
echo "Failed to comment out APN in $lna3_chat_file"
@@ -72,7 +82,7 @@ fi
if ((clear != 1)) ; then
- if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=1,\"IP\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=1,\"IP\",\"${apn}\"'/" $gsm_chat_file ; then
+ if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=1,\"([^\"]*)\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=1,\"\2\",\"${apn}\"'/" $gsm_chat_file ; then
echo "Set APN to \"${apn}\" in $gsm_chat_file"
else
echo "Failed to set APN in $gsm_chat_file"
@@ -80,22 +90,22 @@ if ((clear != 1)) ; then
echo "Not allowed to set APN for $lvw2_chat_file"
# We cannot set the APN for a Verizon modem
# sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=3,\"IPV4V6\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=3,\"IPV4V6\",\"${apn}\"'/" $lvw2_chat_file
- if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=1,\"IPV4V6\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=1,\"IPV4V6\",\"${apn}\"'/" $leu1_chat_file ; then
+ if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=1,\"([^\"]*)\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=1,\"\2\",\"${apn}\"'/" $leu1_chat_file ; then
echo "Set APN to \"${apn}\" in $leu1_chat_file"
else
echo "Failed to set APN in $leu1_chat_file"
fi
else
- if sed -r -i "s/^(OK\s+'AT\+CGDCONT=1,\"IP\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $gsm_chat_file ; then
+ if sed -r -i "s/^(OK\s+'AT\+CGDCONT=1,\"[^\"]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $gsm_chat_file ; then
echo "Commented out APN in $gsm_chat_file"
else
echo "Failed to comment out APN in $gsm_chat_file"
fi
# Not setting APN in lvw2 is OK, since Verizon should not have an APN in a chat file.
- if sed -r -i "s/^(OK\s+'AT\+CGDCONT=3,\"IPV4V6\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $lvw2_chat_file ; then
+ if sed -r -i "s/^(OK\s+'AT\+CGDCONT=3,\"[^\"]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $lvw2_chat_file ; then
echo "Commented out APN in $lvw2_chat_file"
fi
- if sed -r -i "s/^(OK\s+'AT\+CGDCONT=1,\"IPV4V6\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $leu1_chat_file ; then
+ if sed -r -i "s/^(OK\s+'AT\+CGDCONT=1,\"[^\"]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $leu1_chat_file ; then
echo "Commented out APN in $leu1_chat_file"
else
echo "Failed to comment out APN in $leu1_chat_file"