core/initscripts to 2012.01.3

This commit is contained in:
Kevin Mihelich 2012-01-21 17:21:45 -05:00
parent db7ba9882f
commit c1ead68ada
23 changed files with 91 additions and 2194 deletions

View file

@ -1,35 +0,0 @@
VER := $(shell git describe)
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
installdirs:
install -dm755 $(foreach DIR, $(DIRS), $(DESTDIR)$(DIR))
install: minilogd installdirs
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 -m644 -t $(DESTDIR)/etc/logrotate.d bootlog
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 -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 zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d
clean:
rm -f minilogd minilogd.o
release:
git archive HEAD --prefix=initscripts-$(VER)/ | xz > initscripts-$(VER).tar.xz

View file

@ -1,80 +1,49 @@
# Maintainer: Mike Staszel <mikestaszel@plugapps.com>
# $Id$
# Maintainer: Tom Gundersen <teg@jklm.no>
# Contributor: Thomas Bächler <thomas@archlinux.org>
# Contributor: Aaron Griffin <aaron@archlinux.org>
# ALARM changes: inittab has a line for ttyS0 at 115200, 2 ttys
# for armv5te, 6 for armv7
# rc.shutdown has an LED turn-off line
# rc.conf is different
# rc.sysinit has our copyright info
# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
# - inittab serial setup for v5/v7
# - patch to adjust naming to ALARM, fix remounting root, turn off LEDs on shutdown
plugrel=1
noautobuild=1
pkgname=initscripts
pkgver=2011.07.3
pkgver=2012.01.3
pkgrel=1
pkgdesc="System initialization/bootup scripts"
plugrel=1
arch=('arm' 'armv7h')
url="http://www.archlinuxarm.org"
arch=('any')
url="http://www.archlinux.org"
license=('GPL2')
groups=('base')
backup=(etc/inittab etc/rc.conf etc/rc.local etc/rc.local.shutdown etc/conf.d/wireless)
depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=171' 'iproute2'
depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=174' 'iproute2'
'ncurses' 'kbd' 'findutils' 'sysvinit')
optdepends=('bridge-utils: Network bridging support'
'dhcpcd: DHCP network configuration'
'net-tools: legacy network support'
'wireless_tools: Wireless networking')
makedepends=(asciidoc)
install=initscripts.install
source=(arch-tmpfiles
bash-completion
bootlog
functions
hwclock
inittab
inittab.armv7
Makefile
minilogd.c
netfs
network
rc.conf
rc.d
rc.local
rc.local.shutdown
rc.multi
rc.shutdown
rc.single
rc.sysinit
tmpfiles.conf
wireless.conf.d
zsh-completion)
md5sums=('3f889b8993f56460fd93f47436a67845'
'2733ca8c0ef21a0c2f58ea2fb6dc8c4a'
'5d253f4da16e543efaff53ac9684c1c6'
'3c59d41b921ab471a82781819946d15e'
'f5a999a8a280154dbf56d5f714cc4e52'
'f02566fd9a1eeac3aadd5d6af32453c5'
'6260da9309cdcfd68444867dc91d574a'
'126ead847b9c9136ccbc2fd90576831a'
'2c2dcc7ce7586f27fc5e6887f8ec74b8'
'4ca1cb187131ef4c570a3d28cb9c4040'
'15b8356952306ebf081a34b21a584b4b'
'c618e099f522f861e08a475f8960a6c2'
'dc3397395140d3d4341e780042ed2968'
'bd236a57bc00aa4727b98c5ae401c457'
'669ce6d766dd9deb86686219f3763fe4'
'3fe2916688c65100a63f2ec417821571'
'8bfdbfd09ba8851837dc390470a3cfb0'
'6be273bc0a206734cffc82cd7e34b487'
'ca2ddb4fcdd20dd96c227d6640db9bc1'
'93a31c4c3dd41d82e7bf923d71897133'
source=("ftp://ftp.archlinux.org/other/initscripts/${pkgname}-${pkgver}.tar.xz"
'wireless.conf.d'
'alarm.patch'
'rc.conf')
md5sums=('3d4e02ddefb0c7e8ae7000161ae89448'
'027576534885b8d5dded9be546057b12'
'b2b960ae69bbb63b1b4cd0a81f793089')
'7593a88cdc36d92bd286687ca4340eb1'
'c618e099f522f861e08a475f8960a6c2')
package() {
cd ${srcdir}
cd ${srcdir}/${pkgname}-${pkgver}
patch -p1 -i "${srcdir}/alarm.patch"
cp "${srcdir}/rc.conf" .
[ "${CARCH}" == "arm" ] && sed -i 's/@TTY@/ttyS0/' inittab
[ "${CARCH}" == "armv7h" ] && sed -i 's/@TTY@/ttyO2/' inittab
make DESTDIR=${pkgdir} install
install -D -m644 ${srcdir}/wireless.conf.d ${pkgdir}/etc/conf.d/wireless
# On the armv7 boards, all ttys are enabled in this inittab file
if [ "${CARCH}" = "armv7h" ]; then
install -D -m644 inittab.armv7 ${pkgdir}/etc/inittab
fi
}

View file

@ -0,0 +1,58 @@
diff -urN a/inittab b/inittab
--- a/inittab 2012-01-18 16:02:04.000000000 -0700
+++ b/inittab 2012-01-21 14:44:00.000000000 -0700
@@ -24,12 +24,13 @@
su:S:wait:/sbin/sulogin -p
# -8 options fixes umlauts problem on login
+s0:12345:respawn:/sbin/agetty -8 -s 115200 @TTY@ 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
+#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 -s 9600 ttyS0 linux
diff -urN a/rc.shutdown b/rc.shutdown
--- a/rc.shutdown 2012-01-18 16:02:04.000000000 -0700
+++ b/rc.shutdown 2012-01-21 14:44:00.000000000 -0700
@@ -87,6 +87,10 @@
run_hook shutdown_poweroff
+# ALARM: Turn LEDs off
+
+/usr/bin/find /sys/ -path *led* -name *trigger* -exec sh -c '/bin/echo none > {}' \;
+
if [[ -x /run/initramfs/shutdown ]]; then
# decide what we want to do
diff -urN a/rc.sysinit b/rc.sysinit
--- a/rc.sysinit 2012-01-18 16:02:04.000000000 -0700
+++ b/rc.sysinit 2012-01-21 14:44:22.000000000 -0700
@@ -7,8 +7,8 @@
. /etc/rc.d/functions
echo " "
-printhl "Arch Linux\n"
-printhl "${C_H2}http://www.archlinux.org"
+printhl "Arch Linux ARM\n"
+printhl "${C_H2}http://www.archlinuxarm.org"
printsep
# mount /proc, /sys, /run, /dev, /run/lock, /dev/pts, /dev/shm (the api filesystems)
@@ -190,7 +190,7 @@
fsck_reboot $fsckret
status "Remounting Root" \
- mount -o remount /
+ mount -o remount,rw /
# now mount all the local filesystems
run_hook sysinit_premount

View file

@ -1,250 +0,0 @@
#!/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,24 +0,0 @@
# rc.d bash completion by Seblu <seblu@seblu.net>
_rc_d()
{
local action cur prev
action="help list start stop reload restart"
_get_comp_words_by_ref cur prev
if ((COMP_CWORD == 1)); then
COMPREPLY=($(compgen -W "${action}" -- "$cur"))
elif [[ "$prev" == help ]]; then
COMPREPLY=()
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)))
elif [[ "$prev" =~ 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:

View file

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

View file

@ -1,537 +0,0 @@
#!/bin/bash
# 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:
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=$(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
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
TERM_COLORS=$(tput colors 2>/dev/null)
if (( $? != 3 )); then
case $TERM_COLORS in
*[!0-9]*) USECOLOR="";;
[0-7]) USECOLOR="";;
'') USECOLOR="";;
esac
fi
unset TERM_COLORS
# clear the TZ envvar, so daemons always respect /etc/localtime
unset TZ
# sanitize the locale settins
unset LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE \
LC_MEASUREMENT LC_IDENTIFICATION LC_ALL
if [[ $DAEMON_LOCALE = [yY][eE][sS] && $LOCALE ]]; then
export LANG="${LOCALE}"
else
export LANG=C
fi
# set colors
if [[ $USECOLOR = [yY][eE][sS] ]]; then
if tput setaf 0 &>/dev/null; then
C_CLEAR=$(tput sgr0) # clear text
C_MAIN=${C_CLEAR}$(tput bold) # main text
C_OTHER=${C_MAIN}$(tput setaf 4) # prefix & brackets
C_SEPARATOR=${C_MAIN}$(tput setaf 0) # separator
C_BUSY=${C_CLEAR}$(tput setaf 6) # busy
C_FAIL=${C_MAIN}$(tput setaf 1) # failed
C_DONE=${C_MAIN} # completed
C_BKGD=${C_MAIN}$(tput setaf 5) # backgrounded
C_H1=${C_MAIN} # highlight text 1
C_H2=${C_MAIN}$(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
# prefixes:
PREFIX_REG="::"
PREFIX_HL=" >"
# functions:
deltext() {
printf "${DEL_TEXT}"
}
printhl() {
printf "${C_OTHER}${PREFIX_HL} ${C_H1}${1}${C_CLEAR} \n"
}
printsep() {
printf "\n${C_SEPARATOR} ------------------------------\n"
}
stat_bkgd() {
printf "${C_OTHER}${PREFIX_REG} ${C_MAIN}${1}${C_CLEAR} "
deltext
printf " ${C_OTHER}[${C_BKGD}BKGD${C_OTHER}]${C_CLEAR} "
}
stat_busy() {
printf "${C_OTHER}${PREFIX_REG} ${C_MAIN}${1}${C_CLEAR} "
printf "${SAVE_POSITION}"
deltext
printf " ${C_OTHER}[${C_BUSY}BUSY${C_OTHER}]${C_CLEAR} "
}
stat_append() {
printf "${RESTORE_POSITION}"
printf -- "${C_MAIN}${1}${C_CLEAR}"
printf "${SAVE_POSITION}"
}
stat_done() {
deltext
printf " ${C_OTHER}[${C_DONE}DONE${C_OTHER}]${C_CLEAR} \n"
}
stat_fail() {
deltext
printf " ${C_OTHER}[${C_FAIL}FAIL${C_OTHER}]${C_CLEAR} \n"
}
stat_die() {
stat_fail
exit ${1:-1}
}
status() {
stat_busy "$1"
shift
"$@" &>/dev/null
local ret=$?
(( ret == 0 )) && stat_done || stat_fail
return $ret
}
# usage : in_array( $needle, $haystack )
# return : 0 - found
# 1 - not found
in_array() {
local needle=$1; shift
local item
for item; do
[[ $item = "${needle}" ]] && return 0
done
return 1 # Not Found
}
# daemons:
add_daemon() {
[[ -d /run/daemons ]] || mkdir -p /run/daemons
>| /run/daemons/"$1"
}
rm_daemon() {
rm -f /run/daemons/"$1"
}
ck_daemon() {
[[ ! -f /run/daemons/$1 ]]
}
# Check if $1 is a valid daemon name
have_daemon() {
[[ -f /etc/rc.d/$1 && -x /etc/rc.d/$1 ]]
}
# Check if $1 is started at boot
ck_autostart() {
local daemon
for daemon in "${DAEMONS[@]}"; do
[[ $1 = "${daemon#@}" ]] && return 1
done
return 0
}
start_daemon() {
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() {
local daemon
for daemon; do
ck_daemon "$daemon" && start_daemon "$daemon"
done
}
start_daemon_bkgd() {
stat_bkgd "Starting $1"
have_daemon "$1" && (start_daemon "$1") &>/dev/null &
}
stop_daemon() {
have_daemon "$1" && /etc/rc.d/"$1" stop
}
# Status functions
status_started() {
deltext
echo -ne "$C_OTHER[${C_STRT}STARTED$C_OTHER]$C_CLEAR "
}
status_stopped() {
deltext
echo -ne "$C_OTHER[${C_STRT}STOPPED$C_OTHER]$C_CLEAR "
}
ck_status() {
! ck_daemon "$1" && status_started || 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
return 1
}
# PIDs to be omitted by killall5
declare -a omit_pids
add_omit_pids() {
omit_pids+=( $@ )
}
# Stop all daemons
# This function should *never* ever perform any other actions beside calling stop_daemon()!
# It might be used by a splash system etc. to get a list of daemons to be stopped.
stop_all_daemons() {
# Find daemons NOT in the DAEMONS array. Shut these down first
local daemon
for daemon in /run/daemons/*; do
[[ -f $daemon ]] || continue
daemon=${daemon##*/}
ck_autostart "$daemon" && stop_daemon "$daemon"
done
# Shutdown daemons in reverse order
local i daemon
for (( i=${#DAEMONS[@]}-1; i>=0; i-- )); do
[[ ${DAEMONS[i]} = '!'* ]] && continue
daemon=${DAEMONS[i]#@}
ck_daemon "$daemon" || stop_daemon "$daemon"
done
}
kill_all() {
# 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"
local i
killall5 -15 ${omit_pids[@]/#/-o } &>/dev/null
for (( i=0; i<20 && $?!=2; i++ )); do
sleep .25 # 1/4 second
killall5 -18 ${omit_pids[@]/#/-o } &>/dev/null
done
stat_done
stat_busy "Sending SIGKILL To Processes"
local i
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
# 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() {
[[ $USELVM = [yY][eE][sS] && -x $(type -P lvm) && -d /sys/block ]] || return 0
# Kernel 2.6.x, LVM2 groups
stat_busy "Activating LVM2 groups"
modprobe -q dm-mod 2>/dev/null
vgchange --sysinit -a y >/dev/null
(( $? == 0 )) && stat_done || stat_fail
}
# Arch cryptsetup packages traditionally contained the binaries
# /usr/sbin/cryptsetup
# /sbin/cryptsetup.static
# By default, initscripts used the /sbin/cryptsetup.static.
# Newer packages will only have /sbin/cryptsetup and no static binary
# This ensures maximal compatibility with the old and new layout
for CS in /sbin/cryptsetup /usr/sbin/cryptsetup \
/sbin/cryptsetup.static ''; do
[[ -x $CS ]] && break
done
read_crypttab() {
# $1 = function to call with the split out line from the crypttab
local line nspo failed=0
while read line; do
[[ $line && $line != '#'* ]] || continue
eval nspo=("${line%#*}")
if $1 "${nspo[0]}" "${nspo[1]}" "${nspo[2]}" "${nspo[*]:3}"; then
crypto_unlocked=1
else
failed=1
fi
done < /etc/crypttab
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 #
###############################
# Hooks can be used to include custom code in various places in the rc.* scripts
#
# Define a hook function in a functions.d file using:
# function_name() {
# ...
# }
# add_hook hook_name function_name
# It is allowed to register several hook functions for the same hook
# Is is also allowed to register the same hook function for several hooks
#
# Currently, the following hooks exist:
# sysinit_start: at the beginning of rc.sysinit
# multi_start: at the beginning of rc.multi
# single_start: at the beginning of rc.single
# shutdown_start: at the beginning of rc.shutdown
# sysinit_end: at the end of rc.sysinit
# multi_end: at the end of rc.multi
# single_end: at the end of rc.single
# sysinit_udevlaunched: after udev has been launched in rc.sysinit
# single_udevlaunched: after udev has been launched in rc.single
# sysinit_udevsettled: after uevents have settled in rc.sysinit
# 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_postmount: after local filesystems are mounted
# shutdown_prekillall: before all processes are being killed in rc.shutdown
# single_prekillall: before all processes are being killed in rc.single
# shutdown_postkillall: after all processes have been killed in rc.shutdown
# 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
#
# Declare add_hook and run_hook as read-only to prevent overwriting them.
# Too bad we cannot do the same thing with hook_funcs
if (( RC_FUNCTIONS_HOOK_FUNCS_DEFINED != 1 )); then
declare -A hook_funcs
add_hook() {
[[ $1 && $2 ]] || return 1
hook_funcs[$1]+=" $2"
}
run_hook() {
[[ $1 ]] || return 1
local func
for func in ${hook_funcs["$1"]}; do
"${func}"
done
}
declare -fr add_hook run_hook
declare -r RC_FUNCTIONS_HOOK_FUNCS_DEFINED=1
fi
# Function for setting console font if required
set_consolefont() {
[[ $CONSOLEFONT ]] || return 0
stat_busy "Loading Console Font: $CONSOLEFONT"
#CONSOLEMAP in UTF-8 shouldn't be used
[[ $CONSOLEMAP && ${LOCALE,,} =~ utf ]] && CONSOLEMAP=""
local i
for i in /dev/tty[0-9]*; do
setfont ${CONSOLEMAP:+-m "${CONSOLEMAP}"} \
"$CONSOLEFONT" -C ${i} &>/dev/null
done
if (( $? )); then
stat_fail
elif [[ $CONSOLEMAP ]]; then
cat <<"EOF" >>/etc/profile.d/locale.sh
if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\033(K"; fi
EOF
stat_done
else
stat_done
fi
}
# Source additional functions at the end to allow overrides
for f in /etc/rc.d/functions.d/*; do
[[ -e $f ]] && . "$f"
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
# vim: set ts=2 sw=2 noet:

View file

@ -1,30 +0,0 @@
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
case $HARDWARECLOCK in
UTC) HWCLOCK_PARAMS="--utc";;
localtime) HWCLOCK_PARAMS="--localtime";;
*) HWCLOCK_PARAMS="";;
esac
case "$1" in
start)
add_daemon hwclock;;
stop)
case $HARDWARECLOCK in
UTC) hwclock --adjust --utc;;
localtime) hwclock --adjust --localtime;;
"") hwclock --adjust;;
esac
rm_daemon hwclock
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac

View file

@ -12,4 +12,8 @@ post_upgrade() {
echo "VERBOSE= in rc.conf no longer has any effect."
echo "Please append 'quiet' to your kernel command line."
fi
if [ "$(vercmp $2 2011.10.1)" -lt 0 ]; then
echo "If using non-bash-compatible shell, please set LANG in /etc/locale.conf,"
echo "as LOCALE in /etc/rc.conf no longer works."
fi
}

View file

@ -1,49 +0,0 @@
#
# /etc/inittab
#
# Runlevels:
# 0 Halt
# 1(S) Single-user
# 2 Not used
# 3 Multi-user
# 4 Not used
# 5 X11
# 6 Reboot
## Only one of the following two lines can be uncommented!
# Boot to console
id:3:initdefault:
# Boot to X11
#id:5:initdefault:
rc::sysinit:/etc/rc.sysinit
rs:S1:wait:/etc/rc.single
rm:2345:wait:/etc/rc.multi
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 -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 -s 9600 ttyS0 linux
# Hypervisor Virtual Console for Xen and KVM
#h0:2345:respawn:/sbin/agetty -8 -s 38400 hvc0 linux
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
# Example lines for starting a login manager
x:5:respawn:/usr/bin/xdm -nodaemon
#x:5:respawn:/usr/sbin/gdm -nodaemon
#x:5:respawn:/usr/bin/kdm -nodaemon
#x:5:respawn:/usr/bin/slim >/dev/null 2>&1
# End of file

View file

@ -1,49 +0,0 @@
#
# /etc/inittab
#
# Runlevels:
# 0 Halt
# 1(S) Single-user
# 2 Not used
# 3 Multi-user
# 4 Not used
# 5 X11
# 6 Reboot
## Only one of the following two lines can be uncommented!
# Boot to console
id:3:initdefault:
# Boot to X11
#id:5:initdefault:
rc::sysinit:/etc/rc.sysinit
rs:S1:wait:/etc/rc.single
rm:2345:wait:/etc/rc.multi
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 -s 115200 ttyO2 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 -s 9600 ttyS0 linux
# Hypervisor Virtual Console for Xen and KVM
#h0:2345:respawn:/sbin/agetty -8 -s 38400 hvc0 linux
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
# Example lines for starting a login manager
x:5:respawn:/usr/bin/xdm -nodaemon
#x:5:respawn:/usr/sbin/gdm -nodaemon
#x:5:respawn:/usr/bin/kdm -nodaemon
#x:5:respawn:/usr/bin/slim >/dev/null 2>&1
# End of file

View file

@ -1,202 +0,0 @@
/* minilogd.c
*
* A pale imitation of syslogd. Most notably, doesn't write anything
* anywhere except possibly back to syslogd.
*
*/
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <stdarg.h>
#include <syslog.h>
#ifndef __USE_BSD
# define __USE_BSD
#endif
#include <unistd.h>
#include <sys/poll.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
#define MAX_BUF_LINES 10000
#define BUF_LINE_SIZE 8192
static int we_own_log=0;
static char **buffer=NULL;
static int buflines=0;
int debug;
int recvsock;
void alarm_handler(int x) {
alarm(0);
close(recvsock);
recvsock = -1;
}
void freeBuffer() {
struct sockaddr_un addr;
int sock;
int x=0,conn;
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_LOCAL;
strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1);
/* wait for klogd to hit syslog */
sleep(2);
sock = socket(AF_LOCAL, SOCK_STREAM,0);
conn=connect(sock,(struct sockaddr *) &addr,(socklen_t)sizeof(addr));
while (x<buflines) {
if (!conn) {
/*printf("to syslog: %s\n", buffer[x]);*/
write(sock,buffer[x],strlen(buffer[x])+1);
}
free(buffer[x]);
x++;
}
free(buffer);
}
void cleanup(int exitcode) {
/* If we own the log, unlink it before trying to free our buffer.
* Otherwise, sending the buffer to /dev/log doesn't make much sense.... */
if (we_own_log) {
perror("wol");
unlink(_PATH_LOG);
}
/* Don't try to free buffer if we were called from a signal handler */
if (exitcode<=0) {
if (buffer)
freeBuffer();
exit(exitcode);
} else
exit(exitcode+128);
}
void runDaemon(int sock) {
struct sockaddr_un addr;
int x,done=0;
ssize_t len;
socklen_t addrlen = (socklen_t)sizeof(struct sockaddr_un);
char *message = NULL;
struct stat s1,s2;
struct pollfd pfds;
daemon(0,-1);
/* try not to leave stale sockets lying around */
/* Hopefully, we won't actually get any of these */
signal(SIGHUP,cleanup);
signal(SIGINT,cleanup);
signal(SIGQUIT,cleanup);
signal(SIGILL,cleanup);
signal(SIGABRT,cleanup);
signal(SIGFPE,cleanup);
signal(SIGSEGV,cleanup);
signal(SIGPIPE,cleanup);
signal(SIGBUS,cleanup);
signal(SIGTERM,cleanup);
done = 0;
/* Get stat info on /dev/log so we can later check to make sure we
* still own it... */
if (stat(_PATH_LOG,&s1) != 0)
memset(&s1, 0, sizeof(struct stat));
while (!done) {
pfds.fd = sock;
pfds.events = POLLIN|POLLPRI;
pfds.revents = 0;
if ( ( (x=poll(&pfds,1,500))==-1) && errno !=EINTR) {
perror("poll");
cleanup(-1);
}
if ( (x>0) && (pfds.revents & (POLLIN | POLLPRI))) {
if (message == NULL) {
message = calloc(BUF_LINE_SIZE,sizeof(char));
}
recvsock = accept(sock,(struct sockaddr *) &addr, &addrlen);
alarm(2);
signal(SIGALRM, alarm_handler);
len = read(recvsock,message,BUF_LINE_SIZE);
alarm(0);
close(recvsock);
if (len>0) {
/*printf("line recv'd: %s\n", message);*/
if (buflines < MAX_BUF_LINES) {
if (buffer)
buffer = realloc(buffer,(buflines+1)*sizeof(char *));
else
buffer = malloc(sizeof(char *));
message[strlen(message)]='\n';
buffer[buflines]=message;
message = NULL;
buflines++;
}
}
else {
recvsock=-1;
}
}
if ( (x>0) && ( pfds.revents & (POLLHUP | POLLNVAL)) )
done = 1;
/* Check to see if syslogd's yanked our socket out from under us */
if ( (stat(_PATH_LOG,&s2)!=0) ||
(s1.st_ino != s2.st_ino ) || (s1.st_ctime != s2.st_ctime) ||
(s1.st_mtime != s2.st_mtime) ) { /*|| (s1.st_atime != s2.st_atime) ) {*/
done = 1;
we_own_log = 0;
/*printf("someone stole our %s\n", _PATH_LOG);
printf("st_ino: %d %d\n", s1.st_ino, s2.st_ino);
printf("st_ctime: %d %d\n", s1.st_ctime, s2.st_ctime);
printf("st_atime: %d %d\n", s1.st_atime, s2.st_atime);
printf("st_mtime: %d %d\n", s1.st_mtime, s2.st_mtime);*/
}
}
free(message);
cleanup(0);
}
int main(int argc, char **argv) {
struct sockaddr_un addr;
int sock;
int pid;
/* option processing made simple... */
if (argc>1) debug=1;
/* just in case */
sock = open("/dev/null",O_RDWR);
dup2(sock,0);
dup2(sock,1);
dup2(sock,2);
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_LOCAL;
strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1);
sock = socket(AF_LOCAL, SOCK_STREAM,0);
unlink(_PATH_LOG);
/* Bind socket before forking, so we know if the server started */
if (!bind(sock,(struct sockaddr *) &addr, (socklen_t)sizeof(addr))) {
we_own_log = 1;
listen(sock,5);
if ((pid=fork())==-1) {
perror("fork");
exit(3);
}
if (pid) {
exit(0);
} else {
/*printf("starting daemon...\n");*/
runDaemon(sock);
/* shouldn't get back here... */
exit(4);
}
} else {
exit(5);
}
}
/* vim: set ts=2 noet: */

View file

@ -1,36 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. /etc/rc.conf
. /etc/rc.d/functions
case "$1" in
start)
stat_busy "Mounting Network Filesystems"
mount -a -t "$NETFS"
rc=$?
mount -a -O _netdev
(( rc || $? )) && stat_die
add_daemon netfs
stat_done
;;
stop)
stat_busy "Unmounting Network Filesystems"
umount -a -O _netdev
rc=$?
umount -a -t "$NETFS"
(( rc || $? )) && stat_die
rm_daemon netfs
stat_done
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
exit 1
esac
# vim: set ts=2 noet:

View file

@ -1,304 +0,0 @@
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
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() {
# complain when `interface' is unset and `INTERFACES' has profiles enabled
if [[ -z $interface && ${INTERFACES[@]##!*} ]]; then
return 0 # need legacy
fi
return 1 # enough present for iproute2 support
}
deprecated() {
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 " connection, or use a utility such as netcfg.\n"
}
network_up() {
ip link set dev $interface up || return 1
if [[ $address ]]; then
ip addr add $address/${netmask:-24} broadcast ${broadcast:-+} dev $interface || return 1
[[ $gateway ]] && { ip route add default via $gateway || return 1; }
else
dhcpcd $DHCPCD_ARGS $interface || return 1
fi
}
network_down() {
if [[ -f /var/run/dhcpcd-$interface.pid ]]; then
dhcpcd -k $interface || return 1
else
ip addr flush dev $interface || return 1
fi
ip link set dev $interface down || return 1
}
ifup() {
local ifcfg=${!1}
if [[ ! $1 ]]; then
echo "usage: $0 ifup <interface_name>"
return 1
fi
# Get the name of the interface from the first token in the string
if [[ $ifcfg = dhcp ]]; then
ifname=$1
else
ifname=${ifcfg%% *}
fi
ifconfig $ifname up
wi_up $1 || return 1
if [[ $ifcfg = dhcp ]]; then
# remove the .pid file if it exists
rm -f /var/run/dhcpcd-${1}.pid >/dev/null 2>&1
rm -f /var/run/dhcpcd-${1}.cache >/dev/null 2>&1
dhcpcd $DHCPCD_ARGS ${1}
else
ifconfig $ifcfg
fi
}
wi_up() {
local iwcfg=wlan_$1
[[ ${!iwcfg} ]] || return 0
iwconfig ${!iwcfg}
[[ $WIRELESS_TIMEOUT ]] || WIRELESS_TIMEOUT=2
sleep $WIRELESS_TIMEOUT
bssid=$(iwgetid $1 -ra)
if [[ $bssid = 00:00:00:00:00:00 ]]; then
printhl "Could not associate $1 - try increasing WIRELESS_TIMEOUT and check network is WEP or has no security"
return 1
fi
return 0
}
ifdown() {
local ifcfg=${!1}
if [[ ! $1 ]]; then
echo "usage: $0 ifdown <interface_name>"
return 1
fi
if [[ $ifcfg = dhcp && -f /var/run/dhcpcd-${1}.pid ]]; then
dhcpcd -k ${1} >/dev/null 2>&1
fi
# Always bring the interface itself down
ifconfig ${1} down >/dev/null 2>&1
}
iflist() {
for ifline in ${INTERFACES[@]}; do
if [[ $ifline = ${ifline#!} ]]; then
printf " $ifline:\t"
else
printf "$ifline:\t"
fi
echo ${!ifline#!}
done
}
rtup() {
local routecfg=${!1}
if [[ ! $1 ]]; then
echo "usage: $0 rtup <route_name>"
return 1
fi
if [[ $routecfg =~ :: ]]; then
route -A inet6 add $routecfg
else
route add $routecfg
fi
}
rtdown() {
local routecfg=${!1}
if [[ ! $1 ]]; then
echo "usage: $0 rtdown <route_name>"
return 1
fi
if [[ $routecfg =~ :: ]]; then
route -A inet6 del $routecfg
else
route del $routecfg
fi
}
rtlist() {
for rtline in ${ROUTES[@]}; do
if [[ $rtline = ${rtline#!} ]]; then
printf " $rtline:\t"
else
printf "$rtline:\t"
fi
echo ${!rtline#!}
done
}
bond_up() {
for ifline in ${BOND_INTERFACES[@]}; do
if [[ $ifline = ${ifline#!} ]]; then
bondcfg="bond_$ifline"
if [[ ${!bondcfg} ]]; then
ifenslave $ifline ${!bondcfg} || error=1
fi
fi
done
}
bond_down() {
for ifline in ${BOND_INTERFACES[@]}; do
if [[ $ifline = ${ifline#!} ]]; then
bondcfg="bond_$ifline"
ifenslave -d $ifline ${!bondcfg} || error=1
fi
done
}
bridge_up() {
for br in ${BRIDGE_INTERFACES[@]}; do
if [[ $br = ${br#!} ]]; then
# if the bridge already exists, remove it
if [[ $(ifconfig $br 2>/dev/null) ]]; then
ifconfig $br down
brctl delbr $br
fi
brctl addbr $br
brifs="bridge_$br"
for brif in ${!brifs}; do
if [[ $brif = ${brif#!} ]]; then
for ifline in ${BOND_INTERFACES[@]}; do
if [[ $brif = $ifline && $ifline = ${ifline#!} ]]; then
ifup $ifline
bondcfg="bond_$ifline"
ifenslave $ifline ${!bondcfg} || error=1
unset bond_$ifline
fi
done
brctl addif $br $brif || error=1
fi
done
fi
done
}
bridge_down() {
for br in ${BRIDGE_INTERFACES[@]}; do
if [[ $br = ${br#!} ]]; then
brctl delbr $br
fi
done
}
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
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
else
stat_fail
fi
;;
stop)
# deprecation check
need_legacy && deprecated
if [[ $NETWORK_PERSIST =~ yes|YES && $RUNLEVEL == [06] ]]; then
status "Skipping Network Shutdown" true
exit 0
fi
stat_busy "Stopping Network"
rm_daemon network
error=0
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
stat_fail
fi
;;
restart)
$0 stop
sleep 2
$0 start
;;
ifup|ifdown|iflist|rtup|rtdown|rtlist)
# deprecation check
deprecated
$1 $2
;;
*)
echo "usage: $0 {start|stop|restart}"
echo " $0 {ifup|ifdown|iflist|rtup|rtdown|rtlist}";;
esac
# vim: set ts=2 sw=2 noet:

View file

@ -1,81 +0,0 @@
#!/bin/bash
NEED_ROOT=0 # this script can be run without be root
. /etc/rc.conf
. /etc/rc.d/functions
usage() {
local name=${0##*/}
cat >&2 << EOF
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
$name list started
$name help
$name start sshd gpm
EOF
exit 1
}
(( $# < 1 )) && usage
declare -i ret=0
case $1 in
help)
usage
;;
list)
shift
cd /etc/rc.d/
for d in *; do
have_daemon "$d" || continue
# print running / stopped satus
if ! ck_daemon "$d"; then
[[ "$1" == stopped ]] && continue
printf "${C_OTHER}[${C_DONE}STARTED${C_OTHER}]"
else
[[ "$1" == started ]] && continue
printf "${C_OTHER}[${C_FAIL}STOPPED${C_OTHER}]"
fi
# print auto / manual status
if ! ck_autostart "$d"; then
printf "${C_OTHER}[${C_DONE}AUTO${C_OTHER}]"
else
printf "${C_OTHER}[${C_FAIL} ${C_OTHER}]"
fi
printf " ${C_CLEAR}$d\n"
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"
"PREVLEVEL=${runlevel%% *}"
"RUNLEVEL=${runlevel##* }"
"CONSOLE=${CONSOLE:-/dev/console}"
"TERM=$TERM")
cd /
for i; do
if [[ -x "/etc/rc.d/$i" ]]; then
env -i "${ENV[@]}" "/etc/rc.d/$i" "$action"
else
printf "${C_OTHER}:: ${C_FAIL}Error: ${C_DONE}Daemon script $i does not exist.${C_CLEAR}\n"
fi
(( ret += !! $? )) # clamp exit value to 0/1
done
;;
esac
exit $ret
# vim: set ts=2 sw=2 ft=sh noet:

View file

@ -1,6 +0,0 @@
#!/bin/bash
#
# /etc/rc.local: Local multi-user startup script.
#

View file

@ -1,5 +0,0 @@
#!/bin/bash
#
# /etc/rc.local.shutdown: Local shutdown script.
#

View file

@ -1,29 +0,0 @@
#!/bin/bash
#
# /etc/rc.multi
#
. /etc/rc.conf
. /etc/rc.d/functions
run_hook multi_start
# Load sysctl variables if sysctl.conf is present
[[ -r /etc/sysctl.conf ]] && sysctl -q -p &>/dev/null
# Start daemons
for daemon in "${DAEMONS[@]}"; do
case ${daemon:0:1} in
'!') continue;; # Skip this daemon.
'@') start_daemon_bkgd "${daemon#@}";;
*) start_daemon "$daemon";;
esac
done
[[ -x /etc/rc.local ]] && /etc/rc.local
run_hook multi_end
bootlogd_stop
# vim: set ts=2 sw=2 noet:

View file

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

View file

@ -1,44 +0,0 @@
#!/bin/bash
#
# /etc/rc.single: Single-user startup script.
#
. /etc/rc.conf
. /etc/rc.d/functions
run_hook single_start
if [[ $PREVLEVEL != N ]]; then
stop_all_daemons
run_hook single_prekillall
kill_all
run_hook single_postkillall
# start up our mini logger until syslog takes over
minilogd
# Start/trigger UDev, load MODULES and settle UDev
udevd_modprobe single
# Removing leftover files
remove_leftover
fi
run_hook single_end
bootlogd_stop
if [[ $RUNLEVEL = 1 ]]; then
printsep
printhl "Entering single-user mode..."
# make sure /dev/initctl is in place
kill -HUP 1
exec init -t1 S
fi
# End of file
# vim: set ts=2 sw=2 noet:

View file

@ -1,281 +0,0 @@
#!/bin/bash
#
# /etc/rc.sysinit
#
. /etc/rc.conf
. /etc/rc.d/functions
echo " "
printhl "Arch Linux ARM\n"
printhl "${C_H2}http://www.archlinuxarm.org"
printsep
# mount /proc, /sys, /run, /dev, /run/lock, /dev/pts, /dev/shm (the api filesystems)
mountpoint -q /proc || mount -n -t proc proc /proc -o nosuid,noexec,nodev
mountpoint -q /sys || mount -n -t sysfs sys /sys -o nosuid,noexec,nodev
mountpoint -q /run || mount -n -t tmpfs run /run -o mode=0755,size=10M,nosuid,nodev
mountpoint -q /dev || mount -n -t devtmpfs udev /dev -o mode=0755,size=10M,nosuid &>/dev/null \
|| mount -n -t tmpfs udev /dev -o mode=0755,size=10M,nosuid
mkdir -p -m 1777 /run/lock
mkdir -p /dev/{pts,shm}
mountpoint -q /dev/pts || mount -n /dev/pts &>/dev/null \
|| mount -n -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec
mountpoint -q /dev/shm || mount -n /dev/shm &>/dev/null \
|| mount -n -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev
# remount root ro to allow for fsck later on, we remount now to
# make sure nothing can open files rw on root which would block a remount
findmnt / --options ro &>/dev/null ||
status "Mounting Root Read-Only" mount -n -o remount,ro /
run_hook sysinit_start
# start up our mini logger until syslog takes over
minilogd
bootlogd -p /run/bootlogd.pid
HWCLOCK_PARAMS="--systz"
case $HARDWARECLOCK in
"") ;;
UTC) HWCLOCK_PARAMS+=" --utc --noadjfile";;
localtime) HWCLOCK_PARAMS+=" --localtime --noadjfile";;
*) HWCLOCK_PARAMS="";;
esac
if [[ $HWCLOCK_PARAMS ]]; then
stat_busy "Adjusting system time and setting kernel timezone"
# enable rtc access
modprobe -q -a rtc-cmos rtc genrtc
# If devtmpfs is used, the required RTC device already exists now
# Otherwise, create whatever device is available
if ! [[ -c /dev/rtc || -c /dev/rtc0 ]]; then
for dev in /sys/class/rtc/rtc0/dev /sys/class/misc/rtc/dev; do
[[ -e $dev ]] || continue
IFS=: read -r major minor < "$dev"
mknod /dev/rtc c $major $minor
done
fi
# Adjust the system time for timezone offset if rtc is not in UTC
# 1. Make creation time on udev nodes sane (FS#8665)
# 2. Filesystem checks can depend on system time
# 3. This also sets the kernel time zone, used by e.g. vfat
# If TIMEZONE is not set in rc.conf, the timezone stored in /etc/localtime
# is used. If HARDWARECLOCK is not set in rc.conf, the value in
# /var/lib/hwclock/adjfile is used (in this case /var can not be a separate
# partition).
TZ=$TIMEZONE hwclock $HWCLOCK_PARAMS && stat_done || stat_fail
fi
# Start/trigger UDev, load MODULES and settle UDev
udevd_modprobe sysinit
# bring up the loopback interface
[[ -d /sys/class/net/lo ]] &&
status "Bringing up loopback interface" ip link set up dev lo
# FakeRAID devices detection
[[ $USEDMRAID = [Yy][Ee][Ss] && -x $(type -P dmraid) ]] &&
status "Activating FakeRAID arrays" dmraid -i -ay
# BTRFS devices detection
[[ $USEBTRFS = [Yy][Ee][Ss] && -x $(type -P btrfs) ]] &&
status "Activating BTRFS volumes" btrfs device scan
# Activate LVM2 groups if any
activate_vgs
# Set up non-root encrypted partition mappings
if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then
stat_busy "Unlocking encrypted volumes:"
modprobe -q dm-crypt 2>/dev/null
do_unlock() {
# $1 = requested name
# $2 = source device
# $3 = password
# $4 = options
stat_append "${1}.."
local open=create a=$1 b=$2 failed=0
# Ordering of options is different if you are using LUKS vs. not.
# Use ugly swizzling to deal with it.
# isLuks only gives an exit code but no output to stdout or stderr.
if $CS isLuks "$2" 2>/dev/null; then
open=luksOpen
a=$2
b=$1
fi
case $3 in
SWAP)
local _overwriteokay=0
if [[ -b $2 && -r $2 ]]; then
# This is DANGEROUS! If there is any known file system,
# partition table, RAID or LVM volume on the device
# we don't overwrite it.
#
# 'blkid' returns 2 if no valid signature has been found.
# Only in this case we should allow overwriting the device.
#
# This sanity check _should_ be sufficient, but it might not.
# This may cause dataloss if it is not used carefully.
blkid -p "$2" &>/dev/null
(( $? == 2 )) && _overwriteokay=1
fi
if (( _overwriteokay == 0 )); then
false
elif $CS -d /dev/urandom $4 $open "$a" "$b" >/dev/null; then
stat_append "creating swapspace.."
mkswap -f -L $1 /dev/mapper/$1 >/dev/null
fi;;
ASK)
printf "\nOpening '$1' volume:\n"
$CS $4 $open "$a" "$b" < /dev/console;;
/dev*)
local ckdev=${3%%:*}
local cka=${3#*:}
local ckb=${cka#*:}
local cka=${cka%:*}
local ckfile=/dev/ckfile
local ckdir=/dev/ckdir
case ${cka} in
*[!0-9]*)
# Use a file on the device
# cka is not numeric: cka=filesystem, ckb=path
mkdir ${ckdir}
mount -r -t ${cka} ${ckdev} ${ckdir}
dd if=${ckdir}/${ckb} of=${ckfile} >/dev/null 2>&1
umount ${ckdir}
rmdir ${ckdir};;
*)
# Read raw data from the block device
# cka is numeric: cka=offset, ckb=length
dd if=${ckdev} of=${ckfile} bs=1 skip=${cka} count=${ckb} >/dev/null 2>&1;;
esac
$CS -d ${ckfile} $4 $open "$a" "$b" >/dev/null
dd if=/dev/urandom of=${ckfile} bs=1 count=$(stat -c %s ${ckfile}) conv=notrunc >/dev/null 2>&1
rm ${ckfile};;
/*)
$CS -d "$3" $4 $open "$a" "$b" >/dev/null;;
*)
echo "$3" | $CS $4 $open "$a" "$b" >/dev/null;;
esac
if (( $? )); then
failed=1
stat_append "failed "
else
stat_append "ok "
fi
return $failed
}
crypto_unlocked=0
read_crypttab do_unlock && stat_done || stat_fail
# Maybe someone has LVM on an encrypted block device
(( crypto_unlocked == 1 )) && activate_vgs
fi
# Check filesystems
[[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-- -f"
declare -r FORCEFSCK
run_hook sysinit_prefsck
if [[ -x $(type -P fsck) ]]; then
stat_busy "Checking Filesystems"
fsck_all >|"${FSCK_OUT:-/dev/stdout}" 2>|"${FSCK_ERR:-/dev/stdout}"
declare -r fsckret=$?
(( fsckret <= 1 )) && stat_done || stat_fail
else
declare -r fsckret=0
fi
run_hook sysinit_postfsck
# Single-user login and/or automatic reboot if needed
fsck_reboot $fsckret
status "Remounting Root Read/Write" \
mount -n -o remount,rw /
# don't touch /etc/mtab if it is a symlink to /proc/self/mounts
if [[ ! -L /etc/mtab ]]; then
stat_busy "Creating mtab"
if [[ -x $(type -P findmnt) && -e /proc/self/mountinfo ]]; then
findmnt -rnu -o SOURCE,TARGET,FSTYPE,OPTIONS >| /etc/mtab
else
cat /proc/mounts >| /etc/mtab
fi
(( $? == 0 )) && stat_done || stat_fail
fi
# now mount all the local filesystems
run_hook sysinit_premount
status "Mounting Local Filesystems" \
mount_all
run_hook sysinit_postmount
# enable monitoring of lvm2 groups, now that the filesystems are mounted rw
[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]] &&
status "Activating monitoring of LVM2 groups" \
vgchange --monitor y >/dev/null
status "Activating Swap" swapon -a
[[ $TIMEZONE ]] &&
status "Configuring Time Zone" \
cp --remove-destination "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
RANDOM_SEED=/var/lib/misc/random-seed
[[ -f $RANDOM_SEED ]] &&
status "Initializing Random Seed" \
cp $RANDOM_SEED /dev/urandom
# Remove leftover files
remove_leftover
if [[ $HOSTNAME ]]; then
stat_busy "Setting Hostname: $HOSTNAME"
echo "$HOSTNAME" >| /proc/sys/kernel/hostname && stat_done || stat_fail
fi
# Flush old locale settings and set user defined locale
stat_busy "Setting Locale: ${LOCALE:=en_US}"
echo "export LANG=$LOCALE" > /etc/profile.d/locale.sh &&
chmod 0755 /etc/profile.d/locale.sh && stat_done || stat_fail
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
kbd_mode -u < ${i}
printf "\e%%G" > ${i}
done
echo 1 >| /sys/module/vt/parameters/default_utf8
stat_done
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
kbd_mode -a < ${i}
printf "\e%%@" > ${i}
done
echo 0 >| /sys/module/vt/parameters/default_utf8
stat_done
fi
[[ $KEYMAP ]] &&
status "Loading Keyboard Map: $KEYMAP" loadkeys -q $KEYMAP
# Set console font if required
set_consolefont
stat_busy "Saving dmesg Log"
if [[ -e /proc/sys/kernel/dmesg_restrict ]] &&
(( $(< /proc/sys/kernel/dmesg_restrict) == 1 )); then
install -Tm 0600 <( dmesg ) /var/log/dmesg.log
else
install -Tm 0644 <( dmesg ) /var/log/dmesg.log
fi
(( $? == 0 )) && stat_done || stat_fail
run_hook sysinit_end
# End of file
# vim: set ts=2 sw=2 noet:

View file

@ -1,20 +0,0 @@
#
# /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

@ -1,40 +0,0 @@
#compdef rc.d
_rc.d () {
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments "1: :->action" "*: :->service"
case $state in
action)
_arguments "1:action:(list help start stop restart)"
;;
service)
local action="$words[2]"
curcontext="${curcontext%:*:*}:rc.d-${action}:"
case $action in
help)
_arguments "*: :"
;;
list)
_arguments "2: :(started stopped)"
;;
start)
_arguments "*: :($(comm -23 <(echo /etc/rc.d/*(N-*:t)|tr ' ' '\n') <(echo /run/daemons/*(N:t)|tr ' ' '\n')))"
;;
stop|restart|reload)
_arguments "*: :(/run/daemons/*(N:t))"
;;
*)
_arguments "*: :(/etc/rc.d/*(N-*:t))"
;;
esac
;;
esac
}
_rc.d "$@"
# vim: set ts=2 sw=2 ft=sh noet: