diff options
author | Tom Gundersen <teg@jklm.no> | 2012-05-15 01:44:52 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2012-05-29 12:48:18 +0200 |
commit | 6aae67af18fcb9af1ab47c7dd4bfd9c265f0203b (patch) | |
tree | 5fab7dbe3b0f28abb3d65b73d670b0ccc08f54fa | |
parent | 6f3ad111dd2dc18e0d393d59e3a1b383e69d0741 (diff) |
tmpfiles,sysctl,binfmt: use the systemd tools
No point in reinventing the wheel.
These and other tools are shipped in the systemd-tools
package. Functionality should be unchanged, but we no
longer have to maintain the code.
Signed-off-by: Tom Gundersen <teg@jklm.no>
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | PKGBUILD | 2 | ||||
-rwxr-xr-x | arch-binfmt | 45 | ||||
-rwxr-xr-x | arch-sysctl | 29 | ||||
-rwxr-xr-x | arch-tmpfiles | 297 | ||||
-rw-r--r-- | functions | 3 | ||||
-rwxr-xr-x | rc.multi | 4 | ||||
-rwxr-xr-x | rc.sysinit | 6 |
8 files changed, 9 insertions, 386 deletions
@@ -6,14 +6,8 @@ DIRS := \ /etc/rc.d/functions.d \ /etc/logrotate.d \ /etc/profile.d \ - /usr/sbin \ - /etc/tmpfiles.d \ /usr/lib/tmpfiles.d \ - /etc/binfmt.d \ - /usr/lib/binfmt.d \ - /etc/sysctl.d \ - /usr/lib/sysctl.d \ - /usr/lib/initscripts \ + /usr/sbin \ /usr/share/bash-completion/completions \ /usr/share/zsh/site-functions \ /usr/share/man/man5 \ @@ -41,7 +35,6 @@ install: installdirs doc install -m755 -t $(DESTDIR)/usr/sbin rc.d install -m644 -t $(DESTDIR)/usr/share/man/man5 $(filter %.5, $(MAN_PAGES)) install -m644 -t $(DESTDIR)/usr/share/man/man8 $(filter %.8, $(MAN_PAGES)) - install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl arch-binfmt install -m644 tmpfiles.conf $(DESTDIR)/usr/lib/tmpfiles.d/arch.conf install -m644 -T bash-completion $(DESTDIR)/usr/share/bash-completion/completions/rc.d install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d @@ -10,7 +10,7 @@ conflicts=('initscripts') provides=('initscripts=9999') backup=(etc/inittab etc/rc.conf etc/rc.local etc/rc.local.shutdown) makedepends=('asciidoc') -depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=182' 'iproute2' +depends=('glibc' 'bash' 'grep' 'coreutils' 'systemd-tools' 'iproute2' 'ncurses' 'kbd' 'findutils' 'sysvinit') optdepends=('net-tools: legacy networking support' 'bridge-utils: Network bridging support' diff --git a/arch-binfmt b/arch-binfmt deleted file mode 100755 index 91468ef..0000000 --- a/arch-binfmt +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# -# /usr/lib/initscripts/arch-binfmt -# -# Configure additional binary formats at boot -# - -shopt -s nullglob - -declare -a binfmt_d -# files given has argv supersede config files -if (( $# > 0 )); then - for arg; do [[ -r "$arg" ]] && binfmt_d+=("$arg"); done -else - binfmt_d=( - /usr/lib/binfmt.d/*.conf - /etc/binfmt.d/*.conf - /run/binfmt.d/*.conf - ) -fi - -# check there is file to load -(( ${#binfmt_d[@]} > 0 )) || exit 1 - -# mount binfmt_misc if api filesystem is missing -mountpoint -q /proc/sys/fs/binfmt_misc || - mount -t binfmt_misc binfmt /proc/sys/fs/binfmt_misc - -# files declared later in the binfmt_d array will override earlier -# Example: `/etc/binfmt.d/foo.conf' supersedes `/usr/lib/binfmt.d/foo.conf'. -declare -A fragments -for path in "${binfmt_d[@]}"; do - [[ -f $path ]] && fragments[${path##*/}]=$path -done - -for path in "${fragments[@]}"; do - while read -r line; do - [[ ${line:0:1} == '#' ]] && continue - printf "%s" "$line" > /proc/sys/fs/binfmt_misc/register - done < "$path" -done - -: - -# vim: set ts=2 sw=2 noet: diff --git a/arch-sysctl b/arch-sysctl deleted file mode 100755 index f73f1f0..0000000 --- a/arch-sysctl +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# -# /usr/lib/initscripts/arch-sysctl -# -# Load sysctl configuration files following -# http://0pointer.de/public/systemd-man/sysctl.d.html -# - -shopt -s nullglob - -declare -a sysctl_d=( - /usr/lib/sysctl.d/*.conf - /etc/sysctl.d/*.conf - /run/sysctl.d/*.conf - /etc/sysctl.conf -) -declare -A fragments - -# files declared later in the sysctl_d array will override earlier -# Example: `/etc/sysctl.d/foo.conf' supersedes `/usr/lib/sysctl.d/foo.conf'. -for path in "${@:-${sysctl_d[@]}}"; do - [[ -f $path ]] && fragments[${path##*/}]=$path -done - -for path in "${fragments[@]}"; do - sysctl -q -p"$path" -done - -# vim: set ts=2 sw=2 noet: diff --git a/arch-tmpfiles b/arch-tmpfiles deleted file mode 100755 index 9355fdc..0000000 --- a/arch-tmpfiles +++ /dev/null @@ -1,297 +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 - # don't try to resolve numeric IDs in case they don't exist - if [[ $uid ]]; then - if [[ $uid != +([0-9]) ]] && ! getent passwd "$uid" >/dev/null; then - return 1 - fi - fi - - # gid must be numeric or a valid group name - # don't try to resolve numeric IDs in case they don't exist - if [[ $gid ]]; then - if [[ $gid != +([0-9]) ]] && ! getent group "$gid" >/dev/null; then - return 1 - fi - fi - - return 0 -} - -relabel() { - local -a paths=($1) - local mode=$2 uid=$3 gid=$4 - - if ! checkparams 4 "$@"; then - warninvalid - return - fi - - for path in "${paths[@]}"; do - if [[ -e $path ]]; then - [[ $uid != '-' ]] && chown $CHOPTS "$uid" "$path" - [[ $gid != '-' ]] && chgrp $CHOPTS "$gid" "$path" - [[ $mode != '-' ]] && chmod $CHOPTS "$mode" "$path" - fi - done -} - -_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" /dev/null "$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" /dev/null "$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 - - if ! checkparams 4 "$@"; then - warninvalid - return - fi - - if [[ -d $path ]] && (( REMOVE )); then - find "$path" -mindepth 1 -maxdepth 1 -xdev -exec rm -rf {} + - fi - - if (( CREATE )); then - install -d -m"$mode" -o"$uid" -g"$gid" "$path" - fi -} - -_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 -} - -_z() { - # Set ownership, access mode and relabel security context of a file or - # directory if it exists. Lines of this type accept shell-style globs in - # place of normal path names. - local -a paths=($1) - local mode=$2 uid=$3 gid=$4 - - (( CREATE )) || return 0 - - relabel "$@" -} - -_Z() { - # Recursively set ownership, access mode and relabel security context of 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. - - (( CREATE )) || return 0 - - CHOPTS=-R relabel "$@" -} - -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]='root' - [[ ${line[4]} = '-' ]] && line[4]='root' - - "_${line[@]}" - done <"$FILE" -done < <(printf '%s\0' "${!fragments[@]}" | sort -z) - -exit $error - -# vim: set ts=2 sw=2 noet: @@ -576,8 +576,7 @@ umount_all() { } remove_leftover() { - stat_busy "Removing Leftover Files" - /usr/lib/initscripts/arch-tmpfiles --create --remove && stat_done || stat_fail + status -v 'Removing Leftover Files' /usr/lib/systemd/systemd-tmpfiles --create --remove # move from static /var/{run,lock} to /run if [[ ! -L /var/lock ]]; then rm -rf /var/lock @@ -9,10 +9,10 @@ run_hook multi_start # Load sysctl config files -[[ -x /usr/lib/initscripts/arch-sysctl ]] && /usr/lib/initscripts/arch-sysctl +/usr/lib/systemd/systemd-sysctl # Load additional binary formats -[[ -x /usr/lib/initscripts/arch-binfmt ]] && /usr/lib/initscripts/arch-binfmt +/usr/lib/systemd/systemd-binfmt # Start daemons for daemon in "${DAEMONS[@]}"; do @@ -20,9 +20,11 @@ mountpoint -q /dev || mount -t devtmpfs dev /dev -o mode=0755,nosuid mkdir -p -m 1777 /run/lock mkdir -p /dev/{pts,shm} mountpoint -q /dev/pts || mount /dev/pts &>/dev/null || - mount -n -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec + mount -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec mountpoint -q /dev/shm || mount /dev/shm &>/dev/null || - mount -n -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev + mount -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev +mountpoint -q /proc/sys/fs/binfmt_misc || mount /proc/sys/fs/binfmt_misc &>/dev/null || + mount -t binfmt_misc binfmt /proc/sys/fs/binfmt_misc if [[ ! -e /run/initramfs/fsck-root ]]; then # remount root ro to allow for fsck later on, we remount now to |