diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2010-02-21 21:21:48 +0200 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2011-02-28 15:31:44 -0500 |
commit | 5212d0a596d67bbd2f5effdd3686c123f778078f (patch) | |
tree | 78f41b7fd9ed97f6326a61c7da25f0b9fabec0df | |
parent | 681717364c786083356ebe5d92c4cc6fd73af307 (diff) | |
download | initscripts-5212d0a596d67bbd2f5effdd3686c123f778078f.tar initscripts-5212d0a596d67bbd2f5effdd3686c123f778078f.tar.gz initscripts-5212d0a596d67bbd2f5effdd3686c123f778078f.tar.bz2 initscripts-5212d0a596d67bbd2f5effdd3686c123f778078f.tar.xz initscripts-5212d0a596d67bbd2f5effdd3686c123f778078f.zip |
Drop some unnecessary command invocations.
-rwxr-xr-x | lang.csh | 4 | ||||
-rw-r--r-- | ppp/ip-down.ipv6to4 | 4 | ||||
-rw-r--r-- | ppp/ip-up.ipv6to4 | 10 | ||||
-rw-r--r-- | ppp/ipv6-up | 2 | ||||
-rw-r--r-- | rc.d/init.d/functions | 6 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifdown-ipv6 | 4 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifdown-sit | 2 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-ipv6 | 10 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-ipx | 2 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-sit | 4 | ||||
-rw-r--r-- | sysconfig/network-scripts/network-functions | 5 | ||||
-rw-r--r-- | sysconfig/network-scripts/network-functions-ipv6 | 12 |
12 files changed, 32 insertions, 33 deletions
@@ -5,7 +5,7 @@ set sourced=0 if ($?LANG) then set saved_lang=$LANG if ( -f "$HOME/.i18n" ) then - eval `grep -v '^[[:blank:]]*#' "$HOME/.i18n" | sed 's|\([^=]*\)=\([^=]*\)|setenv \1 \2|g' | sed 's|$|;|'` + eval `sed -ne 's|^[[:blank:]]*\([^#=]\{1,\}\)=\([^=]*\)|setenv \1 \2;|p' "$HOME/.i18n"` set sourced=1 endif setenv LANG $saved_lang @@ -13,7 +13,7 @@ if ($?LANG) then else foreach file (/etc/sysconfig/i18n "$HOME/.i18n") if ( -f $file ) then - eval `grep -v '^[[:blank:]]*#' $file | sed 's|\([^=]*\)=\([^=]*\)|setenv \1 \2|g' | sed 's|$|;|'` + eval `sed -ne 's|^[[:blank:]]*\([^#=]\{1,\}\)=\([^=]*\)|setenv \1 \2;|p' $file` set sourced=1 endif end diff --git a/ppp/ip-down.ipv6to4 b/ppp/ip-down.ipv6to4 index d6e50b54..29f1c646 100644 --- a/ppp/ip-down.ipv6to4 +++ b/ppp/ip-down.ipv6to4 @@ -48,7 +48,7 @@ CONFIG=$1 source_config # IPv6 don't need aliases anymore, config is skipped -REALDEVICE=$(echo ${DEVICE} | sed 's/:.*//g') +REALDEVICE=${DEVICE%%:*} [ "$DEVICE" != "$REALDEVICE" ] && exit 0 if [ ! -f /etc/sysconfig/network-scripts/network-functions-ipv6 ]; then @@ -104,7 +104,7 @@ if [ "$valid6to4config" = "yes" ]; then if [ -n "$IPV6TO4_ROUTING" ]; then # Delete routes to local networks for devsuf in $IPV6TO4_ROUTING; do - dev="$(echo $devsuf | awk -F- '{ print $1 }')" + dev="${devsuf%%-*}" ipv6_cleanup_6to4_device $dev done fi diff --git a/ppp/ip-up.ipv6to4 b/ppp/ip-up.ipv6to4 index b2f6e6e6..6343fbc5 100644 --- a/ppp/ip-up.ipv6to4 +++ b/ppp/ip-up.ipv6to4 @@ -54,7 +54,7 @@ CONFIG=$1 source_config # IPv6 don't need aliases anymore, config is skipped -REALDEVICE=$(echo ${DEVICE} | sed 's/:.*//g') +REALDEVICE=${DEVICE%%:*} [ "$DEVICE" != "$REALDEVICE" ] && exit 0 if [ ! -f /etc/sysconfig/network-scripts/network-functions-ipv6 ]; then @@ -104,7 +104,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then if [ "$valid6to4config" = "yes" ]; then # Delete routes to local networks for devsuf in $IPV6TO4_ROUTING; do - dev="$(echo $devsuf | awk -F- '{ print $1 }')" + dev="${devsuf%%-*}" ipv6_cleanup_6to4_device $dev done @@ -112,7 +112,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then ipv6_cleanup_6to4_tunnels tun6to4 # Get MTU of master device - ipv4mtu="$(/sbin/ip link show dev $DEVICE | grep -w "mtu" | awk '{ print $5 }')" + ipv4mtu="$(/sbin/ip link show dev $DEVICE | awk '/\<mtu\>/ { print $5 }')" if [ -n "$ipv4mtu" ]; then # IPv6 tunnel MTU is IPv4 MTU minus 20 for IPv4 header tunnelmtu=$[ $ipv4mtu - 20 ] @@ -155,7 +155,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then # Setup additional static IPv6 routes (newer config style) if [ -f "/etc/sysconfig/network-scripts/route6-tun6to4" ]; then - cat "/etc/sysconfig/network-scripts/route6-tun6to4" | sed 's/#.*//g' | grep -v '^[[:space:]]*$' | while read line; do + sed -ne 's/#.*//' -e '/[^[:space:]]/p' /etc/sysconfig/network-scripts/route6-tun6to4 | while read line; do if echo "$line" | grep -vq 'via'; then # Add gateway if missing line="$line via $ipv6to4_relay" @@ -178,7 +178,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then if [ -n "$ipv6to4prefix" ]; then # Add IPv6 address to interface (required interface route will be set automatically) for devsuf in $IPV6TO4_ROUTING; do - dev="$(echo $devsuf | awk -F- '{ print $1 }')" + dev="${devsuf%%-*}" suf="$(echo $devsuf | awk -F- '{ print $2 }')" ipv6_add_addr_on_device ${dev} ${ipv6to4prefix}${suf} done diff --git a/ppp/ipv6-up b/ppp/ipv6-up index 06062cfa..54219e43 100644 --- a/ppp/ipv6-up +++ b/ppp/ipv6-up @@ -97,7 +97,7 @@ fi # Setup additional static IPv6 routes (newer config style) if [ -f "/etc/sysconfig/network-scripts/route6-$DEVICE" ]; then - cat "/etc/sysconfig/network-scripts/route6-$DEVICE" | sed 's/#.*//g' | grep -v '^[[:space:]]*$' | while read line; do + sed -ne 's/#.*//' -e '/[^[:space:]]/p' "/etc/sysconfig/network-scripts/route6-$DEVICE" | while read line; do /sbin/ip -6 route add $line done fi diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index 3eddf1ea..63d1190e 100644 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -671,7 +671,7 @@ find_crypto_mount_point() { # Because of a chicken/egg problem, init_crypto must be run twice. /var may be # encrypted but /var/lib/random-seed is needed to initialize swap. init_crypto() { - local have_random dst src key opt mode owner params makeswap skip arg opt + local have_random dst src key opt lsl owner params makeswap skip arg opt local param value rc ret mke2fs mdir prompt mount_point ret=0 @@ -686,8 +686,8 @@ init_crypto() { if test -e "$key" ; then owner=$(ls -l $key | (read a b owner rest; echo $owner)) if ! key_is_random "$key"; then - mode=$(ls -l "$key" | cut -c 5-10) - if [ "$mode" != "------" ]; then + lsl=$(ls -l "$key") + if [ "${lsl:4:6}" != "------" ]; then echo $"INSECURE MODE FOR $key" fi fi diff --git a/sysconfig/network-scripts/ifdown-ipv6 b/sysconfig/network-scripts/ifdown-ipv6 index 9f04531a..51c4028f 100755 --- a/sysconfig/network-scripts/ifdown-ipv6 +++ b/sysconfig/network-scripts/ifdown-ipv6 @@ -46,7 +46,7 @@ CONFIG=$1 source_config # IPv6 don't need aliases anymore, config is skipped -REALDEVICE=$(echo ${DEVICE} | sed 's/:.*//g') +REALDEVICE=${DEVICE%%:*} [ "$DEVICE" != "$REALDEVICE" ] && exit 0 [ -f /etc/sysconfig/network-scripts/network-functions-ipv6 ] || exit 1 @@ -120,7 +120,7 @@ if [ "$valid6to4config" = "yes" ]; then if [ -n "$IPV6TO4_ROUTING" ]; then # Delete routes to local networks for devsuf in $IPV6TO4_ROUTING; do - dev="$(echo $devsuf | awk -F- '{ print $1 }')" + dev="${devsuf%%-*}" ipv6_cleanup_6to4_device $dev done fi diff --git a/sysconfig/network-scripts/ifdown-sit b/sysconfig/network-scripts/ifdown-sit index 041dc3cd..314b91f1 100755 --- a/sysconfig/network-scripts/ifdown-sit +++ b/sysconfig/network-scripts/ifdown-sit @@ -28,7 +28,7 @@ CONFIG=$1 source_config # IPv6 don't need aliases anymore, config is skipped -REALDEVICE=$(echo ${DEVICE} | sed 's/:.*//g') +REALDEVICE=${DEVICE%%:*} [ "$DEVICE" != "$REALDEVICE" ] && exit 0 [ -f /etc/sysconfig/network-scripts/network-functions-ipv6 ] || exit 1 diff --git a/sysconfig/network-scripts/ifup-ipv6 b/sysconfig/network-scripts/ifup-ipv6 index da1062ec..6f104dc5 100755 --- a/sysconfig/network-scripts/ifup-ipv6 +++ b/sysconfig/network-scripts/ifup-ipv6 @@ -63,7 +63,7 @@ CONFIG=$1 source_config # IPv6 don't need aliases anymore, config is skipped -REALDEVICE=$(echo ${DEVICE} | sed 's/:.*//g') +REALDEVICE=${DEVICE%%:*} [ "$DEVICE" != "$REALDEVICE" ] && exit 0 # Test whether IPv6 configuration is enabled for this interface, else stop @@ -162,7 +162,7 @@ fi # Setup additional static IPv6 routes (newer config style) if [ -f "/etc/sysconfig/network-scripts/route6-$DEVICE" ]; then - cat "/etc/sysconfig/network-scripts/route6-$DEVICE" | sed 's/#.*//g' | grep -v '^[[:space:]]*$' | while read line; do + sed -ne 's/#.*//' -e '/[^[:space:]]/p' "/etc/sysconfig/network-scripts/route6-$DEVICE" | while read line; do /sbin/ip -6 route add $line done fi @@ -222,7 +222,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then # Setup 6to4 tunnel (hardwired name is "tun6to4"), if config is valid if [ "$valid6to4config" = "yes" ]; then # Get MTU of master device - ipv4mtu="$(/sbin/ip link show dev $DEVICE | grep -w "mtu" | awk '{ print $5 }')" + ipv4mtu="$(/sbin/ip link show dev $DEVICE | awk '/\<mtu\>/ { print $5 }')" if [ -n "$ipv4mtu" ]; then # IPv6 tunnel MTU is IPv4 MTU minus 20 for IPv4 header tunnelmtu=$(($ipv4mtu-20)) @@ -264,7 +264,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then # Setup additional static IPv6 routes (newer config style) if [ -f "/etc/sysconfig/network-scripts/route6-tun6to4" ]; then - cat "/etc/sysconfig/network-scripts/route6-tun6to4" | sed 's/#.*//g' | LC_ALL=C grep -v '^[[:space:]]*$' | while read line; do + sed -ne 's/#.*//' -e '/[^[:space:]]/p' /etc/sysconfig/network-scripts/route6-tun6to4 | while read line; do if echo "$line" | LC_ALL=C grep -vq 'via'; then # Add gateway if missing line="$line via $ipv6to4_relay" @@ -288,7 +288,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then if [ -n "$ipv6to4prefix" ]; then # Add route to local networks for devsuf in $IPV6TO4_ROUTING; do - dev="$(echo $devsuf | awk -F- '{ print $1 }')" + dev="${devsuf%%-*}" suf="$(echo $devsuf | awk -F- '{ print $2 }')" ipv6_add_addr_on_device ${dev} ${ipv6to4prefix}${suf} done diff --git a/sysconfig/network-scripts/ifup-ipx b/sysconfig/network-scripts/ifup-ipx index a5693cfe..dbd294a8 100755 --- a/sysconfig/network-scripts/ifup-ipx +++ b/sysconfig/network-scripts/ifup-ipx @@ -23,7 +23,7 @@ CONFIG=$1 source_config for frametype in 802.2 802.3 ETHERII SNAP ; do - framename=$(echo $frametype | sed 's/\./_/') + framename=${frametype/./_} eval ACT=\$IPXACTIVE_$framename case $ACT in yes|true) diff --git a/sysconfig/network-scripts/ifup-sit b/sysconfig/network-scripts/ifup-sit index f593a677..6d1a8c79 100755 --- a/sysconfig/network-scripts/ifup-sit +++ b/sysconfig/network-scripts/ifup-sit @@ -40,7 +40,7 @@ CONFIG=$1 source_config # IPv6 don't need aliases anymore, config is skipped -REALDEVICE=$(echo ${DEVICE} | sed 's/:.*//g') +REALDEVICE=${DEVICE%%:*} [ "$DEVICE" != "$REALDEVICE" ] && exit 0 # Test whether IPv6 configuration is enabled for this interface, else stop @@ -106,7 +106,7 @@ fi # Setup additional static IPv6 routes (newer config style) if [ -f "/etc/sysconfig/network-scripts/route6-$REALDEVICE" ]; then - cat "/etc/sysconfig/network-scripts/route6-$REALDEVICE" | sed 's/#.*//g' | grep -v '^[[:space:]]*$' | while read line; do + sed -ne 's/#.*//' -e '/[^[:space:]]/p' "/etc/sysconfig/network-scripts/route6-$REALDEVICE" | while read line; do /sbin/ip -6 route add $line done fi diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 562fe7cb..0d2528ee 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -51,7 +51,7 @@ get_config_by_name () get_device_by_hwaddr () { - LANG=C ip -o link | grep -v link/ieee802.11 | awk -F ': ' -vIGNORECASE=1 "/$1/ { print \$2 }" + LANG=C ip -o link | awk -F ': ' -vIGNORECASE=1 '!/link\/ieee802\.11/ && /'"$1"'/ { print $2 }' } get_uuid_by_config () @@ -207,9 +207,8 @@ do_netreport () ( cd /var/run/netreport || exit for i in * ; do if [ -f $i ]; then - OWNER=$(ls -l $i | awk '{ print $3 }') - if [ "$(id -u)" = "0" ]; then + OWNER=$(stat -c %U $i) su -s /bin/bash $OWNER -c "kill -SIGIO $i >/dev/null 2>&1 || rm -f $i >/dev/null 2>&1" > /dev/null 2>&1 else kill -SIGIO $i >/dev/null 2>&1 || rm -f $i >/dev/null 2>&1 diff --git a/sysconfig/network-scripts/network-functions-ipv6 b/sysconfig/network-scripts/network-functions-ipv6 index 24100cba..64b9b593 100644 --- a/sysconfig/network-scripts/network-functions-ipv6 +++ b/sysconfig/network-scripts/network-functions-ipv6 @@ -322,7 +322,7 @@ ipv6_add_addr_on_device() { # Extract address parts local prefixlength_implicit="$(echo $address | awk -F/ '{ print $2 }')" - local address_implicit="$(echo $address | awk -F/ '{ print $1 }')" + local address_implicit="${address%%/*}" # Check prefix length and using '64' as default if [ -z "$prefixlength_implicit" ]; then @@ -389,7 +389,7 @@ ipv6_cleanup_6to4_device() { ipv6_test testonly || return 2 # Cleanup 6to4 addresses on this device - /sbin/ip -6 addr show dev $dev scope global permanent | LC_ALL=C grep -w inet6 | awk '{ print $2}' | LC_ALL=C grep "^2002:" | while read addr; do + /sbin/ip -6 addr show dev $dev scope global permanent | awk '/\<inet6\>/ && $2 ~ /^2002:/ { print $2 }' | while read addr; do /sbin/ip -6 addr del ${addr} dev ${dev} done @@ -496,7 +496,7 @@ ipv6_create_6to4_prefix() { ipv6_log $"Missing parameter 'IPv4 address' (arg 1)" stderr.err $fn fi - local major1="$(echo $ipv4addr | awk -F. '{ print $1 }')" + local major1="${ipv4addr%%.*}" local minor1="$(echo $ipv4addr | awk -F. '{ print $2 }')" local major2="$(echo $ipv4addr | awk -F. '{ print $3 }')" local minor2="$(echo $ipv4addr | awk -F. '{ print $4 }')" @@ -654,7 +654,7 @@ ipv6_cleanup_6to4_tunnels() { ipv6_del_tunnel_device tun6to4 # Remove all unspecific unreachable routes for local 6to4 address space - /sbin/ip -6 route | LC_ALL=C grep "^unreachable 2002:" | LC_ALL=C grep "/48 dev lo" | while read token net rest; do + /sbin/ip -6 route | LC_ALL=C grep "^unreachable 2002:.*/48 dev lo" | while read token net rest; do /sbin/ip route del unreach $net done @@ -831,7 +831,7 @@ ipv6_cleanup_tunnel_devices() { # Find still existing tunnel devices and shutdown and delete them - /sbin/ip tunnel show | LC_ALL=C grep -w "ipv6/ip" | awk -F: '{ print $1 }' | while read device; do + /sbin/ip tunnel show | awk -F: '/\<ipv6\/ip\>/ { print $1 }' | while read device; do ipv6_del_tunnel_device $device done @@ -987,7 +987,7 @@ ipv6_set_default_route() { fi if [ -n "$address" ]; then - local addressgw=$(echo $address | awk -F% '{ print $1 }') + local addressgw=${address%%%*} local device_scope=$(echo $address | awk -F% '{ print $2 }') if [ -z "$addressgw" ]; then |