X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=stage2%2Fbootscripts%2Fifup;h=5ba66bb7efff66a8419a679e48ca2bd83b21e3a3;hb=2121ae9154ff063eef0defe0a9208663062a2d01;hp=5434264b136569e5278072390bd64e37c1c24dfa;hpb=727c462da1a14421a7ace1978f03f659124d9418;p=hvlinux.git diff --git a/stage2/bootscripts/ifup b/stage2/bootscripts/ifup index 5434264..5ba66bb 100755 --- a/stage2/bootscripts/ifup +++ b/stage2/bootscripts/ifup @@ -16,6 +16,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() { @@ -58,37 +67,24 @@ bring_if_up() # Static IP address protocol proto_static() { - cmd_run_log ip addr add ${IPADDR}/${PREFIX_LENGTH} dev ${DEVICE} brd + ${IFSCOPE} && + cmd_run_log ip addr add ${IPADDR}/${NETMASK_LENGTH} dev ${DEVICE} \ + brd + ${IFSCOPE} || exit ${EXIT_CODE_FAILURE} + + # Bring interface up bring_if_up if [ -n "${GATEWAY}" ]; then - if ip route | grep -q default; then - msg_log "Gateway already setup; skipping." - else - cmd_run_log_box "Adding default route to gateway ${GATEWAY} via ${DEVICE}" \ - ip route add default via ${GATEWAY} dev ${DEVICE} - fi + cmd_run_log ip route add default via ${GATEWAY} || \ + exit ${EXIT_CODE_FAILURE} fi } # Obtain IP address from DHCP proto_dhcp() { + # Bring interface up bring_if_up - # Load DHCP client parameters - source /etc/sysconfig/network/dhcp-client - - # Make sure no file named `/var/run/dhclient.pid' remains. - if [ -f "/var/run/dhclient.pid" ]; then - rm -f /var/run/dhclient.pid - fi - - if [ ! -x "${DHCP_PROG}" ]; then - echo "Program \"${DHCP_PROG}\" is not executable." - exit ${EXIT_CODE_FAILURE} - fi - cmd_run_log ${DHCP_PROG} ${DHCP_START} ${DEVICE} } @@ -147,9 +143,9 @@ proto_wireless() fi # Warning: - # wpa_supplicant will connect to a given network SSID even if the case is incorrect - # (MyNetwork and MYNETWORK will work). But the ssid network file configuration - # case must match exactly what was returned by wpa_supplicant + # wpa_supplicant will connect to a given network SSID even if the case is + # incorrect (MyNetwork and MYNETWORK will work). But the ssid network file + # configuration case must match exactly what was returned by wpa_supplicant. if [ ! -f "/etc/sysconfig/network/ssid/${SSID}" ]; then echo "${0}: Missing network configuration file \"/etc/sysconfig/network/ssid/${SSID}\"" exit ${EXIT_CODE_FAILURE}