diff options
Diffstat (limited to 'sysconfig')
25 files changed, 505 insertions, 482 deletions
diff --git a/sysconfig/init b/sysconfig/init index 249ae6df..fc874e10 100644 --- a/sysconfig/init +++ b/sysconfig/init @@ -3,15 +3,15 @@ # anything else => new style bootup without ANSI colors or positioning BOOTUP=color # column to start "[ OK ]" label in -RES_COL=60 +RES_COL=$((COLUMNS - 15)) # terminal sequence to move to that column. You could change this # to something like "tput hpa ${RES_COL}" if your terminal supports it MOVE_TO_COL="echo -en \\033[${RES_COL}G" # terminal sequence to set color to a 'success' color (currently: green) -SETCOLOR_SUCCESS="echo -en \\033[0;32m" +SETCOLOR_SUCCESS="echo -en \\033[1;32m" # terminal sequence to set color to a 'failure' color (currently: red) -SETCOLOR_FAILURE="echo -en \\033[0;31m" +SETCOLOR_FAILURE="echo -en \\033[1;31m" # terminal sequence to set color to a 'warning' color (currently: yellow) -SETCOLOR_WARNING="echo -en \\033[0;33m" +SETCOLOR_WARNING="echo -en \\033[1;33m" # terminal sequence to reset to the default color. SETCOLOR_NORMAL="echo -en \\033[0;39m" diff --git a/sysconfig/init.s390 b/sysconfig/init.s390 index 79955f07..d28446c9 100644 --- a/sysconfig/init.s390 +++ b/sysconfig/init.s390 @@ -3,7 +3,7 @@ # anything else => new style bootup without ANSI colors or positioning BOOTUP=serial # column to start "[ OK ]" label in -RES_COL=60 +RES_COL=65 # terminal sequence to move to that column. You could change this # to something like "tput hpa ${RES_COL}" if your terminal supports it MOVE_TO_COL= diff --git a/sysconfig/network-scripts/ifcfg-lo b/sysconfig/network-scripts/ifcfg-lo index cb4f3f94..cb4f3f94 100644..100755 --- a/sysconfig/network-scripts/ifcfg-lo +++ b/sysconfig/network-scripts/ifcfg-lo diff --git a/sysconfig/network-scripts/ifdown b/sysconfig/network-scripts/ifdown index 65608ee2..b9a7a1fc 100755 --- a/sysconfig/network-scripts/ifdown +++ b/sysconfig/network-scripts/ifdown @@ -7,7 +7,7 @@ unset WINDOW # defined by screen, conflicts with our usage cd /etc/sysconfig/network-scripts . ./network-functions -[ -f ../network ] && . ../network +[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network CONFIG=$1 @@ -52,6 +52,8 @@ if [ "$_use_nm" = "true" ]; then fi exit 0 fi + echo $"$0: interface ${CONFIG} is controlled by NetworkManager; skipping." >&2 + exit 0 fi if [ -x /sbin/ifdown-pre-local ]; then diff --git a/sysconfig/network-scripts/ifdown-bnep b/sysconfig/network-scripts/ifdown-bnep index b8064fd8..b7749adf 100755 --- a/sysconfig/network-scripts/ifdown-bnep +++ b/sysconfig/network-scripts/ifdown-bnep @@ -5,7 +5,7 @@ cd /etc/sysconfig/network-scripts . ./network-functions -[ -f ../network ] && . ../network +[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network CONFIG=${1} diff --git a/sysconfig/network-scripts/ifdown-eth b/sysconfig/network-scripts/ifdown-eth index 99eb1a0a..cd91e766 100755 --- a/sysconfig/network-scripts/ifdown-eth +++ b/sysconfig/network-scripts/ifdown-eth @@ -20,9 +20,12 @@ cd /etc/sysconfig/network-scripts . ./network-functions -[ -f ../network ] && . ../network +[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network CONFIG=${1} +boot=$2 +daemon= +[ "foo${boot}" = "fooboot" -o "foo${boot}" = "foodaemon" ] && daemon=1 source_config @@ -80,6 +83,10 @@ if is_bonding_device ${DEVICE} ; then fi /etc/sysconfig/network-scripts/ifdown-ipv6 ${CONFIG} +if [[ "${DHCPV6C}" = [Yy1]* ]] && [ -f /var/run/dhcp6c_${DEVICE}.pid ]; then + kill $(cat /var/run/dhcp6c_${DEVICE}.pid); + rm -f /var/run/dhcp6c_${DEVICE}.pid; +fi retcode=0 [ -n "$(pidof -x dhclient)" ] && { @@ -101,7 +108,31 @@ retcode=0 fi fi done -} +} + +# Kill running dhcp client if present (supports more clients than the above) +dhcp_client_pids() { + CLIENTS='dhcpcd|pump|dhcpxd|dhclient|zcip' + [ -n "${daemon}" -o "$MII_NOT_SUPPORTED" = "yes" ] && CLIENTS="${CLIENTS}|wpa_supplicant" + ps xw | egrep "${CLIENTS}" | grep ${DEVICE} | awk '{print $1;}' +} + +if [ -n "${daemon}" -a "$MII_NOT_SUPPORTED" != "yes" ]; then + # use ifplugd -k -W to wait for it to be killed + /sbin/ifplugd -k -W -i ${DEVICE} +fi + +pids=`dhcp_client_pids` +if [ -n "$pids" ]; then + kill $pids + retcode=$? + waited=0 + while ! dhcp_client_pids > /dev/null && [ "$waited" -lt 50 ] ; do + usleep 10000 + waited=$(($waited+1)) + done +fi + # we can't just delete the configured address because that address # may have been changed in the config file since the device was # brought up. Flush all addresses associated with this @@ -117,6 +148,11 @@ if [ -d "/sys/class/net/${REALDEVICE}" ]; then echo "-${DEVICE}" > /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null fi + # Remove ip addresses from kernel + for ip in `ip addr show | egrep ${DEVICE}\$ | grep inet | awk '{print $2;}'`; do + ip addr del $ip dev ${DEVICE} + done + if [ "${REALDEVICE}" = "${DEVICE}" ]; then ip link set dev ${DEVICE} down 2>/dev/null fi @@ -148,7 +184,7 @@ while ! check_device_down ${DEVICE} && [ "$waited" -lt 50 ] ; do done # don't leave an outdated key sitting around -if [ -n "${WIRELESS_ENC_KEY}" ] && [ -x /sbin/iwconfig ]; then +if [ -z "$IN_HOTPLUG" -a -n "${WIRELESS_ENC_KEY}" -a -x /sbin/iwconfig ]; then /sbin/iwconfig ${DEVICE} enc 0 >/dev/null 2>&1 fi diff --git a/sysconfig/network-scripts/ifdown-ippp b/sysconfig/network-scripts/ifdown-ippp deleted file mode 100755 index f6fe5f12..00000000 --- a/sysconfig/network-scripts/ifdown-ippp +++ /dev/null @@ -1,34 +0,0 @@ -#! /bin/sh - -PATH=/sbin:/usr/sbin:/bin:/usr/bin - -# Get global network configuration -[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network - -CONFIG=$1 - -. ./$CONFIG - -# stopping ibod daemon for channel bundling -if [ -f /var/lock/subsys/ibod ] ; then - kill -9 $(pidof ibod) >/dev/null 2>&1 - rm -f /var/lock/subsys/ibod -fi - -# Shut down IPv6 -/etc/sysconfig/network-scripts/ifdown-ipv6 $CONFIG - -# shutdown isdn device -isdnctrl hangup $DEVICE >/dev/null 2>&1 -sleep 1 -ip link set dev $DEVICE down >/dev/null 2>&1 - -# delete isdn device -isdnctrl delif $DEVICE >/dev/null 2>&1 - -# kill ipppd daemon -if [ -f /var/run/ipppd.$DEVICE.pid ] ; then - pppdpid=$(cat /var/run/ipppd.$DEVICE.pid) - kill -9 $pppdpid > /dev/null 2>&1 - rm -f /var/run/ipppd.$DEVICE.pid > /dev/null 2>&1 -fi diff --git a/sysconfig/network-scripts/ifdown-ipv6 b/sysconfig/network-scripts/ifdown-ipv6 index 7bfcfb34..7bfcfb34 100755..100644 --- a/sysconfig/network-scripts/ifdown-ipv6 +++ b/sysconfig/network-scripts/ifdown-ipv6 diff --git a/sysconfig/network-scripts/ifdown-post b/sysconfig/network-scripts/ifdown-post index bcf47654..ce356f1e 100755 --- a/sysconfig/network-scripts/ifdown-post +++ b/sysconfig/network-scripts/ifdown-post @@ -19,12 +19,9 @@ source_config /etc/sysconfig/network-scripts/ifdown-routes ${REALDEVICE} ${DEVNAME} if [ "$PEERDNS" != "no" -o -n "$RESOLV_MODS" -a "$RESOLV_MODS" != "no" ]; then - if [ -f /etc/resolv.conf.save ]; then - change_resolv_conf /etc/resolv.conf.save - rm -f /etc/resolv.conf.save - fi + clear_resolv_conf if [ "${DEVICETYPE}" = "ppp" -o "${DEVICETYPE}" = "ippp" ]; then - if [ -f /etc/ppp/peers/$DEVICE ] ; then + if [ -f /etc/ppp/peers/$DEVICE -a "$TYPE" != "ADSL" ] ; then rm -f /etc/ppp/peers/$DEVICE fi fi @@ -54,6 +51,12 @@ fi # Notify programs that have requested notification do_netreport +mdv-network-event interface_down ${DEVICE} + +if [ -d /etc/sysconfig/network-scripts/ifdown.d -a -x /usr/bin/run-parts ]; then + /usr/bin/run-parts --arg ${DEVICE} /etc/sysconfig/network-scripts/ifdown.d +fi + if [ -x /sbin/ifdown-local ]; then /sbin/ifdown-local ${DEVICE} fi diff --git a/sysconfig/network-scripts/ifdown-ppp b/sysconfig/network-scripts/ifdown-ppp index fca64638..99b1b09e 100755 --- a/sysconfig/network-scripts/ifdown-ppp +++ b/sysconfig/network-scripts/ifdown-ppp @@ -4,10 +4,11 @@ cd /etc/sysconfig/network-scripts . ./network-functions CONFIG=$1 +[ -f "$CONFIG" ] || CONFIG=ifcfg-$1 source_config if [ "$TYPE" = "xDSL" ] && [ -x /usr/sbin/adsl-stop ] ; then - adsl-stop /etc/sysconfig/network-scripts/$CONFIG + adsl-stop exit $? fi @@ -25,7 +26,11 @@ if [ "${DEMAND}" = "yes" ] && [ -f /var/run/ppp-${CONFIG}.pid ] ; then exit 1 fi -file=/var/run/pppwatch-${DEVICE}.pid +if [ "$TYPE" = "ADSL" ]; then + file=/var/run/${DEVICE}.pid +else + file=/var/run/pppwatch-${DEVICE}.pid +fi if [ ! -f $file ]; then # ppp isn't running, or we didn't start it diff --git a/sysconfig/network-scripts/ifdown-sit b/sysconfig/network-scripts/ifdown-sit index e4d07345..e4d07345 100755..100644 --- a/sysconfig/network-scripts/ifdown-sit +++ b/sysconfig/network-scripts/ifdown-sit diff --git a/sysconfig/network-scripts/ifdown-tunnel b/sysconfig/network-scripts/ifdown-tunnel index a5384b18..d2ac6922 100755 --- a/sysconfig/network-scripts/ifdown-tunnel +++ b/sysconfig/network-scripts/ifdown-tunnel @@ -25,7 +25,7 @@ cd /etc/sysconfig/network-scripts . ./network-functions -[ -f ../network ] && . ../network +[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network CONFIG=$1 need_config "$CONFIG" diff --git a/sysconfig/network-scripts/ifup b/sysconfig/network-scripts/ifup index d16eca68..a5feff88 100755 --- a/sysconfig/network-scripts/ifup +++ b/sysconfig/network-scripts/ifup @@ -15,6 +15,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +PATH=/sbin:/usr/sbin:/bin:/usr/bin +TEXTDOMAIN=initscripts + unset WINDOW # defined by screen, conflicts with our usage . /etc/init.d/functions @@ -22,7 +25,7 @@ unset WINDOW # defined by screen, conflicts with our usage cd /etc/sysconfig/network-scripts . ./network-functions -[ -f ../network ] && . ../network +[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network CONFIG=${1} @@ -65,12 +68,16 @@ then exit 0 fi -if [ "$_use_nm" = "true" -a -n "$UUID" ]; then - if [ "foo$2" = "fooboot" ] && [ "${TYPE}" = "Wireless" ]; then - exit 0 +if [ "$_use_nm" = "true" ]; then + if [ -n "$UUID" ]; then + if [ "foo$2" = "fooboot" ] && [ "${TYPE}" = "Wireless" ]; then + exit 0 + fi + nmcli con up uuid "$UUID" + exit $? fi - nmcli con up uuid "$UUID" - exit $? + echo $"$0: interface ${CONFIG} is controlled by NetworkManager; skipping." >&2 + exit 0 fi # Ethernet 802.1Q VLAN support @@ -133,9 +140,8 @@ if [ "${VLAN}" = "yes" ] && [ "$ISALIAS" = "no" ]; then /usr/lib/systemd/systemd-sysctl --prefix "/proc/sys/net/ipv4/conf/${DEVICE}" --prefix "/proc/sys/net/ipv6/conf/${DEVICE}" fi -if [ "${BOOTPROTO}" = "bootp" -o "${BOOTPROTO}" = "dhcp" ]; then - DYNCONFIG=true -fi +# signalling the start of connection +mdv-network-event connection_start ${DEVICE} if [ -x /sbin/ifup-pre-local ]; then /sbin/ifup-pre-local ${CONFIG} $2 diff --git a/sysconfig/network-scripts/ifup-bnep b/sysconfig/network-scripts/ifup-bnep index 5aff2777..e80ccb6b 100755 --- a/sysconfig/network-scripts/ifup-bnep +++ b/sysconfig/network-scripts/ifup-bnep @@ -5,7 +5,7 @@ cd /etc/sysconfig/network-scripts . ./network-functions -[ -f ../network ] && . ../network +[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network CONFIG=${1} diff --git a/sysconfig/network-scripts/ifup-eth b/sysconfig/network-scripts/ifup-eth index c8287d64..9d62adfb 100755 --- a/sysconfig/network-scripts/ifup-eth +++ b/sysconfig/network-scripts/ifup-eth @@ -15,21 +15,33 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +PATH=/sbin:/usr/sbin:/bin:/usr/bin +TEXTDOMAIN=initscripts + . /etc/init.d/functions cd /etc/sysconfig/network-scripts . ./network-functions -[ -f ../network ] && . ../network +[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network CONFIG=${1} +boot=${2} +daemon= +[ "foo${boot}" = "fooboot" -o "foo${boot}" = "foodaemon" ] && daemon=1 need_config "${CONFIG}" source_config +# Old BOOTP variable +if [ "${BOOTP}" = "yes" ]; then + BOOTPROTO=bootp +fi + if [ "${BOOTPROTO}" = "bootp" -o "${BOOTPROTO}" = "dhcp" ]; then DYNCONFIG=true + [ "${BOOTPROTO}" = bootp ] && DHCP_CLIENT=/sbin/pump fi # load the module associated with that device @@ -41,6 +53,7 @@ if [ -n "${HWADDR}" ]; then FOUNDMACADDR=$(get_hwaddr ${REALDEVICE}) if [ "${FOUNDMACADDR}" != "${HWADDR}" -a "${FOUNDMACADDR}" != "${MACADDR}" ]; then net_log $"Device ${DEVICE} has different MAC address than expected, ignoring." + mdv-network-event connection_failure ${DEVICE} exit 1 fi fi @@ -49,6 +62,7 @@ fi if [ "${TYPE}" = "Bridge" ]; then if [ ! -x /usr/sbin/brctl ]; then net_log $"Bridge support not available: brctl not found" + mdv-network-event connection_failure ${DEVICE} exit 1 fi if [ ! -d /sys/class/net/${DEVICE}/bridge ]; then @@ -66,6 +80,15 @@ fi # Create tap device. if [ "${TYPE}" = "Tap" ]; then + # load the correct module if necessary (#54748) + if [ ! -c /dev/net/tun ]; then + if ! modprobe tun > /dev/null 2>&1; then + echo $"No TUN/TAP support available in kernel for device ${DEVICE}" + mdv-network-event connection_failure ${DEVICE} + exit 1 + fi + fi + [ -n "${OWNER}" ] && OWNER="user ${OWNER}" TUNMODE="mode tap" [[ ${DEVICE} == tun* ]] && TUNMODE="mode tun" @@ -79,9 +102,67 @@ is_available ${REALDEVICE} || { else net_log $"Device ${DEVICE} does not seem to be present, delaying initialization." fi + mdv-network-event connection_failure ${DEVICE} exit 1 } +# is the device wireless? If so, configure wireless device specifics +IS_WIRELESS= +if is_wireless_device ${DEVICE}; then + # ralink devices need to be up for wireless-tools to work + ip link set dev ${DEVICE} up + if [ -n "${daemon}" -o "$MII_NOT_SUPPORTED" = "yes" ]; then + # try to trigger association (and always load wireless settings) + WIRELESS_CONFIG="wireless.d/$WIRELESS_ESSID" + [ -f "$WIRELESS_CONFIG" ] && source "$WIRELESS_CONFIG" + . ./ifup-wireless + if [ -n "$WIRELESS_WPA_DRIVER" -a -x /usr/sbin/wpa_supplicant -a -f /etc/wpa_supplicant.conf ]; then + if wpa_cli -i${DEVICE} status &>/dev/null; then + echo "Another wpa_supplicant instance is already running for device $DEVICE" + else + /usr/sbin/wpa_supplicant -B -i ${DEVICE} \ + -c /etc/wpa_supplicant.conf \ + -D ${WIRELESS_WPA_DRIVER} + fi + if [ "$WIRELESS_WPA_REASSOCIATE" = "yes" ]; then + sleep 2 + wpa_cli reassociate + fi + fi + elif [ -n "$WIRELESS_WPA_DRIVER" ]; then + # roaming enabled, on association + # source interface parameters related to current ESSID or AP if any + WIRELESS_CURRENT_ESSID=`iwgetid -r ${DEVICE}` + if [ -n "$WIRELESS_CURRENT_ESSID" ]; then + WIRELESS_CONFIG="wireless.d/$WIRELESS_CURRENT_ESSID" + if [ ! -f "$WIRELESS_CONFIG" ]; then + WIRELESS_CURRENT_AP=`iwgetid -r -a ${DEVICE}` + WIRELESS_CONFIG="wireless.d/$WIRELESS_CURRENT_AP" + fi + if [ -f "$WIRELESS_CONFIG" ]; then + source "$WIRELESS_CONFIG" + else + echo "Wireless device $DEVICE is associated with $WIRELESS_CURRENT_ESSID but configuration is missing" + fi + else + echo "Wireless device $DEVICE is configured with a roaming daemon but isn't associated" + fi + fi + IS_WIRELESS=1 +fi + +# DVB Card +if [ -n "${DVB_ADAPTER_ID}" -a -n "${DVB_NETWORK_DEMUX}" -a -n "${DVB_NETWORK_PID}" ]; then + dvbnet -a ${DVB_ADAPTER_ID} -n ${DVB_NETWORK_DEMUX} -p ${DVB_NETWORK_PID} +fi + +# ATMARP protocol support, enabled if ATM_ADDR is defined (VCI.VPI) +# useful for modems using the atm kernel module (e.g. Speedtouch) +# and ISP using "RFC 1483 Routed VC MUX" (e.g. Free Degroupe) +if [ -n "${ATM_ADDR}" -a -x /usr/sbin/atmarpd -a -x /usr/sbin/atmarp ]; then + pidof atmarpd >/dev/null 2>&1 || /usr/sbin/atmarpd -b -l syslog >/dev/null 2>&1 + atmarp -c ${DEVICE} 2>/dev/null +fi # this isn't the same as the MAC in the configuration filename. It is # available as a configuration option in the config file, forcing the kernel @@ -93,9 +174,6 @@ if [ -n "${MTU}" ]; then ip link set dev ${DEVICE} mtu ${MTU} fi -# is the device wireless? If so, configure wireless device specifics -is_wireless_device ${DEVICE} && . ./ifup-wireless - # slave device? if [ "${SLAVE}" = yes -a "${ISALIAS}" = no -a "${MASTER}" != "" ]; then install_bonding_driver ${MASTER} @@ -152,33 +230,155 @@ if [ -n "${BRIDGE}" ] && [ -x /usr/sbin/brctl ]; then exit 0 fi -if [ -n "${DYNCONFIG}" ] && [ -x /sbin/dhclient ]; then - if [[ "${PERSISTENT_DHCLIENT}" = [yY1]* ]]; then - ONESHOT=""; +# exec ifplugd daemon at boot if supported +if [ -n "${daemon}" -a "$MII_NOT_SUPPORTED" != "yes" ]; then + IFPLUGD_ARGS="${IFPLUGD_ARGS=-I -b}" + exec /sbin/ifplugd $IFPLUGD_ARGS -i $DEVICE +fi + + +BLURB="# temporary ifup addition" + +if [ -n "$DYNCONFIG" -a "XXX$DHCP_CLIENT" = "XXX" ];then + if [ -x /sbin/dhclient ];then + DHCP_CLIENT=/sbin/dhclient + # Remove any temporary references which were previously added to dhclient config + if [ -w /etc/dhclient-${DEVICE}.conf -a -x /sbin/dhclient ] ; then + grep -v "$BLURB" /etc/dhclient-${DEVICE}.conf > /etc/dhclient-${DEVICE}.conf.ifupnew 2> /dev/null + cat /etc/dhclient-${DEVICE}.conf.ifupnew > /etc/dhclient-${DEVICE}.conf + rm -f /etc/dhclient-${DEVICE}.conf.ifupnew + fi + elif [ -x /sbin/dhcpcd ];then + DHCP_CLIENT=/sbin/dhcpcd + elif [ -x /sbin/pump ];then + DHCP_CLIENT=/sbin/pump + elif [ -x /sbin/dhcpxd ];then + DHCP_CLIENT=/sbin/dhcpxd + else + echo $"Can't find a dhcp client" + mdv-network-event connection_failure ${DEVICE} + exit 1; + fi +fi + +if [ "$DHCP_HOSTNAME" ] && [ "$DOMAINNAME" ] +then + DHCP_HOSTNAME=`echo $DHCP_HOSTNAME | sed -e "s/\.$DOMAINNAME//g"` +fi + +DHCP_ARGS= +if [ "XXX$DHCP_CLIENT" != "XXX" ];then +case $(basename $DHCP_CLIENT) in + dhcpcd) + DHCP_ARGS="--waitip" + [ -n "${DHCP_HOSTNAME}" ] && DHCP_ARGS="${DHCP_ARGS} -h ${DHCP_HOSTNAME}" + [ "${PEERDNS}" = "no" ] && DHCP_ARGS="${DHCP_ARGS} -C resolv.conf" + [ "${PEERGATEWAY}" = "no" ] && DHCP_ARGS="${DHCP_ARGS} -G" + [ -n "${DHCP_TIMEOUT}" ] && DHCP_ARGS="${DHCP_ARGS} -t ${DHCP_TIMEOUT}" + [ "${NEEDHOSTNAME}" = "no" ] && DHCP_ARGS="${DHCP_ARGS} -C lookup-hostname" + if [ "${PEERNTPD}" = "yes" ]; then + DHCP_ARGS="${DHCP_ARGS} -o ntp_servers" else - ONESHOT="-1"; - fi; + DHCP_ARGS="${DHCP_ARGS} -C ntp.conf -O ntp_servers" + fi + if [ "${PEERYP}" = "yes" ]; then + DHCP_ARGS="${DHCP_ARGS} -o nis_domain -o nis_servers" + else + DHCP_ARGS="${DHCP_ARGS} -C yp.conf -C ypbind -O nis_domain -O nis_servers" + fi + + DHCP_ARGS="${DHCP_ARGS} ${DEVICE}" + PIDF=/var/run/dhcpcd-${DEVICE}.pid + if [[ -f ${PIDF} ]]; then + PID=$(cat ${PIDF}) + if [[ -n ${PID} ]]; then + echo "dhcpcd is running, ifdown the interface first" + exit; + fi + /bin/rm -f ${PIDF}; #clear it + fi + ;; + pump) + [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-h $DHCP_HOSTNAME" + [ "${NEEDHOSTNAME}" = "yes" ] && DHCP_ARGS="$DHCP_ARGS --lookup-hostname" + [ "${PEERDNS}" = "no" ] && DHCP_ARGS="$DHCP_ARGS -d" + [ "${PEERGATEWAY}" = "no" ] && DHCP_ARGS="$DHCP_ARGS --no-gateway" + DHCP_ARGS="$DHCP_ARGS -i $DEVICE" + ;; + dhcpxd) + # dhcpxd don't support NEEDHOSTNAME, PEERGATEWAY + [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-H $HOSTNAME" + DHCP_ARGS="$DHCP_ARGS --wait $DEVICE" + ;; + dhclient) + if [[ "${PERSISTENT_DHCLIENT}" = [yY1]* ]]; then + ONESHOT= + else + ONESHOT="-1" + fi generate_config_file_name generate_lease_file_name - DHCLIENTARGS="${DHCLIENTARGS} -H ${DHCP_HOSTNAME:-${HOSTNAME%%.*}} ${ONESHOT} -q ${DHCLIENTCONF} -lf ${LEASEFILE} -pf /var/run/dhclient-${DEVICE}.pid" + DHCP_ARGS="$DHCP_ARGS $ONESHOT -q ${DHCLIENTCONF} -lf ${LEASEFILE} -pf /var/run/dhclient-${DEVICE}.pid $DEVICE" + if [ -n "$DHCP_HOSTNAME" ]; then + if [ ! -e /etc/dhclient-${DEVICE}.conf ] || ! grep -q "[^# ]*send *host-name" /etc/dhclient-${DEVICE}.conf; then + echo "send host-name \"${DHCP_HOSTNAME}\"; $BLURB" >> /etc/dhclient-${DEVICE}.conf + fi + fi + if [ -n "$DHCP_TIMEOUT" ]; then + if [ ! -e /etc/dhclient-${DEVICE}.conf ] || ! grep -q "[^# ]*timeout" /etc/dhclient-${DEVICE}.conf; then + echo "timeout $DHCP_TIMEOUT; $BLURB" >> /etc/dhclient-${DEVICE}.conf + fi + fi + ;; +esac +fi + +# Remove any temporary references which were previously added to dhclient config +if [ -w /etc/dhclient-${DEVICE}.conf ] && [ -x /sbin/dhclient ] ; then + LC_ALL=C grep -v "# temporary MDK ifup addition" /etc/dhclient-${DEVICE}.conf > /etc/dhclient-${DEVICE}.conf.ifupnew 2> /dev/null + cat /etc/dhclient-${DEVICE}.conf.ifupnew > /etc/dhclient-${DEVICE}.conf + rm -f /etc/dhclient-${DEVICE}.conf.ifupnew +fi + +if [ -n "${DYNCONFIG}" ]; then echo echo -n $"Determining IP information for ${DEVICE}..." if [[ "${PERSISTENT_DHCLIENT}" != [yY1]* ]] && check_link_down ${DEVICE}; then echo $" failed; no link present. Check cable?" + ip link set dev ${DEVICE} down >/dev/null 2>&1 + mdv-network-event connection_failure ${DEVICE} exit 1 fi ethtool_set - if /sbin/dhclient ${DHCLIENTARGS} ${DEVICE} ; then + mdv-network-event dhcp_request ${DEVICE} + if $DHCP_CLIENT $DHCP_ARGS ; then + mdv-network-event dhcp_success ${DEVICE} echo $" done." dhcpipv4="good" else + mdv-network-event dhcp_failure ${DEVICE} + # Associate a zeroconf IP address to an alias of the interface + if [ -x /sbin/zcip ]; then + mdv-network-event zcip_request ${DEVICE} + if /sbin/zcip -s -i $DEVICE:${ZEROCONF_ALIAS_NUMER=9}; then + mdv-network-event zcip_success ${DEVICE} + echo $" done." + if [ -x /etc/init.d/tmdns ]; then + /etc/init.d/tmdns reload > /dev/null 2>&1 + fi + exit 0 + fi + fi + mdv-network-event zcip_failure ${DEVICE} echo $" failed." if [[ "${IPV4_FAILURE_FATAL}" = [Yy1]* ]] ; then + mdv-network-event connection_failure ${DEVICE} exit 1 fi if [[ "$IPV6INIT" = [nN0]* || "$DHCPV6C" != [yY1]* ]] ; then + mdv-network-event connection_failure ${DEVICE} exit 1 fi net_log "Unable to obtain IPv4 DHCP address ${DEVICE}." warning @@ -199,6 +399,7 @@ else if ! ip link set dev ${REALDEVICE} up ; then net_log $"Failed to bring up ${DEVICE}." + mdv-network-event connection_failure ${DEVICE} exit 1 fi @@ -218,6 +419,7 @@ else SRC= fi + if [ "${REALDEVICE}" != "lo" ]; then # set IP address(es) for idx in {0..256} ; do if [ -z "${ipaddr[$idx]}" ]; then @@ -229,6 +431,7 @@ else /sbin/arping -q -c 2 -w 3 -D -I ${REALDEVICE} ${ipaddr[$idx]} if [ $? = 1 ]; then net_log $"Error, some other host already uses address ${ipaddr[$idx]}." + mdv-network-event connection_failure ${DEVICE} exit 1 fi fi @@ -250,11 +453,18 @@ else /sbin/arping -q -U -c 1 -I ${REALDEVICE} ${ipaddr[$idx]} ) > /dev/null 2>&1 < /dev/null & fi done + fi # Set a default route. if [ "${DEFROUTE}" != "no" ] && [ -z "${GATEWAYDEV}" -o "${GATEWAYDEV}" = "${REALDEVICE}" ]; then # set up default gateway. replace if one already exists if [ -n "${GATEWAY}" ] && [ "$(ipcalc --network ${GATEWAY} ${netmask[0]} 2>/dev/null)" = "NETWORK=${NETWORK}" ]; then + if [ -n "${ATM_ADDR}" -a -x /usr/sbin/atmarpd -a -x /usr/sbin/atmarp ]; then + ip link set dev ${REALDEVICE} down + ip link set dev ${REALDEVICE} up + sleep 2 + atmarp -s ${GATEWAY} ${ATM_ADDR} null 2>/dev/null + fi ip route replace default ${METRIC:+metric $METRIC} \ via ${GATEWAY} ${WINDOW:+window $WINDOW} ${SRC} \ ${GATEWAYDEV:+dev $GATEWAYDEV} || @@ -269,7 +479,7 @@ else fi # Add Zeroconf route. -if [ -z "${NOZEROCONF}" -a "${ISALIAS}" = "no" -a "${REALDEVICE}" != "lo" ]; then +if [ "${NOZEROCONF}" != "yes" -a "${ISALIAS}" = "no" -a "${REALDEVICE}" != "lo" ]; then ip route add 169.254.0.0/16 dev ${REALDEVICE} metric $((1000 + $(cat /sys/class/net/${REALDEVICE}/ifindex))) scope link fi diff --git a/sysconfig/network-scripts/ifup-ippp b/sysconfig/network-scripts/ifup-ippp deleted file mode 100755 index 8405c8d9..00000000 --- a/sysconfig/network-scripts/ifup-ippp +++ /dev/null @@ -1,384 +0,0 @@ -#! /bin/bash -# -# ifup-ippp -# -# This script is normally called from the ifup script when it detects a ippp device. - -. /etc/init.d/functions - -cd /etc/sysconfig/network-scripts -. ./network-functions - -# Get global network configuration -[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network - -GATEWAY="" - -# set device -CONFIG=$1 -[ -f "${CONFIG}" ] || CONFIG=ifcfg-${1} -source_config - -if [ "${2}" = "boot" -a "${ONBOOT}" = "no" ]; then - exit -fi - -if [ ! -f /var/lock/subsys/isdn ] && [ -x /etc/init.d/isdn ] ; then - /etc/init.d/isdn start -fi - -# check that ipppd is available for syncppp -if [ "$ENCAP" = "syncppp" ]; then - if [ ! -x /sbin/ipppd ] && [ ! -x /usr/sbin/ipppd ] ; then - /usr/bin/logger -p daemon.info -t ifup-ippp "ipppd does not exist or is not executable" - exit 1 - fi -fi - -# check that isdnctrl is available -if [ ! -x /sbin/isdnctrl ] && [ ! -x /usr/sbin/isdnctrl ] ; then - /usr/bin/logger -p daemon.info -t ifup-ippp "isdnctrl does not exist or is not executable" - exit 1 -fi - -# check all ISDN devices -if ! isdnctrl list all >/dev/null 2>&1 ; then - /usr/bin/logger -p daemon.info -t ifup-ippp "cannot list ISDN devices" - exit 1 -fi - -# check if device already is configured -isdnctrl list $DEVICE >/dev/null 2>&1 && exit 0 - -function log_echo() -{ - /usr/bin/logger -p daemon.info -t ifup-ippp $"$*" -} - -function log_isdnctrl() -{ - /usr/bin/logger -p daemon.info -t ifup-ippp isdnctrl $* - isdnctrl $* >/dev/null 2>&1 || exit 1 -} - -function create_option_file() -{ - umask 066 - echo "$1" > /etc/ppp/ioption-secret-$DEVICE - umask 022 -} - -function start_ibod() -{ - # don't start ibod, if it's running - [ -f /var/lock/subsys/ibod ] && return - - device=$1 - if [ -f /etc/isdn/ibod.cf ] && [ -x /usr/sbin/ibod ] ; then - ibod $device & - pid=$(pidof ibod) - [ -n "$pid" ] && touch /var/lock/subsys/ibod - fi -} - -function addprovider() -{ - options= - if [ -z "$PHONE_OUT" ]; then - log_echo "Error: $1: no outgoing phone number set" - return 1 - fi - - # set the encapsulation mode - [ -z "$ENCAP" ] && ENCAP="syncppp" - - # set the dial mode - [ -z "$DIALMODE" ] && DIALMODE="off" - - [ "$AUTH" = "none" -o "$AUTH" = "noauth" -o -z "$AUTH" ] && AUTH="-pap -chap" - - # set layer-2/3 protocol - [ -z "$L2_PROT" ] && L2_PROT="hdlc" - [ -z "$L3_PROT" ] && L3_PROT="trans" - - # check local/remote IP - [ -z "$IPADDR" ] && IPADDR="0.0.0.0" - [ -z "$GATEWAY" ] && GATEWAY="0.0.0.0" - - # set default route - [ "$DEFROUTE" = "yes" ] && options="$options defaultroute deldefaultroute" - - # set authentication - _auth=$(echo "$AUTH" | sed 's/[a-z -]*//g') - if [ -n "$_auth" ]; then - if [ -z "$USER" -a "$DIALIN" != "on" ]; then - log_echo " Error: $1 (syncppp) user is not set" - return 1 - fi - if [ "$DIALIN" != "on" ]; then - # we should hide the user name, so i add user name to option file. - if [ "$AUTH" = "-pap +chap" ]; then - create_option_file "name \"$USER\"" - else - create_option_file "user \"$USER\"" - fi - options="$options file /etc/ppp/ioption-secret-$DEVICE" - fi - - # authentication options: - # +pap and/or +chap does not work correct by dialout - remove - # them if it's configured as dialout - [ "$DIALIN" = "on" ] || AUTH=$(echo "$AUTH" | sed 's/+[a-z]*//g') - fi - - # add ISDN device - log_isdnctrl addif $DEVICE - - # set local MSN - [ -z "$MSN" ] || log_isdnctrl eaz $DEVICE $MSN - - # set dialout numbers - if echo $COUNTRYCODE | grep ":" >/dev/null 2>&1 ; then - COUNTRYCODE="$(echo $COUNTRYCODE | cut -f 2 -d ':')" - [ "$COUNTRYCODE" = "0" ] && COUNTRYCODE= - else - COUNTRYCODE= - fi - for i in $PHONE_OUT; do - log_isdnctrl addphone $DEVICE out $COUNTRYCODE$PREFIX$AREACODE$i - done - for i in $PHONE_IN; do - log_isdnctrl addphone $DEVICE in $i - done - - # set layer-2/3 protocol - log_isdnctrl l2_prot $DEVICE $L2_PROT - log_isdnctrl l3_prot $DEVICE $L3_PROT - - # set encapsulation - log_isdnctrl encap $DEVICE $ENCAP - - # set dialmode - log_isdnctrl dialmode $DEVICE $DIALMODE - - [ -n "$SECURE" ] && log_isdnctrl secure $DEVICE $SECURE - [ -n "$HUPTIMEOUT" ] && log_isdnctrl huptimeout $DEVICE $HUPTIMEOUT - [ -n "$CHARGEHUP" ] && log_isdnctrl chargehup $DEVICE $CHARGEHUP - [ -n "$CHARGEINT" ] && log_isdnctrl chargeint $DEVICE $CHARGEINT - - [ -n "$IHUP" ] && log_isdnctrl ihup $DEVICE $IHUP - - # set the number of dial atempts for each number - [ -n "$DIALMAX" ] && log_isdnctrl dialmax $DEVICE $DIALMAX - - # set callback - if [ "$CALLBACK" = "out" -o "$CALLBACK" = "in" ] ; then - log_isdnctrl callback $DEVICE $CALLBACK - else - log_isdnctrl callback $DEVICE off - fi - [ -n "$CBDELAY" ] && log_isdnctrl cbdelay $DEVICE $CBDELAY - [ -n "$CBHUP" ] && log_isdnctrl cbhup $DEVICE $CBHUP - - options="$options ipparam $DEVNAME" - - [ "$ENCAP" = "syncppp" ] && log_isdnctrl pppbind $DEVICE - - if [ "$IPADDR" = "0.0.0.0" ]; then - options="$options ipcp-accept-local" - else - if [ "$DIALIN" != "on" ]; then - options="$options noipdefault" - fi - fi - # Add device - options="$options /dev/$DEVICE" - - # set channel bundling - if [ "$BUNDLING" = "yes" -o "$BUNDLING" = "on" ] && [ -n "$SLAVE_DEVICE" ]; then - [ -z "$SLAVE_MSN" ] && SLAVE_MSN="$MSN" - [ -z "$SLAVE_PHONE_OUT" ] && SLAVE_PHONE_OUT="$PHONE_OUT" - [ -z "$SLAVE_PHONE_IN" ] && SLAVE_PHONE_IN="$PHONE_IN" - [ -z "$SLAVE_HUPTIMEOUT" ] && SLAVE_HUPTIMEOUT="$HUPTIMEOUT" - [ -z "$SLAVE_CHARGEHUP" ] && SLAVE_CHARGEHUP="$CHARGEHUP" - [ -z "$SLAVE_CHARGEINT" ] && SLAVE_CHARGEINT="$CHARGEINT" - [ -z "$SLAVE_CBHUP" ] && SLAVE_CBHUP="$CBHUP" - [ -z "$SLAVE_IHUP" ] && SLAVE_IHUP="$IHUP" - [ -z "$SLAVE_DIALMAX" ] && SLAVE_DIALMAX="$DIALMAX" - [ -z "$SLAVE_CALLBACK" ] && SLAVE_CALLBACK="$CALLBACK" - [ -z "$SLAVE_CBDELAY" ] && SLAVE_CBDELAY="$CBDELAY" - if [ "$DIALIN" != "on" ] ; then - [ -z "$SLAVE_DIALMODE" ] && SLAVE_DIALMODE="auto" - else - # Master should not dial by default on incoming MPPP - [ -z "$SLAVE_DIALMODE" ] && SLAVE_DIALMODE="$DIALMODE" - fi - - slave=$SLAVE_DEVICE - options="$options /dev/$slave +mp" - - # Create slave and set options - log_isdnctrl addslave $DEVICE $slave - [ -z $SLAVE_MSN ] || log_isdnctrl eaz $slave $SLAVE_MSN - - # set phone number - for i in $SLAVE_PHONE_OUT; do - log_isdnctrl addphone $slave out $COUNTRYCODE$PREFIX$AREACODE$i - done - for i in $SLAVE_PHONE_IN; do - log_isdnctrl addphone $slave in $i - done - - # set layer-2/3 protocol - log_isdnctrl l2_prot $slave $L2_PROT - log_isdnctrl l3_prot $slave $L3_PROT - - # set encapsulation - log_isdnctrl encap $slave $ENCAP - - # set dial mode - log_isdnctrl dialmode $slave $SLAVE_DIALMODE - - [ -n "$SECURE" ] && log_isdnctrl secure $slave $SECURE - [ -n "$SLAVE_HUPTIMEOUT" ] && log_isdnctrl huptimeout $slave $SLAVE_HUPTIMEOUT - [ -n "$SLAVE_CHARGEHUP" ] && log_isdnctrl chargehup $slave $SLAVE_CHARGEHUP - [ -n "$SLAVE_CHARGEINT" ] && log_isdnctrl chargeint $slave $SLAVE_CHARGEINT - [ -n "$SLAVE_IHUP" ] && log_isdnctrl ihup $slave $SLAVE_IHUP - [ -n "$SLAVE_DIALMAX" ] && log_isdnctrl dialmax $slave $SLAVE_DIALMAX - - # set callback - [ -n "$SLAVE_CBHUP" ] && log_isdnctrl cbhup $slave $SLAVE_CBHUP - [ -n "$SLAVE_CALLBACK" ] || SLAVE_CALLBACK="off" - log_isdnctrl callback $slave $SLAVE_CALLBACK - [ -n "$SLAVE_CBDELAY" ] && log_isdnctrl cbdelay $DEVICE $SLAVE_CBDELAY - - # options for master device - [ -n "$SLAVE_DELAY" ] && log_isdnctrl sdelay $DEVICE $SLAVE_DELAY - [ -n "$SLAVE_TRIGGER" ] && log_isdnctrl trigger $DEVICE $SLAVE_TRIGGER - fi - - if [ "$GATEWAY" = "0.0.0.0" ]; then - if [ "$DIALIN" != "on" ]; then - options="$options ipcp-accept-remote" - fi - options="$IPADDR:$GATEWAY $options" - else - options="$options $IPADDR:$GATEWAY" - fi - - # Van Jacobson style TCP/IP header compression and - # VJ connection-ID compression - [ "$VJ" = "off" ] && options="$options -vj" - [ "$VJCCOMP" = "off" ] && options="$options -vjccomp" - - # Address/Control compression, protocol field compression, - [ "$AC" = "off" ] && options="$options -ac" - [ "$PC" = "off" ] && options="$options -pc" - - # BSD-Compression scheme - if [ "$BSDCOMP" = "on" ] ; then - options="$options bsdcomp 9,9" - else - options="$options -bsdcomp" - fi - # Stac compression - if [ "$LZS" = "on" ] ; then - # supports LZS check mode 3 and 4 - [ -n "$LZS_MODE" ] || LZS_MODE="4" - [ "$LZS_MODE" = "3" ] && options="$options lzs 1" - [ "$LZS_MODE" = "4" ] && options="$options lzs 1:4" - fi - - # Set max receive and max transmit units - [ -n "$MRU" ] && options="$options mru $MRU" - [ -n "$MTU" ] && options="$options mtu $MTU" - - # set CBCP protocoll - if [ "$CBCP" = "on" ] ; then - if [ -n "$CBCP_MSN" ] ; then - # User managed callback - options="$options callback $CBCP_MSN" - else - # admin managed callback, it's enabled by default - options="$options callback 6" - fi - else - # Disable CBCP - options="$options -callback-cbcp" - fi - - # set CCP protocoll - [ "$CCP" = "off" ] && options="$options noccp" - - # set host name - [ -n "$ISDN_HOSTNAME" ] && options="$options remotename $ISDN_HOSTNAME" - - # Set authentication - for i in $AUTH ; do - options="$options $i" - done - - # add ppp options - for i in $PPPOPTIONS ; do - options="$options $i" - done - - # check dns entry - if [ -z "$DNS1" -a -z "$DNS2" ]; then - options="$options ms-get-dns" - else - [ -n "$DNS1" ] && options="$options ms-dns $DNS1" - [ -n "$DNS2" ] && options="$options ms-dns $DNS2" - fi - - # set debug - [ "$DEBUG" = "yes" ] && options="-d $options" - - # set netmask, if available - [ -n "$NETMASK" ] && { - val=$(ipcalc --prefix $IPADDR $NETMASK) - pfx=${val##PREFIX=} - } - # activate ISDN device - /usr/bin/logger -p daemon.info -t ifup-ippp "ip addr add $IPADDR peer $GATEWAY${pfx:/$pfx} dev $DEVICE" - ip addr add $IPADDR peer $GATEWAY${pfx:/$pfx} dev $DEVICE - ip link set dev $DEVICE up - - if [ "$ENCAP" = "syncppp" ]; then - # start ipppd daemon - /usr/bin/logger -p daemon.info -t ifup-ippp "ipppd $options $netmask" - ipppd $options $netmask >/dev/null 2>&1 - - # start ibod daemon - if [ "$DIALIN" != "on" ]; then - [ "$BUNDLING" = "yes" -o "$BUNDLING" = "on" ] && [ -n "$SLAVE_DEVICE" ] && start_ibod $DEVICE - fi - fi - - # set default gateway for dial on demand - if [ "$DIALMODE" = "auto" ] ; then - echo 1 > /proc/sys/net/ipv4/ip_dynaddr - if [ "$DEFROUTE" = "yes" ] ; then - if [ "$GATEWAY" = "0.0.0.0" ]; then - ip route replace default ${METRIC:+metric $METRIC} dev ${DEVICE} >/dev/null 2>&1 - else - ip route replace default ${METRIC:+metric $METRIC} via ${GATEWAY} dev ${DEVICE} >/dev/null 2>&1 - fi - fi - fi - - # Setup IPv6 - if [[ "$IPV6INIT" != [nN0]* && ! -z "$IPV6ADDR" ]]; then - # Native IPv6 use of device configured, check of encapsulation required - if [ "$ENCAP" = "syncppp" ]; then - echo $"Warning: ipppd (kernel 2.4.x and below) doesn't support IPv6 using encapsulation 'syncppp'" - elif [ "$ENCAP" = "rawip" ]; then - echo $"Warning: link doesn't support IPv6 using encapsulation 'rawip'" - fi - fi - /etc/sysconfig/network-scripts/ifup-ipv6 $CONFIG -} - -addprovider || exit 1 - -exit 0 diff --git a/sysconfig/network-scripts/ifup-ipv6 b/sysconfig/network-scripts/ifup-ipv6 index 31b3b64c..4d84afee 100755..100644 --- a/sysconfig/network-scripts/ifup-ipv6 +++ b/sysconfig/network-scripts/ifup-ipv6 @@ -79,6 +79,7 @@ ipv6_test || exit 1 ipv6_test_device_status $DEVICE if [ $? != 0 -a $? != 11 ]; then # device doesn't exist or other problem occurs + mdv-network-event connection_failure ${DEVICE} exit 1 fi @@ -169,6 +170,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then if [ $? = 0 ]; then # device is already up net_log $"Device 'tun6to4' (from '$DEVICE') is already up, shutdown first" + mdv-network-event connection_failure ${DEVICE} exit 1 fi @@ -297,6 +299,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then fi else net_log $"6to4 configuration is not valid" + mdv-network-event connection_failure ${DEVICE} exit 1 fi fi diff --git a/sysconfig/network-scripts/ifup-plusb b/sysconfig/network-scripts/ifup-plusb index ce5a0321..ce5a0321 100755..100644 --- a/sysconfig/network-scripts/ifup-plusb +++ b/sysconfig/network-scripts/ifup-plusb diff --git a/sysconfig/network-scripts/ifup-post b/sysconfig/network-scripts/ifup-post index 2e93e008..61cfc446 100755 --- a/sysconfig/network-scripts/ifup-post +++ b/sysconfig/network-scripts/ifup-post @@ -3,7 +3,7 @@ cd /etc/sysconfig/network-scripts . ./network-functions -[ -f ../network ] && . ../network +[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network unset REALDEVICE if [ "$1" = --realdevice ] ; then @@ -22,8 +22,12 @@ fi /etc/sysconfig/network-scripts/ifup-routes ${REALDEVICE} ${DEVNAME} +# metric setting (skip for alias interfaces) +if [ "${REALDEVICE}" = "${DEVICE}" ] && [ -n "$METRIC" ] && type -p ifmetric > /dev/null 2>&1; then + ifmetric ${DEVICE} $METRIC +fi -if [ "$PEERDNS" != "no" ] ||[ -n "$RESOLV_MODS" -a "$RESOLV_MODS" != "no" ]; then +if [ "$PEERDNS" != "no" -a "$BOOTPROTO" != "dhcp" ] ||[ -n "$RESOLV_MODS" -a "$RESOLV_MODS" != "no" ]; then [ -n "$MS_DNS1" ] && DNS1=$MS_DNS1 [ -n "$MS_DNS2" ] && DNS2=$MS_DNS2 if [ -n "$DNS1" ] && ! grep -q "^nameserver $DNS1" /etc/resolv.conf && @@ -101,6 +105,12 @@ fi # Notify programs that have requested notification do_netreport +mdv-network-event interface_up ${DEVICE} + +if [ -d /etc/sysconfig/network-scripts/ifup.d -a -x /usr/bin/run-parts ]; then + /usr/bin/run-parts --arg ${DEVICE} /etc/sysconfig/network-scripts/ifup.d +fi + if [ -x /sbin/ifup-local ]; then /sbin/ifup-local ${DEVICE} fi diff --git a/sysconfig/network-scripts/ifup-ppp b/sysconfig/network-scripts/ifup-ppp index fb30639d..d53f3d70 100755 --- a/sysconfig/network-scripts/ifup-ppp +++ b/sysconfig/network-scripts/ifup-ppp @@ -9,16 +9,20 @@ cd /etc/sysconfig/network-scripts if [ "${1}" = daemon ] ; then # we've been called from ppp-watch, so don't invoke it for persistence shift + # do not detach connection so that ppp-watch can monitor it + DETACH=nodetach else # just in case a full path to the configuration file is passed in CONFIG=${1##*/} # CONFIG=$(basename $1) [ -f "${CONFIG}" ] || CONFIG=ifcfg-${1} source_config - # don't start ppp-watch by xDSL - if [ "${DEMAND}" != yes -a "$TYPE" != "xDSL" ] ; then + # don't start ppp-watch by xDSL and ADSL + if [ "${DEMAND}" != yes -a "$TYPE" != "xDSL" -a "$TYPE" != "ADSL" ] ; then # let ppp-watch do the right thing exec /sbin/ppp-watch "${CONFIG##ifcfg-}" "$2" fi + # detach connection not to hang boot + DETACH=updetach fi CONFIG=$1 @@ -46,17 +50,19 @@ fi echo $"ifup-ppp for ${DEVICE} exiting" /usr/bin/logger -p daemon.info -t ifup-ppp \ $"pppd does not exist or is not executable for ${DEVICE}" + mdv-network-event connection_failure ${DEVICE} exit 1 } # check that xDSL connection if [ "$TYPE" = "xDSL" ] ; then if [ -x /usr/sbin/adsl-start ] ; then - adsl-start /etc/sysconfig/network-scripts/$CONFIG + adsl-start exit $? else /usr/bin/logger -p daemon.info -t ifup-ppp \ $"adsl-start does not exist or is not executable for ${DEVICE}" + mdv-network-event connection_failure ${DEVICE} exit 1 fi fi @@ -75,6 +81,7 @@ if [ ! -f ${PEERCONF} ]; then echo $"ifup-ppp for ${DEVNAME} exiting" /usr/bin/logger -p daemon.info -t ifup-ppp \ $"/etc/sysconfig/network-scripts/chat-${DEVNAME} does not exist for ${DEVICE}" + mdv-network-event connection_failure ${DEVICE} exit 1 } fi @@ -102,12 +109,12 @@ fi if [ "${DEFROUTE}" != no ] ; then # pppd will no longer delete an existing default route # so we have to help it out a little here. - DEFRT=$(ip route list match 0.0.0.0/0) + DEFRT=$(ip route list match 0.0.0.0/0 dev ${DEVICE}) [ -n "${DEFRT}" ] && echo "$DEFRT" > /etc/default-routes - echo "$DEFRT" | while read spec; do + [ -n "${DEFRT}" ] && echo "$DEFRT" | while read spec; do ip route del $spec; done - opts="$opts defaultroute" + opts="$opts defaultroute multipledefaultroutes" fi if [ "${PEERDNS}" != no ] ; then cp -f /etc/resolv.conf /etc/resolv.conf.save @@ -130,16 +137,30 @@ if [ "${DEBUG}" = yes ] ; then opts="$opts debug" fi -if [ ${DEMAND} = yes ] ; then +if [ "${DEMAND}" = yes ] ; then opts="$opts demand ktune idle ${IDLETIMEOUT} holdoff ${RETRYTIMEOUT}" exec= else - opts="$opts nodetach" + opts="$opts $DETACH" exec=exec fi -/usr/bin/logger -p daemon.info -t ifup-ppp \ - $"pppd started for ${DEVNAME} on ${MODEMPORT} at ${LINESPEED}" +if [ "$TYPE" != "xDSL" -a "$TYPE" != "ADSL" ] ; then + CELLULAR_PIN=$(cat pin-${DEVICE} 2>/dev/null) + if [ -n "$CELLULAR_PIN" -a -x /usr/sbin/comgt ]; then + COMGTPIN=$CELLULAR_PIN comgt PIN -d $MODEMPORT + fi +fi + +# ATM bridging support, enabled if ATM_ADDR is defined (VCI.VPI) +# useful for pppoe over USB modems +if [ -n "${ATM_ADDR}" -a -n "${ATM_DEVICE}" -a -x /usr/sbin/br2684ctl ]; then + br2684ctl -b -c 0 -a ${ATM_ADDR} + ifconfig ${ATM_DEVICE} up +fi + +(logger -p daemon.info -t ifup-ppp \ + $"pppd started for ${DEVNAME} on ${MODEMPORT} at ${LINESPEED}" &)& $exec pppd $opts ${MODEMPORT} ${LINESPEED} \ ipparam ${DEVNAME} linkname ${DEVNAME} call ${DEVNAME}\ diff --git a/sysconfig/network-scripts/ifup-sit b/sysconfig/network-scripts/ifup-sit index 01c8756c..e83ef058 100755..100644 --- a/sysconfig/network-scripts/ifup-sit +++ b/sysconfig/network-scripts/ifup-sit @@ -56,11 +56,13 @@ ipv6_test || exit 1 # Generic tunnel device sit0 is not supported here if [ "$DEVICE" = "sit0" ]; then net_log $"Device '$DEVICE' isn't supported here, use IPV6_AUTOTUNNEL setting and restart (IPv6) networking" + mdv-network-event connection_failure ${DEVICE} exit 1 fi if [ -z "$IPV6TUNNELIPV4" ]; then net_log $"Missing remote IPv4 address of tunnel, configuration is not valid" + mdv-network-event connection_failure ${DEVICE} exit 1 fi @@ -69,6 +71,7 @@ ipv6_test_device_status $DEVICE if [ $? = 0 ]; then # device is already up net_log $"Device '$DEVICE' is already up, please shutdown first" + mdv-network-event connection_failure ${DEVICE} exit 1 fi diff --git a/sysconfig/network-scripts/ifup-tunnel b/sysconfig/network-scripts/ifup-tunnel index 2eaa4bb7..a4762127 100755 --- a/sysconfig/network-scripts/ifup-tunnel +++ b/sysconfig/network-scripts/ifup-tunnel @@ -61,6 +61,7 @@ esac # Generic tunnel devices are not supported here if [ "$DEVICE" = gre0 -o "$DEVICE" = tunl0 -o "$DEVICE" = ip6tnl0 ]; then net_log $"Device '$DEVICE' isn't supported as a valid GRE device name." + mdv-network-event connection_failure ${DEVICE} exit 1 fi diff --git a/sysconfig/network-scripts/ifup-wireless b/sysconfig/network-scripts/ifup-wireless index 580725fa..f983e2dc 100755 --- a/sysconfig/network-scripts/ifup-wireless +++ b/sysconfig/network-scripts/ifup-wireless @@ -18,6 +18,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # Configure wireless network device options. See iwconfig(8) for more info. +# Mageia prefixes the following variables with WIRELESS_ prefix. # Valid variables: # MODE: Ad-Hoc, Managed, etc. # ESSID: Name of the wireless network @@ -26,44 +27,94 @@ # CHANNEL: Numbered frequency to operate on. See FREQ # SENS: Sensitivity threshold for packet rejection. # RATE: Transfer rate. Usually one of Auto, 11, 5, 2, or 1. -# KEY: Encryption key for WEP. # RTS: Explicit RTS handshake. Usually not specified (auto) # FRAG: Fragmentation threshold to split packets. Usually not specified. -# SPYIPS: List of IP addresses to "spy" on for link performance stats. # IWCONFIG: Extra parameters to pass directly to IWCONFIG -# SECURITYMODE: Security mode, e.g: 'open' or 'restricted' # IWPRIV: Extra parameters to pass directly to IWPRIV +# +# redhat-only variables: +# KEY: Encryption key for WEP. +# KEY[1-4]: Encryption key for WEP in position [1-4] +# SECURITYMODE: Security mode, e.g: 'open' or 'restricted' +# SPYIPS: List of IP addresses to "spy" on for link performance stats. +# +# mandriva-only variables: +# WIRELESS_NICK: nickname for wireless connection +# WIRELESS_ENC_KEY: Encryption key for WEP. +# WIRELESS_ENC_MODE: Security mode, e.g: 'open' or 'restricted' +# WIRELESS_XSUPPLICANT: Enabling xsupplicant support +# WIRELESS_XSUPPLICANT_FILE: Custom location for xsupplicant.conf file # Only meant to be called from ifup. +# unify variables common to RH and Mageia-style ifcfg +MODE=${MODE:-$WIRELESS_MODE} +ESSID=${ESSID:-$WIRELESS_ESSID} +NWID=${NWID:-$WIRELESS_NWID} +FREQ=${FREQ:-$WIRELESS_FREQ} +CHANNEL=${CHANNEL:-$WIRELESS_CHANNEL} +SENS=${SENS:-$WIRELESS_SENS} +RATE=${RATE:-$WIRELESS_RATE} +POWER=${POWER:-$WIRELESS_POWER} +RTS=${RTS:-$WIRELESS_RTS} +FRAG=${FRAG:-$WIRELESS_FRAG} +IWCONFIG=${IWCONFIG:-$WIRELESS_IWCONFIG} +IWSPY=${IWSPY:-$WIRELESS_IWSPY} +IWPRIV=${IWPRIV:-$WIRELESS_IWPRIV} + # Mode need to be first : some settings apply only in a specific mode ! if [ -n "$MODE" ] ; then + # for some cards, the mode can only be set with the card is down + # so we bring the card down (and suspending ifplugd if it is running) + # in order to do so (mdv bug #43166) + ifplugd -S -i $DEVICE 2>/dev/null + /sbin/ip link set dev $DEVICE down iwconfig $DEVICE mode $MODE + ifplugd -R -i $DEVICE 2>/dev/null fi # Set link up (some cards require this.) /sbin/ip link set dev ${DEVICE} up +# Setup the card nickname # This is a bit hackish, but should do the job right... if [ -n "$ESSID" -o -n "$MODE" ] ; then NICKNAME=$(/bin/hostname) iwconfig $DEVICE nick "$NICKNAME" >/dev/null 2>&1 fi +if [ -n "$WIRELESS_NICK" ] ; then + iwconfig $DEVICE nick $WIRELESS_NICK >/dev/null 2>&1 +elif [ -n "$ESSID" ] || [ -n "$MODE" ] ; then + # This is a bit hackish, but should do the job right... + NICKNAME=`/bin/hostname` + iwconfig $DEVICE nick $NICKNAME >/dev/null 2>&1 +fi + # Regular stuff... +# network id if [ -n "$NWID" ] ; then iwconfig $DEVICE nwid $NWID fi + +# frequency and channel if [ -n "$FREQ" -a "$MODE" != "Managed" ] ; then iwconfig $DEVICE freq $FREQ elif [ -n "$CHANNEL" -a "$MODE" != "Managed" ] ; then iwconfig $DEVICE channel $CHANNEL fi + +# sensitivity if [ -n "$SENS" ] ; then iwconfig $DEVICE sens $SENS fi + +# rate if [ -n "$RATE" ] ; then iwconfig $DEVICE rate "$RATE" fi + +# encryption +# for redhat-style ifcfg if [ -n "$KEY" -o -n "$KEY1" -o -n "$KEY2" -o -n "$KEY3" -o -n "$KEY4" ] ; then [ -n "$KEY1" ] && iwconfig $DEVICE key "[1]" $KEY1 [ -n "$KEY2" ] && iwconfig $DEVICE key "[2]" $KEY2 @@ -74,12 +125,39 @@ if [ -n "$KEY" -o -n "$KEY1" -o -n "$KEY2" -o -n "$KEY3" -o -n "$KEY4" ] ; then else iwconfig $DEVICE key off fi + +# for mandriva-style ifcfg +if [ -n "$WIRELESS_ENC_KEY" -o "$WIRELESS_ENC_MODE" ] ; then + if [ -n "$WIRELESS_ENC_MODE" ]; then + iwconfig $DEVICE key $WIRELESS_ENC_MODE "$WIRELESS_ENC_KEY" + else + # compatibility for older config files + # that used to contain enc mode in key + echo "$WIRELESS_ENC_KEY" | egrep -q '^(open|restricted) ' + if [ $? == 0 ]; then + iwconfig $DEVICE key $WIRELESS_ENC_KEY + else + iwconfig $DEVICE key "$WIRELESS_ENC_KEY" + fi + fi +fi + +# security mode if [ -n "$SECURITYMODE" ]; then iwconfig $DEVICE enc $SECURITYMODE fi + +# power +if [ -n "$POWER" ] ; then + iwconfig $DEVICE power $POWER +fi + +# rts if [ -n "$RTS" ] ; then iwconfig $DEVICE rts $RTS fi + +# fragmentation if [ -n "$FRAG" ] ; then iwconfig $DEVICE frag $FRAG fi @@ -89,13 +167,21 @@ if [ -n "$IWCONFIG" ] ; then iwconfig $DEVICE $IWCONFIG fi +# iwspy settings if [ -n "$SPYIPS" ] ; then for IP in $SPYIPS; do - iwspy $DEVICE + $IP + iwspy $DEVICE + $IP done fi +if [ -n "$IWSPY" ] ; then + /sbin/iwspy $DEVICE $IWSPY +fi + +# private options if [ -n "$IWPRIV" ] ; then - iwpriv $DEVICE $IWPRIV + IFS=$'\n' echo "$IWPRIV" | while read priv; do + [ -n -n "$priv" ] && eval "/sbin/iwpriv $DEVICE $priv" + done fi # ESSID need to be last : most device re-perform the scanning/discovery @@ -107,3 +193,17 @@ else # use any essid iwconfig $DEVICE essid any >/dev/null 2>&1 fi + +# settings for xsupplicant +if [ -n "$WIRELESS_XSUPPLICANT" -a -x /usr/sbin/xsupplicant ]; then + if [ -f /var/run/console.lock ] ; then + WIRELESS_XSUPPLICANT_FILE=/home/$(cat /var/run/console.lock)/.xsupplicant.conf + elif [ -f /etc/xsupplicant.conf ] ; then + WIRELESS_XSUPPLICANT_FILE=/etc/xsupplicant.conf + fi + if [ -n "$WIRELESS_XSUPPLICANT_FILE" ]; then + iwconfig $DEVICE key on + ifconfig $DEVICE allmulti + /usr/sbin/xsupplicant -i ${DEVICE} -c ${WIRELESS_XSUPPLICANT_FILE} & + fi +fi diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index c699fc0d..2ffdee55 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -9,6 +9,8 @@ export PATH [ -z "$__sed_discard_ignored_files" ] && . /etc/init.d/functions +RESOLVCONF_FLAGFILE=/var/run/resolvconf/enable-updates + get_hwaddr () { if [ -f /sys/class/net/${1}/address ]; then @@ -271,17 +273,25 @@ do_netreport () is_nm_running () { - [ "$(LANG=C nmcli -t --fields running nm status 2>/dev/null)" = "running" ] + [ -x /usr/bin/nmcli ] && \ + [ "$(LANG=C LC_ALL=C nmcli -t --fields running nm status 2>/dev/null)" = "running" ] +} + +is_nm_device_unavailable () +{ + [ -x /usr/bin/nmcli ] && \ + LANG=C LC_ALL=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^${1}:unavailable$" } is_nm_active () { - LANG=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^${1}:connected$" + [ -x /usr/bin/nmcli ] && \ + LANG=C LC_ALL=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^${1}:connected$" } is_nm_device_unmanaged () { - LANG=C nmcli -t --fields GENERAL dev list iface "${1}" 2>/dev/null | awk -F ':' '/GENERAL.STATE/ { if ($2 == "unmanaged") exit 0 ; else exit 1; }' + LANG=C LC_ALL=C nmcli -t --fields GENERAL dev list iface "${1}" 2>/dev/null | awk -F ':' '/GENERAL.STATE/ { if ($2 == "unmanaged") exit 0 ; else exit 1; }' } # Sets $alias to the device module if $? != 0 @@ -347,6 +357,9 @@ set_hostname () /bin/rm -f $rsctmp fi fi + if [ -d /etc/sysconfig/network-scripts/hostname.d -a -x /usr/bin/run-parts ]; then + /usr/bin/run-parts --arg $1 /etc/sysconfig/network-scripts/hostname.d + fi } check_device_down () @@ -361,7 +374,10 @@ check_device_down () check_link_down () { - if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q ",UP" ; then + if [ "${MII_NOT_SUPPORTED}" = yes ]; then + return 1 + fi + if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q UP ; then ip link set dev $1 up >/dev/null 2>&1 fi timeout=0 @@ -493,23 +509,39 @@ change_resolv_conf () fi; n_args=$(($n_args-1)); done; - elif [ $# -eq 1 ]; then + elif [ $# -eq 1 -a -r "$1" ]; then if [ "x$s" != "x" ]; then s="$s"$(/bin/grep -vF "$s" $1); else s=$(cat $1); fi; + else + return fi; - (echo "$s" > /etc/resolv.conf;) >/dev/null 2>&1; + if [ -e "$RESOLVCONF_FLAGFILE" ]; then + echo "$s" | /sbin/resolvconf -a ${DEVICE} + else + (echo "$s" > /etc/resolv.conf;) >/dev/null 2>&1; + fi r=$? if [ $r -eq 0 ]; then [ -x /sbin/restorecon ] && /sbin/restorecon /etc/resolv.conf >/dev/null 2>&1 # reset the correct context /usr/bin/logger -p local7.notice -t "NET" -i "$0 : updated /etc/resolv.conf"; - [ -e /var/run/nscd/socket ] && /usr/sbin/nscd -i hosts; # invalidate cache + [ -e /var/run/nscd/socket ] && [ ! -e "$RESOLVCONF_FLAGFILE" ] && /usr/sbin/nscd -i hosts; # invalidate cache fi; return $r; } +clear_resolv_conf () +{ + if [ -e "$RESOLVCONF_FLAGFILE" ]; then + /sbin/resolvconf -d ${DEVICE} + elif [ -f /etc/resolv.conf.save ]; then + change_resolv_conf /etc/resolv.conf.save + rm -f /etc/resolv.conf.save + fi +} + # Logging function # # Usage: net_log <message> <err|warning|info> <optional file/function name> diff --git a/sysconfig/networking/ifcfg-lo b/sysconfig/networking/ifcfg-lo new file mode 100755 index 00000000..cb4f3f94 --- /dev/null +++ b/sysconfig/networking/ifcfg-lo @@ -0,0 +1,9 @@ +DEVICE=lo +IPADDR=127.0.0.1 +NETMASK=255.0.0.0 +NETWORK=127.0.0.0 +# If you're having problems with gated making 127.0.0.0/8 a martian, +# you can change this to something else (255.255.255.255, for example) +BROADCAST=127.255.255.255 +ONBOOT=yes +NAME=loopback |