summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt J. Bosch <kjb-temp-2009@alpenjodel.de>2011-06-24 21:12:56 +0200
committerKurt J. Bosch <kjb-temp-2009@alpenjodel.de>2011-06-24 21:12:56 +0200
commitcd4b6dde21fde2a461dbbe42db649cc83fac303b (patch)
treeaa681a33bf12d8f7bc675515f5a667782c770946
parent339d0a10258a8cf862c84b5f26cdd042dfeca8c2 (diff)
Get rid of simple if-constucts by using '&&'
-rwxr-xr-xrc.multi4
-rwxr-xr-xrc.shutdown58
-rwxr-xr-xrc.sysinit33
3 files changed, 38 insertions, 57 deletions
diff --git a/rc.multi b/rc.multi
index 4b55a27..b801fb6 100755
--- a/rc.multi
+++ b/rc.multi
@@ -20,9 +20,7 @@ for daemon in "${DAEMONS[@]}"; do
esac
done
-if [[ -x /etc/rc.local ]]; then
- /etc/rc.local
-fi
+[[ -x /etc/rc.local ]] && /etc/rc.local
run_hook multi_end
diff --git a/rc.shutdown b/rc.shutdown
index 473953f..9eb0b31 100755
--- a/rc.shutdown
+++ b/rc.shutdown
@@ -22,21 +22,20 @@ echo " "
kill_everything shutdown
stat_busy "Saving Random Seed"
-RANDOM_SEED=/var/lib/misc/random-seed
-install -TDm 0600 <(:) $RANDOM_SEED
-POOL_FILE=/proc/sys/kernel/random/poolsize
-if [[ -r $POOL_FILE ]]; then
- read POOL_SIZE < $POOL_FILE
-else
- POOL_SIZE=512
-fi
-dd if=/dev/urandom of=$RANDOM_SEED count=1 bs=$POOL_SIZE &>/dev/null
+ RANDOM_SEED=/var/lib/misc/random-seed
+ install -TDm 0600 <(:) $RANDOM_SEED
+ POOL_FILE=/proc/sys/kernel/random/poolsize
+ if [[ -r $POOL_FILE ]]; then
+ read POOL_SIZE < $POOL_FILE
+ else
+ POOL_SIZE=512
+ fi
+ dd if=/dev/urandom of=$RANDOM_SEED count=1 bs=$POOL_SIZE &>/dev/null
stat_done
-if [[ $TIMEZONE ]]; then
+[[ $TIMEZONE ]] &&
status "Saving Time Zone" \
cp --remove-destination "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
-fi
# Write to wtmp file before unmounting
halt -w
@@ -44,41 +43,36 @@ halt -w
status "Deactivating Swap" swapoff -a
# stop monitoring of lvm2 groups before unmounting filesystems
-if [[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]]; then
+[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]] &&
status "Deactivating monitoring of LVM2 groups" \
vgchange --monitor n &>/dev/null
-fi
-stat_busy "Unmounting Filesystems"
- # if we don't have devtmpfs support, /dev is mounted as tmpfs, so don't unmount it
+# if we don't have devtmpfs support, /dev is mounted as tmpfs, so don't unmount it
+status "Unmounting Filesystems" \
umount -a -r -t nodevtmpfs,notmpfs,nosysfs,noproc,nodevpts -O no_netdev
-stat_done
run_hook shutdown_postumount
# Kill non-root encrypted partition mappings
if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then
stat_busy "Deactivating encrypted volumes:"
- # Maybe someone has LVM on an encrypted block device
- # executing an extra vgchange is errorless
- if [[ $USELVM = [Yy][Ee][Ss] ]]; then
- vgchange --sysinit -a n &>/dev/null
- fi
- do_lock() {
- stat_append "${1}.."
- if $CS remove "$1" &>/dev/null; then
- stat_append "ok "
- else
- stat_append "failed "
- fi
- }
- read_crypttab do_lock
+ # Maybe someone has LVM on an encrypted block device
+ # executing an extra vgchange is errorless
+ [[ $USELVM = [Yy][Ee][Ss] ]] && vgchange --sysinit -a n &>/dev/null
+ do_lock() {
+ stat_append "${1}.."
+ if $CS remove "$1" &>/dev/null; then
+ stat_append "ok "
+ else
+ stat_append "failed "
+ fi
+ }
+ read_crypttab do_lock
stat_done
fi
-if [[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]]; then
+[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]] &&
status "Deactivating LVM2 groups" vgchange --sysinit -a n &>/dev/null
-fi
status "Remounting Root Filesystem Read-only" \
mount -n -o remount,ro /
diff --git a/rc.sysinit b/rc.sysinit
index 0d99aa3..c0a35df 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -66,9 +66,7 @@ if [[ $HWCLOCK_PARAMS ]]; then
# configured timezone. Any new timezone put in rc.conf is copied over at
# a later time.
# This also sets the kernel time zone.
- if [[ -f /etc/localtime ]]; then
- hwclock $HWCLOCK_PARAMS
- fi
+ [[ -f /etc/localtime ]] && hwclock $HWCLOCK_PARAMS
fi
# Start/trigger UDev, load MODULES and settle UDev
@@ -79,14 +77,12 @@ udevd_modprobe sysinit
status "Bringing up loopback interface" ip link set up dev lo
# FakeRAID devices detection
-if [[ $USEDMRAID = [Yy][Ee][Ss] && -x $(type -P dmraid) ]]; then
+[[ $USEDMRAID = [Yy][Ee][Ss] && -x $(type -P dmraid) ]] &&
status "Activating FakeRAID arrays" dmraid -i -ay
-fi
# BTRFS devices detection
-if [[ $USEBTRFS = [Yy][Ee][Ss] && -x $(type -P btrfs) ]]; then
+[[ $USEBTRFS = [Yy][Ee][Ss] && -x $(type -P btrfs) ]] &&
status "Activating BTRFS volumes" btrfs device scan
-fi
activate_vgs
@@ -123,9 +119,7 @@ if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then
# This sanity check _should_ be sufficient, but it might not.
# This may cause dataloss if it is not used carefully.
blkid -p "$2" &>/dev/null
- if (( $? == 2 )); then
- _overwriteokay=1
- fi
+ (( $? == 2 )) && _overwriteokay=1
fi
if (( _overwriteokay == 0 )); then
false
@@ -206,23 +200,20 @@ fi
mount_all
# enable monitoring of lvm2 groups, now that the filesystems are mounted rw
-if [[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]]; then
+[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]] &&
status "Activating monitoring of LVM2 groups" \
vgchange --monitor y >/dev/null
-fi
status "Activating Swap" swapon -a
-if [[ $TIMEZONE ]]; then
+[[ $TIMEZONE ]] &&
status "Configuring Time Zone" \
cp --remove-destination "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
-fi
RANDOM_SEED=/var/lib/misc/random-seed
-if [[ -f $RANDOM_SEED ]]; then
+[[ -f $RANDOM_SEED ]] &&
status "Initializing Random Seed" \
cat $RANDOM_SEED > /dev/urandom
-fi
stat_busy "Removing Leftover Files"
rm -rf /etc/{nologin,shutdownpid} /forcefsck /tmp/* /tmp/.*
@@ -236,11 +227,9 @@ stat_busy "Removing Leftover Files"
mkdir -m 1777 /tmp/.{X11,ICE}-unix
stat_done
-if [[ $HOSTNAME ]]; then
- stat_busy "Setting Hostname: $HOSTNAME"
- echo "$HOSTNAME" > /proc/sys/kernel/hostname
- stat_done
-fi
+[[ $HOSTNAME ]] &&
+ status "Setting Hostname: $HOSTNAME" \
+ eval 'echo "$HOSTNAME" > /proc/sys/kernel/hostname'
stat_busy "Setting Locale: ${LOCALE:=en_US}"
# Flush old locale settings
@@ -270,7 +259,7 @@ else
echo 0 > /sys/module/vt/parameters/default_utf8
stat_done
fi
-[[ $KEYMAP ]] && \
+[[ $KEYMAP ]] &&
status "Loading Keyboard Map: $KEYMAP" loadkeys -q $KEYMAP
# Set console font if required