diff options
author | Nicolás Reynolds <apoyosis@correo.inta.gob.ar> | 2011-12-14 11:17:39 -0300 |
---|---|---|
committer | Nicolás Reynolds <apoyosis@correo.inta.gob.ar> | 2011-12-14 11:17:39 -0300 |
commit | a68232261a533c2c9998a8016f27b00f4534fdde (patch) | |
tree | a06e6ae1c5aaec9cd072140717e2234050dac600 | |
parent | c3d6cdb72f7130d3361bc1b8c99e862fe15a75fa (diff) | |
parent | b420829c5fe4441038c125789b1dd3eafb61457c (diff) |
Merge branch 'master' of https://projects.archlinux.org/git/initscripts into HEAD
Conflicts:
functions
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | PKGBUILD | 2 | ||||
-rw-r--r-- | RELEASE | 34 | ||||
-rw-r--r-- | functions | 198 | ||||
-rw-r--r-- | locale.sh | 8 | ||||
-rwxr-xr-x | rc.d | 2 | ||||
-rwxr-xr-x | rc.shutdown | 43 | ||||
-rwxr-xr-x | rc.single | 3 | ||||
-rwxr-xr-x | rc.sysinit | 49 | ||||
-rw-r--r-- | tmpfiles.conf | 2 |
10 files changed, 218 insertions, 129 deletions
@@ -42,5 +42,9 @@ doc: rc.d.8 clean: rm -f rc.d.8 -release: +tar: git archive HEAD --prefix=initscripts-$(VER)/ | xz > initscripts-$(VER).tar.xz + +release: tar + scp initscripts-$(VER).tar.xz gerolde.archlinux.org:/srv/ftp/other/initscripts/ + scp initscripts-$(VER).tar.xz pkgbuild.com:~/svn-packages/initscripts/trunk/ @@ -1,5 +1,5 @@ pkgname=initscripts-git -pkgver=$(date +%s) +pkgver=$(date +%Y%m%d) pkgrel=$(git log -1 --pretty=format:%h) pkgdesc="System initialization/bootup scripts" arch=('any') @@ -5,39 +5,35 @@ Releasing $ git tag -a 2011.04.1 -2) create a tarball +2) create a tarball and push it to gerolde and pkgbuild.com (needs 4.3.2 to be done...( $ make release -3) copy the tarball to gerolde +3) check that the PKGBUILD in git is in sync with the PKGBUILD to be released - $ scp initscripts-YYYY.MM.X.tar.xz gerolde.archlinux.org:/srv/ftp/other/initscripts/ +4) create package and push to testing: -4) check that the PKGBUILD in git is in sync with the PKGBUILD to be released + 4.1) [first time only] set up ssh forwarding so you can connect to gerolde from alderaan -5) create package and push to testing: + 4.1.1) Add "ForwardAgent=yes" to ~/.ssh/config - 5.1) [first time only] set up ssh forwarding so you can connect to gerolde from alderaan + 4.1.2) Add your private key to the authentication agent "ssh-add" - 5.1.1) Add "ForwardAgent=yes" to ~/.ssh/config + 4.2) ssh pkgbuild.com - 5.1.2) Add your private key to the authentication agent "ssh-add" + 4.3) [first time only] check out initscripts from svn - 5.2) ssh pkgbuild.com + 4.3.1) svn checkout -N svn+ssh://gerolde.archlinux.org/srv/svn-packages - 5.3) [first time only] check out initscripts from svn + 4.3.2) "cd svn-packages && svn update initscripts" - 5.3.1) svn checkout -N svn+ssh://gerolde.archlinux.org/srv/svn-packages + 4.4) get the latest version of initscripts: "cd svn-packages && svn update" - 5.3.2) "cd svn-packages && svn update initscripts" + 4.5) update the version field in the PKGBUILD - 5.4) get the latest version of initscripts: "cd svn-packages && svn update" + 4.6) build the package for both arches: "sudo testing-{i686,x86_64}-build" - 5.5) update the version field in the PKGBUILD + 4.7) run checkpkg, namcap, and install test at least one of the two packages - 5.6) build the package for both arches: "sudo testing-{i686,x86_64}-build" - - 5.7) run checkpkg, namcap, and install test at least one of the two packages - - 5.8) commit to svn and move package to your staging folder (which needs to exist on gerolde): + 4.8) commit to svn and move package to your staging folder (which needs to exist on gerolde): 'testingpkg "commit message"' @@ -5,6 +5,12 @@ # 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" +localevars=(LANG 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) + +vconsolevars=(KEYMAP KEYMAP_TOGGLE FONT FONT_MAP FONT_UNIMAP) + if [[ $1 == "start" ]]; then if [[ $STARTING ]]; then echo "A daemon is starting another daemon, this is unlikely to work as intended." @@ -64,52 +70,57 @@ unset TERM_COLORS 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] ]]; then - LANG="${LOCALE:=C}" - if [ -r /etc/locale.conf ]; then - . /etc/locale.conf +unset "${localevars[@]}" + +parse_envfile() { + local file=$1 validkeys=("${@:2}") ret=0 lineno=0 key= val= + local -r quotes=$'[\'"]' comments=$'[;#]*' + + if [[ -z $file ]]; then + printf "error: no environment file specified\n" + return 1 fi - export LANG 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 -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 5) # 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;35m" # 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 + if [[ ! -f $file ]]; then + printf "error: cannot parse \`%s': No such file or directory\n" "$file" + return 1 fi -fi -# prefixes: + if [[ ! -r $file ]]; then + printf "error: cannot read \`%s': Permission denied\n" "$file" + return 1 + fi -PREFIX_REG="::" -PREFIX_HL=" >" + while IFS='=' read -r key val; do + (( ++lineno )) + + # trim whitespace, avoiding usage of a tempfile + key=$(echo "$key" | { read -r key; echo "$key"; }) + + # key must exist and line must not be a comment + [[ -z $key || ${key:0:1} = $comments ]] && continue + + # trim whitespace, strip matching quotes + val=$(echo "$val" | { read -r val; echo "$val"; }) + [[ ${val:0:1} = $quotes && ${val:(-1)} = "${val:0:1}" ]] && val=${val:1:(-1)} + + if [[ -z $val ]]; then + printf "error: found key \`%s' without value on line %s of %s\n" \ + "$key" "$lineno" "$file" + (( ++ret )) + continue + fi + + # ignore invalid keys if we have a list of valid ones + if (( ${#validkeys[*]} )) && ! in_array "$key" "${validkeys[@]}"; then + continue + fi + + export "$key=$val" || (( ++ret )) + done <"$file" + + return $ret +} # functions: @@ -128,7 +139,7 @@ printsep() { stat_bkgd() { printf "${C_OTHER}${PREFIX_REG} ${C_MAIN}${1}${C_CLEAR} " deltext - printf " ${C_OTHER}[${C_BKGD}BKGD${C_OTHER}]${C_CLEAR} " + printf " ${C_OTHER}[${C_BKGD}BKGD${C_OTHER}]${C_CLEAR} \n" } stat_busy() { @@ -370,7 +381,7 @@ activate_vgs() { # 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 + /sbin/cryptsetup.static ''; do [[ -x $CS ]] && break done @@ -417,8 +428,11 @@ NETFS="nfs,nfs4,smbfs,cifs,codafs,ncpfs,shfs,fuse,fuseblk,glusterfs,davfs,fuse.g # Check local filesystems fsck_all() { - fsck -A -T -C"$FSCK_FD" -a -t "no${NETFS//,/,no},noopts=_netdev" $FORCEFSCK - return $? + if [[ -e /run/initramfs/root-fsck ]]; then + IGNORE_MOUNTED="-M" + fi + + fsck -A -T -C${FSCK_FD} -a -t no${NETFS//,/,no},noopts=_netdev ${FORCEFSCK} ${IGNORE_MOUNTED} } # Single-user login and/or automatic reboot after fsck (if needed) @@ -460,15 +474,48 @@ mount_all() { mount -a -t "nosysfs,no${NETFS//,/,no}" -O no_netdev } +umount_all() { + # $1: restrict to fstype + + local mounts + + while read -r target fstype options; do + + # match only targetted fstypes + if [[ $1 && $1 != "$fstype" ]]; then + continue + fi + + # don't unmount API filesystems + if [[ $target = /@(proc|sys|run|dev|dev/pts) ]]; then + continue + fi + + # avoid networked devices + IFS=, read -ra opts <<< "$options" + if in_array _netdev "${opts[@]}"; then + continue + fi + + mounts+=("$target") + done < <(findmnt -mrunRo TARGET,FSTYPE,OPTIONS / | tac) + + umount -r "${mounts[@]}" + +} + 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 + # move from static /var/{run,lock} to /run + if [[ ! -L /var/lock ]]; then + rm -rf /var/lock + ln -s /run/lock /var/lock + fi + if [[ ! -L /var/run ]]; then + rm -rf /var/run + ln -s /run /var/run + fi } bootlogd_stop() { @@ -477,7 +524,7 @@ bootlogd_stop() { 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/\^\[(\[1?[0-9]1|%)G//g' -e 's/\^\[\[0;1//g' /var/log/boot + -e 's/\^\[(\[1?[0-9][0-9]|%)G//g' -e 's/\^\[\[0;1//g' /var/log/boot } ############################### @@ -511,6 +558,7 @@ bootlogd_stop() { # 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_preumount: after last filesystem write, but before filesystems are unmounted # shutdown_postumount: after filesystems are unmounted # shutdown_poweroff: directly before powering off in rc.shutdown # @@ -550,16 +598,52 @@ set_consolefont() { 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 } +if [[ $DAEMON_LOCALE = [yY][eE][sS] ]]; then + export LANG=${LOCALE:-C} + if [[ -r /etc/locale.conf ]]; then + parse_envfile /etc/locale.conf "${localevars[@]}" + fi +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 5) # 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;35m" # 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=" >" + # Source additional functions at the end to allow overrides for f in /etc/rc.d/functions.d/*; do [[ -e $f ]] && . "$f" @@ -1,3 +1,5 @@ +unset LANG + if [ -s /etc/locale.conf ]; then . /etc/locale.conf fi @@ -67,6 +69,12 @@ else fi if [ -n "$LC_TELEPHONE" ]; then + export LC_TELEPHONE +else + unset LC_TELEPHONE +fi + +if [ -n "$LC_MEASUREMENT" ]; then export LC_MEASUREMENT else unset LC_MEASUREMENT @@ -36,7 +36,7 @@ filter_daemons() { for daemon in "${daemons[@]}"; do # check if daemons is valid if ! have_daemon "$daemon"; then - printf "${C_FAIL}:: ${C_DONE}Dameon script ${C_FAIL}${daemon}${C_DONE} does \ + printf "${C_FAIL}:: ${C_DONE}Daemon script ${C_FAIL}${daemon}${C_DONE} does \ not exist or is not executable.${C_CLEAR}\n" >&2 exit 2 fi diff --git a/rc.shutdown b/rc.shutdown index 5928b2d..4b513f7 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -19,20 +19,6 @@ run_hook shutdown_start stop_all_daemons -status "Shutting down UDev" udevadm control --exit - -status "Deactivating Swap" swapoff -a - -# stop monitoring of lvm2 groups before unmounting filesystems -[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) ]] && - status "Deactivating monitoring of LVM2 groups" vgchange --monitor n - -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 /dev/null $RANDOM_SEED @@ -51,9 +37,30 @@ stat_done # Write to wtmp file before unmounting halt -w -# 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 +# stop monitoring of lvm2 groups before unmounting filesystems +[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) ]] && + status "Deactivating monitoring of LVM2 groups" vgchange --monitor n + +# any future uevents can and should be ignored +status "Shutting down UDev" udevadm control --exit + +run_hook shutdown_prekillall + +kill_all + +run_hook shutdown_postkillall + +run_hook shutdown_preumount + +# unmount any non-api partitions that are backed by swap, we don't want to +# move their contents into memory (waste of time and might caues OOM). +status "Unmounting Swap-backed Filesystems" umount_all "tmpfs" + +# almost everything is dead now, so the swap should hopefully be relatively +# empty, and quick to switch off +status "Deactivating Swap" swapoff -a + +status "Unmounting Non-API Filesystems" umount_all run_hook shutdown_postumount @@ -116,7 +123,7 @@ if [[ -x /run/initramfs/shutdown ]]; then else status "Remounting Root Filesystem Read-only" \ - mount -n -o remount,ro / + mount -n -o remount,ro / # Power off or reboot printsep @@ -18,9 +18,6 @@ if [[ $PREVLEVEL != N ]]; then 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 @@ -15,20 +15,22 @@ 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 \ - || mount -n -t tmpfs udev /dev -o mode=0755,size=10M,nosuid +mountpoint -q /run || mount -n -t tmpfs run /run -o mode=0755,nosuid,nodev +mountpoint -q /dev || mount -n -t devtmpfs udev /dev -o mode=0755,nosuid || + mount -n -t tmpfs udev /dev -o mode=0755,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 / +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 + +if [[ ! -e /run/initramfs/fsck-root ]]; then + # 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 / +fi run_hook sysinit_start @@ -194,20 +196,11 @@ 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" - rm -f /etc/mtab~* # delete any stale locks - 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 +status "Remounting Root" \ + mount -n -o remount / + +# force linkage of /etc/mtab to the kernel +[[ -L /etc/mtab ]] || ln -sf /proc/self/mounts /etc/mtab # now mount all the local filesystems run_hook sysinit_premount @@ -238,7 +231,7 @@ if [[ $HOSTNAME ]]; then fi if [[ -s /etc/locale.conf ]]; then - . /etc/locale.conf + parse_envfile /etc/locale.conf "LANG" [[ $LANG ]] && LOCALE=$LANG fi if [[ ${LOCALE,,} =~ utf ]]; then @@ -264,7 +257,7 @@ else fi if [[ -s /etc/vconsole.conf ]]; then - . /etc/vconsole.conf + parse_envfile /etc/vconsole.conf "${vconsolevars[@]}" [[ $FONT ]] && CONSOLEFONT=$FONT [[ $FONT_MAP ]] && CONSOLEMAP=$FONT_MAP fi diff --git a/tmpfiles.conf b/tmpfiles.conf index 7dd1358..90deb9d 100644 --- a/tmpfiles.conf +++ b/tmpfiles.conf @@ -11,7 +11,7 @@ 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 +F /run/utmp 0664 root utmp r /tmp/.X[0-9]-lock r /etc/nologin |