autoinst

scripts to make automated installations of debian easy
git clone git://deadbeef.fr/autoinst.git
Log | Files | Refs | README | LICENSE

commit 0a82747a438fa0640ca0ee540c4f411787e0cc09
parent 9d40a784d2963281d408f39b93879ef5b3329fe0
Author: Morel BĂ©renger <berengermorel76@gmail.com>
Date:   Sun,  3 Jan 2021 16:45:04 +0100

generic: allow restarting bb-udhcpc more easily

Diffstat:
Dtemplates/generic/root/etc/sv/bb-udhcpc/finish | 16----------------
Mtemplates/generic/root/etc/sv/bb-udhcpc/run | 17++++++++++++-----
2 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/templates/generic/root/etc/sv/bb-udhcpc/finish b/templates/generic/root/etc/sv/bb-udhcpc/finish @@ -1,16 +0,0 @@ -#!/bin/sh - -. /etc/runit/common - -# no checks on valid IFACE, we already did that -IFACE="$(echo ${SVNAME} | cut -f2 -d-)" - -EXIT_CODE=$1 -STATUS=$2 -SLEEP=60 - -if test "$EXIT_CODE" = "1" -then - test "$VERBOSE" = "yes" && echo unplugged, sleeping $SLEEP - sleep $SLEEP -fi diff --git a/templates/generic/root/etc/sv/bb-udhcpc/run b/templates/generic/root/etc/sv/bb-udhcpc/run @@ -16,11 +16,18 @@ test -n "$IFACE" || badconf "Unable to retrieve interface name from \"$SVNAME\"" ip link show "$IFACE" > /dev/null || badconf "Unknown IFACE" #try to detect plugged cable before trying using the NIC -#default to true, so if detection broken, try anyway -TRY=yes -test -e /sbin/ethtool $IFACE | grep -q 'Link detected: no' && TRY=no - -test "$TRY" = "no" && return 1 +#it could be done in ./finish, but there is then no way to skip DELAY +#which is annoying at best (except to kill the right sleep process). +# +#ethtool is used here, since it's the less annoying method. +#other ones would be: +#(unreliable) cat /sys/class/net/$IFACE/carrier +#(I feel a trap) cat /sys/class/net/$IFACE/operstate +test -e /sbin/ethtool && while $(/sbin/ethtool $IFACE | grep -q 'Link detected: no') +do + test "$VERBOSE" = "yes" && echo "$IFACE unpluged, sleep for ${DELAY:=60}" + sleep $DELAY +done echo "Starting udhcpc on $IFACE..." exec udhcpc -i ${IFACE} -f -R -n