From 265989c6fce9523b46aa9020f241ab2450307aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 19 Dec 2009 15:57:03 +0200 Subject: Eliminate bunch of unnecessary stat calls and command invocations. --- rc.d/init.d/functions | 4 ++-- rc.d/init.d/halt | 8 ++++---- rc.d/init.d/killall | 6 +++--- rc.d/init.d/netfs | 4 ++-- rc.d/init.d/network | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'rc.d/init.d') 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= -- cgit v1.2.1