diff --git a/board/common/overlay/etc/init.d/S36ppp b/board/common/overlay/etc/init.d/S36ppp index 18913f6dfe..af33db7030 100755 --- a/board/common/overlay/etc/init.d/S36ppp +++ b/board/common/overlay/etc/init.d/S36ppp @@ -1,7 +1,7 @@ #!/bin/bash sys_conf="/etc/ppp/default" -boot_conf="/boot/ppp/default" +boot_conf="/boot/ppp" conf="/data/etc/ppp" prog="/usr/sbin/pppd" @@ -20,7 +20,8 @@ if ! [ -d $conf ]; then fi fi -test -f $conf/modem || exit 0 +test -e $conf/modem || exit 0 +test -e $conf/apn || exit 0 test -n "$os_version" || source /etc/init.d/base @@ -47,26 +48,10 @@ watch() { } start() { - if [ -s $conf/usb_modeswitch ]; then - IFS=: venprod=($(cat $conf/usb_modeswitch)) - vendor=${venprod[0]} - product=${venprod[1]} - # wait for usb device - if [ -n "$vendor" ] && [ -n "$product" ]; then - msg_begin "Starting usb_modeswitch" - count=0 - while true; do - if lsusb | grep $vendor:$product >/dev/null 2>&1 || [ $count -gt $link_watch_timeout ]; then - break - fi - - count=$(($count + 1)) - sleep 1 - done - /usr/sbin/usb_modeswitch -c /etc/usb_modeswitch.conf -v $vendor -p $product > /var/log/usb_modeswitch.log 2>&1 - msg_done - fi - fi + test -e $conf/auth || touch $conf/auth + test -e $conf/extra || touch $conf/extra + test -e $conf/pin || touch $conf/pin + mknod /dev/ppp c 108 0 &>/dev/null msg_begin "Starting pppd" @@ -84,7 +69,7 @@ start() { if ! [ -e /dev/$modem ]; then msg_fail "modem /dev/$modem not present" - return 1 + return fi $prog call $provider @@ -98,8 +83,7 @@ start() { if [ $count -gt $link_watch_timeout ] || ! pidof pppd > /dev/null; then msg_fail - reboot - return 1 + return fi count=$(($count + 1)) diff --git a/board/common/overlay/etc/ppp/auth b/board/common/overlay/etc/ppp/auth deleted file mode 120000 index 40e432132d..0000000000 --- a/board/common/overlay/etc/ppp/auth +++ /dev/null @@ -1 +0,0 @@ -/data/etc/ppp/auth \ No newline at end of file diff --git a/board/common/overlay/etc/ppp/chatscripts/apn b/board/common/overlay/etc/ppp/chatscripts/apn deleted file mode 120000 index 248ca7e0db..0000000000 --- a/board/common/overlay/etc/ppp/chatscripts/apn +++ /dev/null @@ -1 +0,0 @@ -/data/etc/ppp/apn \ No newline at end of file diff --git a/board/common/overlay/etc/ppp/chatscripts/extra b/board/common/overlay/etc/ppp/chatscripts/extra deleted file mode 120000 index 0562e2be2a..0000000000 --- a/board/common/overlay/etc/ppp/chatscripts/extra +++ /dev/null @@ -1 +0,0 @@ -/data/etc/ppp/extra \ No newline at end of file diff --git a/board/common/overlay/etc/ppp/chatscripts/mobile.chat b/board/common/overlay/etc/ppp/chatscripts/mobile.chat index 9d3e19dbf4..fcc8293667 100644 --- a/board/common/overlay/etc/ppp/chatscripts/mobile.chat +++ b/board/common/overlay/etc/ppp/chatscripts/mobile.chat @@ -10,12 +10,12 @@ TIMEOUT 6 '' 'ATQ0' 'OK-AT-OK' 'ATZ' TIMEOUT 3 -'OK' @/etc/ppp/chatscripts/pin +'OK' @/data/etc/ppp/pin 'OK\d-AT-OK' 'ATI' 'OK' 'ATZ' 'OK' 'ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0' -'OK' @/etc/ppp/chatscripts/extra -'OK-AT-OK' @/etc/ppp/chatscripts/apn +'OK' @/data/etc/ppp/extra +'OK-AT-OK' @/data/etc/ppp/apn 'OK' 'ATDT*99***1#' TIMEOUT 30 CONNECT '' diff --git a/board/common/overlay/etc/ppp/chatscripts/pin b/board/common/overlay/etc/ppp/chatscripts/pin deleted file mode 120000 index ab1a1fab42..0000000000 --- a/board/common/overlay/etc/ppp/chatscripts/pin +++ /dev/null @@ -1 +0,0 @@ -/data/etc/ppp/pin \ No newline at end of file diff --git a/board/common/overlay/etc/ppp/modem b/board/common/overlay/etc/ppp/modem deleted file mode 120000 index 858889ebdb..0000000000 --- a/board/common/overlay/etc/ppp/modem +++ /dev/null @@ -1 +0,0 @@ -/data/etc/ppp/modem \ No newline at end of file diff --git a/board/common/overlay/etc/ppp/peers/mobile b/board/common/overlay/etc/ppp/peers/mobile index 94ad0c03a5..03d451c681 100644 --- a/board/common/overlay/etc/ppp/peers/mobile +++ b/board/common/overlay/etc/ppp/peers/mobile @@ -1,4 +1,4 @@ -file /etc/ppp/modem +file /data/etc/ppp/modem file /etc/ppp/options -file /etc/ppp/auth +file /data/etc/ppp/auth connect "/usr/sbin/chat -v -t15 -f /etc/ppp/chatscripts/mobile.chat" diff --git a/configs/bananapi_defconfig b/configs/bananapi_defconfig index 2921740137..7636f9a765 100644 --- a/configs/bananapi_defconfig +++ b/configs/bananapi_defconfig @@ -73,6 +73,7 @@ BR2_PACKAGE_LINUX_FIRMWARE_RTL_87XX=y BR2_PACKAGE_LINUX_FIRMWARE_RTL_88XX=y BR2_PACKAGE_SUNXI_BOARDS=y BR2_PACKAGE_SUNXI_BOARDS_FEX_FILE="a20/Bananapi.fex" +BR2_PACKAGE_USB_MODESWITCH_DATA=y BR2_PACKAGE_PYTHON_SSL=y BR2_PACKAGE_PYTHON_HASHLIB=y BR2_PACKAGE_PYTHON_JINJA2=y diff --git a/configs/cubietruck_defconfig b/configs/cubietruck_defconfig index 86b5a338bd..72e6c80d60 100644 --- a/configs/cubietruck_defconfig +++ b/configs/cubietruck_defconfig @@ -71,6 +71,7 @@ BR2_PACKAGE_LINUX_FIRMWARE_RALINK_RT2XX=y BR2_PACKAGE_LINUX_FIRMWARE_RTL_81XX=y BR2_PACKAGE_LINUX_FIRMWARE_RTL_87XX=y BR2_PACKAGE_LINUX_FIRMWARE_RTL_88XX=y +BR2_PACKAGE_USB_MODESWITCH_DATA=y BR2_PACKAGE_PYTHON_SSL=y BR2_PACKAGE_PYTHON_HASHLIB=y BR2_PACKAGE_PYTHON_JINJA2=y diff --git a/configs/odroidc1_defconfig b/configs/odroidc1_defconfig index 54f7a313b1..13eed3e35c 100644 --- a/configs/odroidc1_defconfig +++ b/configs/odroidc1_defconfig @@ -71,6 +71,7 @@ BR2_PACKAGE_LINUX_FIRMWARE_RALINK_RT2XX=y BR2_PACKAGE_LINUX_FIRMWARE_RTL_81XX=y BR2_PACKAGE_LINUX_FIRMWARE_RTL_87XX=y BR2_PACKAGE_LINUX_FIRMWARE_RTL_88XX=y +BR2_PACKAGE_USB_MODESWITCH_DATA=y BR2_PACKAGE_PYTHON_SSL=y BR2_PACKAGE_PYTHON_HASHLIB=y BR2_PACKAGE_PYTHON_JINJA2=y diff --git a/configs/odroidxu4_defconfig b/configs/odroidxu4_defconfig index db1c526da2..d8402b066f 100644 --- a/configs/odroidxu4_defconfig +++ b/configs/odroidxu4_defconfig @@ -62,6 +62,7 @@ BR2_PACKAGE_LINUX_FIRMWARE_RALINK_RT2XX=y BR2_PACKAGE_LINUX_FIRMWARE_RTL_81XX=y BR2_PACKAGE_LINUX_FIRMWARE_RTL_87XX=y BR2_PACKAGE_LINUX_FIRMWARE_RTL_88XX=y +BR2_PACKAGE_USB_MODESWITCH_DATA=y BR2_PACKAGE_PYTHON_SSL=y BR2_PACKAGE_PYTHON_HASHLIB=y BR2_PACKAGE_PYTHON_JINJA2=y diff --git a/configs/raspberrypi2_defconfig b/configs/raspberrypi2_defconfig index 22cc9c2c2e..c8e3ad1d7a 100644 --- a/configs/raspberrypi2_defconfig +++ b/configs/raspberrypi2_defconfig @@ -72,6 +72,7 @@ BR2_PACKAGE_RPI_FIRMWARE=y BR2_PACKAGE_RPI_FIRMWARE_X=y BR2_PACKAGE_I2C_TOOLS=y BR2_PACKAGE_RPI_USERLAND=y +BR2_PACKAGE_USB_MODESWITCH_DATA=y BR2_PACKAGE_PYTHON_SSL=y BR2_PACKAGE_PYTHON_HASHLIB=y BR2_PACKAGE_PYTHON_JINJA2=y diff --git a/configs/raspberrypi3_defconfig b/configs/raspberrypi3_defconfig index 2907a25d50..71ff34c499 100644 --- a/configs/raspberrypi3_defconfig +++ b/configs/raspberrypi3_defconfig @@ -73,6 +73,7 @@ BR2_PACKAGE_RPI_FIRMWARE=y BR2_PACKAGE_RPI_FIRMWARE_X=y BR2_PACKAGE_I2C_TOOLS=y BR2_PACKAGE_RPI_USERLAND=y +BR2_PACKAGE_USB_MODESWITCH_DATA=y BR2_PACKAGE_PYTHON_SSL=y BR2_PACKAGE_PYTHON_HASHLIB=y BR2_PACKAGE_PYTHON_JINJA2=y diff --git a/configs/raspberrypi_defconfig b/configs/raspberrypi_defconfig index ea1339b64a..4740959b6a 100644 --- a/configs/raspberrypi_defconfig +++ b/configs/raspberrypi_defconfig @@ -72,6 +72,7 @@ BR2_PACKAGE_RPI_FIRMWARE_X=y BR2_PACKAGE_I2C_TOOLS=y BR2_PACKAGE_RPI_ARMMEM=y BR2_PACKAGE_RPI_USERLAND=y +BR2_PACKAGE_USB_MODESWITCH_DATA=y BR2_PACKAGE_PYTHON_SSL=y BR2_PACKAGE_PYTHON_HASHLIB=y BR2_PACKAGE_PYTHON_JINJA2=y diff --git a/writeimage.sh b/writeimage.sh index c722804be6..70c0d6f5b4 100755 --- a/writeimage.sh +++ b/writeimage.sh @@ -7,6 +7,7 @@ function usage() { echo "Available options:" echo " <-i image_file> - indicates the path to the image file (e.g. -i /home/user/Download/file.img.gz)" echo " <-d sdcard_dev> - indicates the path to the sdcard block device (e.g. -d /dev/mmcblk0)" + echo " [-m modem:apn:user:pwd:pin] - configures the mobile network modem (e.g. -m ttyUSB0:internet)" echo " [-n ssid:psk] - sets the wireless network name and key (e.g. -n mynet:mykey1234)" echo " [-s ip/cidr:gw:dns] - sets a static IP configuration instead of DHCP (e.g. -s 192.168.1.101/24:192.168.1.1:8.8.8.8)" exit 1 @@ -30,6 +31,14 @@ while getopts "a:d:f:h:i:ln:o:p:s:w" o; do i) DISK_IMG=$OPTARG ;; + m) + IFS=":" SETTINGS=($OPTARG) + MODEM=${SETTINGS[0]} + APN=${SETTINGS[1]} + MUSER=${SETTINGS[2]} + MPWD=${SETTINGS[3]} + PIN=${SETTINGS[4]} + ;; n) IFS=":" NETWORK=($OPTARG) SSID=${NETWORK[0]} @@ -115,6 +124,25 @@ if [ -n "$SSID" ]; then echo -e "}\n" >> $conf fi +# modem +if [ -n "$MODEM" ]; then + msg "creating mobile network configuration" + conf=$BOOT/ppp + mkdir -p $conf + echo $MODEM > $conf/modem + echo "AT+CGDCONT=1,\"IP\",\"$APN\"" > $conf/apn + echo > $conf/extra + echo > $conf/auth + echo > $conf/pin + if [ -n "$MUSER" ]; then + echo "user \"$MUSER\"" > $conf/auth + echo "password \"$MPWD\"" >> $conf/auth + fi + if [ -n "$PIN" ]; then + echo "AT+CPIN=$PIN" > $conf/pin + fi +fi + # static ip if [ -n "$IP" ] && [ -n "$GW" ] && [ -n "$DNS" ]; then msg "setting static IP configuration"