[arch-projects] [initscripts] [PATCH 00/13] Minor fixes, simplifications and cosmetics
Kurt J. Bosch (13): Fix hwclock comments Simplify timezone copying Simplify creating files by using /bin/install Simplify keyboard map loading by using loadkeys autodetection Simplify API filesystems mounting Some cosmetics Simplify rc.single udevadm stuff as in rc.sysinit Simplify unmounting filesystems rc.single: Avoid rc.multi syslog start error - use minilogd as in rc.sysinit Fix bootlogd not stopped when booting into runlevel '1' Simplify random seed file creation Some more cosmetics Simplify in_array function functions | 57 +++++++++++++++++++-------------------- rc.conf | 2 +- rc.shutdown | 34 +++++++++------------- rc.single | 39 +++++++++++---------------- rc.sysinit | 86 ++++++++++++++++++++++++---------------------------------- 5 files changed, 95 insertions(+), 123 deletions(-)
--- rc.conf | 2 +- rc.sysinit | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/rc.conf b/rc.conf index 5984171..b217ddb 100644 --- a/rc.conf +++ b/rc.conf @@ -9,7 +9,7 @@ # LOCALE: available languages can be listed with the 'locale -a' command # DAEMON_LOCALE: If set to 'yes', use $LOCALE as the locale during daemon # startup and during the boot process. If set to 'no', the C locale is used. -# HARDWARECLOCK: set to "UTC" or "localtime", any other value will result +# HARDWARECLOCK: set to "", "UTC" or "localtime", any other value will result # in the hardware clock being left untouched (useful for virtualization) # Note: Using "localtime" is discouraged. # TIMEZONE: timezones are found in /usr/share/zoneinfo diff --git a/rc.sysinit b/rc.sysinit index 7bcd0a5..e4c1c36 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -70,8 +70,7 @@ if [[ $HWCLOCK_PARAMS ]]; then # 3. This will set the clock, if using non-UTC, off the last known # configured timezone. Any new timezone put in rc.conf is copied over at # a later time. - # This does *NOT* take into account a time adjustment file as /var may not be - # mounted yet. A second set may occur in rc.d/hwclock to match rc.conf. + # This also sets the kernel time zone. if [[ -f /etc/localtime ]]; then hwclock $HWCLOCK_PARAMS fi -- 1.7.1
--- rc.shutdown | 5 ++--- rc.sysinit | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/rc.shutdown b/rc.shutdown index 637974f..4014df2 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -35,10 +35,9 @@ fi dd if=/dev/urandom of=$RANDOM_SEED count=1 bs=$POOL_SIZE &> /dev/null stat_done -if [[ $TIMEZONE && -e /usr/share/zoneinfo/$TIMEZONE ]]; then - rm -f /etc/localtime +if [[ $TIMEZONE ]]; then status "Saving Time Zone" \ - cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime + cp --remove-destination "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime fi # Write to wtmp file before unmounting diff --git a/rc.sysinit b/rc.sysinit index e4c1c36..6c1fef9 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -238,10 +238,9 @@ fi status "Activating Swap" swapon -a -if [[ $TIMEZONE && -e /usr/share/zoneinfo/$TIMEZONE ]]; then - rm -f /etc/localtime +if [[ $TIMEZONE ]]; then status "Configuring Time Zone" \ - cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime + cp --remove-destination "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime fi RANDOM_SEED=/var/lib/misc/random-seed -- 1.7.1
On Fri, Jun 24, 2011 at 11:14 AM, Kurt J. Bosch <kjb-temp-2009@alpenjodel.de> wrote:
--- rc.shutdown | 5 ++--- rc.sysinit | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) index 637974f..4014df2 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -35,10 +35,9 @@ fi dd if=/dev/urandom of=$RANDOM_SEED count=1 bs=$POOL_SIZE &> /dev/null stat_done
-if [[ $TIMEZONE && -e /usr/share/zoneinfo/$TIMEZONE ]]; then - rm -f /etc/localtime +if [[ $TIMEZONE ]]; then status "Saving Time Zone" \ - cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime + cp --remove-destination "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime fi
# Write to wtmp file before unmounting diff --git a/rc.sysinit b/rc.sysinit index e4c1c36..6c1fef9 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -238,10 +238,9 @@ fi
status "Activating Swap" swapon -a
-if [[ $TIMEZONE && -e /usr/share/zoneinfo/$TIMEZONE ]]; then - rm -f /etc/localtime +if [[ $TIMEZONE ]]; then status "Configuring Time Zone" \ - cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime + cp --remove-destination "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime fi
RANDOM_SEED=/var/lib/misc/random-seed -- 1.7.1
Could you add a comment in the commit message saying what happens when $TIMEZONE is empty or invalid? I haven't tried your code, but if it does nothing (no error messages either) in the mentioned cases, then it looks good. -t
Error/stat_fail when $TIMEZONE is invalid instead of skipping silently. --- rc.shutdown | 5 ++--- rc.sysinit | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/rc.shutdown b/rc.shutdown index 637974f..4014df2 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -35,10 +35,9 @@ fi dd if=/dev/urandom of=$RANDOM_SEED count=1 bs=$POOL_SIZE &> /dev/null stat_done -if [[ $TIMEZONE && -e /usr/share/zoneinfo/$TIMEZONE ]]; then - rm -f /etc/localtime +if [[ $TIMEZONE ]]; then status "Saving Time Zone" \ - cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime + cp --remove-destination "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime fi # Write to wtmp file before unmounting diff --git a/rc.sysinit b/rc.sysinit index e4c1c36..6c1fef9 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -238,10 +238,9 @@ fi status "Activating Swap" swapon -a -if [[ $TIMEZONE && -e /usr/share/zoneinfo/$TIMEZONE ]]; then - rm -f /etc/localtime +if [[ $TIMEZONE ]]; then status "Configuring Time Zone" \ - cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime + cp --remove-destination "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime fi RANDOM_SEED=/var/lib/misc/random-seed -- 1.7.1
On Fri, Jun 24, 2011 at 11:54 AM, Kurt J. Bosch <kjb-temp-2009@alpenjodel.de> wrote:
Error/stat_fail when $TIMEZONE is invalid instead of skipping silently.
Ah, of course, that makes perfect sense. I was assuming that you tried to keep the old behavior, but this is indeed better. -t
--- rc.sysinit | 14 ++++---------- 1 files changed, 4 insertions(+), 10 deletions(-) diff --git a/rc.sysinit b/rc.sysinit index 6c1fef9..13d789f 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -257,9 +257,7 @@ stat_busy "Removing Leftover Files" [[ ! -L /var/run && ! -L /var/run/daemons ]] && rm -rf /var/run/daemons && ln -s /run/daemons /var/run/daemons - : >| /var/run/utmp - chmod 0664 /var/run/utmp - chown root:utmp /var/run/utmp + install -Tm 0664 -o root -g utmp <(:) /var/run/utmp # Keep {x,k,g}dm happy with xorg mkdir -m1777 /tmp/.{X11,ICE}-unix stat_done @@ -272,8 +270,7 @@ fi stat_busy "Setting Locale: ${LOCALE:=en_US}" # Flush old locale settings - : >| /etc/profile.d/locale.sh - chmod 755 /etc/profile.d/locale.sh + install -Tm 0755 <(:) /etc/profile.d/locale.sh # Set user defined locale echo "export LANG=$LOCALE" >>/etc/profile.d/locale.sh stat_done @@ -306,13 +303,10 @@ fi set_consolefont if [[ -e /proc/sys/kernel/dmesg_restrict && $(< /proc/sys/kernel/dmesg_restrict) -eq 1 ]]; then - : >| /var/log/dmesg.log - chmod 600 /var/log/dmesg.log + install -Tm 0600 <( dmesg ) /var/log/dmesg.log else - : >| /var/log/dmesg.log - chmod 644 /var/log/dmesg.log + install -Tm 0644 <( dmesg ) /var/log/dmesg.log fi -dmesg >| /var/log/dmesg.log run_hook sysinit_end -- 1.7.1
--- rc.sysinit | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rc.sysinit b/rc.sysinit index 13d789f..5dc3da6 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -286,7 +286,6 @@ if [[ ${LOCALE,,} =~ utf ]]; then done echo 1 > /sys/module/vt/parameters/default_utf8 stat_done - [[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" loadkeys -q -u $KEYMAP else stat_busy "Setting Consoles to legacy mode" # make non-UTF-8 consoles work on 2.6.24 and newer kernels @@ -296,8 +295,9 @@ else done echo 0 > /sys/module/vt/parameters/default_utf8 stat_done - [[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" loadkeys -q $KEYMAP fi +[[ $KEYMAP ]] && \ + status "Loading Keyboard Map: $KEYMAP" loadkeys -q $KEYMAP # Set console font if required set_consolefont -- 1.7.1
--- rc.sysinit | 13 ++++--------- 1 files changed, 4 insertions(+), 9 deletions(-) diff --git a/rc.sysinit b/rc.sysinit index 5dc3da6..2b86011 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -20,15 +20,10 @@ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" mountpoint -q /proc || mount -n -t proc proc /proc -o nosuid,noexec,nodev mountpoint -q /sys || mount -n -t sysfs sys /sys -o nosuid,noexec,nodev mountpoint -q /run || mount -n -t tmpfs run /run -o mode=755,size=10M,nosuid,nodev -if ! mountpoint -q /dev; then - if grep -q devtmpfs /proc/filesystems &>/dev/null; then - mount -n -t devtmpfs udev /dev -o mode=0755,size=10M,nosuid - else - mount -n -t tmpfs udev /dev -o mode=0755,size=10M,nosuid - fi -fi -mkdir -p /run/lock /dev/{pts,shm} -chmod 1777 /run/lock +mountpoint -q /dev || mount -n -t devtmpfs udev /dev -o mode=0755,size=10M,nosuid &>/dev/null \ + || mount -n -t tmpfs udev /dev -o mode=0755,size=10M,nosuid +mkdir -p -m 1777 /run/lock +mkdir -p /dev/{pts,shm} mountpoint -q /dev/pts || mount -n /dev/pts &> /dev/null \ || mount -n -t devpts devpts /dev/pts -o mode=620,gid=5,nosuid,noexec mountpoint -q /dev/shm || mount -n /dev/shm &> /dev/null \ -- 1.7.1
--- functions | 51 ++++++++++++++++++++++++++------------------------- rc.shutdown | 17 +++++++++-------- rc.sysinit | 39 +++++++++++++++++++-------------------- 3 files changed, 54 insertions(+), 53 deletions(-) diff --git a/functions b/functions index 3e92fb0..93d0147 100644 --- a/functions +++ b/functions @@ -17,14 +17,14 @@ calc_columns () { # is /usr/share/terminfo already mounted, and TERM recognized? STAT_COL=$(/bin/tput cols) fi - if ((STAT_COL==0)); then + if (( STAT_COL == 0 )); then # if output was 0 (serial console), set default width to 80 STAT_COL=80 USECOLOR="" fi # we use 13 characters for our own stuff - STAT_COL=$(($STAT_COL - 13)) + STAT_COL=$(( $STAT_COL - 13 )) if [[ -t 1 ]]; then SAVE_POSITION="\e[s" @@ -41,7 +41,7 @@ calc_columns # disable colors on broken terminals TERM_COLORS="$(/bin/tput colors 2>/dev/null)" -if (($? != 3)); then +if (( $? != 3 )); then case $TERM_COLORS in *[!0-9]*) USECOLOR="";; [0-7]) USECOLOR="";; @@ -57,14 +57,14 @@ unset TZ unset LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \ LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE \ LC_MEASUREMENT LC_IDENTIFICATION LC_ALL -if [[ $DAEMON_LOCALE =~ yes|YES && -n $LOCALE ]]; then +if [[ $DAEMON_LOCALE = [yY][eE][sS] && $LOCALE ]]; then export LANG="${LOCALE}" else export LANG=C fi # set colors -if [[ $USECOLOR =~ yes|YES ]]; then +if [[ $USECOLOR = [yY][eE][sS] ]]; then if /bin/tput setaf 0 &>/dev/null; then C_CLEAR="$(tput sgr0)" # clear text C_MAIN="${C_CLEAR}$(/bin/tput bold)" # main text @@ -237,17 +237,17 @@ ck_status() { # Return PID of $1 get_pid() { - pidof -o %PPID $1 || return 1 + pidof -o %PPID $1 || return 1 } # Check if PID-file $1 is still the active PID-file for command $2 ck_pidfile() { - if [[ -f "$1" ]]; then - read -r fpid <"$1" - ppid=$(get_pid $2) - [[ "$fpid" = "$ppid" ]] && return 0 - fi - return 1 + if [[ -f "$1" ]]; then + read -r fpid <"$1" + ppid=$(get_pid $2) + [[ "$fpid" = "$ppid" ]] && return 0 + fi + return 1 } # PIDs to be omitted by killall5 @@ -269,9 +269,9 @@ kill_everything() { done # Shutdown daemons in reverse order - for ((i=${#DAEMONS[@]}-1; i>=0; i--)); do - [[ ${DAEMONS[$i]:0:1} = '!' ]] && continue - ck_daemon ${DAEMONS[$i]#@} || stop_daemon ${DAEMONS[$i]#@} + for (( i=${#DAEMONS[@]}-1; i>=0; i-- )); do + [[ ${DAEMONS[i]} = '!'* ]] && continue + ck_daemon ${DAEMONS[i]#@} || stop_daemon ${DAEMONS[i]#@} done # Terminate all processes @@ -281,12 +281,12 @@ kill_everything() { for pid in ${omit_pids[@]}; do k5args+=" -o $pid" done - /sbin/killall5 -15 $k5args &> /dev/null + /sbin/killall5 -15 $k5args &>/dev/null /bin/sleep 5 stat_done stat_busy "Sending SIGKILL To Processes" - /sbin/killall5 -9 $k5args &> /dev/null + /sbin/killall5 -9 $k5args &>/dev/null /bin/sleep 1 stat_done @@ -294,7 +294,7 @@ kill_everything() { } activate_vgs() { - [[ $USELVM =~ yes|YES && -x /sbin/lvm && -d /sys/block ]] || return + [[ $USELVM = [yY][eE][sS] && -x $(type -P lvm) && -d /sys/block ]] || return # Kernel 2.6.x, LVM2 groups /sbin/modprobe -q dm-mod 2>/dev/null stat_busy "Activating LVM2 groups" @@ -320,7 +320,7 @@ read_crypttab() { # $1 = function to call with the split out line from the crypttab local line nspo failed=0 while read line; do - [[ $line && ${line:0:1} != '#' ]] || continue + [[ $line && $line != '#'* ]] || continue eval nspo=("${line%#*}") if $1 "${nspo[0]}" "${nspo[1]}" "${nspo[2]}" "${nspo[*]:3}"; then crypto_unlocked=1 @@ -343,7 +343,7 @@ fsck_all() { run_hook sysinit_prefsck fsck -A -T -C$FSCK_FD -a -t "$NETFS,noopts=_netdev" $FORCEFSCK >$FSCK_OUT 2>$FSCK_ERR local fsckret=$? - if ((fsckret > 1)); then + if (( fsckret > 1 )); then stat_fail else stat_done @@ -357,7 +357,7 @@ fsck_reboot() { # Ignore conditions 'FS errors corrected' and 'Cancelled by the user' if (( ($1 | 33) == 33 )); then return 0 - elif (($1 & 2)); then + elif (( $1 & 2 )); then echo echo "********************** REBOOT REQUIRED *********************" echo "* *" @@ -432,7 +432,7 @@ mount_all() { # Declare add_hook and run_hook as read-only to prevent overwriting them. # Too bad we cannot do the same thing with hook_funcs -if [[ $RC_FUNCTIONS_HOOK_FUNCS_DEFINED -ne 1 ]]; then +if (( RC_FUNCTIONS_HOOK_FUNCS_DEFINED != 1 )); then declare -A hook_funcs add_hook() { @@ -458,11 +458,12 @@ set_consolefont() { stat_busy "Loading Console Font: $CONSOLEFONT" #CONSOLEMAP in UTF-8 shouldn't be used [[ $CONSOLEMAP && ${LOCALE,,} =~ utf ]] && CONSOLEMAP="" + local i for i in /dev/tty[0-9]*; do /usr/bin/setfont ${CONSOLEMAP:+-m ${CONSOLEMAP}} \ - $CONSOLEFONT -C ${i} >/dev/null 2>&1 + $CONSOLEFONT -C ${i} &>/dev/null done - if (($? != 0)); then + if (( $? )); then stat_fail elif [[ $CONSOLEMAP ]]; then cat <<"EOF" >>/etc/profile.d/locale.sh @@ -481,7 +482,7 @@ done # Exit current shell if user is not root need_root() { - (( $EUID != 0 )) && printf 'You need to be root.\n' && exit 1 + (( EUID )) && printf 'You need to be root.\n' && exit 1 } # Quit script if it's not running by root diff --git a/rc.shutdown b/rc.shutdown index 4014df2..2d23554 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -32,7 +32,7 @@ if [[ -r $POOL_FILE ]]; then else POOL_SIZE=512 fi -dd if=/dev/urandom of=$RANDOM_SEED count=1 bs=$POOL_SIZE &> /dev/null +dd if=/dev/urandom of=$RANDOM_SEED count=1 bs=$POOL_SIZE &>/dev/null stat_done if [[ $TIMEZONE ]]; then @@ -48,7 +48,7 @@ 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 status "Deactivating monitoring of LVM2 groups" \ - vgchange --monitor n >/dev/null 2>&1 + vgchange --monitor n &>/dev/null fi stat_busy "Unmounting Filesystems" @@ -63,16 +63,16 @@ stat_done run_hook shutdown_postumount # Kill non-root encrypted partition mappings -if [[ -f /etc/crypttab && -n $CS ]] && grep -q ^[^#] /etc/crypttab; then +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 2>&1 + vgchange --sysinit -a n &>/dev/null fi do_lock() { stat_append "${1}.." - if $CS remove "$1" >/dev/null 2>&1; then + if $CS remove "$1" &>/dev/null; then stat_append "ok " else stat_append "failed " @@ -83,10 +83,11 @@ if [[ -f /etc/crypttab && -n $CS ]] && grep -q ^[^#] /etc/crypttab; then fi if [[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]]; then - status "Deactivating LVM2 groups" vgchange --sysinit -a n >/dev/null 2>&1 + status "Deactivating LVM2 groups" vgchange --sysinit -a n &>/dev/null fi -status "Remounting Root Filesystem Read-only" mount -n -o remount,ro / +status "Remounting Root Filesystem Read-only" \ + mount -n -o remount,ro / run_hook shutdown_poweroff @@ -98,7 +99,7 @@ if [[ $RUNLEVEL = 0 ]]; then else printhl "${C_H2}REBOOTING" # if kexec is installed and a kernel is loaded, use it - [[ -x $(type -P kexec) ]] && kexec -e > /dev/null 2>&1 + [[ -x $(type -P kexec) ]] && kexec -e &>/dev/null reboot -d -f -i fi diff --git a/rc.sysinit b/rc.sysinit index 2b86011..5167a14 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -19,14 +19,14 @@ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # mount /proc, /sys, /run, /dev, /run/lock, /dev/pts, /dev/shm (the api filesystems) mountpoint -q /proc || mount -n -t proc proc /proc -o nosuid,noexec,nodev mountpoint -q /sys || mount -n -t sysfs sys /sys -o nosuid,noexec,nodev -mountpoint -q /run || mount -n -t tmpfs run /run -o mode=755,size=10M,nosuid,nodev +mountpoint -q /run || mount -n -t tmpfs run /run -o mode=0755,size=10M,nosuid,nodev mountpoint -q /dev || mount -n -t devtmpfs udev /dev -o mode=0755,size=10M,nosuid &>/dev/null \ || mount -n -t tmpfs udev /dev -o mode=0755,size=10M,nosuid mkdir -p -m 1777 /run/lock mkdir -p /dev/{pts,shm} -mountpoint -q /dev/pts || mount -n /dev/pts &> /dev/null \ - || mount -n -t devpts devpts /dev/pts -o mode=620,gid=5,nosuid,noexec -mountpoint -q /dev/shm || mount -n /dev/shm &> /dev/null \ +mountpoint -q /dev/pts || mount -n /dev/pts &>/dev/null \ + || mount -n -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec +mountpoint -q /dev/shm || mount -n /dev/shm &>/dev/null \ || mount -n -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev # remount root ro to allow for fsck later on, we remount now to @@ -84,7 +84,6 @@ stat_done if [[ -f /proc/modules ]] && (( ${#MODULES[*]} )); then status "Loading Modules" modprobe -ab "${MODULES[@]}" fi -unset mods status "Waiting for UDev uevents to be processed" \ udevadm settle --timeout=${UDEV_TIMEOUT:-30} @@ -111,7 +110,7 @@ fi activate_vgs # Set up non-root encrypted partition mappings -if [[ -f /etc/crypttab && -n $CS ]] && grep -q ^[^#] /etc/crypttab; then +if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then modprobe -q dm-crypt 2>/dev/null stat_busy "Unlocking encrypted volumes:" do_unlock() { @@ -143,11 +142,11 @@ if [[ -f /etc/crypttab && -n $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 [[ $? -eq 2 ]]; then + if (( $? == 2 )); then _overwriteokay=1 fi fi - if [[ $_overwriteokay -eq 0 ]]; then + if (( _overwriteokay == 0 )); then false elif $CS -d /dev/urandom $4 $open "$a" "$b" >/dev/null; then stat_append "creating swapspace.." @@ -185,7 +184,7 @@ if [[ -f /etc/crypttab && -n $CS ]] && grep -q ^[^#] /etc/crypttab; then *) echo "$3" | $CS $4 $open "$a" "$b" >/dev/null;; esac - if (($? != 0)); then + if (( $? )); then failed=1 stat_append "failed " else @@ -199,7 +198,7 @@ if [[ -f /etc/crypttab && -n $CS ]] && grep -q ^[^#] /etc/crypttab; then else stat_fail fi - if [[ ${crypto_unlocked} -eq 1 ]]; then + if (( crypto_unlocked == 1 )); then # Maybe someone has LVM on an encrypted block device activate_vgs fi @@ -213,16 +212,16 @@ fi status "Remounting Root Read/Write" \ mount -n -o remount,rw / - # don't touch /etc/mtab if it is a symlink to /proc/self/mounts - if [[ -L /etc/mtab ]]; then - : - elif [[ -x $(type -P findmnt) && -e /proc/self/mountinfo ]]; then - findmnt -rnu -o SOURCE,TARGET,FSTYPE,OPTIONS >| /etc/mtab - else - cat /proc/mounts >| /etc/mtab - fi +# don't touch /etc/mtab if it is a symlink to /proc/self/mounts +if [[ -L /etc/mtab ]]; then + : +elif [[ -x $(type -P findmnt) && -e /proc/self/mountinfo ]]; then + findmnt -rnu -o SOURCE,TARGET,FSTYPE,OPTIONS >| /etc/mtab +else + cat /proc/mounts >| /etc/mtab +fi - # now mount all the local filesystems +# now mount all the local filesystems mount_all # enable monitoring of lvm2 groups, now that the filesystems are mounted rw @@ -254,7 +253,7 @@ stat_busy "Removing Leftover Files" ln -s /run/daemons /var/run/daemons install -Tm 0664 -o root -g utmp <(:) /var/run/utmp # Keep {x,k,g}dm happy with xorg - mkdir -m1777 /tmp/.{X11,ICE}-unix + mkdir -m 1777 /tmp/.{X11,ICE}-unix stat_done if [[ $HOSTNAME ]]; then -- 1.7.1
--- rc.single | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-) diff --git a/rc.single b/rc.single index bb27ddf..dc9687e 100755 --- a/rc.single +++ b/rc.single @@ -12,22 +12,20 @@ run_hook single_start if [[ $PREVLEVEL != N ]]; then kill_everything single + status "Starting UDev Daemon" udevd --daemon + run_hook single_udevlaunched # Trigger udev uevents - if pidof -o %PPID /udevd >/dev/null; then - stat_busy "Triggering UDev uevents" + stat_busy "Triggering UDev uevents" udevadm trigger --action=add --type=subsystems udevadm trigger --action=add --type=devices - stat_done - fi + stat_done # Wait for udev uevents - if pidof -o %PPID udevd >/dev/null; then - status "Waiting for UDev uevents to be processed" \ - udevadm settle --quiet --timeout=${UDEV_TIMEOUT:-30} - fi + status "Waiting for UDev uevents to be processed" \ + udevadm settle --quiet --timeout=${UDEV_TIMEOUT:-30} run_hook single_udevsettled -- 1.7.1
This also keeps all tmpfs allways. Some might be in still in use because of a running splash daemon etc. --- rc.shutdown | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-) diff --git a/rc.shutdown b/rc.shutdown index 2d23554..39adaad 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -52,12 +52,8 @@ if [[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]]; then fi stat_busy "Unmounting Filesystems" -if grep -q devtmpfs /proc/filesystems &>/dev/null; then - umount -a -r -t nosysfs,noproc,nodevtmpfs,nodevpts -O no_netdev -else # if we don't have devtmpfs support, /dev is mounted as tmpfs, so don't unmount it - umount -a -r -t notmpfs,nosysfs,noproc,nodevpts -O no_netdev -fi + umount -a -r -t nodevtmpfs,notmpfs,nosysfs,noproc,nodevpts -O no_netdev stat_done run_hook shutdown_postumount -- 1.7.1
On Fri, Jun 24, 2011 at 11:14 AM, Kurt J. Bosch <kjb-temp-2009@alpenjodel.de> wrote:
This also keeps all tmpfs allways. Some might be in still in use because of a running splash daemon etc. --- rc.shutdown | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/rc.shutdown b/rc.shutdown index 2d23554..39adaad 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -52,12 +52,8 @@ if [[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]]; then fi
stat_busy "Unmounting Filesystems" -if grep -q devtmpfs /proc/filesystems &>/dev/null; then - umount -a -r -t nosysfs,noproc,nodevtmpfs,nodevpts -O no_netdev -else # if we don't have devtmpfs support, /dev is mounted as tmpfs, so don't unmount it - umount -a -r -t notmpfs,nosysfs,noproc,nodevpts -O no_netdev -fi + umount -a -r -t nodevtmpfs,notmpfs,nosysfs,noproc,nodevpts -O no_netdev stat_done
run_hook shutdown_postumount --
In principle I agree (especially due to /run), but the reason we had this code was that in case someone has a tmpfs mounted on top of a blockdevice. This means that we need to unmount that tmpfs before we can unmount the blockdevice. Maybe what we need is the inverse of what is done at the beginning of rc.sysinit. I.e., unmount all filesystems, regardless of type, except the ones we explicitly mounted at early boot. What do you think? -t
Tom Gundersen, 2011-06-24 11:44:
This also keeps all tmpfs allways. Some might be in still in use because of a running splash daemon etc. --- rc.shutdown | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/rc.shutdown b/rc.shutdown index 2d23554..39adaad 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -52,12 +52,8 @@ if [[ $USELVM = [Yy][Ee][Ss]&& -x $(type -P lvm)&& -d /sys/block ]]; then fi
stat_busy "Unmounting Filesystems" -if grep -q devtmpfs /proc/filesystems&>/dev/null; then - umount -a -r -t nosysfs,noproc,nodevtmpfs,nodevpts -O no_netdev -else # if we don't have devtmpfs support, /dev is mounted as tmpfs, so don't unmount it - umount -a -r -t notmpfs,nosysfs,noproc,nodevpts -O no_netdev -fi + umount -a -r -t nodevtmpfs,notmpfs,nosysfs,noproc,nodevpts -O no_netdev stat_done
run_hook shutdown_postumount -- In principle I agree (especially due to /run), but the reason we had
On Fri, Jun 24, 2011 at 11:14 AM, Kurt J. Bosch <kjb-temp-2009@alpenjodel.de> wrote: this code was that in case someone has a tmpfs mounted on top of a blockdevice. This means that we need to unmount that tmpfs before we can unmount the blockdevice.
Maybe what we need is the inverse of what is done at the beginning of rc.sysinit. I.e., unmount all filesystems, regardless of type, except the ones we explicitly mounted at early boot.
What do you think? Disks will be remounted read-only if unmount failes. I guess that should be save enough as it happens to the root-FS anyways because /dev isn't unmounted. -- Kurt
--- rc.single | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-) diff --git a/rc.single b/rc.single index dc9687e..1a95ee9 100755 --- a/rc.single +++ b/rc.single @@ -29,13 +29,8 @@ if [[ $PREVLEVEL != N ]]; then run_hook single_udevsettled - # try syslog-NG first, then fall back to good ol' syslogd - if [[ -x /etc/rc.d/syslog-ng ]]; then - /etc/rc.d/syslog-ng start - elif [[ -x /etc/rc.d/syslogd ]]; then - /etc/rc.d/syslogd start - [[ -x /etc/rc.d/klogd ]] && /etc/rc.d/klogd start - fi + # start up our mini logger until syslog takes over + minilogd fi run_hook single_end -- 1.7.1
--- rc.single | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rc.single b/rc.single index 1a95ee9..74368fd 100755 --- a/rc.single +++ b/rc.single @@ -35,14 +35,6 @@ fi run_hook single_end -if [[ $RUNLEVEL = 1 ]]; then - printsep - printhl "Entering single-user mode..." - # make sure /dev/initctl is in place - kill -HUP 1 - exec init -t1 S -fi - if [[ -f /run/bootlogd.pid ]]; then touch /var/log/boot kill $(< /run/bootlogd.pid) @@ -51,5 +43,13 @@ if [[ -f /run/bootlogd.pid ]]; then -e 's/\^\[(\[151|%)G//g' /var/log/boot fi +if [[ $RUNLEVEL = 1 ]]; then + printsep + printhl "Entering single-user mode..." + # make sure /dev/initctl is in place + kill -HUP 1 + exec init -t1 S +fi + # End of file # vim: set ts=2 sw=2 noet: -- 1.7.1
--- rc.shutdown | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/rc.shutdown b/rc.shutdown index 39adaad..b0b97d6 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -23,9 +23,7 @@ kill_everything shutdown stat_busy "Saving Random Seed" RANDOM_SEED=/var/lib/misc/random-seed -[[ -d ${RANDOM_SEED%/*} ]] || mkdir -p ${RANDOM_SEED%/*} -: > $RANDOM_SEED -chmod 0600 $RANDOM_SEED +install -TDm 0600 <(:) $RANDOM_SEED POOL_FILE=/proc/sys/kernel/random/poolsize if [[ -r $POOL_FILE ]]; then read POOL_SIZE <$POOL_FILE -- 1.7.1
--- functions | 4 ++-- rc.shutdown | 2 +- rc.sysinit | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/functions b/functions index 93d0147..06828c3 100644 --- a/functions +++ b/functions @@ -24,7 +24,7 @@ calc_columns () { fi # we use 13 characters for our own stuff - STAT_COL=$(( $STAT_COL - 13 )) + STAT_COL=$(( STAT_COL - 13 )) if [[ -t 1 ]]; then SAVE_POSITION="\e[s" @@ -146,7 +146,7 @@ stat_die() { status() { stat_busy "$1" shift - if "$@" >/dev/null 2>&1; then + if "$@" &>/dev/null; then stat_done return 0 fi diff --git a/rc.shutdown b/rc.shutdown index b0b97d6..473953f 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -26,7 +26,7 @@ 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 + read POOL_SIZE < $POOL_FILE else POOL_SIZE=512 fi diff --git a/rc.sysinit b/rc.sysinit index 5167a14..52d9d4b 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -244,8 +244,7 @@ if [[ -f $RANDOM_SEED ]]; then fi stat_busy "Removing Leftover Files" - rm -rf /etc/{nologin,shutdownpid} /forcefsck &>/dev/null - rm -rf /tmp/* /tmp/.* &>/dev/null + rm -rf /etc/{nologin,shutdownpid} /forcefsck /tmp/* /tmp/.* [[ ! -L /var/lock ]] && rm -rf /var/lock/* [[ ! -L /var/run && -d /var/run ]] && find /var/run/ \! -type d -delete [[ ! -L /var/run && ! -L /var/run/daemons ]] && @@ -258,7 +257,7 @@ stat_done if [[ $HOSTNAME ]]; then stat_busy "Setting Hostname: $HOSTNAME" - echo $HOSTNAME > /proc/sys/kernel/hostname + echo "$HOSTNAME" > /proc/sys/kernel/hostname stat_done fi @@ -296,7 +295,8 @@ fi # Set console font if required set_consolefont -if [[ -e /proc/sys/kernel/dmesg_restrict && $(< /proc/sys/kernel/dmesg_restrict) -eq 1 ]]; then +if [[ -e /proc/sys/kernel/dmesg_restrict ]] && + (( $(< /proc/sys/kernel/dmesg_restrict) == 1 )); then install -Tm 0600 <( dmesg ) /var/log/dmesg.log else install -Tm 0644 <( dmesg ) /var/log/dmesg.log -- 1.7.1
--- functions | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/functions b/functions index 06828c3..aafc686 100644 --- a/functions +++ b/functions @@ -157,12 +157,10 @@ status() { # usage : in_array( $needle, $haystack ) # return : 0 - found # 1 - not found -# Copied from makepkg in_array() { - [[ $2 ]] || return 1 local needle=$1; shift local item - for item in "$@"; do + for item; do [[ ${item#@} = $needle ]] && return 0 done return 1 # Not Found -- 1.7.1
On Fri, Jun 24, 2011 at 11:14 AM, Kurt J. Bosch <kjb-temp-2009@alpenjodel.de> wrote:
Kurt J. Bosch (13): Fix hwclock comments Simplify timezone copying Simplify creating files by using /bin/install Simplify keyboard map loading by using loadkeys autodetection Simplify API filesystems mounting Some cosmetics Simplify rc.single udevadm stuff as in rc.sysinit Simplify unmounting filesystems rc.single: Avoid rc.multi syslog start error - use minilogd as in rc.sysinit Fix bootlogd not stopped when booting into runlevel '1' Simplify random seed file creation Some more cosmetics Simplify in_array function
functions | 57 +++++++++++++++++++-------------------- rc.conf | 2 +- rc.shutdown | 34 +++++++++------------- rc.single | 39 +++++++++++---------------- rc.sysinit | 86 ++++++++++++++++++++++++---------------------------------- 5 files changed, 95 insertions(+), 123 deletions(-)
Thanks for your work! In general looks very nice (especially when you delete more than you add!). In addition to the comment I made about unmounting tmpfs, I just have to have an extra look a the cosmetics changes to check what non-whitespace changes are there, and I have to try out the TIMEZONE copy stuff. Do you have a public git repo I could pull from to make my life simpler? Cheers, Tom
Tom Gundersen, 2011-06-24 11:50:
On Fri, Jun 24, 2011 at 11:14 AM, Kurt J. Bosch <kjb-temp-2009@alpenjodel.de> wrote:
Kurt J. Bosch (13): Fix hwclock comments Simplify timezone copying Simplify creating files by using /bin/install Simplify keyboard map loading by using loadkeys autodetection Simplify API filesystems mounting Some cosmetics Simplify rc.single udevadm stuff as in rc.sysinit Simplify unmounting filesystems rc.single: Avoid rc.multi syslog start error - use minilogd as in rc.sysinit Fix bootlogd not stopped when booting into runlevel '1' Simplify random seed file creation Some more cosmetics Simplify in_array function
functions | 57 +++++++++++++++++++-------------------- rc.conf | 2 +- rc.shutdown | 34 +++++++++------------- rc.single | 39 +++++++++++---------------- rc.sysinit | 86 ++++++++++++++++++++++++---------------------------------- 5 files changed, 95 insertions(+), 123 deletions(-) Thanks for your work! In general looks very nice (especially when you delete more than you add!).
In addition to the comment I made about unmounting tmpfs, I just have to have an extra look a the cosmetics changes to check what non-whitespace changes are there, and I have to try out the TIMEZONE copy stuff.
Do you have a public git repo I could pull from to make my life simpler? Sorry, no. Guess I would need to learn more about git first. -- Kurt
On Fri, Jun 24, 2011 at 12:05:47PM +0200, Kurt J. Bosch wrote:
Tom Gundersen, 2011-06-24 11:50:
On Fri, Jun 24, 2011 at 11:14 AM, Kurt J. Bosch <kjb-temp-2009@alpenjodel.de> wrote:
Kurt J. Bosch (13): Fix hwclock comments Simplify timezone copying Simplify creating files by using /bin/install Simplify keyboard map loading by using loadkeys autodetection Simplify API filesystems mounting Some cosmetics Simplify rc.single udevadm stuff as in rc.sysinit Simplify unmounting filesystems rc.single: Avoid rc.multi syslog start error - use minilogd as in rc.sysinit Fix bootlogd not stopped when booting into runlevel '1' Simplify random seed file creation Some more cosmetics Simplify in_array function
functions | 57 +++++++++++++++++++-------------------- rc.conf | 2 +- rc.shutdown | 34 +++++++++------------- rc.single | 39 +++++++++++---------------- rc.sysinit | 86 ++++++++++++++++++++++++---------------------------------- 5 files changed, 95 insertions(+), 123 deletions(-) Thanks for your work! In general looks very nice (especially when you delete more than you add!).
In addition to the comment I made about unmounting tmpfs, I just have to have an extra look a the cosmetics changes to check what non-whitespace changes are there, and I have to try out the TIMEZONE copy stuff.
Do you have a public git repo I could pull from to make my life simpler? Sorry, no. Guess I would need to learn more about git first. -- Kurt
This might help you, all the 13 patches in one tarball. -- -- Kwpolska (http://kwpolska.co.cc) stop html mail | always bottom-post www.asciiribbon.org | www.netmeister.org/news/learn2quote.html GPG KEY: 5EAAEA16 | Arch Linux x86_64, zsh, mutt, vim. # vim:set textwidth=70:
Kwpolska, 2011-06-24 12:19:
On Fri, Jun 24, 2011 at 12:05:47PM +0200, Kurt J. Bosch wrote:
Tom Gundersen, 2011-06-24 11:50:
On Fri, Jun 24, 2011 at 11:14 AM, Kurt J. Bosch <kjb-temp-2009@alpenjodel.de> wrote:
Kurt J. Bosch (13): Fix hwclock comments Simplify timezone copying Simplify creating files by using /bin/install Simplify keyboard map loading by using loadkeys autodetection Simplify API filesystems mounting Some cosmetics Simplify rc.single udevadm stuff as in rc.sysinit Simplify unmounting filesystems rc.single: Avoid rc.multi syslog start error - use minilogd as in rc.sysinit Fix bootlogd not stopped when booting into runlevel '1' Simplify random seed file creation Some more cosmetics Simplify in_array function
functions | 57 +++++++++++++++++++-------------------- rc.conf | 2 +- rc.shutdown | 34 +++++++++------------- rc.single | 39 +++++++++++---------------- rc.sysinit | 86 ++++++++++++++++++++++++---------------------------------- 5 files changed, 95 insertions(+), 123 deletions(-) Thanks for your work! In general looks very nice (especially when you delete more than you add!).
In addition to the comment I made about unmounting tmpfs, I just have to have an extra look a the cosmetics changes to check what non-whitespace changes are there, and I have to try out the TIMEZONE copy stuff.
Do you have a public git repo I could pull from to make my life simpler? Sorry, no. Guess I would need to learn more about git first. -- Kurt
This might help you, all the 13 patches in one tarball. For now a TGZ with git formatted patches attached. This should even work well with command: git am <dir>/*
-- Kurt
participants (3)
-
Kurt J. Bosch
-
Kwpolska
-
Tom Gundersen