>From 1caff7ad48086375ddf6eee6b4eb5ee2b0e24fe4 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Mon, 2 Aug 2010 13:36:26 +0200 Subject: [PATCH 2/3] ifup* - echo and log error messages via syslog --- sysconfig/network-scripts/ifup | 12 +++++------- sysconfig/network-scripts/ifup-aliases | 14 +++++++------- sysconfig/network-scripts/ifup-eth | 18 +++++++++--------- sysconfig/network-scripts/ifup-ippp | 14 +++++++------- sysconfig/network-scripts/ifup-ipv6 | 20 ++++++++++---------- sysconfig/network-scripts/ifup-ppp | 13 +++---------- sysconfig/network-scripts/ifup-sit | 6 +++--- sysconfig/network-scripts/ifup-tunnel | 4 ++-- 8 files changed, 46 insertions(+), 55 deletions(-) diff --git a/sysconfig/network-scripts/ifup b/sysconfig/network-scripts/ifup index 27469e1..5e1145a 100755 --- a/sysconfig/network-scripts/ifup +++ b/sysconfig/network-scripts/ifup @@ -46,7 +46,7 @@ if [ ${UID} != 0 ]; then exec /usr/sbin/usernetctl ${CONFIG} up fi fi - echo $"Users cannot control this device." >&2 + echo_log error ifup $"Users cannot control this device." >&2 exit 1 fi @@ -83,21 +83,21 @@ if [ "${VLAN}" = "yes" ] && [ "$ISALIAS" = "no" ]; then VID=$(echo "${DEVICE}" | LC_ALL=C sed 's/^vlan0*//') # PHYSDEV should be set in ifcfg-vlan* file if test -z "$PHYSDEV"; then - echo $"PHYSDEV should be set for device ${DEVICE}" + echo_log error ifup $"PHYSDEV should be set for device ${DEVICE}" exit 1 fi fi if [ -n "$VID" ]; then if [ ! -d /proc/net/vlan ]; then if ! modprobe 8021q >/dev/null 2>&1 ; then - echo $"No 802.1Q VLAN support available in kernel for device ${DEVICE}" + echo_log error ifup $"No 802.1Q VLAN support available in kernel for device ${DEVICE}" exit 1 fi fi is_available ${PHYSDEV} || { if [ "$?" = "1" ] ; then - echo $"$alias device ${DEVICE} does not seem to be present, delaying initialization." + echo_log error ifup $"$alias device ${DEVICE} does not seem to be present, delaying initialization." exit 1 else exit 0 @@ -115,9 +115,7 @@ if [ "${VLAN}" = "yes" ] && [ "$ISALIAS" = "no" ]; then fi ip link add dev ${DEVICE} link ${PHYSDEV} type vlan id ${VID} ${FLAG_REORDER_HDR} || { - (/usr/bin/logger -p daemon.info -t ifup \ - $"ERROR: could not add vlan ${VID} as ${DEVICE} on dev ${PHYSDEV}" &)& - echo $"ERROR: could not add vlan ${VID} as ${DEVICE} on dev ${PHYSDEV}" + echo_log error ifup $"ERROR: could not add vlan ${VID} as ${DEVICE} on dev ${PHYSDEV}" exit 1 } fi diff --git a/sysconfig/network-scripts/ifup-aliases b/sysconfig/network-scripts/ifup-aliases index 1312eed..999c196 100755 --- a/sysconfig/network-scripts/ifup-aliases +++ b/sysconfig/network-scripts/ifup-aliases @@ -125,7 +125,7 @@ eval ` ( # read defaults from the parent config file [ -f $PARENTCONFIG ] || { - echo $"Missing config file $PARENTCONFIG." >&2 + echo_log error ifup-aliases $"Missing config file $PARENTCONFIG." >&2 exit 1 } eval ` ( @@ -169,7 +169,7 @@ function new_interface () MATCH='^[0-9A-Za-z_]*$' if (LC_ALL=C; [[ ! "$DEVNUM" =~ $MATCH ]]); then - echo $"error in $FILE: invalid alias number" >&2 + echo_log error ifup-aliases $"error in $FILE: invalid alias number" >&2 return 1 fi @@ -179,17 +179,17 @@ function new_interface () "; if [ -n "$ipseen" ]; then - echo $"error in $FILE: already seen ipaddr $IPADDR in $ipseen" >&2 + echo_log error ifup-aliases $"error in $FILE: already seen ipaddr $IPADDR in $ipseen" >&2 return 1 fi if [ -n "$devseen" ]; then - echo $"error in $FILE: already seen device $parent_device:$DEVNUM in $devseen" >&2 + echo_log error ifup-aliases $"error in $FILE: already seen device $parent_device:$DEVNUM in $devseen" >&2 return 1 fi if [ -z "$DEVICE" -o -z "$IPADDR" ]; then - echo $"error in $FILE: didn't specify device or ipaddr" >&2 + echo_log error ifup-aliases $"error in $FILE: didn't specify device or ipaddr" >&2 return 1 fi @@ -337,11 +337,11 @@ for FILE in ifcfg-${parent_device}-range* ; do ipaddr_endnum=${IPADDR_END##*.} if [ "${IPADDR_START%.*}" != "${IPADDR_END%.*}" ]; then - echo $"error in $FILE: IPADDR_START and IPADDR_END don't agree" >&2; continue + echo_log error ifup-aliases $"error in $FILE: IPADDR_START and IPADDR_END don't agree" >&2; continue fi if [ $ipaddr_startnum -gt $ipaddr_endnum ]; then - echo $"error in $FILE: IPADDR_START greater than IPADDR_END" >&2; continue + echo_log error ifup-aliases $"error in $FILE: IPADDR_START greater than IPADDR_END" >&2; continue fi ipaddr_num=$ipaddr_startnum diff --git a/sysconfig/network-scripts/ifup-eth b/sysconfig/network-scripts/ifup-eth index cae0078..bbc6b2c 100755 --- a/sysconfig/network-scripts/ifup-eth +++ b/sysconfig/network-scripts/ifup-eth @@ -40,7 +40,7 @@ is_available ${REALDEVICE} if [ -n "${HWADDR}" ]; then FOUNDMACADDR=$(get_hwaddr ${REALDEVICE}) if [ "${FOUNDMACADDR}" != "${HWADDR}" -a "${FOUNDMACADDR}" != "${MACADDR}" ]; then - echo $"Device ${DEVICE} has different MAC address than expected, ignoring." + echo_log error net_log $"Device ${DEVICE} has different MAC address than expected, ignoring." exit 1 fi fi @@ -48,7 +48,7 @@ fi # If the device is a bridge, create it with brctl, if available. if [ "${TYPE}" = "Bridge" ]; then if [ ! -x /usr/sbin/brctl ]; then - echo $"Bridge support not available: brctl not found" + echo_log error net_log $"Bridge support not available: brctl not found" exit 1 fi if [ ! -d /sys/class/net/${DEVICE}/bridge ]; then @@ -61,7 +61,7 @@ fi # If the device is a tap device, create it with tunctl, if available. if [ "${TYPE}" = "Tap" ]; then if [ ! -x /usr/sbin/tunctl ]; then - echo $"Tap support not available: tunctl not found" + echo_log error net_log $"Tap support not available: tunctl not found" exit 1 fi [ -n "${OWNER}" ] && OWNER="-u ${OWNER}" @@ -71,9 +71,9 @@ fi # now check the real state is_available ${REALDEVICE} || { if [ -n "$alias" ]; then - echo $"$alias device ${DEVICE} does not seem to be present, delaying initialization." + echo_log error net_log $"$alias device ${DEVICE} does not seem to be present, delaying initialization." else - echo $"Device ${DEVICE} does not seem to be present, delaying initialization." + echo_log error net_log $"Device ${DEVICE} does not seem to be present, delaying initialization." fi exit 1 } @@ -188,7 +188,7 @@ if [ -n "${DYNCONFIG}" ] && [ -x /sbin/dhclient ]; 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?" + echo_log error net_log $" failed; no link present. Check cable?" exit 1 fi @@ -219,7 +219,7 @@ else ip link set dev ${REALDEVICE} $(toggle_value arp $ARP) if ! ip link set dev ${REALDEVICE} up ; then - echo $"Failed to bring up ${DEVICE}." + echo_log error net_log $"Failed to bring up ${DEVICE}." exit 1 fi @@ -244,12 +244,12 @@ else if [ "${REALDEVICE}" != "lo" ]; then if ! LC_ALL=C ip addr ls ${REALDEVICE} | LC_ALL=C grep -q "${IPADDR}/${PREFIX}" ; then if ! /sbin/arping -q -c 2 -w 3 -D -I ${REALDEVICE} ${IPADDR} ; then - echo $"Error, some other host already uses address ${IPADDR}." + echo_log error net_log $"Error, some other host already uses address ${IPADDR}." exit 1 fi if ! ip addr add ${IPADDR}/${PREFIX} \ brd ${BROADCAST:-+} dev ${REALDEVICE} ${SCOPE} label ${DEVICE}; then - echo $"Error adding address ${IPADDR} for ${DEVICE}." + echo_log error net_log $"Error adding address ${IPADDR} for ${DEVICE}." fi fi diff --git a/sysconfig/network-scripts/ifup-ippp b/sysconfig/network-scripts/ifup-ippp index 7cfe6f3..086a7fe 100755 --- a/sysconfig/network-scripts/ifup-ippp +++ b/sysconfig/network-scripts/ifup-ippp @@ -30,20 +30,20 @@ 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" + echo_log error 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" + echo_log error 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" + echo_log error -t ifup-ippp "cannot list ISDN devices" exit 1 fi @@ -52,12 +52,12 @@ isdnctrl list $DEVICE >/dev/null 2>&1 && exit 0 function log_echo() { - /usr/bin/logger -p daemon.info -t ifup-ippp $"$*" + echo_log info ifup-ippp $"$*" } function log_isdnctrl() { - /usr/bin/logger -p daemon.info -t ifup-ippp isdnctrl $* + echo_log info ifup-ippp isdnctrl $* isdnctrl $* >/dev/null 2>&1 || exit 1 } @@ -85,7 +85,7 @@ function addprovider() { options= if [ -z "$PHONE_OUT" ]; then - log_echo "Error: $1: no outgoing phone number set" + echo_log error ifup-ippp "Error: $1: no outgoing phone number set" return 1 fi @@ -112,7 +112,7 @@ function addprovider() _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" + echo_log error ifup-ippp " Error: $1 (syncppp) user is not set" return 1 fi if [ "$DIALIN" != "on" ]; then diff --git a/sysconfig/network-scripts/ifup-ipv6 b/sysconfig/network-scripts/ifup-ipv6 index 29ba8af..cb6f78d 100755 --- a/sysconfig/network-scripts/ifup-ipv6 +++ b/sysconfig/network-scripts/ifup-ipv6 @@ -144,7 +144,7 @@ fi if [ "$IPV6_PRIVACY" = "rfc3041" ]; then /sbin/sysctl -e -w net.ipv6.conf.$DEVICE.use_tempaddr=2 >/dev/null 2>&1 if [ $? -ne 0 ]; then - echo $"Cannot enable IPv6 privacy method '$IPV6_PRIVACY', not supported by kernel" + echo_log info ifup-ipv6 $"Cannot enable IPv6 privacy method '$IPV6_PRIVACY', not supported by kernel" fi fi @@ -175,7 +175,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then ipv6_test_device_status tun6to4 if [ $? = 0 ]; then # device is already up - echo $"Device 'tun6to4' (from '$DEVICE') is already up, shutdown first" + echo_log error ifup-ipv6 $"Device 'tun6to4' (from '$DEVICE') is already up, shutdown first" exit 1 fi @@ -202,7 +202,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then if [ -n "$ipv4addr" ]; then if ! ipv6_test_ipv4_addr_global_usable $ipv4addr; then - echo $"Given IPv4 address '$ipv4addr' is not globally usable" + echo_log info ifup-ipv6 $"Given IPv4 address '$ipv4addr' is not globally usable" valid6to4config="no" fi if [ -z "$IPV6TO4_RELAY" ]; then @@ -215,7 +215,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then valid6to4config="no" fi else - echo $"IPv6to4 configuration needs an IPv4 address on related interface or otherwise specified" + echo_log info ifup-ipv6 $"IPv6to4 configuration needs an IPv4 address on related interface or otherwise specified" valid6to4config="no" fi @@ -230,7 +230,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then if [ -n "$IPV6TO4_MTU" ]; then if [ $IPV6TO4_MTU -gt $tunnelmtu ]; then - echo $"Warning: configured MTU '$IPV6TO4_MTU' for 6to4 exceeds maximum limit of '$tunnelmtu', ignored" + echo_log info ifup-ipv6 $"Warning: configured MTU '$IPV6TO4_MTU' for 6to4 exceeds maximum limit of '$tunnelmtu', ignored" else tunnelmtu=$IPV6TO4_MTU fi @@ -244,7 +244,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then # Add default route, if device matches if [ "$IPV6_DEFAULTDEV" = "tun6to4" ]; then if [ -n "$IPV6_DEFAULTGW" ]; then - echo $"Warning: interface 'tun6to4' does not support 'IPV6_DEFAULTGW', ignored" + echo_log info ifup-ipv6 $"Warning: interface 'tun6to4' does not support 'IPV6_DEFAULTGW', ignored" fi ipv6_set_default_route $ipv6to4_relay tun6to4 fi @@ -280,7 +280,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then if [ "$IPV6_CONTROL_RADVD" = "yes" ]; then # RADVD is in use, so forwarding of IPv6 packets should be enabled, display warning if [ $ipv6_global_forwarding_current -ne 1 ]; then - echo $"Using 6to4 and RADVD IPv6 forwarding usually should be enabled, but it isn't" + echo_log info ifup-ipv6 $"Using 6to4 and RADVD IPv6 forwarding usually should be enabled, but it isn't" fi if [ -n "$IPV6TO4_ROUTING" ]; then @@ -293,17 +293,17 @@ if [ "$IPV6TO4INIT" = "yes" ]; then ipv6_add_addr_on_device ${dev} ${ipv6to4prefix}${suf} done else - echo $"Error occurred while calculating the IPv6to4 prefix" + echo_log info ifup-ipv6 $"Error occurred while calculating the IPv6to4 prefix" fi else - echo $"radvd control enabled, but config is not complete" + echo_log info ifup-ipv6 $"radvd control enabled, but config is not complete" fi # Control running radvd ipv6_trigger_radvd up "$IPV6_RADVD_TRIGGER_ACTION" $IPV6_RADVD_PIDFILE fi else - echo $"6to4 configuration is not valid" + echo_log error ifup-ipv6 $"6to4 configuration is not valid" exit 1 fi fi diff --git a/sysconfig/network-scripts/ifup-ppp b/sysconfig/network-scripts/ifup-ppp index fb30639..db27c32 100755 --- a/sysconfig/network-scripts/ifup-ppp +++ b/sysconfig/network-scripts/ifup-ppp @@ -42,10 +42,7 @@ if [ "${2}" = "boot" -a "${ONBOOT}" = "no" ]; then fi [ -x /usr/sbin/pppd ] || { - echo $"pppd does not exist or is not executable" - 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}" + echo_log info ifup-ppp $"pppd does not exist or is not executable for ${DEVICE}, exiting" exit 1 } @@ -55,8 +52,7 @@ if [ "$TYPE" = "xDSL" ] ; then adsl-start /etc/sysconfig/network-scripts/$CONFIG exit $? else - /usr/bin/logger -p daemon.info -t ifup-ppp \ - $"adsl-start does not exist or is not executable for ${DEVICE}" + echo_log info ifup-ppp $"adsl-start does not exist or is not executable for ${DEVICE}" exit 1 fi fi @@ -71,10 +67,7 @@ if [ ! -f ${PEERCONF} ]; then if [ -z "${WVDIALSECT}" ] ; then CHATSCRIPT=/etc/sysconfig/network-scripts/chat-${DEVNAME} [ -f ${CHATSCRIPT} ] || { - echo $"/etc/sysconfig/network-scripts/chat-${DEVNAME} does not exist" - 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}" + echo_log info ifup-ppp $"/etc/sysconfig/network-scripts/chat-${DEVNAME} does not exist for ${DEVICE}, exiting" exit 1 } fi diff --git a/sysconfig/network-scripts/ifup-sit b/sysconfig/network-scripts/ifup-sit index f593a67..14b6ee9 100755 --- a/sysconfig/network-scripts/ifup-sit +++ b/sysconfig/network-scripts/ifup-sit @@ -55,12 +55,12 @@ ipv6_test || exit 1 # Generic tunnel device sit0 is not supported here if [ "$DEVICE" = "sit0" ]; then - echo $"Device '$DEVICE' isn't supported here, use IPV6_AUTOTUNNEL setting and restart (IPv6) networking" + echo_log error ifup-sit $"Device '$DEVICE' isn't supported here, use IPV6_AUTOTUNNEL setting and restart (IPv6) networking" exit 1 fi if [ -z "$IPV6TUNNELIPV4" ]; then - echo $"Missing remote IPv4 address of tunnel, configuration is not valid" + echo_log error ifup-sit $"Missing remote IPv4 address of tunnel, configuration is not valid" exit 1 fi @@ -68,7 +68,7 @@ fi ipv6_test_device_status $DEVICE if [ $? = 0 ]; then # device is already up - echo $"Device '$DEVICE' is already up, please shutdown first" + echo_log error ifup-sit $"Device '$DEVICE' is already up, please shutdown first" exit 1 fi diff --git a/sysconfig/network-scripts/ifup-tunnel b/sysconfig/network-scripts/ifup-tunnel index 8fd631e..854db22 100755 --- a/sysconfig/network-scripts/ifup-tunnel +++ b/sysconfig/network-scripts/ifup-tunnel @@ -46,14 +46,14 @@ case "$TYPE" in /sbin/modprobe ipip ;; *) - echo $"Invalid tunnel type $TYPE" + echo_log error ifup-tunnel $"Invalid tunnel type $TYPE" exit 1 ;; esac # Generic tunnel devices are not supported here if [ "$DEVICE" = gre0 -o "$DEVICE" = tunl0 ]; then - echo $"Device '$DEVICE' isn't supported as a valid GRE device name." + echo_log error ifup-tunnel $"Device '$DEVICE' isn't supported as a valid GRE device name." exit 1 fi -- 1.7.1