summaryrefslogtreecommitdiff
path: root/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-set-apn
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-set-apn')
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-set-apn71
1 files changed, 28 insertions, 43 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 8e4d3d2..8c59c78 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
@@ -20,14 +20,21 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
+gsm_chat_file=/etc/ppp/peers/gsm_chat
+lvw2_chat_file=/etc/ppp/peers/lvw2_chat
+leu1_chat_file=/etc/ppp/peers/leu1_chat
+lna3_chat_file=/etc/ppp/peers/lna3_chat_non_vz
+lna3_chat_link=/etc/ppp/peers/lna3_chat
+lna3_readme=/etc/ppp/peers/README.lna3
+
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
}
+
((clear=0))
if (($# < 1)); then
usage
@@ -41,55 +48,22 @@ elif [[ $1 =~ ^- ]] ; then
else
apn=$1
fi
-gsm_chat_file=/etc/ppp/peers/gsm_chat
-lvw2_chat_file=/etc/ppp/peers/lvw2_chat
-leu1_chat_file=/etc/ppp/peers/leu1_chat
-lna3_chat_file=/etc/ppp/peers/lna3_chat
radioproduct=$(/usr/sbin/mts-io-sysfs show product-id) # LNA3?
-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
-# Only support LNA3
-
-if [[ $model == LE910-NA1 ]] && [[ $radioproduct =~ -LNA3- ]] ; then
- if ((clear != 1)) ; 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)
- 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,\"[^/]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $lna3_chat_file
- fi
- else
- 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"
- fi
- fi
- exit 0
-else
- echo "Radio in product-id must be -LNA3- for LE910-NA1"
- echo "Radio model is \"$model\", product-id is \"$radioproduct\""
+# Disable the LNA3 chat script
+if ! [[ -L $lna3_chat_link ]] || [[ $(basename $(readlink -f $lna3_chat_link)) != README.lna3 ]] ; then
+ ln -sf "${lna3_readme}" "${lna3_chat_link}"
+ echo Disabling LNA3 chat script.
fi
-
if ((clear != 1)) ; 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
+ if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=([0-9]*),\"([^\"]*)\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=\2,\"\3\",\"${apn}\"'/" $gsm_chat_file ; then
echo "Set APN to \"${apn}\" in $gsm_chat_file"
else
echo "Failed to set APN in $gsm_chat_file"
@@ -97,25 +71,36 @@ 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,\"([^\"]*)\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=1,\"\2\",\"${apn}\"'/" $leu1_chat_file ; then
+ if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=([0-9]*),\"([^\"]*)\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=\2,\"\3\",\"${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
+ if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=([0-9]*),\"([^\"]*)\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=\2,\"\3\",\"${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
else
- if sed -r -i "s/^(OK\s+'AT\+CGDCONT=1,\"[^\"]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $gsm_chat_file ; then
+ if sed -r -i "s/^(OK\s+'AT\+CGDCONT=[0-9]*,\"[^\"]*\",\"[^\"]*\"'$)/#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,\"[^\"]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $lvw2_chat_file ; then
+ if sed -r -i "s/^(OK\s+'AT\+CGDCONT=[0-9]*,\"[^\"]*\",\"[^\"]*\"'$)/#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,\"[^\"]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $leu1_chat_file ; then
+ if sed -r -i "s/^(OK\s+'AT\+CGDCONT=[0-9]*,\"[^\"]*\",\"[^\"]*\"'$)/#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"
fi
+ if sed -r -i "s/^(OK\s+'AT\+CGDCONT=[0-9]*,\"[^\"]*\",\"[^\"]*\"'$)/#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"
+ fi
fi
+
exit 0