diff options
author | Olav Vitters <olav@vitters.nl> | 2020-07-30 22:10:35 +0200 |
---|---|---|
committer | Olav Vitters <olav@vitters.nl> | 2020-07-30 22:10:35 +0200 |
commit | a5c52c00c16be69e14360222520129d30f76e042 (patch) | |
tree | d44ff9f87b2985ead827c72c55b5aaee23c5dd10 /mageia/network-scripts/ifdown-hso | |
parent | 817ca842f086f7290f183720539834263c2f1afe (diff) | |
download | initscripts-a5c52c00c16be69e14360222520129d30f76e042.tar initscripts-a5c52c00c16be69e14360222520129d30f76e042.tar.gz initscripts-a5c52c00c16be69e14360222520129d30f76e042.tar.bz2 initscripts-a5c52c00c16be69e14360222520129d30f76e042.tar.xz initscripts-a5c52c00c16be69e14360222520129d30f76e042.zip |
Align Makefile and tree structure with upstream tree structure
Instead of placing the custom files with the upstream files it seems
clearer to have them mostly separated. This makes it easier to see which
parts are custom and which parts are more or less upstream.
As a result the upstream Makefile only needed minor changes to
accomodate this. The Makefile is NOT bug free, unfortunately it doesn't
always do the right thing, this due to inexperience.
Diffstat (limited to 'mageia/network-scripts/ifdown-hso')
-rwxr-xr-x | mageia/network-scripts/ifdown-hso | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/mageia/network-scripts/ifdown-hso b/mageia/network-scripts/ifdown-hso new file mode 100755 index 00000000..0cedb00e --- /dev/null +++ b/mageia/network-scripts/ifdown-hso @@ -0,0 +1,57 @@ +#!/bin/bash + +. /etc/init.d/functions + +cd /etc/sysconfig/network-scripts +. ./network-functions + +CONFIG=${1} + +source_config + +[ -z "$CELLULAR_CID" ] && CELLULAR_CID=1 +[ "${DEBUG}" = "yes" ] && CHATDBG="-v" + +CHATSCRIPT=`mktemp /tmp/chatXXXXXX` +cat > $CHATSCRIPT <<EOF +ABORT ERROR +TIMEOUT 5 +"" ATZ +OK "AT_OWANCALL=${CELLULAR_CID},0,0" +OK "" +EOF + +if ! /usr/sbin/chat ${CHATDBG} -s -f ${CHATSCRIPT} < $MODEMPORT > $MODEMPORT; then + echo $"Disconnect script failed (HSO)" +fi + +# ask status (it also waits for device state to be cleaner) +# do not fail if status querying fail +cat > $CHATSCRIPT <<EOF +ABORT ERROR +TIMEOUT 2 +"" ATZ +OK "AT_OWANDATA=${CELLULAR_CID}" +EOF +/usr/sbin/chat ${CHATDBG} -s -f ${CHATSCRIPT} < $MODEMPORT > $MODEMPORT + +rm -f $CHATSCRIPT + +ip addr flush dev ${DEVICE} 2>/dev/null +ip link set dev ${DEVICE} down 2>/dev/null +retcode=$? + +# wait up to 5 seconds for device to actually come down... +waited=0 +while ! check_device_down ${DEVICE} && [ "$waited" -lt 50 ] ; do + usleep 10000 + waited=$(($waited+1)) +done + +if [ "$retcode" = 0 ] ; then + /etc/sysconfig/network-scripts/ifdown-post $CONFIG + # do NOT use $? because ifdown should return whether or not + # the interface went down. +fi + +exit $retcode |