diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2009-12-19 15:57:03 +0200 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2010-01-12 17:09:10 -0500 |
commit | 265989c6fce9523b46aa9020f241ab2450307aa4 (patch) | |
tree | 168538aa78bb8280848af13978f56fef5caf2c05 | |
parent | d4c58cd1c84f99030c3f4778d2c64377838e0634 (diff) | |
download | initscripts-265989c6fce9523b46aa9020f241ab2450307aa4.tar initscripts-265989c6fce9523b46aa9020f241ab2450307aa4.tar.gz initscripts-265989c6fce9523b46aa9020f241ab2450307aa4.tar.bz2 initscripts-265989c6fce9523b46aa9020f241ab2450307aa4.tar.xz initscripts-265989c6fce9523b46aa9020f241ab2450307aa4.zip |
Eliminate bunch of unnecessary stat calls and command invocations.
-rw-r--r-- | rc.d/init.d/functions | 4 | ||||
-rwxr-xr-x | rc.d/init.d/halt | 8 | ||||
-rwxr-xr-x | rc.d/init.d/killall | 6 | ||||
-rwxr-xr-x | rc.d/init.d/netfs | 4 | ||||
-rwxr-xr-x | rc.d/init.d/network | 2 | ||||
-rwxr-xr-x | rc.d/rc | 4 | ||||
-rwxr-xr-x | rc.d/rc.sysinit | 28 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifdown-eth | 6 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifdown-ppp | 2 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup | 2 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-eth | 6 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-ippp | 8 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-ipsec | 2 | ||||
-rw-r--r-- | sysconfig/network-scripts/network-functions | 2 |
14 files changed, 42 insertions, 42 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index 09f11b8f..2b117d58 100644 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -18,7 +18,7 @@ export PATH [ -z "${CONSOLETYPE:-}" ] && CONSOLETYPE="$(/sbin/consoletype)" -if [ -f /etc/sysconfig/i18n -a -z "${NOLOCALE:-}" -a -z "${LANGSH_SOURCED:-}" ] ; then +if [ -z "${NOLOCALE:-}" ] && [ -z "${LANGSH_SOURCED:-}" ] && [ -f /etc/sysconfig/i18n ] ; then . /etc/profile.d/lang.sh 2>/dev/null # avoid propagating LANGSH_SOURCED any further unset LANGSH_SOURCED @@ -157,7 +157,7 @@ __pids_var_run() { read line [ -z "$line" ] && break for p in $line ; do - [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p" + [ -z "${p//[0-9]/}" ] && [ -d "/proc/$p" ] && pid="$pid $p" done done < "$pid_file" diff --git a/rc.d/init.d/halt b/rc.d/init.d/halt index 8cb437fc..94d4fb08 100755 --- a/rc.d/init.d/halt +++ b/rc.d/init.d/halt @@ -78,7 +78,7 @@ esac # Find mdmon pid's and omit killing them OMITARGS= for i in /dev/.mdadm/*.pid; do - if [ "$i" = "mdadm.pid" -o ! -r "$i" ]; then + if [ "$i" = "mdadm.pid" ] || [ ! -r "$i" ]; then continue fi OMITARGS="$OMITARGS -o $(cat $i)" @@ -95,7 +95,7 @@ fi /sbin/halt -w # Save mixer settings, here for lack of a better place. -if [ -s /etc/alsa/alsactl.conf -a -x /sbin/alsactl -a -w /etc/asound.state ]; then +if [ -s /etc/alsa/alsactl.conf ] && [ -x /sbin/alsactl ] && [ -w /etc/asound.state ]; then action $"Saving mixer settings" /sbin/alsactl -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --ignore store fi @@ -188,12 +188,12 @@ elif [ -f /forcefsck ]; then fi # Shutdown UPS drivers -if [ "$command" = /sbin/halt -a -f /etc/sysconfig/ups ]; then +if [ "$command" = /sbin/halt ] && [ -f /etc/sysconfig/ups ]; then . /etc/sysconfig/ups if [ -z $POWERDOWNFLAG ]; then POWERDOWNFLAG=/etc/killpower fi - if [ "$SERVER" = "yes" -a -f $POWERDOWNFLAG ]; then + if [ "$SERVER" = "yes" ] && [ -f $POWERDOWNFLAG ]; then /sbin/upsdrvctl shutdown fi fi diff --git a/rc.d/init.d/killall b/rc.d/init.d/killall index d22982ef..c1169b10 100755 --- a/rc.d/init.d/killall +++ b/rc.d/init.d/killall @@ -24,10 +24,10 @@ for i in /var/lock/subsys/* ; do [ $subsys = network ] && continue # Bring the subsystem down. - if [ -f /etc/init.d/$subsys.init ]; then - /etc/init.d/$subsys.init stop - elif [ -f /etc/init.d/$subsys ]; then + if [ -f /etc/init.d/$subsys ]; then /etc/init.d/$subsys stop + elif [ -f /etc/init.d/$subsys.init ]; then + /etc/init.d/$subsys.init stop else rm -f "$i" fi diff --git a/rc.d/init.d/netfs b/rc.d/init.d/netfs index 17cea9f8..6294aeb9 100755 --- a/rc.d/init.d/netfs +++ b/rc.d/init.d/netfs @@ -32,7 +32,7 @@ NETDEVMTAB=$(LC_ALL=C awk '$4 ~ /_netdev/ && $2 != "/" { print $2 }' /etc/mtab) # See how we were called. case "$1" in start) - [ ! -f /var/lock/subsys/network -a ! -f /var/lock/subsys/NetworkManager ] && exit 0 + [ ! -f /var/lock/subsys/network ] && [ ! -f /var/lock/subsys/NetworkManager ] && exit 0 [ "$EUID" != "0" ] && exit 4 [ -n "$NFSFSTAB" ] && { @@ -46,7 +46,7 @@ case "$1" in if [ -f /etc/mdadm.conf ]; then mdadm -A -s fi - if [ -f /etc/multipath.conf -a -x /sbin/multipath ]; then + if [ -f /etc/multipath.conf ] && [ -x /sbin/multipath ]; then modprobe dm-multipath >/dev/null 2>&1 /sbin/multipath -v 0 if [ -x /sbin/kpartx ]; then diff --git a/rc.d/init.d/network b/rc.d/init.d/network index 52845ae3..07df54e0 100755 --- a/rc.d/init.d/network +++ b/rc.d/init.d/network @@ -34,7 +34,7 @@ fi [ -x /sbin/ip ] || exit 1 # Even if IPX is configured, without the utilities we can't do much -[ ! -x /sbin/ipx_internal_net -o ! -x /sbin/ipx_configure ] && IPX= +[ ! -x /sbin/ipx_internal_net ] || [ ! -x /sbin/ipx_configure ] && IPX= # Even if VLAN is configured, without the utility we can't do much [ ! -x /sbin/vconfig ] && VLAN= @@ -51,7 +51,7 @@ fi # Set language, vc settings once to avoid doing it for every init script # through functions -if [ -f /etc/sysconfig/i18n -a -z "${NOLOCALE:-}" ] ; then +if [ -z "${NOLOCALE:-}" ] && [ -f /etc/sysconfig/i18n ] ; then . /etc/profile.d/lang.sh 2>/dev/null export LANGSH_SOURCED=1 fi @@ -61,7 +61,7 @@ for i in /etc/rc$runlevel.d/K* ; do # Check if the subsystem is already up. subsys=${i#/etc/rc$runlevel.d/K??} - [ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] || continue + [ -f /var/lock/subsys/$subsys ] || [ -f /var/lock/subsys/$subsys.init ] || continue check_runlevel "$i" || continue # Bring the subsystem down. diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit index 2713dd83..b602a7ba 100755 --- a/rc.d/rc.sysinit +++ b/rc.d/rc.sysinit @@ -42,7 +42,7 @@ if [ -e "/selinux/enforce" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ] fi fi -if [ -n "$SELINUX_STATE" -a -x /sbin/restorecon ] && __fgrep " /dev " /proc/mounts >/dev/null 2>&1 ; then +if [ -n "$SELINUX_STATE" ] && [ -x /sbin/restorecon ] && __fgrep " /dev " /proc/mounts >/dev/null 2>&1 ; then /sbin/restorecon -R /dev 2>/dev/null fi @@ -348,8 +348,8 @@ if [ -f /etc/crypttab ]; then init_crypto 0 fi -if ! strstr "$cmdline" nompath && [ -f /etc/multipath.conf -a \ - -x /sbin/multipath ]; then +if ! strstr "$cmdline" nompath && [ -f /etc/multipath.conf ] && \ + [ -x /sbin/multipath ]; then modprobe dm-multipath > /dev/null 2>&1 /sbin/multipath -v 0 if [ -x /sbin/kpartx ]; then @@ -373,7 +373,7 @@ if ! strstr "$cmdline" nodmraid && [ -x /sbin/dmraid ]; then fi # Start any MD RAID arrays that haven't been started yet -[ -f /etc/mdadm.conf -a -x /sbin/mdadm ] && /sbin/mdadm -As --auto=yes --run +[ -f /etc/mdadm.conf ] && [ -x /sbin/mdadm ] && /sbin/mdadm -As --auto=yes --run if [ -x /sbin/lvm ]; then action $"Setting up Logical Volume Management:" /sbin/lvm vgchange -a y --ignorelockingfailure @@ -490,7 +490,7 @@ if [ "$READONLY" = "yes" -o "$TEMPORARY_STATE" = "yes" ]; then *) ;; esac - [ -n "$SELINUX_STATE" -a -e "$path" ] && restorecon -R "$path" + [ -n "$SELINUX_STATE" ] && [ -e "$path" ] && restorecon -R "$path" done done @@ -552,14 +552,14 @@ if [ "$READONLY" = "yes" -o "$TEMPORARY_STATE" = "yes" ]; then for path in $(grep -v "^#" "$file" 2>/dev/null); do mount_state "$path" - [ -n "$SELINUX_STATE" -a -e "$path" ] && restorecon -R "$path" + [ -n "$SELINUX_STATE" ] && [ -e "$path" ] && restorecon -R "$path" done done if [ -f "$STATE_MOUNT/files" ] ; then for path in $(grep -v "^#" "$STATE_MOUNT/files" 2>/dev/null); do mount_state "$path" - [ -n "$SELINUX_STATE" -a -e "$path" ] && restorecon -R "$path" + [ -n "$SELINUX_STATE" ] && [ -e "$path" ] && restorecon -R "$path" done fi fi @@ -570,7 +570,7 @@ if [[ " $fsckoptions" != *" -y"* ]]; then fi _RUN_QUOTACHECK=0 -if [ -f /forcequotacheck ] || strstr "$cmdline" forcequotacheck ; then +if strstr "$cmdline" forcequotacheck || [ -f /forcequotacheck ] ; then _RUN_QUOTACHECK=1 fi if [ -z "$fastboot" -a "$READONLY" != "yes" ]; then @@ -649,7 +649,7 @@ fi # If relabeling, relabel mount points. if [ -n "$SELINUX_STATE" -a "$READONLY" != "yes" ]; then - if [ -f /.autorelabel ] || strstr "$cmdline" autorelabel ; then + if strstr "$cmdline" autorelabel || [ -f /.autorelabel ] ; then restorecon $(awk '!/^#/ && $4 !~ /noauto/ && $2 ~ /^\// { print $2 }' /etc/fstab) >/dev/null 2>&1 fi fi @@ -680,7 +680,7 @@ else fi # Update quotas if necessary -if [ X"$_RUN_QUOTACHECK" = X1 -a -x /sbin/quotacheck ]; then +if [ X"$_RUN_QUOTACHECK" = X1 ] && [ -x /sbin/quotacheck ]; then action $"Checking local filesystem quotas: " /sbin/quotacheck -anug fi @@ -690,11 +690,11 @@ fi # Check to see if a full relabel is needed if [ -n "$SELINUX_STATE" -a "$READONLY" != "yes" ]; then - if [ -f /.autorelabel ] || strstr "$cmdline" autorelabel ; then + if strstr "$cmdline" autorelabel || [ -f /.autorelabel ] ; then relabel_selinux fi else - if [ -d /etc/selinux -a "$READONLY" != "yes" ]; then + if [ "$READONLY" != "yes" ] && [ -d /etc/selinux ]; then [ -f /.autorelabel ] || touch /.autorelabel fi fi @@ -756,7 +756,7 @@ rm -f /fastboot /fsckoptions /forcefsck /.autofsck /forcequotacheck /halt \ # Do we need (w|u)tmpx files? We don't set them up, but the sysadmin might... _NEED_XFILES= -[ -f /var/run/utmpx -o -f /var/log/wtmpx ] && _NEED_XFILES=1 +[ -f /var/run/utmpx ] || [ -f /var/log/wtmpx ] && _NEED_XFILES=1 # Clean up /var. rm -rf /var/lock/cvs/* /var/run/screen/* @@ -831,7 +831,7 @@ touch /.autofsck &> /dev/null if [ "$PROMPT" != no ]; then while :; do pid=$(/sbin/pidof getkey) - [ -n "$pid" -o -e /var/run/getkey_done ] && break + [ -n "$pid" ] || [ -e /var/run/getkey_done ] && break usleep 100000 done [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1 diff --git a/sysconfig/network-scripts/ifdown-eth b/sysconfig/network-scripts/ifdown-eth index 05d44174..3399ee3c 100755 --- a/sysconfig/network-scripts/ifdown-eth +++ b/sysconfig/network-scripts/ifdown-eth @@ -105,7 +105,7 @@ if [ -d "/sys/class/net/${REALDEVICE}" ]; then fi [ "$retcode" = "0" ] && retcode=$? -if [ -n "${BRIDGE}" -a -x /usr/sbin/brctl ]; then +if [ -n "${BRIDGE}" ] && [ -x /usr/sbin/brctl ]; then /sbin/ip link set dev ${DEVICE} down /usr/sbin/brctl delif ${BRIDGE} ${DEVICE} # Upon removing a device from a bridge, @@ -128,7 +128,7 @@ while ! check_device_down ${DEVICE} && [ "$waited" -lt 50 ] ; do done # don't leave an outdated key sitting around -if [ -n "${WIRELESS_ENC_KEY}" -a -x /sbin/iwconfig ]; then +if [ -n "${WIRELESS_ENC_KEY}" ] && [ -x /sbin/iwconfig ]; then /sbin/iwconfig ${DEVICE} enc 0 >/dev/null 2>&1 fi @@ -138,7 +138,7 @@ if [ "$retcode" = 0 ] ; then # the interface went down. fi -if [ -n "$VLAN" -a -x /sbin/vconfig ]; then +if [ -n "$VLAN" ] && [ -x /sbin/vconfig ]; then # 802.1q VLAN if echo ${DEVICE} | LANG=C grep -Ev '(:)' | LANG=C grep -Eq '(eth|bond)[0-9][0-9]*\.[0-9][0-9]?[0-9]?[0-9]?' \ || echo ${DEVICE} | LANG=C grep -Eq 'vlan[0-9][0-9]?[0-9]?[0-9]?' ; then diff --git a/sysconfig/network-scripts/ifdown-ppp b/sysconfig/network-scripts/ifdown-ppp index 2827c7e5..fca64638 100755 --- a/sysconfig/network-scripts/ifdown-ppp +++ b/sysconfig/network-scripts/ifdown-ppp @@ -13,7 +13,7 @@ fi CONFIG=${CONFIG##ifcfg-} -if [ "${DEMAND}" = "yes" -a -f /var/run/ppp-${CONFIG}.pid ] ; then +if [ "${DEMAND}" = "yes" ] && [ -f /var/run/ppp-${CONFIG}.pid ] ; then PID=$(head -1 /var/run/ppp-${CONFIG}.pid) kill -TERM ${PID} sleep 2 diff --git a/sysconfig/network-scripts/ifup b/sysconfig/network-scripts/ifup index 2f85e2d0..e3b01478 100755 --- a/sysconfig/network-scripts/ifup +++ b/sysconfig/network-scripts/ifup @@ -66,7 +66,7 @@ then fi # Ethernet 802.1Q VLAN support -if [ -x /sbin/vconfig -a "${VLAN}" = "yes" -a "$ISALIAS" = "no" ]; then +if [ "${VLAN}" = "yes" ] && [ "$ISALIAS" = "no" ] && [ -x /sbin/vconfig ]; then VID="" MATCH='^(eth|hsi|bond)[0-9]+\.[0-9]{1,4}$' if [[ "${DEVICE}" =~ $MATCH ]]; then diff --git a/sysconfig/network-scripts/ifup-eth b/sysconfig/network-scripts/ifup-eth index 634cb4fe..c0169192 100755 --- a/sysconfig/network-scripts/ifup-eth +++ b/sysconfig/network-scripts/ifup-eth @@ -150,7 +150,7 @@ if [ "$ISALIAS" = no ] && is_bonding_device ${DEVICE} ; then fi # If the device is part of a bridge, add the device to the bridge -if [ -n "${BRIDGE}" -a -x /usr/sbin/brctl ]; then +if [ -n "${BRIDGE}" ] && [ -x /usr/sbin/brctl ]; then if [ ! -d /sys/class/net/${BRIDGE}/bridge ]; then /usr/sbin/brctl addbr ${BRIDGE} 2>/dev/null fi @@ -167,7 +167,7 @@ if [ -n "${BRIDGE}" -a -x /usr/sbin/brctl ]; then exit 0 fi -if [ -n "${DYNCONFIG}" -a -x /sbin/dhclient ]; then +if [ -n "${DYNCONFIG}" ] && [ -x /sbin/dhclient ]; then if [[ "${PERSISTENT_DHCLIENT}" = [yY1]* ]]; then ONESHOT=""; else @@ -270,7 +270,7 @@ else # 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}" -a "$(ipcalc --network ${GATEWAY} ${NETMASK} 2>/dev/null)" = "NETWORK=${NETWORK}" ]; then + if [ -n "${GATEWAY}" ] && [ "$(ipcalc --network ${GATEWAY} ${NETMASK} 2>/dev/null)" = "NETWORK=${NETWORK}" ]; then ip route replace default ${METRIC:+metric $METRIC} \ via ${GATEWAY} ${WINDOW:+window $WINDOW} ${SRC} \ ${GATEWAYDEV:+dev $GATEWAYDEV} diff --git a/sysconfig/network-scripts/ifup-ippp b/sysconfig/network-scripts/ifup-ippp index 643b2a8c..7cfe6f39 100755 --- a/sysconfig/network-scripts/ifup-ippp +++ b/sysconfig/network-scripts/ifup-ippp @@ -23,20 +23,20 @@ if [ "${2}" = "boot" -a "${ONBOOT}" = "no" ]; then exit fi -if [ ! -f /var/lock/subsys/isdn -a -x /etc/init.d/isdn ] ; then +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 /usr/sbin/ipppd -a ! -x /sbin/ipppd ] ; 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 /usr/sbin/isdnctrl -a ! -x /sbin/isdnctrl ] ; then +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 @@ -74,7 +74,7 @@ function start_ibod() [ -f /var/lock/subsys/ibod ] && return device=$1 - if [ -f /etc/isdn/ibod.cf -a -x /usr/sbin/ibod ] ; then + if [ -f /etc/isdn/ibod.cf ] && [ -x /usr/sbin/ibod ] ; then ibod $device & pid=$(pidof ibod) [ -n "$pid" ] && touch /var/lock/subsys/ibod diff --git a/sysconfig/network-scripts/ifup-ipsec b/sysconfig/network-scripts/ifup-ipsec index 4411451c..2d40cc28 100755 --- a/sysconfig/network-scripts/ifup-ipsec +++ b/sysconfig/network-scripts/ifup-ipsec @@ -211,7 +211,7 @@ if [ "$KEYING" = "automatic" -a -n "$IKE_METHOD" ]; then echo "$DST $IKE_PSK" >> $tmpfile mv -f $tmpfile /etc/racoon/psk.txt fi - if [ ! -f /etc/racoon/$DST.conf -o /etc/racoon/$DST.conf -ot $1 ] ; then + if [ ! -f /etc/racoon/$DST.conf ] || [ /etc/racoon/$DST.conf -ot $1 ] ; then cat > /etc/racoon/$DST.conf << EOF remote $DST { diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index e357c0f2..e1c0d6fa 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -58,7 +58,7 @@ need_config () nconfig=$(LANG=C grep -l "^[[:space:]]*DEVICE=${1}\([[:space:]#]\|$\)" \ /etc/sysconfig/network-scripts/ifcfg-* \ | LC_ALL=C sed -e "$__sed_discard_ignored_files") - if [ -n "$nconfig" -a -f "$nconfig" ]; then + if [ -n "$nconfig" ] && [ -f "$nconfig" ]; then CONFIG=${nconfig##*/} return fi |