Add pinentry for gnupg
[hvlinux.git] / stage2 / bootscripts / ifdown
index a6fabf9..fe1406f 100755 (executable)
@@ -14,6 +14,15 @@ log_script_name "$0 $*"
 # Load network interface card parameters
 source /etc/sysconfig/network/ifconfig.${DEVICE}
 
+# Load DHCP client parameters
+source /etc/sysconfig/network/dhcp-client
+
+# Make sure DHCP client is available.
+if [ ! -x ${DHCP_PROG} ]; then
+    echo "Program \"${DHCP_PROG}\" is not executable."
+    exit ${EXIT_CODE_FAILURE}
+fi
+
 # Check that the brctl program is present and executable.
 check_brctl()
 {
@@ -29,31 +38,32 @@ if ! ip link show ${DEVICE} 1> /dev/null 2>&1 ; then
     exit ${EXIT_CODE_WARNING}
 fi
 
-if [ "x${BOOTPROTO}" = "xdhcp" -o "x${BOOTPROTO}" = "xwifi" ]; then
-    # DHCP configuration
-    # Load DHCP client parameters
-    source /etc/sysconfig/network/dhcp-client
+case ${BOOTPROTO} in
+    dhcp)
+        cmd_run_log ${DHCP_PROG} ${DHCP_STOP} ${DEVICE} || \
+            exit ${EXIT_CODE_FAILURE}
+        ;;
 
-    if [ ! -x ${DHCP_PROG} ]; then
-       echo "Program \"${DHCP_PROG}\" is not executable."
-        exit ${EXIT_CODE_FAILURE}
-    fi
-    cmd_run_log ${DHCP_PROG} ${DHCP_STOP} ${DEVICE} || exit ${EXIT_CODE_FAILURE}
-elif [ x${BOOTPROTO} = "xstatic" ]; then
-    # Static configuration
-    cmd_run_log ip addr flush ${DEVICE} || exit ${EXIT_CODE_FAILURE}
-elif [ x${BOOTPROTO} = "xpppoe" ]; then
-    # PPPoE configuration
-    cmd_run_log pppoe-stop
-    cmd_run_log ip addr flush ${DEVICE} || exit ${EXIT_CODE_FAILURE}
-else
-    exit 1
-fi
+    wifi)
+        cmd_run_log ${DHCP_PROG} ${DHCP_STOP} ${DEVICE} || \
+            exit ${EXIT_CODE_FAILURE}
+        echo "Stopping wpa_supplicant"
+        killall wpa_supplicant
+        ;;
 
-if [ "x${BOOTPROTO}" = "xwifi" ]; then
-    killall wpa_supplicant
-fi
+    static)
+        ;;
+
+    pppoe)
+        cmd_run_log pppoe-stop
+        ;;
+
+    *)
+        echo "Invalid BOOTPROTO value: ${BOOTPROTO}"
+       exit ${EXIT_CODE_FAILURE}
+esac
 
+cmd_run_log ip addr flush ${DEVICE} || exit ${EXIT_CODE_FAILURE}
 cmd_run_log ip link set ${DEVICE} down || exit ${EXIT_CODE_FAILURE}
 
 # Determining if the interface is part of a bridge: