summaryrefslogtreecommitdiff
path: root/recipes-core/mlinux-scripts/mlinux-scripts-1.2
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-core/mlinux-scripts/mlinux-scripts-1.2')
-rw-r--r--recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-cell-radio-ready34
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-cell-router147
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-dhcpd65
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-firmware-upgrade69
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-set-apn117
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-apn161
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-cell-fw211
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-wifi-ap165
8 files changed, 969 insertions, 0 deletions
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-cell-radio-ready b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-cell-radio-ready
new file mode 100644
index 0000000..42c5cdc
--- /dev/null
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-cell-radio-ready
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# The timeout can be set in the environment or the
+# first parameter.
+
+COUNTER=0
+
+if [ $# -gt 1 ]; then
+ echo "usage: $0 [timeout]"
+ exit 1
+fi
+
+[ $# -eq 1 ] && TIMEOUT=$1
+
+# Set the default TIMEOUT
+: ${TIMEOUT:=60}
+
+# Wait for the radio to be ready before continuing
+while [ $COUNTER -lt $TIMEOUT ]; do
+ TYPE=$(radio-query --type)
+ MODEL=$(radio-query --model)
+ if [ $? == 0 ]; then
+ echo "Cellular radio is ready."
+ exit 0
+ fi
+ let COUNTER=COUNTER+1
+
+ echo "Waiting for radio to come up in order to identify type ..."
+
+ sleep 1
+done
+
+echo "Cellular radio is not ready."
+exit 1
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-cell-router b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-cell-router
new file mode 100755
index 0000000..1607c32
--- /dev/null
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-cell-router
@@ -0,0 +1,147 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2014 Multi-Tech Systems
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+set -e
+
+do_start() {
+ lan_interfaces=$(echo "$lan" | sed "s/,/ /g")
+
+ echo "Configuring firewall rules..."
+ # Flush all the tables first
+ iptables -t filter -F
+ iptables -t nat -F
+ iptables -t mangle -F
+
+ # Drop all incoming packets by default
+ iptables -t filter -P INPUT DROP
+ # Accept all on local loopback
+ iptables -t filter -A INPUT -i lo -j ACCEPT
+ # Allow packets in for existing socket connections
+ iptables -t filter -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
+
+ # Accept all from LAN interfaces
+ for i in $lan_interfaces; do
+ iptables -t filter -A INPUT -i $i -j ACCEPT
+
+ # Accept ssh from the LAN (Wired)
+ #iptables -t filter -A INPUT -i $i -p tcp --dport 22 -j ACCEPT
+ # Accept http from the LAN (Wired)
+ #iptables -t filter -A INPUT -i $i -p tcp --dport 80 -j ACCEPT
+ # Accept tftp from the LAN (Wired)
+ #iptables -t filter -A INPUT -i $i -p udp --dport 69 -j ACCEPT
+ done
+
+ # Accept ssh from the WAN (Wireless)
+ #iptables -t filter -A INPUT -i $wan -p tcp --dport 22 -j ACCEPT
+ # Accept http from the WAN (Wireless)
+ #iptables -t filter -A INPUT -i $wan -p tcp --dport 80 -j ACCEPT
+
+ # Allow packet fowarding from LAN interfaces to WAN (cell router)
+ iptables -t filter -P FORWARD DROP
+ iptables -t filter -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
+ for i in $lan_interfaces; do
+ iptables -t filter -A FORWARD -i $i -o $wan -j ACCEPT
+ done
+
+ # Allow all output packets
+ iptables -t filter -P OUTPUT ACCEPT
+
+ # enable NAT for cell router
+ iptables -t nat -A POSTROUTING -o $wan -j MASQUERADE
+
+ echo "Enabling packet forwarding..."
+ # turn on packet forwarding last
+ echo 1 > /proc/sys/net/ipv4/ip_forward
+ echo "Done"
+}
+
+do_stop() {
+ echo "Clearing firewall rules..."
+ # clear all tables
+ iptables -t filter -F
+ iptables -t nat -F
+ iptables -t mangle -F
+ # reset policies to ACCEPT
+ iptables -t filter -P INPUT ACCEPT
+ iptables -t filter -P OUTPUT ACCEPT
+ iptables -t filter -P FORWARD ACCEPT
+
+ # turn off packet forwarding
+ echo "Disabling packet forwarding..."
+ echo 0 > /proc/sys/net/ipv4/ip_forward
+ echo "Done"
+}
+
+usage() {
+ echo "Usage: $(basename $0) start|stop [options]"
+ echo " options:"
+ echo " -l <lan-interfaces> LAN interfaces to allow, comma-separated (defaults to \"eth0\")"
+ echo " -w <wan-interface> WAN interface to route out (defaults to \"ppp0\")"
+ exit 1
+}
+
+# main
+if [[ $# < 1 ]]; then
+ usage
+fi
+
+cmd=$1
+shift
+
+while getopts "l:w:h" opt; do
+ case "$opt" in
+ l)
+ l=$OPTARG
+ ;;
+ w)
+ w=$OPTARG
+ ;;
+ h)
+ usage
+ ;;
+ *)
+ usage
+ ;;
+ esac
+done
+
+# default lan to eth0 if not specified
+lan=${l-eth0}
+# default wan to ppp0 if not specified
+wan=${w-ppp0}
+
+case $cmd in
+ start)
+ echo "LAN: $lan"
+ echo "WAN: $wan"
+ do_start
+ ;;
+ stop)
+ do_stop
+ ;;
+ *)
+ usage
+ ;;
+esac
+
+exit 0
+
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-dhcpd b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-dhcpd
new file mode 100755
index 0000000..976b138
--- /dev/null
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-dhcpd
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+# Copyright (C) 2014 Multi-Tech Systems
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+do_start() {
+ echo "starting dhcp daemon"
+ udhcpd -S /etc/udhcpd.conf
+}
+
+do_stop() {
+ echo "stopping dhcp daemon"
+ killall udhcpd
+}
+
+usage() {
+ echo "Usage: $(basename $0) start|stop|restart"
+ exit 1
+}
+
+# main
+if [[ $# != 1 ]]; then
+ usage
+fi
+
+case $1 in
+ start)
+ if [[ ! -f "/etc/udhcpd.conf" ]]
+ then
+ echo "/etc/udhcpd.conf does not exist"
+ exit 1
+ fi
+ do_start
+ ;;
+ stop)
+ do_stop
+ ;;
+ restart)
+ do_stop
+ sleep 1
+ do_start
+ ;;
+ *)
+ usage
+ ;;
+esac
+
+exit 0
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-firmware-upgrade b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-firmware-upgrade
new file mode 100755
index 0000000..a377309
--- /dev/null
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-firmware-upgrade
@@ -0,0 +1,69 @@
+#!/bin/bash
+dofile=/var/volatile/do_flash_upgrade
+
+if [ $# != 1 ]; then
+ echo "Usage: $0 upgrade.bin"
+ exit 1
+fi
+
+set -e
+upgrade=$1
+
+mkdir -p /var/volatile
+cd /var/volatile
+
+# make sure firmware is for this device
+hw_version=$(cat /sys/devices/platform/mts-io/hw-version)
+firmware_model=$(tar -xO -f $upgrade model)
+shopt -s nocasematch
+if [[ ! "$hw_version" =~ ^$firmware_model- ]]; then
+ logger -s -t firmware_upgrade "Wrong firmware for this hardware"
+ logger -s -t firmware_upgrade "hw version: $hw_version"
+ logger -s -t firmware_upgrade "firmware model: $firmware_model"
+ exit 1
+fi
+
+files=(bstrap.bin uboot.bin uImage.bin config.jffs2 oem.jffs2 rootfs.jffs2 install.sh)
+
+tobeflashed=0
+# verify all MD5 sums
+for (( i = 0; i < ${#files[@]}; i++ )); do
+ file=${files[i]}
+ # if the file is in the tar, md5sum it
+ if tar -t -f $upgrade | grep -F -q "$file"; then
+ logger -s -t firmware_upgrade "Checking MD5 for $file..."
+ if ! tar -x -f $upgrade $file.md5; then
+ logger -s -t firmware_upgrade "MD5 is not found for the $file, upgrade aborted"
+ exit 1
+ fi
+ if ! tar -xO -f $upgrade $file | md5sum -c $file.md5; then
+ logger -s -t firmware_upgrade "MD5 check failed, upgrade aborted"
+ exit 1
+ fi
+ tobeflashed=1
+ fi
+done
+
+if (( $tobeflashed )); then
+ mkdir -p /var/volatile/flash-upgrade
+ mv -f $upgrade /var/volatile/flash-upgrade/upgrade.bin
+ touch "${dofile}"
+ chown "root:root" "${dofile}" || true
+ uid=$(stat -c %u "${dofile}") || true
+ result=$?
+ if ((result != 0)) ; then
+ logger -s -t firmware_upgrade "Cannot create ${dofile}"
+ exit 1
+ fi
+ if ((uid != 0)) ; then
+ logger -s -t firmware_upgrade "Cannot set ownership of ${dofile} to root"
+ exit 1
+ fi
+ logger -s -t firmware_upgrade "Rebooting"
+ sleep 1
+ reboot
+ exit 0
+else
+ logger -s -t firmware_upgrade "Nothing to be flashed!"
+ exit 1
+fi
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-set-apn b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-set-apn
new file mode 100755
index 0000000..ebe8096
--- /dev/null
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-set-apn
@@ -0,0 +1,117 @@
+#!/bin/bash
+
+# Copyright (C) 2014,2017,2019 Multi-Tech Systems
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+noapn_modems=(lvw2 lsp3 cdma)
+
+# Comment out AT+CGDCONT= statement
+remove_apn_sedcmd="s/^(OK[[:space:]]+'|#MT[[:space:]]+)(AT\+CGDCONT=[0-9]+[^\']*)'*/#comment by mlinux-set-apn \2/"
+
+
+
+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 -"
+ exit 1
+}
+
+
+((clear=0))
+if (($# < 1)); then
+ usage
+fi
+if [[ $1 == "--" ]] ; then
+ apn=$2
+elif [[ $1 == "-c" ]] ; then
+ clear=1
+elif [[ $1 =~ ^- ]] ; then
+ usage
+else
+ apn=$1
+fi
+
+
+set_apn_sedcmd="s/^(#comment by mlinux-set-apn )*(OK[[:space:]]+'|#MT[[:space:]]+)*AT\+CGDCONT=([0-9]+),\"([^\"]*)\",\"[^\"]*\".*/#MT AT\+CGDCONT=\3,\"\4\",\"${apn}\"/"
+
+
+
+getmodem()
+{
+ radioproduct=$(/usr/sbin/mts-io-sysfs show product-id) # LNA3?
+ if (($? != 0)) ; then
+ echo "Radio is not ready or not found and cannot determine the type"
+ exit 1
+ fi
+ if [[ $radioproduct =~ [^-]*-([^-]*)- ]] ; then
+ echo "${BASH_REMATCH[1]}"
+ fi
+}
+function findItem
+{
+ local s check="$1"
+ shift
+ for s ; do [[ "$s" == "$check" ]] && return 0; done
+ return 1
+}
+
+
+cd /var/config/ppp/peers
+if ((clear != 1)) ; then
+ for f in $noapn ; do
+ echo "Not allowed to set APN for $f"
+ done
+
+ for f in *_chat *_chat_non_vz ; do
+ if [[ -L $f ]] ; then
+ continue
+ fi
+ [[ $f =~ ([^_]*) ]]
+ m=${BASH_REMATCH[1]}
+ if findItem "$m" "${noapn_modems[@]}" ; then
+ continue
+ fi
+
+ if sed -r -i "${set_apn_sedcmd}" ${f}; then
+ echo "Set APN to \"${apn}\" in ${f}"
+ if ! grep -q /usr/libexec/ppp/chat_wrapper ${m} ; then
+ sed -i "s?connect '/usr/sbin/chat?connect '/usr/libexec/ppp/chat_wrapper /usr/sbin/chat?" ${m}
+ fi
+ else
+ echo "Failed to set APN in $f_chat"
+ fi
+ done
+else
+ for f in *_chat *_chat_non_vz ; do
+ if sed -i -r "${remove_apn_sedcmd}" $f ; then
+ echo "Commented out APN in $f"
+ else
+ if [[ $f =~ ([^_]*) ]] ; then
+ m=${BASH_REMATCH[1]}
+ if ! findItem "$m" "${noapn_modems[@]}" ; then
+ echo "Failed to remove APN setting in $f"
+ fi
+ fi
+ fi
+ done
+fi
+
+exit 0
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-apn b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-apn
new file mode 100755
index 0000000..be056eb
--- /dev/null
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-apn
@@ -0,0 +1,161 @@
+#!/bin/bash
+
+# Copyright (C) 2014, 2017, 2019 Multi-Tech Systems
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+MTMODEMS=(LNA3 L4N1)
+MODEMS=(LE910-NA1 LE910C4-NF)
+
+function getactivefirmware
+{
+ /usr/bin/radio-query ${RADIOOPTION} --active-firmware
+# FW=$(/usr/bin/radio-cmd ${RADIOOPTION} 'AT#FWSWITCH?' 2>/dev/null)
+# if (($? != 0)) ; then
+# >&2 echo "FW Query failed"
+# return 1
+# fi
+# [[ $FW =~ \#FWSWITCH:[[:space:]]*([^,]*) ]]
+# echo "${BASH_REMATCH[1]}"
+}
+
+# See if string is in array of strings
+# parm 1 String
+# parm 2 Arrays of strings
+function findItem {
+ local s check="$1"
+ shift
+ for s ; do
+ [[ "$s" == "$check" ]] && return 0;
+ done
+ return 1
+}
+
+function usage {
+ >&2 echo "$(basename $0) [firmware image SKU]"
+ >&2 echo "The firmware image SKU is optional."
+ >&2 echo "If not specified, the image SKU will be determined"
+ >&2 echo "from the SIM, and automatically switched with the"
+ >&2 echo "APN. Current valid SKU's are 0, 1 and 2"
+ exit 1
+}
+
+function setchat {
+ m=$1
+ m=${m,,}
+ fw=$2
+ silent=$3
+ case $fw in
+ 0)
+ ending="non_vz"
+ ;;
+ 1)
+ ending="vz"
+ ;;
+ 2)
+ # Currently L4N1 only
+ ending="non_vz"
+ ;;
+ *)
+ >&2 echo 'Invalid firmware number $fw'
+ usage
+ exit 1
+ ;;
+ esac
+ source="/etc/ppp/peers/${m}_chat_${ending}"
+ target="/etc/ppp/peers/${m}_chat"
+ canon_src=$(readlink -f "${source}")
+ canon_target=$(readlink -f "${target}")
+ if [[ ${canon_src} != ${canon_target} ]] ; then
+ if ((silent == 0)) ; then
+ echo "Setting chat script to ${source}"
+ fi
+ ln -sf "${source}" "${target}"
+ fi
+}
+
+function not_ready {
+ >&2 echo "Radio is not ready"
+ >&2 echo "Try executing mlinux-switch-apn once the radio is ready"
+ exit 1
+}
+
+productid=$(/usr/sbin/mts-io-sysfs show product-id)
+if [[ $productid =~ [^-]*-([^-]*)- ]] ; then
+ mymtmodem="${BASH_REMATCH[1],,}"
+else
+ >&2 echo "Cannot find the modem in the $productid string"
+ exit 1
+fi
+
+if ! findItem "${mymtmodem^^}" "${MTMODEMS[@]}" ; then
+ echo "Firmware switch is not supported on ${mymtmodem}."
+ usage
+ exit 1
+fi
+
+if (($# > 0)) ; then
+ fw="$1"
+ if [[ $fw =~ ^[0-9]+$ ]] ; then
+ echo fw is $fw
+ if ((fw < 0)) || ((fw > 2)) ; then
+ usage
+ fi
+ else
+ >&2 echo "Invalid firmware SKU value"
+ usage
+ fi
+ echo "Switching chat script to firmware SKU $fw"
+ setchat $mymtmodem $fw 0
+ exit $?
+else
+ if ! /usr/sbin/mlinux-cell-radio-ready ; then
+ >&2 echo Radio is not ready
+ >&2 echo Try again later
+ exit 1
+ fi
+ MODEL=$(radio-query ${RADIOOPTION} --model 2>&1)
+ result=$?
+ if [[ $MODEL =~ [Ee][Rr][Rr][Oo][Rr] ]] ; then
+ RADIOOPTION="${RADIOOPTION2}"
+ MODEL=$(radio-query ${RADIOOPTION} --model 2>&1)
+ result=$?
+ fi
+ if ((result != 0)) ; then
+ >&2echo "No radio on this device."
+ usage
+ exit 1
+ fi
+ if ! findItem $MODEL "${MODEMS[@]}" ; then
+ >&2 echo "Firmware switch is supported only on ${MODEMS[@]} and this modem is $MODEL"
+ usage
+ fi
+
+ if fwreply=$(/usr/sbin/mlinux-switch-cell-fw -1); then
+ if [[ $fwreply =~ Cellular[[:space:]]+radio[[:space:]]+firmware[[:space:]]+has[[:space:]]+(already[[:space:]]+)*been[[:space:]]+switched[[:space:]]+to[[:space:]]+([^[:space:]]*)[[:space:]]+image\. ]] ; then
+ fw=${BASH_REMATCH[2]}
+ setchat "${mymtmodem}" $fw 0
+ else
+ fw=$(getactivefirmware)
+ if (($? == 0)) ; then
+ setchat "${mymtmodem}" $fw 0
+ fi
+ fi
+ fi
+fi \ No newline at end of file
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-cell-fw b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-cell-fw
new file mode 100755
index 0000000..4065ccb
--- /dev/null
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-cell-fw
@@ -0,0 +1,211 @@
+#!/bin/bash
+# This script assumes Verizon SIMS ICCID start with 89148 and is firmware 1.
+# This script assumes T-Mobile SIMS start with 8901260 and is firmware 2.
+
+fwsw_modems=(LE910-NA1 LE910C4-NF)
+mt_modems=(lna3 l4n1)
+readme=/etc/ppp/peers/README.fwswitch
+function setactivefirmware
+{
+ radio-cmd ${RADIOOPTION} --set-active-firmware $1
+# RESULT=$(radio-cmd ${RADIOOPTION} 'AT#FWSWITCH='$1',1' 2>&1)
+# if (($? != 0)) ; then
+# >&2 echo "FW Set failed"
+# return 1
+# fi
+# if [[ $RESULT =~ [Ee][Rr][Rr][Oo][Rr] ]] ; then
+# >&2 echo "FW Set failed"
+# return 1
+# fi
+}
+
+function getactivefirmware
+{
+ /usr/bin/radio-query ${RADIOOPTION} --active-firmware
+# FW=$(/usr/bin/radio-cmd ${RADIOOPTION} 'AT#FWSWITCH?' 2>/dev/null)
+# if (($? != 0)) ; then
+# >&2 echo "FW Query failed"
+# return 1
+# fi
+# [[ $FW =~ \#FWSWITCH:[[:space:]]*([^,]*) ]]
+# echo "${BASH_REMATCH[1]}"
+}
+
+# See if string is in array of strings
+# parm 1 String
+# parm 2 Arrays of strings
+function findItem {
+ local s check="$1"
+ shift
+ for s ; do
+ [[ "$s" == "$check" ]] && return 0;
+ done
+ return 1
+}
+
+
+function usage {
+>&2 echo "
+Usage: $0 <image_id> [timeout]
+ image_id <0|1|2|-1> : for dual FW image SKU-s, the id of the image to switch to
+ -1 is based on SIM
+ timeout : wait time for radio to come up if set (default : 15 sec)
+
+"
+ exit 1
+}
+
+if [ $# -gt 2 ] ; then
+ usage
+fi
+
+#
+# Check if the radio present
+#
+MODEL=$(radio-query ${RADIOOPTION} --model 2>&1)
+result=$?
+if [[ $MCONTEXT =~ [Ee][Rr][Rr][Oo][Rr] ]] ; then
+ RADIOOPTION="${RADIOOPTION2}"
+ MODEL=$(radio-query ${RADIOOPTION} --model 2>&1)
+ result=$?
+fi
+
+if ((result != 0)) ; then
+ [ "$VERBOSE" ] && >&2 echo "Assume no radio on this device."
+ exit 0
+fi
+
+#
+# Load args (don't wait for the radio by default)
+#
+FWIMAGE=$1
+if ((FWIMAGE < -2)) || ((FWIMAGE > 2)) ; then
+ usage
+fi
+if ! >&2 /usr/sbin/mlinux-cell-radio-ready ; then
+ [ "$VERBOSE" ] && >&2 echo Radio is not ready
+ [ "$VERBOSE" ] && >&2 echo Try again later
+ exit 1
+fi
+if ((FWIMAGE == -1)) ; then
+ iccid=$(radio-query ${RADIOOPTION} --iccid)
+ if (($? == 0)); then
+ if ((${#iccid} == 0)) ; then
+ [ "$VERBOSE" ] && >&2 echo "No carrier. Maybe no SIM?"
+ [ "$VERBOSE" ] && >&2 echo "ERROR: Cannot decide on firmware"
+ exit 1
+ fi
+ if [[ $iccid =~ ^89148.* ]] ; then
+ # Verizon
+ logger -s -t mlinux-sw-firmware -p daemon.info "Assuming $iccid is a Verizon SIM ICCID using Firmware 1"
+ ((FWIMAGE=1))
+ elif [[ $iccid =~ ^8901260.* ]] ; then
+ # T-Mobile
+ logger -s -t mlinux-sw-firmware -p daemon.info "Assuming $iccid is a T-Mobile SIM ICCID using Firmware 2"
+ ((FWMAGE=2))
+ if [[ $MODEL == LE910-NA1 ]] ; then # Assume LNA3 has no firmware image 2
+ ((FWIMAGE=0))
+ fi
+ else
+ # Everybody else
+ logger -s -t mlinux-sw-firmware -p daemon.info "Assuming $iccid is a possibly AT&T SIM using Firmware 0"
+ ((FWIMAGE=0))
+ fi
+ else
+ >&2 echo "Cannot get ICCID from SIM"
+ >&2 echo "Try again later"
+ exit 1
+ fi
+fi
+
+
+TIMEOUT=${2:-15}
+if [ "$VERBOSE" != "yes" ]; then
+ VERBOSE=""
+fi
+
+[ "$VERBOSE" ] && >&2 echo -n "Switching the radio firmware image: "
+
+#
+# Applicable for LTE910-NA1 and LE910C4-NF with dual FW images only
+#
+if ! findItem "$MODEL" "${fwsw_modems[@]}" ; then
+ echo "Firmware switch is not supported on ${MODEL}."
+ exit 1
+fi
+
+#
+# Check if firmware switch is required
+#
+FWACTIVE=$(getactivefirmware)
+if [ $? -ne 0 ] || [ "$FWACTIVE" == "" ]; then
+ [ "$VERBOSE" ] && >&2 echo "The $MODEL radio does not support firmware switching."
+ exit 0
+fi
+
+if (( FWACTIVE == FWIMAGE )); then
+ echo "Cellular radio firmware has already been switched to $FWIMAGE image."
+ exit 0
+fi
+
+# Disable the LNA3 chat script in case of failure.
+for f in $mt_modems ; do
+ linkf=/etc/ppp/peers/${f}_chat
+ if ! [[ -L ${linkf} ]] || [[ $(basename $(readlink -f ${linkf})) != ${readme} ]] ; then
+ ln -sf "${readme}" "${linkf}"
+ echo "Chat script is now disabled."
+ fi
+done
+
+#
+# Switch the firmware
+#
+RESULT=$(setactivefirmware "$FWIMAGE")
+if [ $? -ne 0 ]; then
+ [ "$VERBOSE" ] && >&2 echo "$RESULT"
+ exit 1
+fi
+
+
+#
+# Exit if no TIMEOUT set
+#
+# This is somewhat dangerous in that we assume the radio
+# will switch.
+if ((TIMEOUT == 0)) ; then
+ if ((FWIMAGE == 0)) ; then
+ [ "$VERBOSE" ] && >&2 echo "Use mlinux-switch-apn to switch the APN when the radio is ready, before dialing"
+ exit 0
+ fi
+fi
+#
+#
+# Wait for the radio to be ready before continuing
+#
+COUNTER=0
+
+[ "$VERBOSE" ] && echo -n "Wait..."
+
+#
+# Give it some time
+#
+sleep 5
+
+while [ $COUNTER -lt $TIMEOUT ]; do
+ MODEL=$(radio-query ${RADIOOPTION} --model)
+ if [ $? -eq 0 ]; then
+ echo "Cellular radio firmware has been switched to $FWIMAGE image."
+ exit 0
+ fi
+
+ let COUNTER=COUNTER+1
+
+ [ "$VERBOSE" ] && echo -n "."
+
+ sleep 1
+done
+
+>&2 echo "Cellular radio is not ready."
+>&2 echo "When it becomes ready, invoke /usr/sbin/mlinux-switch-apn"
+>&2 echo "to set the APN"
+exit 1
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-wifi-ap b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-wifi-ap
new file mode 100755
index 0000000..ddbec95
--- /dev/null
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-wifi-ap
@@ -0,0 +1,165 @@
+#!/bin/bash
+
+# Copyright (C) 2014 Multi-Tech Systems
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+dhcpd_file=/etc/udhcpd.conf
+hostapd_file=/etc/hostapd.conf
+interface=wlan0
+bridge_mode=0
+
+do_start() {
+ if [ "$bridge_mode" = 1 ]; then
+ interface=$b
+ if ! grep -E -q "^bridge=$interface\s*$" $hostapd_file; then
+ echo "Enabling bridge=br0 in $hostapd_file"
+ sed -r -i "s/^#?bridge=.*$/bridge=$interface/" $hostapd_file
+ fi
+ else
+ if grep -E -q "^bridge=.*$" $hostapd_file; then
+ echo "Disabling bridge in $hostapd_file"
+ sed -r -i "s/^bridge=/#bridge=/" $hostapd_file
+ fi
+ fi
+
+ echo "Starting hostap daemon"
+ /etc/init.d/hostapd start
+
+ if [ "$bridge_mode" != 1 ]; then
+ echo "Setting IP address to $ip"
+ ifconfig $interface $ip
+ # strip off end of IP address to get subnet
+ # assumes subnet of /24
+ subnet=${ip%.*}
+ # escape periods for regex
+ subnet_regex=${subnet//./\\.}
+ ip_regex=${ip//./\\.}
+ # set default address range for dhcpd
+ addr_start=100
+ addr_end=254
+ if ! grep -E -q "^start\s+$subnet_regex\." $dhcpd_file; then
+ echo "Changing dhcpd start to $subnet.$addr_start"
+ sed -r -i "s/^start\s+.*$/start $subnet.$addr_start/" $dhcpd_file
+ fi
+ if ! grep -E -q "^end\s+$subnet_regex\." $dhcpd_file; then
+ echo "Changing dhcpd end to $subnet.$addr_end"
+ sed -r -i "s/^end\s+.*$/end $subnet.$addr_end/" $dhcpd_file
+ fi
+ # update dhcpd addresses if needed
+ if ! grep -E -q "^option\s+router\s+$ip_regex" $dhcpd_file; then
+ echo "Changing dhcpd router to $ip"
+ sed -r -i "s/^option\s+router\s+.*$/option router $ip/" $dhcpd_file
+ fi
+ else
+ # unset ip address for bridge mode
+ ifconfig wlan0 0.0.0.0
+ fi
+
+ if ! grep -E -q "^interface\s+$interface" $dhcpd_file; then
+ echo "Changing dhcpd interface to $interface"
+ sed -r -i "s/^interface\s+.*$/interface $interface/" $dhcpd_file
+ fi
+ mlinux-dhcpd start
+}
+
+do_stop() {
+ echo "Stopping hostap daemon"
+ /etc/init.d/hostapd stop
+ mlinux-dhcpd stop
+}
+
+usage() {
+ echo "Usage: $(basename $0) start|stop|restart [options]"
+ echo " options:"
+ echo " -a <address> Sets AP IP address (defaults to 192.168.3.1)"
+ echo " -b <interface> Add AP to specified bridge interface (conflicts with -a)"
+ exit 1
+}
+
+# main
+if [[ $# < 1 ]]; then
+ usage
+fi
+
+cmd=$1
+shift
+
+while getopts "a:b:h" opt; do
+ case "$opt" in
+ a)
+ a=$OPTARG
+ ;;
+ b)
+ b=$OPTARG
+ bridge_mode=1
+ ;;
+ h)
+ usage
+ ;;
+ *)
+ usage
+ ;;
+ esac
+done
+
+# can't specify both address and bridge mode
+if [ -n "$a" ] && [ -n "$b" ]; then
+ usage
+fi
+
+if [ -n "$a" ]; then
+ ret=1
+ if [[ $a =~ ^([0-9]{1,3}\.){3,3}[0-9]{1,3}$ ]]
+ then
+ OIFS=$IFS
+ IFS='.'
+ ip=($a)
+ IFS=$OFIS
+ [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
+ ret=$?
+ fi
+ if [[ ret -ne 0 ]]
+ then
+ echo "invalid IP address"
+ exit 1
+ fi
+ ip=$a
+else
+ ip="192.168.3.1"
+fi
+
+case $cmd in
+ start)
+ do_start
+ ;;
+ stop)
+ do_stop
+ ;;
+ restart)
+ do_stop
+ sleep 1
+ do_start
+ ;;
+ *)
+ usage
+ ;;
+esac
+
+exit 0