From: Hugo Villeneuve Date: Sun, 30 Nov 2014 21:14:29 +0000 (-0500) Subject: Change DHCP client to dhcpcd X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=0016350b745f317376d2fd585fe310c73743b62e;p=hvlinux.git Change DHCP client to dhcpcd --- diff --git a/config/packages-list b/config/packages-list index 46864df..6f22dd9 100644 --- a/config/packages-list +++ b/config/packages-list @@ -59,6 +59,7 @@ DEJAGNU="dejagnu-1.4.4" DEJAVUFONTS="dejavu-fonts-ttf-2.33" DESKTOP_FILE_UTILS="desktop-file-utils-0.20" DHCP="dhcp-4.2.3-P2" +DHCPCD="dhcpcd-6.6.4" DIALOG="dialog_1.1-20120215.orig" DIFFUTILS="diffutils-3.3" DOCBOOK_DSSSL_VER="1.79" diff --git a/stage2/bootscripts/ifdown b/stage2/bootscripts/ifdown index 3634b36..fe1406f 100755 --- a/stage2/bootscripts/ifdown +++ b/stage2/bootscripts/ifdown @@ -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,32 +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 - echo "Stopping wpa_supplicant" - 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: diff --git a/stage2/bootscripts/ifup b/stage2/bootscripts/ifup index 5434264..13bb3e5 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}/${PREFIX_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} diff --git a/stage2/bootscripts/network b/stage2/bootscripts/network index d82e9ee..66039c4 100755 --- a/stage2/bootscripts/network +++ b/stage2/bootscripts/network @@ -11,8 +11,6 @@ source /etc/rc.d/init.d/functions log_script_name "$0 $*" -BACKGROUND_START=yes - # Load global network parameters source /etc/sysconfig/network/network-parameters @@ -35,9 +33,9 @@ clean_network_up_indication() network_start() { NUMBER_OF_IF_STARTED=0 - NUMBER_OF_IF_TO_START=$(echo ${INTERFACES_UP} | wc -w) + NUMBER_OF_IF_TO_START=$(echo ${INTERFACES} | wc -w) - for i in ${INTERFACES_UP}; do + for i in ${INTERFACES}; do if LANG=C egrep -q -L "^ONBOOT=\"?[Yy][Ee][Ss]\"?" ifconfig.$i ; then local STR="Ethernet Adapter <$i> init" local CMD="/etc/rc.d/init.d/ifup $i" @@ -62,20 +60,18 @@ network_start() fi } -if [ x"${DNS_SERVER_ENA}" == xyes ]; then - cat > /etc/dhclient-enter-hooks << "EOF" -# If named is running, do not let dhclient create or modify resolv.conf -# by specifying an empty function hook: -make_resolv_conf(){ - : +network_stop() +{ + for i in ${INTERFACES} ; do + if LC_ALL= LANG= ip link show dev $i 2> /dev/null | grep -q "UP"; + then + cmd_run_log_box_warn "Ethernet Adapter <$i> stop" \ + /etc/rc.d/init.d/ifdown "$i" + fi + done + + ip route flush all } -EOF - chmod u+x /etc/dhclient-enter-hooks -else - if [ -f /etc/dhclient-enter-hooks ]; then - rm /etc/dhclient-enter-hooks - fi -fi # See how we were called. case "$1" in @@ -91,14 +87,7 @@ case "$1" in stop) clean_network_up_indication - - for i in ${INTERFACES_DN} ; do - if LC_ALL= LANG= ip link show dev $i 2> /dev/null | grep -q "UP"; - then - cmd_run_log_box_warn "Ethernet Adapter <$i> stop" \ - /etc/rc.d/init.d/ifdown "$i" - fi - done + network_stop ;; restart) diff --git a/stage2/hv-install-2 b/stage2/hv-install-2 index 6313a10..b20e2d7 100755 --- a/stage2/hv-install-2 +++ b/stage2/hv-install-2 @@ -44,6 +44,7 @@ ipkg ${TEXINFO} ipkg ${EUDEV} CFLAGS="" CPPFLAGS="" CXXFLAGS="" ipkg ${GRUB} --disable-werror ipkg -m acnb ${DHCP} +ipkg -m acnb ${DHCPCD} if [ -n "${WIFI_SUPPORT}" ]; then ipkg -m acnb ${LIBNL} "--disable-static" diff --git a/stage2/install-bootscripts b/stage2/install-bootscripts index 44e0134..6cfef2a 100755 --- a/stage2/install-bootscripts +++ b/stage2/install-bootscripts @@ -49,9 +49,13 @@ fi # "/etc/sysconfig/network/network-parameters" file creation echo "#!/bin/sh" > /etc/sysconfig/network/network-parameters +echo "" >> /etc/sysconfig/network/network-parameters +echo "# Run network script in the background, to speed-up boot time." >> \ + /etc/sysconfig/network/network-parameters +echo "BACKGROUND_START=no" >> /etc/sysconfig/network/network-parameters +echo "" >> /etc/sysconfig/network/network-parameters echo "DOMAINNAME=\"${DOMAIN}\"" >> /etc/sysconfig/network/network-parameters -echo "INTERFACES_UP=\"lo ${INTERFACES}\"" >> /etc/sysconfig/network/network-parameters -echo "INTERFACES_DN=\"${INTERFACES} lo\"" >> /etc/sysconfig/network/network-parameters +echo "INTERFACES=\"lo ${INTERFACES}\"" >> /etc/sysconfig/network/network-parameters cat >> /etc/sysconfig/network/network-parameters << EOF diff --git a/stage2/packages-update b/stage2/packages-update index 7bb8a8a..1b463f5 100755 --- a/stage2/packages-update +++ b/stage2/packages-update @@ -93,6 +93,7 @@ fpkg -e "tar.gz" ${SYSKLOGD} \ "http://www.infodrom.org/projects/sysklogd/download" fpkg -m gnu ${GRUB} fpkg -e "tar.gz" ${DHCP} "ftp://ftp.isc.org/isc/dhcp/$(get_pkg_ver ${DHCP})" +fpkg ${DHCPCD} "http://roy.marples.name/downloads/dhcpcd" fpkg -e "tar.gz" ${ACPID} "http://www.tedfelix.com/linux" fpkg -m hv ${HV_UTILITIES} diff --git a/stage2/pkg/dhcp b/stage2/pkg/dhcp index c4be30c..a25fe74 100644 --- a/stage2/pkg/dhcp +++ b/stage2/pkg/dhcp @@ -21,33 +21,6 @@ hvconfig_post() hvbuild_post() { - install -m 755 client/scripts/linux /sbin/dhclient-script - - # This is for the DHCP client - cat > /etc/dhclient.conf << "EOF" -# dhclient.conf - -timeout 15; - -interface "eth0"{ - supersede domain-name "_DOMAIN_"; - request subnet-mask, broadcast-address, time-offset, routers, - domain-name, domain-name-servers, host-name; - require subnet-mask, domain-name-servers; -} -EOF - - sed -i -e "s!_DOMAIN_!${DOMAIN}!g" /etc/dhclient.conf - - cat > /etc/sysconfig/network/dhcp-client << "EOF" -# dhcp-client -# DHCP client program informations -# -DHCP_PROG="/sbin/dhclient" -DHCP_START="-q -1" -DHCP_STOP="-q -r" -EOF - # Create a base configuration file for a DHCP server. cat > /etc/dhcpd.conf << EOF # Configuration file for DHCP server. diff --git a/stage2/pkg/dhcpcd b/stage2/pkg/dhcpcd new file mode 100644 index 0000000..3efcdc2 --- /dev/null +++ b/stage2/pkg/dhcpcd @@ -0,0 +1,20 @@ +#!/bin/bash + +hvconfig_pre() +{ + CONFIGURE_OPTS="\ + --libexecdir=/lib/dhcpcd \ + --dbdir=/var/tmp" +} + +hvbuild_post() +{ + cat > /etc/sysconfig/network/dhcp-client << "EOF" +# dhcp-client +# DHCP client program informations +# +DHCP_PROG="/sbin/dhcpcd" +DHCP_START="-4 --noarp --timeout 5" +DHCP_STOP="-4 --release" +EOF +}