From 8857be7c19ce9dd298dd36a35b7801723e235c0d Mon Sep 17 00:00:00 2001 From: Mike Staszel Date: Fri, 17 Jun 2011 23:44:09 -0500 Subject: [PATCH] Up-to-date initscripts 2011.06 --- core/initscripts/Makefile | 8 +- core/initscripts/PKGBUILD | 20 +++-- core/initscripts/bash-completion | 22 +++++ core/initscripts/functions | 69 ++++++++++----- core/initscripts/initscripts.install | 4 + core/initscripts/inittab | 18 ++-- core/initscripts/inittab.armv7 | 18 ++-- core/initscripts/network | 123 ++++++++++++++++++-------- core/initscripts/rc.conf | 55 ++++++------ core/initscripts/rc.d | 20 +++-- core/initscripts/rc.sysinit | 125 +++++++++++++-------------- 11 files changed, 295 insertions(+), 187 deletions(-) create mode 100644 core/initscripts/bash-completion mode change 100644 => 100755 core/initscripts/initscripts.install diff --git a/core/initscripts/Makefile b/core/initscripts/Makefile index 692384047..fcabb0efb 100644 --- a/core/initscripts/Makefile +++ b/core/initscripts/Makefile @@ -1,5 +1,5 @@ VER := $(shell git describe) -DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin +DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /etc/bash_completion.d /usr/share/zsh/site-functions minilogd: minilogd.o @@ -8,11 +8,13 @@ installdirs: install: minilogd installdirs install -m644 -t $(DESTDIR)/etc inittab rc.conf - install -m644 -t $(DESTDIR)/etc/rc.d functions install -m755 -t $(DESTDIR)/etc rc.local rc.local.shutdown rc.multi rc.shutdown rc.single rc.sysinit install -m755 -t $(DESTDIR)/etc/cron.hourly adjtime - install -m755 -t $(DESTDIR)/etc/rc.d functions hwclock network netfs + install -m644 -t $(DESTDIR)/etc/rc.d functions + install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs install -m755 -t $(DESTDIR)/sbin minilogd rc.d + install -m644 -T bash-completion $(DESTDIR)/etc/bash_completion.d/rc.d + install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d clean: rm -f minilogd minilogd.o diff --git a/core/initscripts/PKGBUILD b/core/initscripts/PKGBUILD index 7bf5a7172..89d398359 100644 --- a/core/initscripts/PKGBUILD +++ b/core/initscripts/PKGBUILD @@ -7,7 +7,7 @@ # rc.sysinit has our copyright info pkgname=initscripts -pkgver=2011.05.2 +pkgver=2011.06.4 pkgrel=1 pkgdesc="System initialization/bootup scripts" plugrel=1 @@ -23,6 +23,7 @@ optdepends=('bridge-utils: Network bridging support' 'wireless_tools: Wireless networking') install=initscripts.install source=(adjtime + bash-completion functions hwclock inittab @@ -41,22 +42,23 @@ source=(adjtime rc.sysinit wireless.conf.d) md5sums=('f976a1c61c2fb9bd2c30e3fdd0d62b61' - '1aad77c872e7d3b3f9f4c3ba79b515c3' + 'bb2506a443dd1efe1963aa731be2b7a9' + '3a387fbc7567bb053c9964765a7ea747' '16fa1f14f10fc8c1daf04f4b5edb9cab' - 'ac7be5551669fc867e330440e0151067' - 'c6ceb8c7d4820a37b8bf0c827a6916ec' - '366e82ff2faeee4bd72a0b578963235d' + 'f02566fd9a1eeac3aadd5d6af32453c5' + '6260da9309cdcfd68444867dc91d574a' + 'da476ea7e29f23611cc1374a2a4cee8e' '2c2dcc7ce7586f27fc5e6887f8ec74b8' '565f1f24c5dc765831a58622f65844af' - 'b2469f09d0ae5143b91c182b1d802194' - '0559c8a54a1a2720c53f8974143f246d' - '66f90c041410bcf72b5c2747677d7780' + 'f56d3a9eb7c0406b47dfb5fbab4d3cf3' + 'e75db8f5b8852f2a066a3ccf2325f7d5' + 'dc8510d0be00b8c6640be59bfe7d6d27' 'bd236a57bc00aa4727b98c5ae401c457' '669ce6d766dd9deb86686219f3763fe4' '986ca9250756b12f0cb5f517ccb8bc47' 'bdec56c7d6964875c3b3ecaf3bbe58dd' '6d77bdeeb65958171881fe15589d8c6a' - 'bac8777077243c0cfefa093621370071' + 'e3dc54a8c8518c79dbffbf687655bb81' '027576534885b8d5dded9be546057b12') package() { diff --git a/core/initscripts/bash-completion b/core/initscripts/bash-completion new file mode 100644 index 000000000..51519727c --- /dev/null +++ b/core/initscripts/bash-completion @@ -0,0 +1,22 @@ +# rc.d bash completion by Seblu + +_rc.d () +{ + local action="help list start stop reload restart" + local cur="${COMP_WORDS[COMP_CWORD]}" + local caction="${COMP_WORDS[1]}" + if ((${COMP_CWORD} == 1)); then + COMPREPLY=($(compgen -W "${action}" -- "$cur")) + elif [[ "$caction" =~ help|list ]]; then + COMPREPLY=() + elif [[ "$caction" == start ]]; then + COMPREPLY=($(comm -23 <(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort) <(cd /run/daemons/ && compgen -f "$cur"|sort))) + elif [[ "$caction" =~ stop|restart|reload ]]; then + COMPREPLY=($(cd /run/daemons/ && compgen -f "$cur"|sort)) + elif ((${COMP_CWORD} > 1)); then + COMPREPLY=($(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort)) + fi +} +complete -F _rc.d rc.d + +# vim: set ts=2 sw=2 ft=sh noet: diff --git a/core/initscripts/functions b/core/initscripts/functions index fd0928e60..c6de434d3 100644 --- a/core/initscripts/functions +++ b/core/initscripts/functions @@ -49,32 +49,41 @@ else export LANG=C fi -# colors: -if [[ $USECOLOR = YES || $USECOLOR = yes ]]; then - C_MAIN="\033[1;37;40m" # main text - - C_OTHER="\033[1;34;40m" # prefix & brackets - C_SEPARATOR="\033[1;30;40m" # separator - - C_BUSY="\033[0;36;40m" # busy - C_FAIL="\033[1;31;40m" # failed - C_DONE="\033[1;37;40m" # completed - C_BKGD="\033[1;35;40m" # backgrounded - - C_H1="\033[1;37;40m" # highlight text 1 - C_H2="\033[1;36;40m" # highlight text 2 - - C_CLEAR="\033[1;0m" +# set colors +if [[ $USECOLOR =~ yes|YES ]]; then + if /bin/tput setaf 0 &>/dev/null; then + C_CLEAR="$(tput sgr0)" # clear text + C_MAIN="${C_CLEAR}$(/bin/tput bold)" # main text + C_OTHER="${C_MAIN}$(/bin/tput setaf 4)" # prefix & brackets + C_SEPARATOR="${C_MAIN}$(/bin/tput setaf 0)" # separator + C_BUSY="${C_CLEAR}$(/bin/tput setaf 6)" # busy + C_FAIL="${C_MAIN}$(/bin/tput setaf 1)" # failed + C_DONE="${C_MAIN}" # completed + C_BKGD="${C_MAIN}$(/bin/tput setaf 5)" # backgrounded + C_H1="${C_MAIN}" # highlight text 1 + C_H2="${C_MAIN}$(/bin/tput setaf 6)" # highlight text 2 + else + C_CLEAR="\e[m" # clear text + C_MAIN="\e[;1m" # main text + C_OTHER="\e[1;34m" # prefix & brackets + C_SEPARATOR="\e[1;30m" # separator + C_BUSY="\e[;36m" # busy + C_FAIL="\e[1;31m" # failed + C_DONE="${C_MAIN}" # completed + C_BKGD="\e[1;35m" # backgrounded + C_H1="${C_MAIN}" # highlight text 1 + C_H2="\e[1;36m" # highlight text 2 + fi fi if [[ -t 1 ]]; then - SAVE_POSITION="\033[s" - RESTORE_POSITION="\033[u" - DEL_TEXT="\033[$(($STAT_COL+4))G" + SAVE_POSITION="\e[s" + RESTORE_POSITION="\e[u" + DEL_TEXT="\e[$(($STAT_COL+4))G" else - SAVE_POSITION="" - RESTORE_POSITION="" - DEL_TEXT="" + SAVE_POSITION="" + RESTORE_POSITION="" + DEL_TEXT="" fi # prefixes: @@ -222,6 +231,14 @@ ck_status() { fi } +# PIDs to be omitted by killall5 +declare -a omit_pids + +add_omit_pids() { + omit_pids+=( $@ ) +} + + kill_everything() { # $1 = where we are being called from. # This is used to determine which hooks to run. @@ -241,12 +258,16 @@ kill_everything() { # Terminate all processes stat_busy "Sending SIGTERM To Processes" run_hook "$1_prekillall" - /sbin/killall5 -15 &> /dev/null + local pid k5args="" + for pid in ${omit_pids[@]}; do + k5args+=" -o $pid" + done + /sbin/killall5 -15 $k5args &> /dev/null /bin/sleep 5 stat_done stat_busy "Sending SIGKILL To Processes" - /sbin/killall5 -9 &> /dev/null + /sbin/killall5 -9 $k5args &> /dev/null /bin/sleep 1 stat_done diff --git a/core/initscripts/initscripts.install b/core/initscripts/initscripts.install old mode 100644 new mode 100755 index 360101c10..56f69248a --- a/core/initscripts/initscripts.install +++ b/core/initscripts/initscripts.install @@ -4,4 +4,8 @@ post_upgrade() { echo "==> Original file saved as /etc/inittab.pacsave" sed -i'.pacsave' 's#vc/\([0-9]\)#tty\1#' /etc/inittab fi + if [ "$(vercmp $2 2011.06.1)" -lt 0 ]; then + echo "Blacklisting of modules is no longer supported in rc.conf," + echo "please add blacklist entries to /etc/modprobe.d/ instead." + fi } diff --git a/core/initscripts/inittab b/core/initscripts/inittab index 3d6cffa6e..5bf064fdb 100644 --- a/core/initscripts/inittab +++ b/core/initscripts/inittab @@ -24,19 +24,19 @@ rh:06:wait:/etc/rc.shutdown su:S:wait:/sbin/sulogin -p # -8 options fixes umlauts problem on login -s0:12345:respawn:/sbin/agetty -8 115200 ttyS0 linux -c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux -c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux -#c3:2345:respawn:/sbin/agetty -8 38400 tty3 linux -#c4:2345:respawn:/sbin/agetty -8 38400 tty4 linux -#c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux -#c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux +s0:12345:respawn:/sbin/agetty -8 -s 115200 ttyS0 linux +c1:2345:respawn:/sbin/agetty -8 -s 38400 tty1 linux +c2:2345:respawn:/sbin/agetty -8 -s 38400 tty2 linux +#c3:2345:respawn:/sbin/agetty -8 -s 38400 tty3 linux +#c4:2345:respawn:/sbin/agetty -8 -s 38400 tty4 linux +#c5:2345:respawn:/sbin/agetty -8 -s 38400 tty5 linux +#c6:2345:respawn:/sbin/agetty -8 -s 38400 tty6 linux # Serial Virtual Console for KVM and others VMs -#s0:2345:respawn:/sbin/agetty -8 9600 ttyS0 linux +#s0:2345:respawn:/sbin/agetty -8 -s 9600 ttyS0 linux # Hypervisor Virtual Console for Xen and KVM -#h0:2345:respawn:/sbin/agetty -8 38400 hvc0 linux +#h0:2345:respawn:/sbin/agetty -8 -s 38400 hvc0 linux ca::ctrlaltdel:/sbin/shutdown -t3 -r now diff --git a/core/initscripts/inittab.armv7 b/core/initscripts/inittab.armv7 index 69e2ab31c..74087a758 100644 --- a/core/initscripts/inittab.armv7 +++ b/core/initscripts/inittab.armv7 @@ -24,19 +24,19 @@ rh:06:wait:/etc/rc.shutdown su:S:wait:/sbin/sulogin -p # -8 options fixes umlauts problem on login -s0:12345:respawn:/sbin/agetty -8 115200 ttyS0 linux -c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux -c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux -c3:2345:respawn:/sbin/agetty -8 38400 tty3 linux -c4:2345:respawn:/sbin/agetty -8 38400 tty4 linux -c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux -c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux +s0:12345:respawn:/sbin/agetty -8 -s 115200 ttyS0 linux +c1:2345:respawn:/sbin/agetty -8 -s 38400 tty1 linux +c2:2345:respawn:/sbin/agetty -8 -s 38400 tty2 linux +c3:2345:respawn:/sbin/agetty -8 -s 38400 tty3 linux +c4:2345:respawn:/sbin/agetty -8 -s 38400 tty4 linux +c5:2345:respawn:/sbin/agetty -8 -s 38400 tty5 linux +c6:2345:respawn:/sbin/agetty -8 -s 38400 tty6 linux # Serial Virtual Console for KVM and others VMs -#s0:2345:respawn:/sbin/agetty -8 9600 ttyS0 linux +#s0:2345:respawn:/sbin/agetty -8 -s 9600 ttyS0 linux # Hypervisor Virtual Console for Xen and KVM -#h0:2345:respawn:/sbin/agetty -8 38400 hvc0 linux +#h0:2345:respawn:/sbin/agetty -8 -s 38400 hvc0 linux ca::ctrlaltdel:/sbin/shutdown -t3 -r now diff --git a/core/initscripts/network b/core/initscripts/network index 5a261b450..735014978 100755 --- a/core/initscripts/network +++ b/core/initscripts/network @@ -7,6 +7,49 @@ for s in wireless bonding bridges dhcpcd; do [[ -f /etc/conf.d/$s ]] && . "/etc/conf.d/$s" done +# helper function to determine if legacy network support is needed +need_legacy() { + if [[ -z $interface ]]; then + return 0 # need legacy + fi + + return 1 # enough present for iproute2 support +} + +deprecated() { + printf "${C_FAIL}Warning:${C_CLEAR} This functionality is deprecated.\n" + printf " Please refer to /etc/rc.conf on how to define a single wired\n" + printf " connection, or use a utility such as netcfg.\n" +} + +network_up() { + /usr/sbin/ip link set dev $interface up || return 1 + + if [[ $address ]]; then + for var in netmask gateway; do + if [[ -z ${!var} ]]; then + printf "${C_FAIL}Error: static address defined without $var!\n" + return 1 + fi + done + /usr/sbin/ip addr add $address/$netmask dev $interface || return 1 + /usr/sbin/ip route add default via $gateway || return 1 + else + /sbin/dhcpcd $DHCPCD_ARGS $interface || return 1 + fi +} + +network_down() { + if [[ -f /var/run/dhcpcd-$interface.pid ]]; then + /sbin/dhcpcd -k $interface || return 1 + else + /usr/sbin/ip route del default || return 1 + /usr/sbin/ip addr flush dev $interface || return 1 + fi + + /usr/sbin/ip link set dev $interface down || return 1 +} + ifup() { local ifcfg=${!1} @@ -179,29 +222,34 @@ bridge_down() { case "$1" in start) + # deprecation check + need_legacy && deprecated if ! ck_daemon network; then echo "Network is already running. Try 'network restart'" exit fi - stat_busy "Starting Network" error=0 - # bring up bridge interfaces - bridge_up - # bring up ethernet interfaces - for ifline in ${INTERFACES[@]}; do - if [[ $ifline = ${ifline#!} ]]; then - ifup $ifline || error=1 - fi - done - # bring up bond interfaces - bond_up - # bring up routes - for rtline in "${ROUTES[@]}"; do - if [ "$rtline" = "${rtline#!}" ]; then - rtup $rtline || error=1 - fi - done + if need_legacy; then + # bring up bridge interfaces + bridge_up + # bring up ethernet interfaces + for ifline in ${INTERFACES[@]}; do + if [[ $ifline = ${ifline#!} ]]; then + ifup $ifline || error=1 + fi + done + # bring up bond interfaces + bond_up + # bring up routes + for rtline in "${ROUTES[@]}"; do + if [ "$rtline" = "${rtline#!}" ]; then + rtup $rtline || error=1 + fi + done + else + network_up + fi if ((error == 0)); then add_daemon network stat_done @@ -210,11 +258,8 @@ case "$1" in fi ;; stop) - #if ck_daemon network; then - # echo "Network is not running. Try 'network start'" - # exit - #fi - + # deprecation check + need_legacy && deprecated if [[ $NETWORK_PERSIST =~ yes|YES && $RUNLEVEL == [06] ]]; then status "Skipping Network Shutdown" true exit 0 @@ -223,20 +268,24 @@ case "$1" in stat_busy "Stopping Network" rm_daemon network error=0 - for rtline in "${ROUTES[@]}"; do - if [[ $rtline = ${rtline#!} ]]; then - rtdown $rtline || error=1 - fi - done - # bring down bond interfaces - bond_down - for ifline in ${INTERFACES[@]}; do - if [[ $ifline = ${ifline#!} ]]; then - ifdown $ifline || error=1 - fi - done - # bring down bridge interfaces - bridge_down + if need_legacy; then + for rtline in "${ROUTES[@]}"; do + if [[ $rtline = ${rtline#!} ]]; then + rtdown $rtline || error=1 + fi + done + # bring down bond interfaces + bond_down + for ifline in ${INTERFACES[@]}; do + if [[ $ifline = ${ifline#!} ]]; then + ifdown $ifline || error=1 + fi + done + # bring down bridge interfaces + bridge_down + else + network_down + fi if ((error == 0)); then stat_done else @@ -249,6 +298,8 @@ case "$1" in $0 start ;; ifup|ifdown|iflist|rtup|rtdown|rtlist) + # deprecation check + need_legacy && deprecated $1 $2 ;; *) diff --git a/core/initscripts/rc.conf b/core/initscripts/rc.conf index 9309ab9ed..2e5573303 100644 --- a/core/initscripts/rc.conf +++ b/core/initscripts/rc.conf @@ -33,10 +33,12 @@ VERBOSE="3" # HARDWARE # ----------------------------------------------------------------------- # -# MOD_AUTOLOAD: Allow autoloading of modules at boot and when needed -# MODULES: Modules to load at boot-up. Prefix with a ! to blacklist. +# MODULES: Modules to load at boot-up. Blacklisting is no longer supported. +# Replace every !module by an entry as on the following line in a file in +# /etc/modprobe.d: +# blacklist module +# See "man modprobe.conf" for details. # -MOD_AUTOLOAD="yes" MODULES=() # Udev settle timeout (default to 30) @@ -59,41 +61,44 @@ USELVM="no" # HOSTNAME="alarm" -# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces. +# Use 'ip addr' or 'ls /sys/class/net/' to see all available interfaces. # -# Interfaces to start at boot-up (in this order) -# Declare each interface then list in INTERFACES -# - prefix an entry in INTERFACES with a ! to disable it -# - no hyphens in your interface names - Bash doesn't like it -# -# DHCP: Set your interface to "dhcp" (eth0="dhcp") -# Wireless: See network profiles below +# Wired network setup +# - interface: name of device (required) +# - address: IP address (leave blank for DHCP) +# - netmask: subnet mask (ignored for DHCP) +# - gateway: default route (ignored for DHCP) # +# Static IP example +# interface=eth0 +# address=192.168.0.2 +# netmask=255.255.255.0 +# gateway=192.168.0.1 +# +# DHCP example +# interface=eth0 +# address= +# netmask= +# gateway= -#Static IP example -#eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255" -eth0="dhcp" -INTERFACES=(eth0) - -# Routes to start at boot-up (in this order) -# Declare each route then list in ROUTES -# - prefix an entry in ROUTES with a ! to disable it -# -gateway="default gw 192.168.0.1" -ROUTES=(!gateway) +interface= +address= +netmask= +gateway= # Setting this to "yes" will skip network shutdown. # This is required if your root device is on NFS. NETWORK_PERSIST="no" -# Enable these network profiles at boot-up. These are only useful -# if you happen to need multiple network configurations (ie, laptop users) +# Enable these netcfg profiles at boot-up. These are useful if you happen to +# need more advanced network features than the simple network service +# supports, such as multiple network configurations (ie, laptop users) # - set to 'menu' to present a menu during boot-up (dialog package required) # - prefix an entry with a ! to disable it # # Network profiles are found in /etc/network.d # -# This now requires the netcfg package +# This requires the netcfg package # #NETWORKS=(main) diff --git a/core/initscripts/rc.d b/core/initscripts/rc.d index 02c2b6cfb..772f2c63d 100755 --- a/core/initscripts/rc.d +++ b/core/initscripts/rc.d @@ -42,20 +42,28 @@ case $1 in done ;; *) + # check min args count + (( $# < 2 )) && usage action=$1 shift # set same environment variables as init runlevel=$(/sbin/runlevel) - ENV="PATH='/bin:/usr/bin:/sbin:/usr/sbin'" - ENV+=" PREVLEVEL='${runlevel:0:1}'" - ENV+=" RUNLEVEL='${runlevel:2:1}'" - ENV+=" CONSOLE='${CONSOLE:-/dev/console}'" + ENV=("PATH=/bin:/usr/bin:/sbin:/usr/sbin" + "PREVLEVEL=${runlevel%% *}" + "RUNLEVEL=${runlevel##* }" + "CONSOLE=${CONSOLE:-/dev/console}" + "TERM=$TERM") + cd / for i; do - [[ -x "/etc/rc.d/$i" ]] && cd / && eval /usr/bin/env -i $ENV "/etc/rc.d/$i" "$action" + if [[ -x "/etc/rc.d/$i" ]]; then + /usr/bin/env -i "${ENV[@]}" "/etc/rc.d/$i" "$action" + else + printf "${C_OTHER}:: ${C_FAIL}Error: ${C_DONE}Daemon script $i does not exist.\n" + fi (( ret += !! $? )) # clamp exit value to 0/1 done esac exit $ret -# vim: set ts=2 sw=2 noet: +# vim: set ts=2 sw=2 ft=sh noet: diff --git a/core/initscripts/rc.sysinit b/core/initscripts/rc.sysinit index e76780acb..9c13ff542 100755 --- a/core/initscripts/rc.sysinit +++ b/core/initscripts/rc.sysinit @@ -13,7 +13,7 @@ printsep run_hook sysinit_start -# export standard PATH (will be overridden later when /etc/profile is sourced, but is usefull for UDev) +# export standard PATH (will be overridden later when /etc/profile is sourced, but is useful for UDev) 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) @@ -29,9 +29,9 @@ if ! /bin/mountpoint -q /dev; then fi /bin/mkdir -p /run/lock /dev/{pts,shm} /bin/chmod 1777 /run/lock -/bin/mountpoint -q /dev/pts || /bin/mount /dev/pts &> /dev/null \ +/bin/mountpoint -q /dev/pts || /bin/mount -n /dev/pts &> /dev/null \ || /bin/mount -n -t devpts devpts /dev/pts -o mode=620,gid=5,nosuid,noexec -/bin/mountpoint -q /dev/shm || /bin/mount /dev/shm &> /dev/null \ +/bin/mountpoint -q /dev/shm || /bin/mount -n /dev/shm &> /dev/null \ || /bin/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 @@ -90,8 +90,8 @@ run_hook sysinit_udevlaunched # Trigger udev uevents if /bin/pidof /sbin/udevd &>/dev/null; then stat_busy "Triggering UDev uevents" - /sbin/udevadm trigger --action=add --type=subsystems - /sbin/udevadm trigger --action=add --type=devices + /sbin/udevadm trigger --action=add --type=subsystems + /sbin/udevadm trigger --action=add --type=devices stat_done fi @@ -112,7 +112,7 @@ run_hook sysinit_udevsettled # bring up the loopback interface [[ -d /sys/class/net/lo ]] && \ - status "Bringing up loopback interface" /sbin/ifconfig lo 127.0.0.1 up + status "Bringing up loopback interface" /sbin/ip link set up dev lo # FakeRAID devices detection if [[ $USEDMRAID =~ yes|YES && -x /sbin/dmraid ]]; then @@ -275,20 +275,21 @@ if [[ -x /sbin/fsck ]]; then stat_done fi -status "Mounting Local Filesystems" /bin/mount -n -o remount,rw / +stat_busy "Mounting Local Filesystems" + /bin/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 /bin/findmnt && -e /proc/self/mountinfo ]]; then - /bin/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 /bin/findmnt && -e /proc/self/mountinfo ]]; then + /bin/findmnt -rnu -o SOURCE,TARGET,FSTYPE,OPTIONS >| /etc/mtab + else + cat /proc/mounts >| /etc/mtab + fi -run_hook sysinit_premount -# now mount all the local filesystems -/bin/mount -a -t $NETFS -O no_netdev + run_hook sysinit_premount + # now mount all the local filesystems + /bin/mount -a -t $NETFS -O no_netdev stat_done # enable monitoring of lvm2 groups, now that the filesystems are mounted rw @@ -312,62 +313,55 @@ if [[ -f $RANDOM_SEED ]]; then fi stat_busy "Removing Leftover Files" -/bin/rm -rf /etc/{nologin,shutdownpid} /forcefsck &>/dev/null -/bin/mountpoint -q /tmp || /bin/rm -rf /tmp/* /tmp/.* &>/dev/null -[[ ! -L /var/lock ]] && /bin/rm -rf /var/lock/* -[[ ! -L /var/run && -d /var/run ]] && /usr/bin/find /var/run/ \! -type d -delete -[[ ! -L /var/run && ! -L /var/run/daemons ]] && /bin/rm -rf /var/run/daemons \ + /bin/rm -rf /etc/{nologin,shutdownpid} /forcefsck &>/dev/null + /bin/rm -rf /tmp/* /tmp/.* &>/dev/null + [[ ! -L /var/lock ]] && /bin/rm -rf /var/lock/* + [[ ! -L /var/run && -d /var/run ]] && /usr/bin/find /var/run/ \! -type d -delete + [[ ! -L /var/run && ! -L /var/run/daemons ]] && /bin/rm -rf /var/run/daemons \ && /bin/ln -s /run/daemons /var/run/daemons -: >| /var/run/utmp -/bin/chmod 0664 /var/run/utmp -/bin/chown root:utmp /var/run/utmp -# Keep {x,k,g}dm happy with xorg -/bin/mkdir -m1777 /tmp/.{X11,ICE}-unix + : >| /var/run/utmp + /bin/chmod 0664 /var/run/utmp + /bin/chown root:utmp /var/run/utmp + # Keep {x,k,g}dm happy with xorg + /bin/mkdir -m1777 /tmp/.{X11,ICE}-unix stat_done -#status "Updating Shared Library Links" /sbin/ldconfig - if [[ $HOSTNAME ]]; then - status "Setting Hostname: $HOSTNAME" /bin/hostname "$HOSTNAME" -fi - -# Set the NIS domain name, if necessary -[[ -f /etc/conf.d/nisdomainname ]] && . /etc/conf.d/nisdomainname -if [[ $NISDOMAINNAME ]]; then - status "Setting NIS Domain Name: $NISDOMAINNAME" \ - /bin/nisdomainname "$NISDOMAINNAME" + stat_busy "Setting Hostname: $HOSTNAME" + echo $HOSTNAME > /proc/sys/kernel/hostname + stat_done fi stat_busy "Setting Locale: ${LOCALE:=en_US}" -# Flush old locale settings -: >| /etc/profile.d/locale.sh -/bin/chmod 755 /etc/profile.d/locale.sh -# Set user defined locale -echo "export LANG=$LOCALE" >>/etc/profile.d/locale.sh + # Flush old locale settings + : >| /etc/profile.d/locale.sh + /bin/chmod 755 /etc/profile.d/locale.sh + # Set user defined locale + echo "export LANG=$LOCALE" >>/etc/profile.d/locale.sh stat_done if [[ ${LOCALE,,} =~ utf ]]; then - stat_busy "Setting Consoles to UTF-8 mode" - # UTF-8 consoles are default since 2.6.24 kernel - # this code is needed not only for older kernels, - # but also when user has set vt.default_utf8=0 but LOCALE is *.UTF-8. - for i in /dev/tty[0-9]*; do - /usr/bin/kbd_mode -u < ${i} - printf "\033%%G" > ${i} - done - echo 1 > /sys/module/vt/parameters/default_utf8 - stat_done - [[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" /bin/loadkeys -q -u $KEYMAP + stat_busy "Setting Consoles to UTF-8 mode" + # UTF-8 consoles are default since 2.6.24 kernel + # this code is needed not only for older kernels, + # but also when user has set vt.default_utf8=0 but LOCALE is *.UTF-8. + for i in /dev/tty[0-9]*; do + /usr/bin/kbd_mode -u < ${i} + printf "\e%%G" > ${i} + done + echo 1 > /sys/module/vt/parameters/default_utf8 + stat_done + [[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" /bin/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 - for i in /dev/tty[0-9]*; do - /usr/bin/kbd_mode -a < ${i} - printf "\033%%@" > ${i} - done - echo 0 > /sys/module/vt/parameters/default_utf8 - stat_done - [[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" /bin/loadkeys -q $KEYMAP + stat_busy "Setting Consoles to legacy mode" + # make non-UTF-8 consoles work on 2.6.24 and newer kernels + for i in /dev/tty[0-9]*; do + /usr/bin/kbd_mode -a < ${i} + printf "\e%%@" > ${i} + done + echo 0 > /sys/module/vt/parameters/default_utf8 + stat_done + [[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" /bin/loadkeys -q $KEYMAP fi # Set console font if required @@ -378,9 +372,8 @@ set_consolefont # we therefore need to copy this from /run to /etc. This functionality is going away one day. for f in cd net; do [[ -f /run/udev/tmp-rules--70-persistent-$f.rules ]] || continue - stat_busy "Adding persistent $f udev rules" - /bin/cat "/run/udev/tmp-rules--70-persistent-$f.rules" >> "/etc/udev/rules.d/70-persistent-$f.rules" - stat_done + status "Adding persistent $f udev rules" + /bin/cat "/run/udev/tmp-rules--70-persistent-$f.rules" >> "/etc/udev/rules.d/70-persistent-$f.rules" done /bin/dmesg >| /var/log/dmesg.log