X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=sbin%2Fnetcardconfig;h=4a3cd713c47de7ea59ecf412f6c28e1601c96797;hb=5681e2bcbd6864dfba753aa4a9f240d30ac085b6;hp=74fc205bf15fa8eb74157514345528cfc928459f;hpb=20ae6490ff61e8dfe67ac1dd436f3c74fa648f36;p=grml-network.git diff --git a/sbin/netcardconfig b/sbin/netcardconfig index 74fc205..4a3cd71 100755 --- a/sbin/netcardconfig +++ b/sbin/netcardconfig @@ -24,6 +24,20 @@ bailout() { exit "${1:-0}" } +check_for_blocked_devices() { + if ! command -v rfkill &>/dev/null ; then + echo "Warning: rfkill executable not present, skipping check for blocked devices." + return 0 + fi + + # if we detect any blocked devices (SOFT or HARD) then report + if rfkill | grep -w 'blocked' ; then + return 0 + fi + + return 1 +} + # This function produces the IWOURLINE for interfaces writeiwline() { IWOURLINE="" @@ -396,7 +410,12 @@ configiface() { $DIALOG --inputbox "$MESSAGE8 $DV" 10 45 "${BC:-${IP%.*}.255}" 2>"$TMP" || bailout 1 read -r BC <"$TMP" ; rm -f "$TMP" - $DIALOG --inputbox "$MESSAGE9" 10 45 "${DG:-${IP%.*}.1}" 2>"$TMP" + # if we already have a default route, don't suggest to add another one as that might fail + __default_gw="" + if ! route -en | grep -q '^0.0.0.0' ; then + __default_gw="${DG:-${IP%.*}.1}" + fi + $DIALOG --inputbox "$MESSAGE9" 10 45 "${__default_gw}" 2>"$TMP" read -r DG <"$TMP" ; rm -f "$TMP" if [ -f "/etc/resolv.conf" ]; then @@ -585,6 +604,15 @@ while (true); do # first get the device if [ "$count" -gt 1 ]; then if "${INTERACTIVE}" ; then + + # Unblock possibly locked devices? + if [ $iswireless -gt 0 ] && check_for_blocked_devices; then + RF_INFO=$(rfkill | sed 's/$/\\n/') # ensure we have a proper newline layout within dialog + if $DIALOG --yesno "Disabled wireless devices detected:\n\n${RF_INFO}\n\nPlease ensure that any possibly existing hardware switches are disabled.\nDo you want to unblock all of them?" 0 0; then + rfkill unblock all + fi + fi + rm -f "$TMP" $DIALOG --menu "$MESSAGE1" 18 60 12 "${DEVICELIST[@]}" "${EXITMENU[@]}" 2>"$TMP" || bailout read -r DV <"$TMP" ; rm -f "$TMP"