new initscripts just missing md5sums, on my mac so no makepkg to do it

This commit is contained in:
Mike Staszel 2011-08-07 23:11:13 -05:00
parent 50694c6048
commit f89b5afbd9
19 changed files with 871 additions and 594 deletions

View file

@ -1,5 +1,15 @@
VER := $(shell git describe) VER := $(shell git describe)
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 DIRS := \
/etc/rc.d \
/etc/conf.d \
/etc/rc.d/functions.d \
/etc/logrotate.d \
/sbin \
/etc/tmpfiles.d \
/usr/lib/tmpfiles.d \
/usr/lib/initscripts \
/etc/bash_completion.d \
/usr/share/zsh/site-functions
minilogd: minilogd.o minilogd: minilogd.o
@ -9,10 +19,12 @@ installdirs:
install: minilogd installdirs install: minilogd installdirs
install -m644 -t $(DESTDIR)/etc inittab rc.conf install -m644 -t $(DESTDIR)/etc inittab rc.conf
install -m755 -t $(DESTDIR)/etc rc.local rc.local.shutdown rc.multi rc.shutdown rc.single rc.sysinit 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 -m644 -t $(DESTDIR)/etc/logrotate.d bootlog
install -m644 -t $(DESTDIR)/etc/rc.d functions install -m644 -t $(DESTDIR)/etc/rc.d functions
install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs
install -m755 -t $(DESTDIR)/sbin minilogd rc.d install -m755 -t $(DESTDIR)/sbin minilogd rc.d
install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles
install -m644 tmpfiles.conf $(DESTDIR)/usr/lib/tmpfiles.d/arch.conf
install -m644 -T bash-completion $(DESTDIR)/etc/bash_completion.d/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 install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d

View file

@ -1,14 +1,14 @@
# Maintainer: Mike Staszel <mikestaszel@plugapps.com> # Maintainer: Mike Staszel <mikestaszel@plugapps.com>
# PlugApps changes: inittab has a line for ttyS0 at 115200, 2 ttys # ALARM changes: inittab has a line for ttyS0 at 115200, 2 ttys
# for armv5te, 6 for armv7 # for armv5te, 6 for armv7
# rc.shutdown has an LED turn-off line # rc.shutdown has an LED turn-off line
# rc.conf is different # rc.conf is different
# rc.sysinit has our copyright info # rc.sysinit has our copyright info
pkgname=initscripts pkgname=initscripts
pkgver=2011.06.4 pkgver=2011.07.3
pkgrel=1.1 pkgrel=1
pkgdesc="System initialization/bootup scripts" pkgdesc="System initialization/bootup scripts"
plugrel=1 plugrel=1
arch=('arm' 'armv7h') arch=('arm' 'armv7h')
@ -23,8 +23,9 @@ optdepends=('bridge-utils: Network bridging support'
'net-tools: legacy network support' 'net-tools: legacy network support'
'wireless_tools: Wireless networking') 'wireless_tools: Wireless networking')
install=initscripts.install install=initscripts.install
source=(adjtime source=(arch-tmpfiles
bash-completion bash-completion
bootlog
functions functions
hwclock hwclock
inittab inittab
@ -41,28 +42,10 @@ source=(adjtime
rc.shutdown rc.shutdown
rc.single rc.single
rc.sysinit rc.sysinit
tmpfiles.conf
wireless.conf.d wireless.conf.d
zsh-completion) zsh-completion)
md5sums=('f976a1c61c2fb9bd2c30e3fdd0d62b61' #md5sums()
'bb2506a443dd1efe1963aa731be2b7a9'
'3a387fbc7567bb053c9964765a7ea747'
'16fa1f14f10fc8c1daf04f4b5edb9cab'
'f02566fd9a1eeac3aadd5d6af32453c5'
'6260da9309cdcfd68444867dc91d574a'
'da476ea7e29f23611cc1374a2a4cee8e'
'2c2dcc7ce7586f27fc5e6887f8ec74b8'
'565f1f24c5dc765831a58622f65844af'
'f56d3a9eb7c0406b47dfb5fbab4d3cf3'
'afc78ab156a6ec7389a3265af96d922e'
'dc8510d0be00b8c6640be59bfe7d6d27'
'bd236a57bc00aa4727b98c5ae401c457'
'669ce6d766dd9deb86686219f3763fe4'
'986ca9250756b12f0cb5f517ccb8bc47'
'bdec56c7d6964875c3b3ecaf3bbe58dd'
'6d77bdeeb65958171881fe15589d8c6a'
'e3dc54a8c8518c79dbffbf687655bb81'
'027576534885b8d5dded9be546057b12'
'b75f2f05e8272aecf08aabd8c4003b4a')
package() { package() {
cd ${srcdir} cd ${srcdir}

View file

@ -1,15 +0,0 @@
#!/bin/bash
# Update our hwclock for system drift
. /etc/rc.conf
HWCLOCK_PARAMS="--adjust"
case $HARDWARECLOCK in
UTC) HWCLOCK_PARAMS+=" --utc";;
localtime) HWCLOCK_PARAMS+=" --localtime";;
*) HWCLOCK_PARAMS="";;
esac
if [[ $HWCLOCK_PARAMS && -f /run/daemons/hwclock ]]; then
/sbin/hwclock $HWCLOCK_PARAMS
fi

250
core/initscripts/arch-tmpfiles Executable file
View file

@ -0,0 +1,250 @@
#!/bin/bash
#
# /usr/lib/initscripts/arch-tmpfiles
#
# Control creation, deletion, and cleaning of volatile and temporary files
#
warninvalid() {
printf "arch-tmpfiles: ignoring invalid entry on line %d of \`%s'\n" "$LINENUM" "$FILE"
(( ++error ))
} >&2
checkparams() {
local parmreq=$1; shift
local path=$1 mode=$2 uid=$3 gid=$4
# parmcount must be >= parmreq
if (( $# < parmreq )); then
return 1
fi
# mode must be valid octal and 3 or 4 digits
if [[ $mode && ! $mode =~ ^[0-7]{3,4}$ ]]; then
return 1
fi
# uid must be numeric or a valid user name
if [[ $uid && $uid != +([[:digit:]]) ]] && ! getent passwd "$uid" >/dev/null; then
return 1
fi
# gid must be numeric or a valid group name
if [[ $gid && $gid != +([[:digit:]]) ]] && ! getent group "$gid" >/dev/null; then
return 1
fi
return 0
}
_f() {
# Create a file if it doesn't exist yet
local path=$1 mode=$2 uid=$3 gid=$4
(( CREATE )) || return 0
if ! checkparams 4 "$@"; then
warninvalid
return
fi
if [[ ! -e $path ]]; then
install -m"$mode" -o"$uid" -g"$gid" <(:) "$path"
fi
}
_F() {
# Create or truncate a file
local path=$1 mode=$2 uid=$3 gid=$4
(( CREATE )) || return 0
if ! checkparams 4 "$@"; then
warninvalid
return
fi
install -m"$mode" -o"$uid" -g"$gid" <(:) "$path"
}
_d() {
# Create a directory if it doesn't exist yet
local path=$1 mode=$2 uid=$3 gid=$4
(( CREATE )) || return 0
if ! checkparams 4 "$@"; then
warninvalid
return
fi
if [[ ! -d "$path" ]]; then
install -d -m"$mode" -o"$uid" -g"$gid" "$path"
fi
}
_D() {
# Create or empty a directory
local path=$1 mode=$2 uid=$3 gid=$4
(( CREATE )) || return 0
if ! checkparams 4 "$@"; then
warninvalid
return
fi
if [[ -d $path ]]; then
find "$path" -mindepth 1 -maxdepth 1 -xdev -print0 | xargs -r0 rm -rf
fi
install -d -m"$mode" -o"$uid" -g"$gid" "$path"
}
_p() {
# Create a named pipe (FIFO) if it doesn't exist yet
local path=$1 mode=$2 uid=$3 gid=$4
(( CREATE )) || return 0
if ! checkparams 4 "$@"; then
warninvalid
return
fi
if [[ ! -p "$path" ]]; then
mkfifo -m$mode "$path"
chown "$uid:$gid" "$path"
fi
}
_x() {
# Ignore a path during cleaning. Use this type to exclude paths from clean-up as
# controlled with the Age parameter. Note that lines of this type do not
# influence the effect of r or R lines. Lines of this type accept shell-style
# globs in place of of normal path names.
:
# XXX: we don't implement this
}
_r() {
# Remove a file or directory if it exists. This may not be used to remove
# non-empty directories, use R for that. Lines of this type accept shell-style
# globs in place of normal path names.
local path
local -a paths=($1)
(( REMOVE )) || return 0
if ! checkparams 1 "$@"; then
warninvalid
return
fi
for path in "${paths[@]}"; do
if [[ -f $path ]]; then
rm -f "$path"
elif [[ -d $path ]]; then
rmdir "$path"
fi
done
}
_R() {
# Recursively remove a path and all its subdirectories (if it is a directory).
# Lines of this type accept shell-style globs in place of normal path names.
local path
local -a paths=($1)
(( REMOVE )) || return 0
if ! checkparams 1 "$@"; then
warninvalid
return
fi
for path in "${paths[@]}"; do
[[ -d $path ]] && rm -rf --one-file-system "$path"
done
}
shopt -s nullglob
declare -i CREATE=0 REMOVE=0 CLEAN=0 error=0 LINENO=0
declare FILE=
declare -A fragments
declare -a tmpfiles_d=(
/usr/lib/tmpfiles.d/*.conf
/etc/tmpfiles.d/*.conf
/run/tmpfiles.d/*.conf
)
while (( $# )); do
case $1 in
--create) CREATE=1 ;;
--remove) REMOVE=1 ;;
esac
shift
done
if (( !(CREATE + REMOVE) )); then
printf 'usage: %s [--create] [--remove]\n' "${0##*/}"
exit 1
fi
# directories declared later in the tmpfiles_d array will override earlier
# directories, on a per file basis.
# Example: `/etc/tmpfiles.d/foo.conf' supersedes `/usr/lib/tmpfiles.d/foo.conf'.
for path in "${tmpfiles_d[@]}"; do
[[ -f $path ]] && fragments[${path##*/}]=${path%/*}
done
# catch errors in functions so we can exit with something meaningful
set -E
trap '(( ++error ))' ERR
# loop through the gathered fragments, sorted globally by filename.
# `/run/tmpfiles/foo.conf' will always be read after `/etc/tmpfiles.d/bar.conf'
while read -d '' fragment; do
LINENUM=0
printf -v FILE '%s/%s' "${fragments[$fragment]}" "$fragment"
### FILE FORMAT ###
# XXX: We ignore the final 'Age' parameter
# 0 1 2 3 4 5
# Type Path Mode UID GID Age
# d /run/user 0755 root root 10d
# omit read's -r flag to honor escapes here, so that whitespace can be
# escaped for paths. We will _not_ honor quoted paths.
while read -a line; do
(( ++LINENUM ))
# skip over comments and empty lines
if (( ! ${#line[*]} )) || [[ ${line[0]:0:1} = '#' ]]; then
continue
fi
# whine about invalid entries
if ! type -t _${line[0]} >/dev/null; then
warninvalid
continue
fi
# fall back on defaults when parameters are passed as '-'
if [[ ${line[2]} = '-' ]]; then
case ${line[0]} in
p|f|F) line[2]=0644 ;;
d|D) line[2]=0755 ;;
esac
fi
[[ ${line[3]} = '-' ]] && line[3]=0
[[ ${line[4]} = '-' ]] && line[4]=0
_${line[0]} "${line[@]:1}"
done <"$FILE"
done < <(printf '%s\0' "${!fragments[@]}" | sort -z)
exit $error
# vim: set ts=2 sw=2 noet:

View file

@ -1,22 +1,24 @@
# rc.d bash completion by Seblu <seblu@seblu.net> # rc.d bash completion by Seblu <seblu@seblu.net>
_rc.d () _rc_d()
{ {
local action="help list start stop reload restart" local action cur prev
local cur="${COMP_WORDS[COMP_CWORD]}" action="help list start stop reload restart"
local caction="${COMP_WORDS[1]}" _get_comp_words_by_ref cur prev
if ((${COMP_CWORD} == 1)); then if ((COMP_CWORD == 1)); then
COMPREPLY=($(compgen -W "${action}" -- "$cur")) COMPREPLY=($(compgen -W "${action}" -- "$cur"))
elif [[ "$caction" =~ help|list ]]; then elif [[ "$prev" == help ]]; then
COMPREPLY=() COMPREPLY=()
elif [[ "$caction" == start ]]; then elif [[ "$prev" == list ]]; then
((COMP_CWORD == 2)) && COMPREPLY=($(compgen -W "started stopped" -- "$cur")) || COMPREPLY=()
elif [[ "$prev" == start ]]; then
COMPREPLY=($(comm -23 <(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort) <(cd /run/daemons/ && compgen -f "$cur"|sort))) 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 elif [[ "$prev" =~ stop|restart|reload ]]; then
COMPREPLY=($(cd /run/daemons/ && compgen -f "$cur"|sort)) COMPREPLY=($(cd /run/daemons/ && compgen -f "$cur"|sort))
elif ((${COMP_CWORD} > 1)); then elif ((COMP_CWORD > 1)); then
COMPREPLY=($(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort)) COMPREPLY=($(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort))
fi fi
} }
complete -F _rc.d rc.d complete -F _rc_d rc.d
# vim: set ts=2 sw=2 ft=sh noet: # vim: set ts=2 sw=2 ft=sh noet:

9
core/initscripts/bootlog Normal file
View file

@ -0,0 +1,9 @@
/var/log/boot {
compress
rotate 1
size=+1024k
notifempty
missingok
copytruncate
noolddir
}

View file

@ -2,32 +2,56 @@
# initscripts functions # initscripts functions
# #
# sanitize 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"
if [[ $1 == "start" ]]; then
if [[ $STARTING ]]; then
echo "A daemon is starting another daemon, this is unlikely to work as intended.\n"
else
export STARTING=1
fi
fi
# width: # width:
calc_columns () {
STAT_COL=80
if [[ ! -t 1 ]]; then
USECOLOR=""
elif [[ -t 0 ]]; then
# stty will fail when stdin isn't a terminal
STAT_COL="$(/bin/stty size)"
# stty gives "rows cols"; strip the rows number, we just want columns
STAT_COL="${STAT_COL##* }"
elif /bin/tput cols &>/dev/null; then
# is /usr/share/terminfo already mounted, and TERM recognized?
STAT_COL=$(/bin/tput cols)
fi
if ((STAT_COL==0)); then
# if output was 0 (serial console), set default width to 80
STAT_COL=80 STAT_COL=80
USECOLOR="" if [[ ! -t 1 ]]; then
fi USECOLOR=""
elif [[ -t 0 ]]; then
# stty will fail when stdin isn't a terminal
STAT_COL=$(stty size)
# stty gives "rows cols"; strip the rows number, we just want columns
STAT_COL=${STAT_COL##* }
elif tput cols &>/dev/null; then
# is /usr/share/terminfo already mounted, and TERM recognized?
STAT_COL=$(tput cols)
fi
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 # 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"
RESTORE_POSITION="\e[u"
DEL_TEXT="\e[$(( STAT_COL + 4 ))G"
else
SAVE_POSITION=""
RESTORE_POSITION=""
DEL_TEXT=""
fi
}
calc_columns
# disable colors on broken terminals # disable colors on broken terminals
TERM_COLORS="$(/bin/tput colors 2>/dev/null)" TERM_COLORS=$(tput colors 2>/dev/null)
if (($? != 3)); then if (( $? != 3 )); then
case $TERM_COLORS in case $TERM_COLORS in
*[!0-9]*) USECOLOR="";; *[!0-9]*) USECOLOR="";;
[0-7]) USECOLOR="";; [0-7]) USECOLOR="";;
@ -43,47 +67,37 @@ unset TZ
unset LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \ unset LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE \ LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE \
LC_MEASUREMENT LC_IDENTIFICATION LC_ALL 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}" export LANG="${LOCALE}"
else else
export LANG=C export LANG=C
fi fi
# set colors # set colors
if [[ $USECOLOR =~ yes|YES ]]; then if [[ $USECOLOR = [yY][eE][sS] ]]; then
if /bin/tput setaf 0 &>/dev/null; then if tput setaf 0 &>/dev/null; then
C_CLEAR="$(tput sgr0)" # clear text C_CLEAR=$(tput sgr0) # clear text
C_MAIN="${C_CLEAR}$(/bin/tput bold)" # main text C_MAIN=${C_CLEAR}$(tput bold) # main text
C_OTHER="${C_MAIN}$(/bin/tput setaf 4)" # prefix & brackets C_OTHER=${C_MAIN}$(tput setaf 4) # prefix & brackets
C_SEPARATOR="${C_MAIN}$(/bin/tput setaf 0)" # separator C_SEPARATOR=${C_MAIN}$(tput setaf 0) # separator
C_BUSY="${C_CLEAR}$(/bin/tput setaf 6)" # busy C_BUSY=${C_CLEAR}$(tput setaf 6) # busy
C_FAIL="${C_MAIN}$(/bin/tput setaf 1)" # failed C_FAIL=${C_MAIN}$(tput setaf 1) # failed
C_DONE="${C_MAIN}" # completed C_DONE=${C_MAIN} # completed
C_BKGD="${C_MAIN}$(/bin/tput setaf 5)" # backgrounded C_BKGD=${C_MAIN}$(tput setaf 5) # backgrounded
C_H1="${C_MAIN}" # highlight text 1 C_H1=${C_MAIN} # highlight text 1
C_H2="${C_MAIN}$(/bin/tput setaf 6)" # highlight text 2 C_H2=${C_MAIN}$(tput setaf 6) # highlight text 2
else else
C_CLEAR="\e[m" # clear text C_CLEAR="\e[m" # clear text
C_MAIN="\e[;1m" # main text C_MAIN="\e[;1m" # main text
C_OTHER="\e[1;34m" # prefix & brackets C_OTHER="\e[1;34m" # prefix & brackets
C_SEPARATOR="\e[1;30m" # separator C_SEPARATOR="\e[1;30m" # separator
C_BUSY="\e[;36m" # busy C_BUSY="\e[;36m" # busy
C_FAIL="\e[1;31m" # failed C_FAIL="\e[1;31m" # failed
C_DONE="${C_MAIN}" # completed C_DONE=${C_MAIN} # completed
C_BKGD="\e[1;35m" # backgrounded C_BKGD="\e[1;35m" # backgrounded
C_H1="${C_MAIN}" # highlight text 1 C_H1=${C_MAIN} # highlight text 1
C_H2="\e[1;36m" # highlight text 2 C_H2="\e[1;36m" # highlight text 2
fi fi
fi
if [[ -t 1 ]]; then
SAVE_POSITION="\e[s"
RESTORE_POSITION="\e[u"
DEL_TEXT="\e[$(($STAT_COL+4))G"
else
SAVE_POSITION=""
RESTORE_POSITION=""
DEL_TEXT=""
fi fi
# prefixes: # prefixes:
@ -142,24 +156,20 @@ stat_die() {
status() { status() {
stat_busy "$1" stat_busy "$1"
shift shift
if "$@" >/dev/null 2>&1; then "$@" &>/dev/null
stat_done local ret=$?
return 0 (( ret == 0 )) && stat_done || stat_fail
fi return $ret
stat_fail
return 1
} }
# usage : in_array( $needle, $haystack ) # usage : in_array( $needle, $haystack )
# return : 0 - found # return : 0 - found
# 1 - not found # 1 - not found
# Copied from makepkg
in_array() { in_array() {
[[ $2 ]] || return 1
local needle=$1; shift local needle=$1; shift
local item local item
for item in "$@"; do for item; do
[[ ${item#@} = $needle ]] && return 0 [[ $item = "${needle}" ]] && return 0
done done
return 1 # Not Found return 1 # Not Found
} }
@ -167,12 +177,12 @@ in_array() {
# daemons: # daemons:
add_daemon() { add_daemon() {
[[ -d /run/daemons ]] || /bin/mkdir -p /run/daemons [[ -d /run/daemons ]] || mkdir -p /run/daemons
> /run/daemons/"$1" >| /run/daemons/"$1"
} }
rm_daemon() { rm_daemon() {
/bin/rm -f /run/daemons/"$1" rm -f /run/daemons/"$1"
} }
ck_daemon() { ck_daemon() {
@ -186,9 +196,9 @@ have_daemon() {
# Check if $1 is started at boot # Check if $1 is started at boot
ck_autostart() { ck_autostart() {
local d local daemon
for d in "${DAEMONS[@]}"; do for daemon in "${DAEMONS[@]}"; do
[[ "$1" = ${d#@} ]] && return 1 [[ $1 = "${daemon#@}" ]] && return 1
done done
return 0 return 0
} }
@ -197,8 +207,11 @@ start_daemon() {
have_daemon "$1" && /etc/rc.d/"$1" start have_daemon "$1" && /etc/rc.d/"$1" start
} }
# Never use this function, it causes daemons to be stoped in the wrong order.
# The only way to start a daemon at boot is to add it to the DAEMONS array.
ck_depends() { ck_depends() {
for daemon in "$@"; do local daemon
for daemon; do
ck_daemon "$daemon" && start_daemon "$daemon" ck_daemon "$daemon" && start_daemon "$daemon"
done done
} }
@ -224,66 +237,110 @@ status_stopped() {
} }
ck_status() { ck_status() {
if ! ck_daemon "$1"; then ! ck_daemon "$1" && status_started || status_stopped
status_started }
else
status_stopped # Return PID of $1
get_pid() {
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
local fpid ppid
read -r fpid <"$1"
ppid=$(get_pid "$2")
[[ $fpid = "${ppid}" ]] && return 0
fi fi
return 1
} }
# PIDs to be omitted by killall5 # PIDs to be omitted by killall5
declare -a omit_pids declare -a omit_pids
add_omit_pids() { add_omit_pids() {
omit_pids+=( $@ ) omit_pids+=( $@ )
} }
# Stop all daemons
kill_everything() { # This function should *never* ever perform any other actions beside calling stop_daemon()!
# $1 = where we are being called from. # It might be used by a splash system etc. to get a list of daemons to be stopped.
# This is used to determine which hooks to run. stop_all_daemons() {
# Find daemons NOT in the DAEMONS array. Shut these down first # Find daemons NOT in the DAEMONS array. Shut these down first
local daemon
for daemon in /run/daemons/*; do for daemon in /run/daemons/*; do
[[ -f $daemon ]] || continue [[ -f $daemon ]] || continue
daemon=${daemon##*/} daemon=${daemon##*/}
in_array "$daemon" "${DAEMONS[@]}" || stop_daemon "$daemon" ck_autostart "$daemon" && stop_daemon "$daemon"
done done
# Shutdown daemons in reverse order # Shutdown daemons in reverse order
for ((i=${#DAEMONS[@]}-1; i>=0; i--)); do local i daemon
[[ ${DAEMONS[$i]:0:1} = '!' ]] && continue for (( i=${#DAEMONS[@]}-1; i>=0; i-- )); do
ck_daemon ${DAEMONS[$i]#@} || stop_daemon ${DAEMONS[$i]#@} [[ ${DAEMONS[i]} = '!'* ]] && continue
daemon=${DAEMONS[i]#@}
ck_daemon "$daemon" || stop_daemon "$daemon"
done done
}
kill_all() {
# Terminate all processes # Terminate all processes
# and wait until killall5 reports all done or timeout
# Unfortunately killall5 does not support the 0 signal, so just
# use SIGCONT for checking (which should be ignored).
stat_busy "Sending SIGTERM To Processes" stat_busy "Sending SIGTERM To Processes"
run_hook "$1_prekillall" local i
local pid k5args="" killall5 -15 ${omit_pids[@]/#/-o } &>/dev/null
for pid in ${omit_pids[@]}; do for (( i=0; i<20 && $?!=2; i++ )); do
k5args+=" -o $pid" sleep .25 # 1/4 second
done killall5 -18 ${omit_pids[@]/#/-o } &>/dev/null
/sbin/killall5 -15 $k5args &> /dev/null done
/bin/sleep 5
stat_done stat_done
stat_busy "Sending SIGKILL To Processes" stat_busy "Sending SIGKILL To Processes"
/sbin/killall5 -9 $k5args &> /dev/null local i
/bin/sleep 1 killall5 -9 ${omit_pids[@]/#/-o } &>/dev/null
for (( i=0; i<4 && $?!=2; i++ )); do
sleep .25 # 1/4 second
killall5 -18 ${omit_pids[@]/#/-o } &>/dev/null
done
stat_done
}
# Start/trigger UDev, load MODULES and settle UDev
udevd_modprobe() {
# $1 = where we are being called from.
# This is used to determine which hooks to run.
status "Starting UDev Daemon" udevd --daemon
run_hook "$1_udevlaunched"
stat_busy "Triggering UDev uevents"
udevadm trigger --action=add --type=subsystems
udevadm trigger --action=add --type=devices
stat_done stat_done
run_hook "$1_postkillall" # Load modules from the MODULES array defined in rc.conf
[[ -f /proc/modules ]] && (( ${#MODULES[*]} )) &&
status "Loading Modules" modprobe -ab "${MODULES[@]}"
status "Waiting for UDev uevents to be processed" \
udevadm settle --timeout=${UDEV_TIMEOUT:-30}
run_hook "$1_udevsettled"
# in case loading a module changed the display mode
calc_columns
} }
activate_vgs() { activate_vgs() {
[[ $USELVM =~ yes|YES && -x /sbin/lvm && -d /sys/block ]] || return [[ $USELVM = [yY][eE][sS] && -x $(type -P lvm) && -d /sys/block ]] || return 0
# Kernel 2.6.x, LVM2 groups # Kernel 2.6.x, LVM2 groups
/sbin/modprobe -q dm-mod 2>/dev/null
stat_busy "Activating LVM2 groups" stat_busy "Activating LVM2 groups"
if /sbin/vgchange --sysinit -a y >/dev/null; then modprobe -q dm-mod 2>/dev/null
stat_done vgchange --sysinit -a y >/dev/null
else (( $? == 0 )) && stat_done || stat_fail
stat_fail
fi
} }
# Arch cryptsetup packages traditionally contained the binaries # Arch cryptsetup packages traditionally contained the binaries
@ -301,7 +358,7 @@ read_crypttab() {
# $1 = function to call with the split out line from the crypttab # $1 = function to call with the split out line from the crypttab
local line nspo failed=0 local line nspo failed=0
while read line; do while read line; do
[[ $line && ${line:0:1} != '#' ]] || continue [[ $line && $line != '#'* ]] || continue
eval nspo=("${line%#*}") eval nspo=("${line%#*}")
if $1 "${nspo[0]}" "${nspo[1]}" "${nspo[2]}" "${nspo[*]:3}"; then if $1 "${nspo[0]}" "${nspo[1]}" "${nspo[2]}" "${nspo[*]:3}"; then
crypto_unlocked=1 crypto_unlocked=1
@ -312,6 +369,75 @@ read_crypttab() {
return $failed return $failed
} }
# Filesystem functions
# These can be overridden/reused for customizations like shutdown/loop-fsck.
NETFS="nfs,nfs4,smbfs,cifs,codafs,ncpfs,shfs,fuse,fuseblk,glusterfs,davfs,fuse.glusterfs"
# Check local filesystems
fsck_all() {
fsck -A -T -C"$FSCK_FD" -a -t "no${NETFS//,/,no},noopts=_netdev" $FORCEFSCK
return $?
}
# Single-user login and/or automatic reboot after fsck (if needed)
fsck_reboot() {
# $1 = exit code returned by fsck
# Ignore conditions 'FS errors corrected' and 'Cancelled by the user'
(( ($1 | 33) == 33 )) && return 0
if (( $1 & 2 )); then
echo
echo "********************** REBOOT REQUIRED *********************"
echo "* *"
echo "* The system will be rebooted automatically in 15 seconds. *"
echo "* *"
echo "************************************************************"
echo
sleep 15
else
echo
echo "***************** FILESYSTEM CHECK FAILED ****************"
echo "* *"
echo "* Please repair manually and reboot. Note that the root *"
echo "* file system is currently mounted read-only. To remount *"
echo "* it read-write type: mount -n -o remount,rw / *"
echo "* When you exit the maintenance shell the system will *"
echo "* reboot automatically. *"
echo "* *"
echo "************************************************************"
echo
sulogin -p
fi
echo "Automatic reboot in progress..."
umount -a
mount -n -o remount,ro /
reboot -f
exit 0
}
mount_all() {
mount -a -t "nosysfs,no${NETFS//,/,no}" -O no_netdev
}
remove_leftover() {
stat_busy "Removing Leftover Files"
# handle this separately until we declare the non-symlinks obsoleted
[[ ! -L /var/lock ]] && rm -rf /var/lock/*
if [[ ! -L /var/run && -d /var/run ]]; then
find /var/run/ \! -type d -delete
ln -s /run/daemons /var/run/daemons
fi
/usr/lib/initscripts/arch-tmpfiles --create --remove && stat_done || stat_fail
}
bootlogd_stop() {
[[ -f /run/bootlogd.pid ]] || return 0
touch /var/log/boot
kill $(< /run/bootlogd.pid)
rm -f /run/bootlogd.pid
sed -i -r -e 's/\^\[\[[0-9]?;?[0-9]?[0-9]?;?[0-9]?[0-9]?[ms]//g' \
-e 's/\^\[(\[151|%)G//g' /var/log/boot
}
############################### ###############################
# Custom hooks in initscripts # # Custom hooks in initscripts #
############################### ###############################
@ -338,21 +464,23 @@ read_crypttab() {
# sysinit_udevsettled: after uevents have settled in rc.sysinit # sysinit_udevsettled: after uevents have settled in rc.sysinit
# single_udevsettled: after uevents have settled in rc.single # single_udevsettled: after uevents have settled in rc.single
# sysinit_premount: before local filesystems are mounted, but after root is mounted read-write in rc.sysinit # sysinit_premount: before local filesystems are mounted, but after root is mounted read-write in rc.sysinit
# sysinit_postmount: after local filesystems are mounted
# shutdown_prekillall: before all processes are being killed in rc.shutdown # shutdown_prekillall: before all processes are being killed in rc.shutdown
# single_prekillall: before all processes are being killed in rc.single # single_prekillall: before all processes are being killed in rc.single
# shutdown_postkillall: after all processes have been killed in rc.shutdown # shutdown_postkillall: after all processes have been killed in rc.shutdown
# single_postkillall: after all processes have been killed in rc.single # single_postkillall: after all processes have been killed in rc.single
# shutdown_postumount: after filesystems are unmounted
# shutdown_poweroff: directly before powering off in rc.shutdown # shutdown_poweroff: directly before powering off in rc.shutdown
# #
# Declare add_hook and run_hook as read-only to prevent overwriting them. # Declare add_hook and run_hook as read-only to prevent overwriting them.
# Too bad we cannot do the same thing with hook_funcs # 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 declare -A hook_funcs
add_hook() { add_hook() {
[[ $1 && $2 ]] || return 1 [[ $1 && $2 ]] || return 1
hook_funcs["$1"]+=" $2" hook_funcs[$1]+=" $2"
} }
run_hook() { run_hook() {
@ -371,13 +499,14 @@ fi
set_consolefont() { set_consolefont() {
[[ $CONSOLEFONT ]] || return 0 [[ $CONSOLEFONT ]] || return 0
stat_busy "Loading Console Font: $CONSOLEFONT" stat_busy "Loading Console Font: $CONSOLEFONT"
#CONSOLEMAP in UTF-8 shouldn't be used #CONSOLEMAP in UTF-8 shouldn't be used
[[ $CONSOLEMAP && ${LOCALE,,} =~ utf ]] && CONSOLEMAP="" [[ $CONSOLEMAP && ${LOCALE,,} =~ utf ]] && CONSOLEMAP=""
for i in /dev/tty[0-9]*; do local i
/usr/bin/setfont ${CONSOLEMAP:+-m ${CONSOLEMAP}} \ for i in /dev/tty[0-9]*; do
$CONSOLEFONT -C ${i} >/dev/null 2>&1 setfont ${CONSOLEMAP:+-m "${CONSOLEMAP}"} \
done "$CONSOLEFONT" -C ${i} &>/dev/null
if (($? != 0)); then done
if (( $? )); then
stat_fail stat_fail
elif [[ $CONSOLEMAP ]]; then elif [[ $CONSOLEMAP ]]; then
cat <<"EOF" >>/etc/profile.d/locale.sh cat <<"EOF" >>/etc/profile.d/locale.sh
@ -394,5 +523,15 @@ for f in /etc/rc.d/functions.d/*; do
[[ -e $f ]] && . "$f" [[ -e $f ]] && . "$f"
done done
# Exit current shell if user is not root
need_root() {
(( EUID )) && printf 'You need to be root.\n' && exit 1
}
# Quit script if it's not running by root
# This can be disabled in scripts sourcing functions by setting NEED_ROOT=0
# A local call to need_root can be done to ensure part of script need root privilege
(( ${NEED_ROOT:-0} == 1 )) && need_root
# End of file # End of file
# vim: set ts=2 sw=2 noet: # vim: set ts=2 sw=2 noet:

View file

@ -11,27 +11,18 @@ esac
case "$1" in case "$1" in
start) start)
if [[ $HWCLOCK_PARAMS ]]; then add_daemon hwclock;;
status "Adjusting Hardware Clock" \
/sbin/hwclock --adjust
stat_busy "Setting System Clock"
/sbin/hwclock --hctosys $HWCLOCK_PARAMS || stat_die
stat_done
# Note: This also enables /etc/cron.hourly/adjtime
add_daemon hwclock
fi
;;
stop) stop)
if [[ $HWCLOCK_PARAMS ]]; then case $HARDWARECLOCK in
stat_busy "Saving System Clock" UTC) hwclock --adjust --utc;;
/sbin/hwclock --systohc $HWCLOCK_PARAMS || stat_die localtime) hwclock --adjust --localtime;;
stat_done "") hwclock --adjust;;
fi esac
rm_daemon hwclock rm_daemon hwclock
;; ;;
restart) restart)
$0 stop $0 stop
sleep 1 sleep 2
$0 start $0 start
;; ;;
*) *)

4
core/initscripts/initscripts.install Executable file → Normal file
View file

@ -8,4 +8,8 @@ post_upgrade() {
echo "Blacklisting of modules is no longer supported in rc.conf," echo "Blacklisting of modules is no longer supported in rc.conf,"
echo "please add blacklist entries to /etc/modprobe.d/ instead." echo "please add blacklist entries to /etc/modprobe.d/ instead."
fi fi
if [ "$(vercmp $2 2011.07.2)" -lt 0 ]; then
echo "VERBOSE= in rc.conf no longer has any effect."
echo "Please append 'quiet' to your kernel command line."
fi
} }

View file

@ -4,32 +4,24 @@
. /etc/rc.conf . /etc/rc.conf
. /etc/rc.d/functions . /etc/rc.d/functions
rc=0
case "$1" in case "$1" in
start) start)
stat_busy "Mounting Network Filesystems" stat_busy "Mounting Network Filesystems"
/bin/mount -a -t nfs,nfs4,smbfs,codafs,ncpfs,cifs,shfs,glusterfs,fuse,fuseblk,fuse.glusterfs,davfs mount -a -t "$NETFS"
rc=$? rc=$?
/bin/mount -a -O _netdev mount -a -O _netdev
if ((rc + $? > 0)); then (( rc || $? )) && stat_die
stat_fail add_daemon netfs
else stat_done
add_daemon netfs
stat_done
fi
;; ;;
stop) stop)
stat_busy "Unmounting Network Filesystems" stat_busy "Unmounting Network Filesystems"
/bin/umount -a -O _netdev umount -a -O _netdev
rc=$? rc=$?
/bin/umount -a -t nfs,nfs4,smbfs,codafs,ncpfs,cifs,shfs,glusterfs,fuse,fuseblk,fuse.glusterfs,davfs umount -a -t "$NETFS"
if ((rc + $? > 0)); then (( rc || $? )) && stat_die
stat_fail rm_daemon netfs
else stat_done
rm_daemon netfs
stat_done
fi
;; ;;
restart) restart)
$0 stop $0 stop
@ -37,7 +29,8 @@ case "$1" in
$0 start $0 start
;; ;;
*) *)
echo "usage: $0 {start|stop|restart}" echo "usage: $0 {start|stop|restart}"
exit 1
esac esac
# vim: set ts=2 noet: # vim: set ts=2 noet:

View file

@ -9,7 +9,8 @@ done
# helper function to determine if legacy network support is needed # helper function to determine if legacy network support is needed
need_legacy() { need_legacy() {
if [[ -z $interface ]]; then # complain when `interface' is unset and `INTERFACES' has profiles enabled
if [[ -z $interface && ${INTERFACES[@]##!*} ]]; then
return 0 # need legacy return 0 # need legacy
fi fi
@ -17,37 +18,30 @@ need_legacy() {
} }
deprecated() { deprecated() {
printf "${C_FAIL}Warning:${C_CLEAR} This functionality is deprecated.\n" printf "${C_FAIL}Warning:${C_CLEAR} Your network settings are deprecated.\n"
printf " Please refer to /etc/rc.conf on how to define a single wired\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" printf " connection, or use a utility such as netcfg.\n"
} }
network_up() { network_up() {
/usr/sbin/ip link set dev $interface up || return 1 ip link set dev $interface up || return 1
if [[ $address ]]; then if [[ $address ]]; then
for var in netmask gateway; do ip addr add $address/${netmask:-24} broadcast ${broadcast:-+} dev $interface || return 1
if [[ -z ${!var} ]]; then [[ $gateway ]] && { ip route add default via $gateway || return 1; }
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 else
/sbin/dhcpcd $DHCPCD_ARGS $interface || return 1 dhcpcd $DHCPCD_ARGS $interface || return 1
fi fi
} }
network_down() { network_down() {
if [[ -f /var/run/dhcpcd-$interface.pid ]]; then if [[ -f /var/run/dhcpcd-$interface.pid ]]; then
/sbin/dhcpcd -k $interface || return 1 dhcpcd -k $interface || return 1
else else
/usr/sbin/ip route del default || return 1 ip addr flush dev $interface || return 1
/usr/sbin/ip addr flush dev $interface || return 1
fi fi
/usr/sbin/ip link set dev $interface down || return 1 ip link set dev $interface down || return 1
} }
ifup() { ifup() {
@ -65,17 +59,17 @@ ifup() {
ifname=${ifcfg%% *} ifname=${ifcfg%% *}
fi fi
/sbin/ifconfig $ifname up ifconfig $ifname up
wi_up $1 || return 1 wi_up $1 || return 1
if [[ $ifcfg = dhcp ]]; then if [[ $ifcfg = dhcp ]]; then
# remove the .pid file if it exists # remove the .pid file if it exists
/bin/rm -f /var/run/dhcpcd-${1}.pid >/dev/null 2>&1 rm -f /var/run/dhcpcd-${1}.pid >/dev/null 2>&1
/bin/rm -f /var/run/dhcpcd-${1}.cache >/dev/null 2>&1 rm -f /var/run/dhcpcd-${1}.cache >/dev/null 2>&1
/sbin/dhcpcd $DHCPCD_ARGS ${1} dhcpcd $DHCPCD_ARGS ${1}
else else
/sbin/ifconfig $ifcfg ifconfig $ifcfg
fi fi
} }
@ -84,7 +78,7 @@ wi_up() {
[[ ${!iwcfg} ]] || return 0 [[ ${!iwcfg} ]] || return 0
/usr/sbin/iwconfig ${!iwcfg} iwconfig ${!iwcfg}
[[ $WIRELESS_TIMEOUT ]] || WIRELESS_TIMEOUT=2 [[ $WIRELESS_TIMEOUT ]] || WIRELESS_TIMEOUT=2
sleep $WIRELESS_TIMEOUT sleep $WIRELESS_TIMEOUT
@ -105,10 +99,10 @@ ifdown() {
fi fi
if [[ $ifcfg = dhcp && -f /var/run/dhcpcd-${1}.pid ]]; then if [[ $ifcfg = dhcp && -f /var/run/dhcpcd-${1}.pid ]]; then
/sbin/dhcpcd -k ${1} >/dev/null 2>&1 dhcpcd -k ${1} >/dev/null 2>&1
fi fi
# Always bring the interface itself down # Always bring the interface itself down
/sbin/ifconfig ${1} down >/dev/null 2>&1 ifconfig ${1} down >/dev/null 2>&1
} }
iflist() { iflist() {
@ -131,9 +125,9 @@ rtup() {
fi fi
if [[ $routecfg =~ :: ]]; then if [[ $routecfg =~ :: ]]; then
/sbin/route -A inet6 add $routecfg route -A inet6 add $routecfg
else else
/sbin/route add $routecfg route add $routecfg
fi fi
} }
@ -146,9 +140,9 @@ rtdown() {
fi fi
if [[ $routecfg =~ :: ]]; then if [[ $routecfg =~ :: ]]; then
/sbin/route -A inet6 del $routecfg route -A inet6 del $routecfg
else else
/sbin/route del $routecfg route del $routecfg
fi fi
} }
@ -168,7 +162,7 @@ bond_up() {
if [[ $ifline = ${ifline#!} ]]; then if [[ $ifline = ${ifline#!} ]]; then
bondcfg="bond_$ifline" bondcfg="bond_$ifline"
if [[ ${!bondcfg} ]]; then if [[ ${!bondcfg} ]]; then
/sbin/ifenslave $ifline ${!bondcfg} || error=1 ifenslave $ifline ${!bondcfg} || error=1
fi fi
fi fi
done done
@ -178,7 +172,7 @@ bond_down() {
for ifline in ${BOND_INTERFACES[@]}; do for ifline in ${BOND_INTERFACES[@]}; do
if [[ $ifline = ${ifline#!} ]]; then if [[ $ifline = ${ifline#!} ]]; then
bondcfg="bond_$ifline" bondcfg="bond_$ifline"
/sbin/ifenslave -d $ifline ${!bondcfg} || error=1 ifenslave -d $ifline ${!bondcfg} || error=1
fi fi
done done
} }
@ -187,11 +181,11 @@ bridge_up() {
for br in ${BRIDGE_INTERFACES[@]}; do for br in ${BRIDGE_INTERFACES[@]}; do
if [[ $br = ${br#!} ]]; then if [[ $br = ${br#!} ]]; then
# if the bridge already exists, remove it # if the bridge already exists, remove it
if [[ $(/sbin/ifconfig $br 2>/dev/null) ]]; then if [[ $(ifconfig $br 2>/dev/null) ]]; then
/sbin/ifconfig $br down ifconfig $br down
/usr/sbin/brctl delbr $br brctl delbr $br
fi fi
/usr/sbin/brctl addbr $br brctl addbr $br
brifs="bridge_$br" brifs="bridge_$br"
for brif in ${!brifs}; do for brif in ${!brifs}; do
if [[ $brif = ${brif#!} ]]; then if [[ $brif = ${brif#!} ]]; then
@ -199,12 +193,12 @@ bridge_up() {
if [[ $brif = $ifline && $ifline = ${ifline#!} ]]; then if [[ $brif = $ifline && $ifline = ${ifline#!} ]]; then
ifup $ifline ifup $ifline
bondcfg="bond_$ifline" bondcfg="bond_$ifline"
/sbin/ifenslave $ifline ${!bondcfg} || error=1 ifenslave $ifline ${!bondcfg} || error=1
unset bond_$ifline unset bond_$ifline
fi fi
done done
/usr/sbin/brctl addif $br $brif || error=1 brctl addif $br $brif || error=1
fi fi
done done
fi fi
@ -214,7 +208,7 @@ bridge_up() {
bridge_down() { bridge_down() {
for br in ${BRIDGE_INTERFACES[@]}; do for br in ${BRIDGE_INTERFACES[@]}; do
if [[ $br = ${br#!} ]]; then if [[ $br = ${br#!} ]]; then
/usr/sbin/brctl delbr $br brctl delbr $br
fi fi
done done
} }
@ -294,12 +288,12 @@ case "$1" in
;; ;;
restart) restart)
$0 stop $0 stop
/bin/sleep 2 sleep 2
$0 start $0 start
;; ;;
ifup|ifdown|iflist|rtup|rtdown|rtlist) ifup|ifdown|iflist|rtup|rtdown|rtlist)
# deprecation check # deprecation check
need_legacy && deprecated deprecated
$1 $2 $1 $2
;; ;;
*) *)

View file

@ -9,15 +9,16 @@
# LOCALE: available languages can be listed with the 'locale -a' command # LOCALE: available languages can be listed with the 'locale -a' command
# DAEMON_LOCALE: If set to 'yes', use $LOCALE as the locale during daemon # 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. # 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) # in the hardware clock being left untouched (useful for virtualization)
# Note: Using "localtime" is discouraged. # Note: Using "localtime" is discouraged, using "" makes hwclock fall back
# to the value in /var/lib/hwclock/adjfile
# TIMEZONE: timezones are found in /usr/share/zoneinfo # TIMEZONE: timezones are found in /usr/share/zoneinfo
# Note: if unset, the value in /etc/localtime is used unchanged
# KEYMAP: keymaps are found in /usr/share/kbd/keymaps # KEYMAP: keymaps are found in /usr/share/kbd/keymaps
# CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US) # CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
# CONSOLEMAP: found in /usr/share/kbd/consoletrans # CONSOLEMAP: found in /usr/share/kbd/consoletrans
# USECOLOR: use ANSI color sequences in startup messages # USECOLOR: use ANSI color sequences in startup messages
# VERBOSE: Verbose level (from 1 to 8). man 3 syslog for level info
# #
LOCALE="en_US.UTF-8" LOCALE="en_US.UTF-8"
DAEMON_LOCALE="no" DAEMON_LOCALE="no"
@ -27,7 +28,6 @@ KEYMAP="us"
CONSOLEFONT= CONSOLEFONT=
CONSOLEMAP= CONSOLEMAP=
USECOLOR="yes" USECOLOR="yes"
VERBOSE="3"
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# HARDWARE # HARDWARE
@ -66,13 +66,15 @@ HOSTNAME="alarm"
# Wired network setup # Wired network setup
# - interface: name of device (required) # - interface: name of device (required)
# - address: IP address (leave blank for DHCP) # - address: IP address (leave blank for DHCP)
# - netmask: subnet mask (ignored for DHCP) # - netmask: subnet mask (ignored for DHCP) (optional, defaults to 255.255.255.0)
# - broadcast: broadcast address (ignored for DHCP) (optional)
# - gateway: default route (ignored for DHCP) # - gateway: default route (ignored for DHCP)
# #
# Static IP example # Static IP example
# interface=eth0 # interface=eth0
# address=192.168.0.2 # address=192.168.0.2
# netmask=255.255.255.0 # netmask=255.255.255.0
# broadcast=192.168.0.255
# gateway=192.168.0.1 # gateway=192.168.0.1
# #
# DHCP example # DHCP example
@ -84,6 +86,7 @@ HOSTNAME="alarm"
interface=eth0 interface=eth0
address= address=
netmask= netmask=
broadcast=
gateway= gateway=
# Setting this to "yes" will skip network shutdown. # Setting this to "yes" will skip network shutdown.

View file

@ -1,14 +1,22 @@
#!/bin/bash #!/bin/bash
NEED_ROOT=0 # this script can be run without be root
. /etc/rc.conf . /etc/rc.conf
. /etc/rc.d/functions . /etc/rc.d/functions
usage() { usage() {
local name=${0##*/} local name=${0##*/}
cat >&2 << EOF cat >&2 << EOF
usage: $name action daemon ... usage: $name <action> <daemon> [daemon] ...
$name list [started|stopped]
$name help
<daemon> is the name of a script in /etc/rc.d
<action> can be a start, stop, restart, reload, status, ...
WARNING: initscripts are free to implement or not the above actions.
e.g: $name list e.g: $name list
$name list started
$name help $name help
$name start sshd gpm $name start sshd gpm
EOF EOF
@ -23,13 +31,16 @@ case $1 in
usage usage
;; ;;
list) list)
shift
cd /etc/rc.d/ cd /etc/rc.d/
for d in *; do for d in *; do
have_daemon "$d" || continue have_daemon "$d" || continue
# print running / stopped satus # print running / stopped satus
if ! ck_daemon "$d"; then if ! ck_daemon "$d"; then
[[ "$1" == stopped ]] && continue
printf "${C_OTHER}[${C_DONE}STARTED${C_OTHER}]" printf "${C_OTHER}[${C_DONE}STARTED${C_OTHER}]"
else else
[[ "$1" == started ]] && continue
printf "${C_OTHER}[${C_FAIL}STOPPED${C_OTHER}]" printf "${C_OTHER}[${C_FAIL}STOPPED${C_OTHER}]"
fi fi
# print auto / manual status # print auto / manual status
@ -40,7 +51,7 @@ case $1 in
fi fi
printf " ${C_CLEAR}$d\n" printf " ${C_CLEAR}$d\n"
done done
;; ;;
*) *)
# check min args count # check min args count
(( $# < 2 )) && usage (( $# < 2 )) && usage
@ -56,12 +67,13 @@ case $1 in
cd / cd /
for i; do for i; do
if [[ -x "/etc/rc.d/$i" ]]; then if [[ -x "/etc/rc.d/$i" ]]; then
/usr/bin/env -i "${ENV[@]}" "/etc/rc.d/$i" "$action" env -i "${ENV[@]}" "/etc/rc.d/$i" "$action"
else else
printf "${C_OTHER}:: ${C_FAIL}Error: ${C_DONE}Daemon script $i does not exist.\n" printf "${C_OTHER}:: ${C_FAIL}Error: ${C_DONE}Daemon script $i does not exist.${C_CLEAR}\n"
fi fi
(( ret += !! $? )) # clamp exit value to 0/1 (( ret += !! $? )) # clamp exit value to 0/1
done done
;;
esac esac
exit $ret exit $ret

View file

@ -9,7 +9,7 @@
run_hook multi_start run_hook multi_start
# Load sysctl variables if sysctl.conf is present # Load sysctl variables if sysctl.conf is present
[[ -r /etc/sysctl.conf ]] && /sbin/sysctl -q -p &>/dev/null [[ -r /etc/sysctl.conf ]] && sysctl -q -p &>/dev/null
# Start daemons # Start daemons
for daemon in "${DAEMONS[@]}"; do for daemon in "${DAEMONS[@]}"; do
@ -20,14 +20,10 @@ for daemon in "${DAEMONS[@]}"; do
esac esac
done done
if [[ -x /etc/rc.local ]]; then [[ -x /etc/rc.local ]] && /etc/rc.local
/etc/rc.local
fi
run_hook multi_end run_hook multi_end
/bin/touch /var/log/boot bootlogd_stop
kill `/bin/cat /run/bootlogd.pid`
/bin/rm /run/bootlogd.pid
# vim: set ts=2 sw=2 noet: # vim: set ts=2 sw=2 noet:

View file

@ -6,88 +6,84 @@
. /etc/rc.conf . /etc/rc.conf
. /etc/rc.d/functions . /etc/rc.d/functions
run_hook shutdown_start
# avoid staircase effect # avoid staircase effect
/bin/stty onlcr stty onlcr
echo " " echo " "
printhl "Initiating Shutdown..." printhl "Initiating Shutdown..."
echo " " echo " "
run_hook shutdown_start
[[ -x /etc/rc.local.shutdown ]] && /etc/rc.local.shutdown [[ -x /etc/rc.local.shutdown ]] && /etc/rc.local.shutdown
kill_everything shutdown stop_all_daemons
run_hook shutdown_prekillall
kill_all
run_hook shutdown_postkillall
stat_busy "Saving Random Seed" stat_busy "Saving Random Seed"
RANDOM_SEED=/var/lib/misc/random-seed RANDOM_SEED=/var/lib/misc/random-seed
[[ -d ${RANDOM_SEED%/*} ]] || mkdir -p ${RANDOM_SEED%/*} install -TDm 0600 <(:) $RANDOM_SEED
: > $RANDOM_SEED POOL_FILE=/proc/sys/kernel/random/poolsize
/bin/chmod 0600 $RANDOM_SEED if [[ -r $POOL_FILE ]]; then
POOL_FILE=/proc/sys/kernel/random/poolsize read POOL_SIZE < $POOL_FILE
if [[ -r $POOL_FILE ]]; then else
read POOL_SIZE <$POOL_FILE POOL_SIZE=512
else fi
POOL_SIZE=512 dd if=/dev/urandom of=$RANDOM_SEED count=1 bs=$POOL_SIZE &>/dev/null
fi
/bin/dd if=/dev/urandom of=$RANDOM_SEED count=1 bs=$POOL_SIZE &> /dev/null
stat_done stat_done
if [[ $TIMEZONE && -e /usr/share/zoneinfo/$TIMEZONE ]]; then [[ $TIMEZONE ]] &&
/bin/rm -f /etc/localtime
status "Saving Time Zone" \ status "Saving Time Zone" \
/bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime cp --remove-destination "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
fi
# Write to wtmp file before unmounting # Write to wtmp file before unmounting
/sbin/halt -w halt -w
status "Deactivating Swap" /sbin/swapoff -a status "Deactivating Swap" swapoff -a
# stop monitoring of lvm2 groups before unmounting filesystems # stop monitoring of lvm2 groups before unmounting filesystems
if [[ $USELVM =~ yes|YES && -x /sbin/lvm && -d /sys/block ]]; then [[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]] &&
status "Deactivating monitoring of LVM2 groups" \ status "Deactivating monitoring of LVM2 groups" \
/sbin/vgchange --monitor n >/dev/null 2>&1 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 /bin/grep -q devtmpfs /proc/filesystems &>/dev/null; then status "Unmounting Filesystems" \
/bin/umount -a -r -t nosysfs,noproc,nodevtmpfs,nodevpts -O no_netdev umount -a -r -t nodevtmpfs,notmpfs,nosysfs,noproc,nodevpts -O no_netdev
else
# if we don't have devtmpfs support, /dev is mounted as tmpfs, so don't unmount it run_hook shutdown_postumount
/bin/umount -a -r -t notmpfs,nosysfs,noproc,nodevpts -O no_netdev
fi
stat_done
# Kill non-root encrypted partition mappings # Kill non-root encrypted partition mappings
if [[ -f /etc/crypttab && -n $CS ]] && /bin/grep -q ^[^#] /etc/crypttab; then if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then
stat_busy "Deactivating encrypted volumes:" stat_busy "Deactivating encrypted volumes:"
# Maybe someone has LVM on an encrypted block device # Maybe someone has LVM on an encrypted block device
# executing an extra vgchange is errorless # executing an extra vgchange is errorless
if [[ $USELVM =~ yes|YES ]]; then [[ $USELVM = [Yy][Ee][Ss] ]] && vgchange --sysinit -a n &>/dev/null
/sbin/vgchange --sysinit -a n >/dev/null 2>&1 do_lock() {
fi stat_append "${1}.."
do_lock() { if $CS remove "$1" &>/dev/null; then
stat_append "${1}.." stat_append "ok "
if $CS remove "$1" >/dev/null 2>&1; then else
stat_append "ok " stat_append "failed "
else fi
stat_append "failed " }
fi read_crypttab do_lock
}
read_crypttab do_lock
stat_done stat_done
fi fi
if [[ $USELVM =~ yes|YES && -x /sbin/lvm && -d /sys/block ]]; then [[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]] &&
status "Deactivating LVM2 groups" /sbin/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" /bin/mount -n -o remount,ro / status "Remounting Root Filesystem Read-only" \
mount -n -o remount,ro /
run_hook shutdown_poweroff run_hook shutdown_poweroff
# PlugApps: Turn LEDs off # ALARM: Turn LEDs off
/usr/bin/find /sys/ -path *led* -name *trigger* -exec sh -c '/bin/echo none > {}' \; /usr/bin/find /sys/ -path *led* -name *trigger* -exec sh -c '/bin/echo none > {}' \;
@ -95,12 +91,12 @@ run_hook shutdown_poweroff
printsep printsep
if [[ $RUNLEVEL = 0 ]]; then if [[ $RUNLEVEL = 0 ]]; then
printhl "${C_H2}POWER OFF" printhl "${C_H2}POWER OFF"
/sbin/poweroff -d -f -h -i poweroff -d -f -h -i
else else
printhl "${C_H2}REBOOTING" printhl "${C_H2}REBOOTING"
# if kexec is installed and a kernel is loaded, use it # if kexec is installed and a kernel is loaded, use it
[[ -x /sbin/kexec ]] && /sbin/kexec -e > /dev/null 2>&1 [[ -x $(type -P kexec) ]] && kexec -e &>/dev/null
/sbin/reboot -d -f -i reboot -d -f -i
fi fi
# End of file # End of file

View file

@ -9,48 +9,36 @@
run_hook single_start run_hook single_start
if [[ $PREVLEVEL != N ]]; then if [[ $PREVLEVEL != N ]]; then
kill_everything single
status "Starting UDev Daemon" /sbin/udevd --daemon
run_hook single_udevlaunched
# Trigger udev uevents stop_all_daemons
if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then
stat_busy "Triggering UDev uevents"
/sbin/udevadm trigger --action=add --type=subsystems
/sbin/udevadm trigger --action=add --type=devices
stat_done
fi
# Wait for udev uevents run_hook single_prekillall
if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then
status "Waiting for UDev uevents to be processed" \
/sbin/udevadm settle --quiet --timeout=${UDEV_TIMEOUT:-30}
fi
run_hook single_udevsettled kill_all
# try syslog-NG first, then fall back to good ol' syslogd run_hook single_postkillall
if [[ -x /etc/rc.d/syslog-ng ]]; then
/etc/rc.d/syslog-ng start # start up our mini logger until syslog takes over
elif [[ -x /etc/rc.d/syslogd ]]; then minilogd
/etc/rc.d/syslogd start
[[ -x /etc/rc.d/klogd ]] && /etc/rc.d/klogd start # Start/trigger UDev, load MODULES and settle UDev
fi udevd_modprobe single
# Removing leftover files
remove_leftover
fi fi
run_hook single_end run_hook single_end
bootlogd_stop
if [[ $RUNLEVEL = 1 ]]; then if [[ $RUNLEVEL = 1 ]]; then
printsep printsep
printhl "Entering single-user mode..." printhl "Entering single-user mode..."
# make sure /dev/initctl is in place # make sure /dev/initctl is in place
kill -HUP 1 kill -HUP 1
exec /sbin/init -t1 S exec init -t1 S
fi fi
/bin/touch /var/log/boot
kill `/bin/cat /run/bootlogd.pid`
/bin/rm /run/bootlogd.pid
# End of file # End of file
# vim: set ts=2 sw=2 noet: # vim: set ts=2 sw=2 noet:

View file

@ -11,139 +11,99 @@ printhl "Arch Linux ARM\n"
printhl "${C_H2}http://www.archlinuxarm.org" printhl "${C_H2}http://www.archlinuxarm.org"
printsep printsep
run_hook sysinit_start
# 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) # mount /proc, /sys, /run, /dev, /run/lock, /dev/pts, /dev/shm (the api filesystems)
/bin/mountpoint -q /proc || /bin/mount -n -t proc proc /proc -o nosuid,noexec,nodev mountpoint -q /proc || mount -n -t proc proc /proc -o nosuid,noexec,nodev
/bin/mountpoint -q /sys || /bin/mount -n -t sysfs sysfs /sys -o nosuid,noexec,nodev mountpoint -q /sys || mount -n -t sysfs sys /sys -o nosuid,noexec,nodev
/bin/mountpoint -q /run || /bin/mount -n -t tmpfs tmpfs /run -o mode=755,size=10M,nosuid,noexec,nodev mountpoint -q /run || mount -n -t tmpfs run /run -o mode=0755,size=10M,nosuid,nodev
if ! /bin/mountpoint -q /dev; then mountpoint -q /dev || mount -n -t devtmpfs udev /dev -o mode=0755,size=10M,nosuid &>/dev/null \
if /bin/grep -q devtmpfs /proc/filesystems &>/dev/null; then || mount -n -t tmpfs udev /dev -o mode=0755,size=10M,nosuid
/bin/mount -n -t devtmpfs udev /dev -o mode=0755,size=10M,nosuid mkdir -p -m 1777 /run/lock
else mkdir -p /dev/{pts,shm}
/bin/mount -n -t tmpfs udev /dev -o mode=0755,size=10M,nosuid mountpoint -q /dev/pts || mount -n /dev/pts &>/dev/null \
fi || mount -n -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec
fi mountpoint -q /dev/shm || mount -n /dev/shm &>/dev/null \
/bin/mkdir -p /run/lock /dev/{pts,shm} || mount -n -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev
/bin/chmod 1777 /run/lock
/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 -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 # remount root ro to allow for fsck later on, we remount now to
# make sure nothing can open files rw on root which would block a remount # make sure nothing can open files rw on root which would block a remount
/bin/findmnt / --options ro &>/dev/null || \ findmnt / --options ro &>/dev/null ||
status "Mounting Root Read-Only" /bin/mount -n -o remount,ro / status "Mounting Root Read-Only" mount -n -o remount,ro /
run_hook sysinit_start
# start up our mini logger until syslog takes over # start up our mini logger until syslog takes over
/sbin/minilogd minilogd
/sbin/bootlogd -p /run/bootlogd.pid bootlogd -p /run/bootlogd.pid
# Set console verbosity HWCLOCK_PARAMS="--systz"
for cmdarg in $(< /proc/cmdline); do
[[ "$cmdarg" == verbose ]] && VERBOSE=8 && break
[[ "$cmdarg" =~ verbose=[1-8] ]] && VERBOSE=${BASH_REMATCH[0]-8} && break
done
/bin/dmesg -n ${VERBOSE:-3}
HWCLOCK_PARAMS="--hctosys"
case $HARDWARECLOCK in case $HARDWARECLOCK in
UTC) HWCLOCK_PARAMS+=" --utc";; "") ;;
localtime) HWCLOCK_PARAMS+=" --localtime";; UTC) HWCLOCK_PARAMS+=" --utc --noadjfile";;
localtime) HWCLOCK_PARAMS+=" --localtime --noadjfile";;
*) HWCLOCK_PARAMS="";; *) HWCLOCK_PARAMS="";;
esac esac
if [[ $HWCLOCK_PARAMS ]]; then if [[ $HWCLOCK_PARAMS ]]; then
# enable rtc access stat_busy "Adjusting system time and setting kernel timezone"
/sbin/modprobe -q -a rtc-cmos rtc genrtc # enable rtc access
# If devtmpfs is used, the required RTC device already exists now modprobe -q -a rtc-cmos rtc genrtc
# Otherwise, create whatever device is available # If devtmpfs is used, the required RTC device already exists now
if ! [[ -c /dev/rtc || -c /dev/rtc0 ]]; then # Otherwise, create whatever device is available
for dev in /sys/class/rtc/rtc0/dev /sys/class/misc/rtc/dev; do if ! [[ -c /dev/rtc || -c /dev/rtc0 ]]; then
[[ -e $dev ]] || continue for dev in /sys/class/rtc/rtc0/dev /sys/class/misc/rtc/dev; do
IFS=: read -r major minor < "$dev" [[ -e $dev ]] || continue
/bin/mknod /dev/rtc c $major $minor IFS=: read -r major minor < "$dev"
done mknod /dev/rtc c $major $minor
fi done
fi
# Do a clock set here for a few reasons: # Adjust the system time for timezone offset if rtc is not in UTC
# 1. Make creation time on udev nodes sane (FS#8665) # 1. Make creation time on udev nodes sane (FS#8665)
# 2. Filesystem checks can depend on system time # 2. Filesystem checks can depend on system time
# 3. This will set the clock, if using non-UTC, off the last known # 3. This also sets the kernel time zone, used by e.g. vfat
# configured timezone. Any new timezone put in rc.conf is copied over at # If TIMEZONE is not set in rc.conf, the timezone stored in /etc/localtime
# a later time. # is used. If HARDWARECLOCK is not set in rc.conf, the value in
# This does *NOT* take into account a time adjustment file as /var may not be # /var/lib/hwclock/adjfile is used (in this case /var can not be a separate
# mounted yet. A second set may occur in rc.d/hwclock to match rc.conf. # partition).
if [[ -f /etc/localtime ]]; then TZ=$TIMEZONE hwclock $HWCLOCK_PARAMS && stat_done || stat_fail
/sbin/hwclock $HWCLOCK_PARAMS --noadjfile
fi
fi fi
status "Starting UDev Daemon" /sbin/udevd --daemon # Start/trigger UDev, load MODULES and settle UDev
udevd_modprobe sysinit
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
stat_done
fi
# Load modules from the MODULES array defined in rc.conf
mods=${MODULES[@]/!*/}
if [[ $load_modules != off && -f /proc/modules && $mods ]]; then
status "Loading Modules" /sbin/modprobe --all $mods
fi
unset mods
# Wait for udev uevents
if /bin/pidof /sbin/udevd &>/dev/null; then
status "Waiting for UDev uevents to be processed" \
/sbin/udevadm settle --quiet --timeout=${UDEV_TIMEOUT:-30}
fi
run_hook sysinit_udevsettled
# bring up the loopback interface # bring up the loopback interface
[[ -d /sys/class/net/lo ]] && \ [[ -d /sys/class/net/lo ]] &&
status "Bringing up loopback interface" /sbin/ip link set up dev lo status "Bringing up loopback interface" ip link set up dev lo
# FakeRAID devices detection # FakeRAID devices detection
if [[ $USEDMRAID =~ yes|YES && -x /sbin/dmraid ]]; then [[ $USEDMRAID = [Yy][Ee][Ss] && -x $(type -P dmraid) ]] &&
status "Activating FakeRAID arrays" /sbin/dmraid -i -ay status "Activating FakeRAID arrays" dmraid -i -ay
fi
# BTRFS devices detection # BTRFS devices detection
if [[ $USEBTRFS =~ yes|YES && -x /sbin/btrfs ]]; then [[ $USEBTRFS = [Yy][Ee][Ss] && -x $(type -P btrfs) ]] &&
status "Activating BTRFS volumes" /sbin/btrfs device scan status "Activating BTRFS volumes" btrfs device scan
fi
# Activate LVM2 groups if any
activate_vgs activate_vgs
# Set up non-root encrypted partition mappings # Set up non-root encrypted partition mappings
if [[ -f /etc/crypttab && -n $CS ]] && /bin/grep -q ^[^#] /etc/crypttab; then if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then
/sbin/modprobe -q dm-crypt 2>/dev/null
stat_busy "Unlocking encrypted volumes:" stat_busy "Unlocking encrypted volumes:"
modprobe -q dm-crypt 2>/dev/null
do_unlock() { do_unlock() {
# $1 = requested name # $1 = requested name
# $2 = source device # $2 = source device
# $3 = password # $3 = password
# $4 = options # $4 = options
stat_append "${1}.." stat_append "${1}.."
local open=create a="$1" b="$2" failed=0 local open=create a=$1 b=$2 failed=0
# Ordering of options is different if you are using LUKS vs. not. # Ordering of options is different if you are using LUKS vs. not.
# Use ugly swizzling to deal with it. # Use ugly swizzling to deal with it.
# isLuks only gives an exit code but no output to stdout or stderr. # isLuks only gives an exit code but no output to stdout or stderr.
if $CS isLuks "$2" 2>/dev/null; then if $CS isLuks "$2" 2>/dev/null; then
open=luksOpen open=luksOpen
a="$2" a=$2
b="$1" b=$1
fi fi
case $3 in case $3 in
SWAP) SWAP)
@ -158,50 +118,48 @@ if [[ -f /etc/crypttab && -n $CS ]] && /bin/grep -q ^[^#] /etc/crypttab; then
# #
# This sanity check _should_ be sufficient, but it might not. # This sanity check _should_ be sufficient, but it might not.
# This may cause dataloss if it is not used carefully. # This may cause dataloss if it is not used carefully.
/sbin/blkid -p "$2" &>/dev/null blkid -p "$2" &>/dev/null
if [[ $? -eq 2 ]]; then (( $? == 2 )) && _overwriteokay=1
_overwriteokay=1
fi
fi fi
if [[ $_overwriteokay -eq 0 ]]; then if (( _overwriteokay == 0 )); then
false false
elif $CS -d /dev/urandom $4 $open "$a" "$b" >/dev/null; then elif $CS -d /dev/urandom $4 $open "$a" "$b" >/dev/null; then
stat_append "creating swapspace.." stat_append "creating swapspace.."
/sbin/mkswap -f -L $1 /dev/mapper/$1 >/dev/null mkswap -f -L $1 /dev/mapper/$1 >/dev/null
fi;; fi;;
ASK) ASK)
printf "\nOpening '$1' volume:\n" printf "\nOpening '$1' volume:\n"
$CS $4 $open "$a" "$b" < /dev/console;; $CS $4 $open "$a" "$b" < /dev/console;;
/dev*) /dev*)
ckdev=${3%%:*} local ckdev=${3%%:*}
cka=${3#*:} local cka=${3#*:}
ckb=${cka#*:} local ckb=${cka#*:}
cka=${cka%:*} local cka=${cka%:*}
ckfile=/dev/ckfile local ckfile=/dev/ckfile
ckdir=/dev/ckdir local ckdir=/dev/ckdir
case ${cka} in case ${cka} in
*[!0-9]*) *[!0-9]*)
# Use a file on the device # Use a file on the device
# cka is not numeric: cka=filesystem, ckb=path # cka is not numeric: cka=filesystem, ckb=path
/bin/mkdir ${ckdir} mkdir ${ckdir}
/bin/mount -r -t ${cka} ${ckdev} ${ckdir} mount -r -t ${cka} ${ckdev} ${ckdir}
/bin/dd if=${ckdir}/${ckb} of=${ckfile} >/dev/null 2>&1 dd if=${ckdir}/${ckb} of=${ckfile} >/dev/null 2>&1
/bin/umount ${ckdir} umount ${ckdir}
/bin/rmdir ${ckdir};; rmdir ${ckdir};;
*) *)
# Read raw data from the block device # Read raw data from the block device
# cka is numeric: cka=offset, ckb=length # cka is numeric: cka=offset, ckb=length
/bin/dd if=${ckdev} of=${ckfile} bs=1 skip=${cka} count=${ckb} >/dev/null 2>&1;; dd if=${ckdev} of=${ckfile} bs=1 skip=${cka} count=${ckb} >/dev/null 2>&1;;
esac esac
$CS -d ${ckfile} $4 $open "$a" "$b" >/dev/null $CS -d ${ckfile} $4 $open "$a" "$b" >/dev/null
/bin/dd if=/dev/urandom of=${ckfile} bs=1 count=`stat -c %s ${ckfile}` conv=notrunc >/dev/null 2>&1 dd if=/dev/urandom of=${ckfile} bs=1 count=$(stat -c %s ${ckfile}) conv=notrunc >/dev/null 2>&1
rm ${ckfile};; rm ${ckfile};;
/*) /*)
$CS -d "$3" $4 $open "$a" "$b" >/dev/null;; $CS -d "$3" $4 $open "$a" "$b" >/dev/null;;
*) *)
echo "$3" | $CS $4 $open "$a" "$b" >/dev/null;; echo "$3" | $CS $4 $open "$a" "$b" >/dev/null;;
esac esac
if (($? != 0)); then if (( $? )); then
failed=1 failed=1
stat_append "failed " stat_append "failed "
else else
@ -210,173 +168,112 @@ if [[ -f /etc/crypttab && -n $CS ]] && /bin/grep -q ^[^#] /etc/crypttab; then
return $failed return $failed
} }
crypto_unlocked=0 crypto_unlocked=0
if read_crypttab do_unlock; then read_crypttab do_unlock && stat_done || stat_fail
stat_done # Maybe someone has LVM on an encrypted block device
else (( crypto_unlocked == 1 )) && activate_vgs
stat_fail
fi
if [[ ${crypto_unlocked} -eq 1 ]]; then
# Maybe someone has LVM on an encrypted block device
activate_vgs
fi
fi fi
NETFS="nonfs,nonfs4,nosmbfs,nocifs,nocodafs,noncpfs,nosysfs,noshfs,nofuse,nofuseblk,noglusterfs,nodavfs" # Check filesystems
[[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-- -f"
if [[ -x /sbin/fsck ]]; then declare -r FORCEFSCK
run_hook sysinit_prefsck
if [[ -x $(type -P fsck) ]]; then
stat_busy "Checking Filesystems" stat_busy "Checking Filesystems"
fsck_reboot() { fsck_all >|"${FSCK_OUT:-/dev/stdout}" 2>|"${FSCK_ERR:-/dev/stdout}"
echo "Automatic reboot in progress..." declare -r fsckret=$?
/bin/umount -a (( fsckret <= 1 )) && stat_done || stat_fail
/bin/mount -n -o remount,ro / else
/sbin/reboot -f declare -r fsckret=0
exit 0 fi
} run_hook sysinit_postfsck
FSCK_OUT=/dev/stdout
FSCK_ERR=/dev/stdout # Single-user login and/or automatic reboot if needed
FSCK_FD= fsck_reboot $fsckret
FORCEFSCK=
[[ -f /forcefsck ]] && FORCEFSCK="-- -f" status "Remounting Root Read/Write" \
for cmdarg in $(< /proc/cmdline); do mount -n -o remount,rw /
[[ "$cmdarg" == forcefsck ]] && FORCEFSCK="-- -f" && break
done # don't touch /etc/mtab if it is a symlink to /proc/self/mounts
run_hook sysinit_prefsck if [[ ! -L /etc/mtab ]]; then
/sbin/fsck -A -T -C$FSCK_FD -a -t "$NETFS,noopts=_netdev" $FORCEFSCK >$FSCK_OUT 2>$FSCK_ERR stat_busy "Creating mtab"
fsckret=$? if [[ -x $(type -P findmnt) && -e /proc/self/mountinfo ]]; then
if ((fsckret > 1)); then findmnt -rnu -o SOURCE,TARGET,FSTYPE,OPTIONS >| /etc/mtab
stat_fail else
fi cat /proc/mounts >| /etc/mtab
run_hook sysinit_postfsck fi
if (( ( fsckret & 2) == 2)); then (( $? == 0 )) && stat_done || stat_fail
echo
echo "********************** REBOOT REQUIRED *********************"
echo "* *"
echo "* The system will be rebooted automatically in 15 seconds. *"
echo "* *"
echo "************************************************************"
echo
/bin/sleep 15
fsck_reboot
elif ((fsckret > 1 && fsckret != 32)); then
echo
echo "***************** FILESYSTEM CHECK FAILED ****************"
echo "* *"
echo "* Please repair manually and reboot. Note that the root *"
echo "* file system is currently mounted read-only. To remount *"
echo "* it read-write type: mount -n -o remount,rw / *"
echo "* When you exit the maintenance shell the system will *"
echo "* reboot automatically. *"
echo "* *"
echo "************************************************************"
echo
/sbin/sulogin -p
fsck_reboot
fi
stat_done
fi fi
stat_busy "Mounting Local Filesystems" # now mount all the local filesystems
/bin/mount -n -o remount,rw / run_hook sysinit_premount
status "Mounting Local Filesystems" \
# don't touch /etc/mtab if it is a symlink to /proc/self/mounts mount_all
if [[ -L /etc/mtab ]]; then run_hook sysinit_postmount
:
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
stat_done
# enable monitoring of lvm2 groups, now that the filesystems are mounted rw # enable monitoring of lvm2 groups, now that the filesystems are mounted rw
if [[ $USELVM =~ yes|YES && -x /sbin/lvm && -d /sys/block ]]; then [[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]] &&
status "Activating monitoring of LVM2 groups" \ status "Activating monitoring of LVM2 groups" \
/sbin/vgchange --monitor y >/dev/null vgchange --monitor y >/dev/null
fi
status "Activating Swap" /sbin/swapon -a status "Activating Swap" swapon -a
if [[ $TIMEZONE && -e /usr/share/zoneinfo/$TIMEZONE ]]; then [[ $TIMEZONE ]] &&
/bin/rm -f /etc/localtime
status "Configuring Time Zone" \ status "Configuring Time Zone" \
/bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime cp --remove-destination "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
fi
RANDOM_SEED=/var/lib/misc/random-seed RANDOM_SEED=/var/lib/misc/random-seed
if [[ -f $RANDOM_SEED ]]; then [[ -f $RANDOM_SEED ]] &&
status "Initializing Random Seed" \ status "Initializing Random Seed" \
/bin/cat $RANDOM_SEED > /dev/urandom cp $RANDOM_SEED /dev/urandom
fi
stat_busy "Removing Leftover Files" # Remove leftover files
/bin/rm -rf /etc/{nologin,shutdownpid} /forcefsck &>/dev/null remove_leftover
/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
stat_done
if [[ $HOSTNAME ]]; then if [[ $HOSTNAME ]]; then
stat_busy "Setting Hostname: $HOSTNAME" stat_busy "Setting Hostname: $HOSTNAME"
echo $HOSTNAME > /proc/sys/kernel/hostname echo "$HOSTNAME" >| /proc/sys/kernel/hostname && stat_done || stat_fail
stat_done
fi fi
# Flush old locale settings and set user defined locale
stat_busy "Setting Locale: ${LOCALE:=en_US}" stat_busy "Setting Locale: ${LOCALE:=en_US}"
# Flush old locale settings echo "export LANG=$LOCALE" > /etc/profile.d/locale.sh &&
: >| /etc/profile.d/locale.sh chmod 0755 /etc/profile.d/locale.sh && stat_done || stat_fail
/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 if [[ ${LOCALE,,} =~ utf ]]; then
stat_busy "Setting Consoles to UTF-8 mode" stat_busy "Setting Consoles to UTF-8 mode"
# UTF-8 consoles are default since 2.6.24 kernel # UTF-8 consoles are default since 2.6.24 kernel
# this code is needed not only for older kernels, # this code is needed not only for older kernels,
# but also when user has set vt.default_utf8=0 but LOCALE is *.UTF-8. # but also when user has set vt.default_utf8=0 but LOCALE is *.UTF-8.
for i in /dev/tty[0-9]*; do for i in /dev/tty[0-9]*; do
/usr/bin/kbd_mode -u < ${i} kbd_mode -u < ${i}
printf "\e%%G" > ${i} printf "\e%%G" > ${i}
done done
echo 1 > /sys/module/vt/parameters/default_utf8 echo 1 >| /sys/module/vt/parameters/default_utf8
stat_done stat_done
[[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" /bin/loadkeys -q -u $KEYMAP
else else
stat_busy "Setting Consoles to legacy mode" stat_busy "Setting Consoles to legacy mode"
# make non-UTF-8 consoles work on 2.6.24 and newer kernels # make non-UTF-8 consoles work on 2.6.24 and newer kernels
for i in /dev/tty[0-9]*; do for i in /dev/tty[0-9]*; do
/usr/bin/kbd_mode -a < ${i} kbd_mode -a < ${i}
printf "\e%%@" > ${i} printf "\e%%@" > ${i}
done done
echo 0 > /sys/module/vt/parameters/default_utf8 echo 0 >| /sys/module/vt/parameters/default_utf8
stat_done stat_done
[[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" /bin/loadkeys -q $KEYMAP
fi fi
[[ $KEYMAP ]] &&
status "Loading Keyboard Map: $KEYMAP" loadkeys -q $KEYMAP
# Set console font if required # Set console font if required
set_consolefont set_consolefont
# Adding persistent network/cdrom generated rules stat_busy "Saving dmesg Log"
# When the rules are generated before /etc is mounted rw they are saved to /run, if [[ -e /proc/sys/kernel/dmesg_restrict ]] &&
# we therefore need to copy this from /run to /etc. This functionality is going away one day. (( $(< /proc/sys/kernel/dmesg_restrict) == 1 )); then
for f in cd net; do install -Tm 0600 <( dmesg ) /var/log/dmesg.log
[[ -f /run/udev/tmp-rules--70-persistent-$f.rules ]] || continue else
status "Adding persistent $f udev rules" install -Tm 0644 <( dmesg ) /var/log/dmesg.log
/bin/cat "/run/udev/tmp-rules--70-persistent-$f.rules" >> "/etc/udev/rules.d/70-persistent-$f.rules" fi
done (( $? == 0 )) && stat_done || stat_fail
/bin/dmesg >| /var/log/dmesg.log
run_hook sysinit_end run_hook sysinit_end

View file

@ -0,0 +1,20 @@
#
# /usr/lib/tmpfiles.d/arch.conf
#
D /tmp 1777 root root
D /run/daemons 0755 root root
d /tmp/.X11-unix 1777 root root
d /tmp/.ICE-unix 1777 root root
d /tmp/.XIM-unix 1777 root root
d /tmp/.font-unix 1777 root root
d /tmp/.Test-unix 1777 root root
F /var/run/utmp 0664 root utmp
r /tmp/.X[0-9]-lock
r /etc/nologin
r /etc/shutdownpid
r /forcefsck

View file

@ -15,9 +15,12 @@ _rc.d () {
curcontext="${curcontext%:*:*}:rc.d-${action}:" curcontext="${curcontext%:*:*}:rc.d-${action}:"
case $action in case $action in
list|help) help)
_arguments "*: :" _arguments "*: :"
;; ;;
list)
_arguments "2: :(started stopped)"
;;
start) start)
_arguments "*: :($(comm -23 <(echo /etc/rc.d/*(N-*:t)|tr ' ' '\n') <(echo /run/daemons/*(N:t)|tr ' ' '\n')))" _arguments "*: :($(comm -23 <(echo /etc/rc.d/*(N-*:t)|tr ' ' '\n') <(echo /run/daemons/*(N:t)|tr ' ' '\n')))"
;; ;;