From f112e3bc6c8466ff354e91feb87d9da55d291573 Mon Sep 17 00:00:00 2001 From: John Klug Date: Fri, 3 Sep 2021 14:06:24 -0500 Subject: Fix chat_wrapper for radio-reset notification and bump the config package version --- recipes-core/multitech/config/chat_wrapper | 26 +++++--- recipes-core/multitech/config_2.3.bb | 96 ------------------------------ recipes-core/multitech/config_2.4.bb | 96 ++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+), 103 deletions(-) delete mode 100644 recipes-core/multitech/config_2.3.bb create mode 100644 recipes-core/multitech/config_2.4.bb diff --git a/recipes-core/multitech/config/chat_wrapper b/recipes-core/multitech/config/chat_wrapper index 04ea17f..8c2edcc 100755 --- a/recipes-core/multitech/config/chat_wrapper +++ b/recipes-core/multitech/config/chat_wrapper @@ -22,11 +22,15 @@ # On entry to this script, file descriptor 0 is the modem. # For ppp to work, stty must work on file descriptor 0. # If stty fails, so will ppp. +. /usr/libexec/ppp/wait_for_reset NAME=chat_wrapper CONFIG=/etc/default/${NAME} CHAT_WRAPPER_RECURSION=/run/chat_wrapper_recursion RQCMD="/usr/bin/radio-query ${RADIOOPTION}" + +: ${LOG:="/usr/bin/logger -t ${NAME} -p daemon.notice"} + function finish { ${LOG} "Launch:" "$@" @@ -48,7 +52,7 @@ function sanity if ! log=$(stty 2>&1) || ! [[ $($RQCMD --iccid) =~ $id ]] ; then ${LOG} "Modem has response issues, so see if we can try again" if ((${#log} > 0)); then - ${LOG} "stty error: $(log)" + ${LOG} "stty error: ${log}" fi array=( ) # our parent is PPID, which is pppd. Get the pppd @@ -80,7 +84,8 @@ function sanity # we will be sent a SIGHUP. Ignore it (:). trap : SIGHUP /usr/sbin/mts-io-sysfs store radio-reset 0 - sleep 5 + wait_for_reset + ${LOG} "Completed wait_for_reset" count=0 while ((count < 60)) ; do # Wait for radio-reset to get the modem responding @@ -89,9 +94,11 @@ function sanity for f in /run/lock/LCK..modem_at0 /run/lock/LCK..modem_at1 ; do if [[ -f $f ]] ; then mypid=$(cat $f) + mypid="${mypid#"${mypid%%[![:space:]]*}"}" + mypid="${mypid%"${mypid##*[![:space:]]}"}" ${LOG} "PPID is $PPID, pid is $mypid" # Remove the lock, if it belongs to our parent, pppd - if [ $mypid = $PPID ] ; then + if ((${#mypid} == 0)) || [[ $mypid = $PPID ]] ; then ${LOG} "match $mypid $PPID" sleep 60 rm -f $f @@ -127,9 +134,13 @@ WAITREG=0 : ${COPSWAIT:=10} : ${CFUNWAIT:=10} -: ${LOG:="/usr/bin/logger -t ${NAME} -p daemon.notice"} -${LOG} Timeout is $REGWAITTIME, execute "$@" +${LOG} Timeout is $REGWAITTIME, execute "$@" + +# Wait for udev to discover modem has been reset. + +wait_for_reset + ((i=$#)) chatscript="${!i}" @@ -150,7 +161,7 @@ if ((${#CONTEXT} == 0)) ; then finish "$@" # NOTREACHED fi -((CONTEXTNUM=${BASH_REMATCH[2]})) +CONTEXTNUM=${BASH_REMATCH[2]} # Make sure CFUN=1, in case the last pppd was aborted with it set to 0. ${LOG} "Verify CFUN=1" @@ -223,10 +234,11 @@ fi # For Quectel, address 0 is expressed as "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0" Q0ADDR="0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0" +Q1ADDR="0.0.0.0" ADDRMATCH=1 if [[ $MADDR != $ADDR ]] ; then ADDRMATCH=0 - if [[ $MADDR = $Q0ADDR ]] ; then + if [[ $MADDR = $Q0ADDR ]] || [[ $MADDR = $Q1ADDR ]] ; then if [[ -z $ADDR ]] || [[ $ADDR = 0 ]] ; then ADDRMATCH=1 fi diff --git a/recipes-core/multitech/config_2.3.bb b/recipes-core/multitech/config_2.3.bb deleted file mode 100644 index 41187e9..0000000 --- a/recipes-core/multitech/config_2.3.bb +++ /dev/null @@ -1,96 +0,0 @@ -DESCRIPTION = "Provides default system config files and /var/config fs" -SECTION = "base" -LICENSE = "MIT" -RDEPENDS_${PN} += "bash" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" -PACKAGE_ARCH = "all" -PR = "r11" -PACKAGES =+ "${PN}-mths" -inherit update-rc.d -inherit allarch - -INITSCRIPT_NAME = "config" -INITSCRIPT_PARAMS = "start 31 S ." - -FILESEXTRAPATHS_prepend := "${THISDIR}/config:" -FILESEXTRAPATHS_prepend_${PN} := "${THISDIR}/mths_config:" - -SRC_URI = "\ - file://network \ - file://ppp \ - file://config.init \ - file://config-mths \ - file://chat_wrapper \ - file://chat_wrapper.default \ - file://99_radio \ -" - -RDEPENDS_${PN}-mths += "${PN}" - -CONFFILES_${PN} += "${sysconfdir}/defaults.tar.gz" -CONFIGFILES = "network/interfaces ppp" - -CONFIGFILES_MTHS = "config-mths" - -fakeroot do_install () { - cd ${WORKDIR} - - # default config files - rm -f defaults.tar.gz - chown root:root -R ${CONFIGFILES} - tar czf defaults.tar.gz ${CONFIGFILES} - install -d ${D}${sysconfdir} - install -m 0644 ${WORKDIR}/defaults.tar.gz ${D}${sysconfdir}/defaults.tar.gz - - # save root password for resetting to defaults - echo -n '${ROOT_PASSWORD_HASH}' > ${D}${sysconfdir}/default_pass - chmod 400 ${D}${sysconfdir}/default_pass - - # init script - install -d ${D}${sysconfdir}/init.d - install -m 0755 ${WORKDIR}/config.init ${D}${sysconfdir}/init.d/config - - # mths adjustments - tar -C ${CONFIGFILES_MTHS} -czf defaults-mths.tar.gz . - install -m 0644 ${WORKDIR}/defaults-mths.tar.gz ${D}${sysconfdir}/defaults-mths.tar.gz - - install -d ${D}${sysconfdir}/default - install -d ${D}${sysconfdir}/default/volatiles - install -d ${D}${libexecdir}/ppp - install -m 0755 ${WORKDIR}/chat_wrapper ${D}${libexecdir}/ppp/ - install -m 0644 ${WORKDIR}/chat_wrapper.default ${D}${sysconfdir}/default/chat_wrapper - install -m 0644 ${WORKDIR}/99_radio ${D}${sysconfdir}/default/volatiles -} - -FILES_${PN} = "${sysconfdir}/defaults.tar.gz ${sysconfdir}/default_pass" -FILES_${PN} += "${sysconfdir}/init.d/config ${sysconfdir}/default ${libexecdir}/ppp/chat_wrapper" -FILES_${PN} += "${sysconfdir}/default/volatiles" - -FILES_${PN}-mths = "${sysconfdir}/defaults-mths.tar.gz" - -# Create the hotspot version of defaults.tar.gz -pkg_postinst_${PN}-mths() { - X=$D/tmp/mths - mkdir -p $X - export X - ( - - set -x - if tar -tf $D${sysconfdir}/defaults.tar.gz | grep dnsmasq ; then - : - else - tb=$X/tarball # Tarball directory - mkdir $tb - tar -C $tb -xf $D/etc/defaults.tar.gz - tar -C $tb -xf $D/etc/defaults-mths.tar.gz - if ! grep '^auto wifi1' $tb/network/interfaces ; then - cat $tb/network/interfaces $tb/network/interfaces.mths >$tb/network/interfaces.new - mv $tb/network/interfaces $tb/network/interfaces.old - mv $tb/network/interfaces.new $tb/network/interfaces - fi - tar -C $tb -cf $D/etc/defaults.tar.gz . - fi - ) >$X/postinsttrace.txt 2>&1 - # Comment out the final line for a trace. - rm -rf $X -} diff --git a/recipes-core/multitech/config_2.4.bb b/recipes-core/multitech/config_2.4.bb new file mode 100644 index 0000000..7929115 --- /dev/null +++ b/recipes-core/multitech/config_2.4.bb @@ -0,0 +1,96 @@ +DESCRIPTION = "Provides default system config files and /var/config fs" +SECTION = "base" +LICENSE = "MIT" +RDEPENDS_${PN} += "bash" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" +PACKAGE_ARCH = "all" +PR = "r1" +PACKAGES =+ "${PN}-mths" +inherit update-rc.d +inherit allarch + +INITSCRIPT_NAME = "config" +INITSCRIPT_PARAMS = "start 31 S ." + +FILESEXTRAPATHS_prepend := "${THISDIR}/config:" +FILESEXTRAPATHS_prepend_${PN} := "${THISDIR}/mths_config:" + +SRC_URI = "\ + file://network \ + file://ppp \ + file://config.init \ + file://config-mths \ + file://chat_wrapper \ + file://chat_wrapper.default \ + file://99_radio \ +" + +RDEPENDS_${PN}-mths += "${PN}" + +CONFFILES_${PN} += "${sysconfdir}/defaults.tar.gz" +CONFIGFILES = "network/interfaces ppp" + +CONFIGFILES_MTHS = "config-mths" + +fakeroot do_install () { + cd ${WORKDIR} + + # default config files + rm -f defaults.tar.gz + chown root:root -R ${CONFIGFILES} + tar czf defaults.tar.gz ${CONFIGFILES} + install -d ${D}${sysconfdir} + install -m 0644 ${WORKDIR}/defaults.tar.gz ${D}${sysconfdir}/defaults.tar.gz + + # save root password for resetting to defaults + echo -n '${ROOT_PASSWORD_HASH}' > ${D}${sysconfdir}/default_pass + chmod 400 ${D}${sysconfdir}/default_pass + + # init script + install -d ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/config.init ${D}${sysconfdir}/init.d/config + + # mths adjustments + tar -C ${CONFIGFILES_MTHS} -czf defaults-mths.tar.gz . + install -m 0644 ${WORKDIR}/defaults-mths.tar.gz ${D}${sysconfdir}/defaults-mths.tar.gz + + install -d ${D}${sysconfdir}/default + install -d ${D}${sysconfdir}/default/volatiles + install -d ${D}${libexecdir}/ppp + install -m 0755 ${WORKDIR}/chat_wrapper ${D}${libexecdir}/ppp/ + install -m 0644 ${WORKDIR}/chat_wrapper.default ${D}${sysconfdir}/default/chat_wrapper + install -m 0644 ${WORKDIR}/99_radio ${D}${sysconfdir}/default/volatiles +} + +FILES_${PN} = "${sysconfdir}/defaults.tar.gz ${sysconfdir}/default_pass" +FILES_${PN} += "${sysconfdir}/init.d/config ${sysconfdir}/default ${libexecdir}/ppp/chat_wrapper" +FILES_${PN} += "${sysconfdir}/default/volatiles" + +FILES_${PN}-mths = "${sysconfdir}/defaults-mths.tar.gz" + +# Create the hotspot version of defaults.tar.gz +pkg_postinst_${PN}-mths() { + X=$D/tmp/mths + mkdir -p $X + export X + ( + + set -x + if tar -tf $D${sysconfdir}/defaults.tar.gz | grep dnsmasq ; then + : + else + tb=$X/tarball # Tarball directory + mkdir $tb + tar -C $tb -xf $D/etc/defaults.tar.gz + tar -C $tb -xf $D/etc/defaults-mths.tar.gz + if ! grep '^auto wifi1' $tb/network/interfaces ; then + cat $tb/network/interfaces $tb/network/interfaces.mths >$tb/network/interfaces.new + mv $tb/network/interfaces $tb/network/interfaces.old + mv $tb/network/interfaces.new $tb/network/interfaces + fi + tar -C $tb -cf $D/etc/defaults.tar.gz . + fi + ) >$X/postinsttrace.txt 2>&1 + # Comment out the final line for a trace. + rm -rf $X +} -- cgit v1.2.3