summaryrefslogtreecommitdiff
path: root/pcr/openrc-base
diff options
context:
space:
mode:
authorfreaj <freaj@riseup.net>2015-03-23 11:27:55 +0100
committerfreaj <freaj@riseup.net>2015-03-23 11:27:55 +0100
commit0161d0dd7de853da1f86bb3b6f27adf25977c785 (patch)
tree496f2da02a919ddf4fee0001c274237f72835fe2 /pcr/openrc-base
parent1846e57b8e352d4f7fa711f32206375d318e93d8 (diff)
downloadabslibre-0161d0dd7de853da1f86bb3b6f27adf25977c785.tar.gz
abslibre-0161d0dd7de853da1f86bb3b6f27adf25977c785.tar.bz2
abslibre-0161d0dd7de853da1f86bb3b6f27adf25977c785.zip
openrc-base: add missing files
Diffstat (limited to 'pcr/openrc-base')
-rw-r--r--pcr/openrc-base/1.0.6-dmcrypt.confd98
-rw-r--r--pcr/openrc-base/1.5.1-dmcrypt.rc353
-rw-r--r--pcr/openrc-base/anacron-1.0-initd18
-rw-r--r--pcr/openrc-base/cronie-1.3-initd14
-rw-r--r--pcr/openrc-base/dbus.initd50
-rw-r--r--pcr/openrc-base/device-mapper.conf-1.02.22-r31
-rw-r--r--pcr/openrc-base/device-mapper.rc-2.02.105-r2147
-rw-r--r--pcr/openrc-base/dhcpcd.initd17
-rw-r--r--pcr/openrc-base/dmeventd.initd-2.02.67-r126
-rw-r--r--pcr/openrc-base/lvm-monitoring.initd-2.02.105-r239
-rw-r--r--pcr/openrc-base/lvm.confd-2.02.28-r25
-rw-r--r--pcr/openrc-base/lvm.rc-2.02.105-r297
-rw-r--r--pcr/openrc-base/lvmetad.initd-2.02.105-r213
-rw-r--r--pcr/openrc-base/mdadm.confd7
-rw-r--r--pcr/openrc-base/mdadm.rc26
-rw-r--r--pcr/openrc-base/mdraid.confd5
-rw-r--r--pcr/openrc-base/mdraid.rc40
-rw-r--r--pcr/openrc-base/nscd64
-rw-r--r--pcr/openrc-base/udev-postmount55
19 files changed, 1075 insertions, 0 deletions
diff --git a/pcr/openrc-base/1.0.6-dmcrypt.confd b/pcr/openrc-base/1.0.6-dmcrypt.confd
new file mode 100644
index 000000000..9747dff11
--- /dev/null
+++ b/pcr/openrc-base/1.0.6-dmcrypt.confd
@@ -0,0 +1,98 @@
+# /etc/conf.d/dmcrypt
+
+# For people who run dmcrypt on top of some other layer (like raid),
+# use rc_need to specify that requirement. See the runscript(8) man
+# page for more information.
+
+#--------------------
+# Instructions
+#--------------------
+
+# Note regarding the syntax of this file. This file is *almost* bash,
+# but each line is evaluated separately. Separate swaps/targets can be
+# specified. The init-script which reads this file assumes that a
+# swap= or target= line starts a new section, similar to lilo or grub
+# configuration.
+
+# Note when using gpg keys and /usr on a separate partition, you will
+# have to copy /usr/bin/gpg to /bin/gpg so that it will work properly
+# and ensure that gpg has been compiled statically.
+# See http://bugs.gentoo.org/90482 for more information.
+
+# Note that the init-script which reads this file detects whether your
+# partition is LUKS or not. No mkfs is run unless you specify a makefs
+# option.
+
+# Global options:
+#----------------
+
+# Max number of checks to perform (1 per second)
+#dmcrypt_max_timeout=120
+
+# Arguments:
+#-----------
+# target=<name> == Mapping name for partition.
+# swap=<name> == Mapping name for swap partition.
+# source='<dev>' == Real device for partition.
+# key='</path/to/keyfile>[:<mode>]' == Fullpath from / or from inside removable media.
+# remdev='<dev>' == Device that will be assigned to removable media.
+# gpg_options='<opts>' == Default are --quiet --decrypt
+# options='<opts>' == cryptsetup, for LUKS you can only use --readonly
+# loop_file='<file>' == Loopback file.
+# pre_mount='cmds' == commands to execute before mounting partition.
+# post_mount='cmds' == commands to execute after mounting partition.
+#-----------
+# Supported Modes
+# gpg == decrypt and pipe key into cryptsetup.
+# Note: new-line character must not be part of key.
+# Command to erase \n char: 'cat key | tr -d '\n' > cleanKey'
+
+#--------------------
+# dm-crypt examples
+#--------------------
+
+## swap
+# Swap partitions. These should come first so that no keys make their
+# way into unencrypted swap.
+# If no options are given, they will default to: -c aes -h sha1 -d /dev/urandom
+# If no makefs is given then mkswap will be assumed
+#swap=crypt-swap
+#source='/dev/hda2'
+
+## /home with passphrase
+#target=crypt-home
+#source='/dev/hda5'
+
+## /home with regular keyfile
+#target=crypt-home
+#source='/dev/hda5'
+#key='/full/path/to/homekey'
+
+## /home with gpg protected key
+#target=crypt-home
+#source='/dev/hda5'
+#key='/full/path/to/homekey:gpg'
+
+## /home with regular keyfile on removable media(such as usb-stick)
+#target=crypt-home
+#source='/dev/hda5'
+#key='/full/path/to/homekey'
+#remdev='/dev/sda1'
+
+##/home with gpg protected key on removable media(such as usb-stick)
+#target=crypt-home
+#source='/dev/hda5'
+#key='/full/path/to/homekey:gpg'
+#remdev='/dev/sda1'
+
+##/tmp with regular keyfile
+#target=crypt-tmp
+#source='/dev/hda6'
+#key='/full/path/to/tmpkey'
+#pre_mount='/sbin/mkreiserfs -f -f ${dev}'
+#post_mount='chown root:root ${mount_point}; chmod 1777 ${mount_point}'
+
+## Loopback file example
+#target='crypt-loop-home'
+#source='/dev/loop0'
+#loop_file='/mnt/crypt/home'
diff --git a/pcr/openrc-base/1.5.1-dmcrypt.rc b/pcr/openrc-base/1.5.1-dmcrypt.rc
new file mode 100644
index 000000000..9415a0bce
--- /dev/null
+++ b/pcr/openrc-base/1.5.1-dmcrypt.rc
@@ -0,0 +1,353 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/cryptsetup/files/1.5.1-dmcrypt.rc,v 1.2 2014/10/19 04:37:19 vapier Exp $
+
+depend() {
+ before checkfs fsck
+}
+
+# We support multiple dmcrypt instances based on $SVCNAME
+execute_hook="dm_crypt_execute_dmcrypt"
+# XXX: Should we drop this ?
+# execute_hook="dm_crypt_execute_localmount"
+conf_file="/etc/conf.d/${SVCNAME}"
+
+# Get splash helpers if available.
+if [ -e /sbin/splash-functions.sh ] ; then
+ . /sbin/splash-functions.sh
+fi
+
+# Setup mappings for an individual target/swap
+# Note: This relies on variables localized in the main body below.
+dm_crypt_execute_dmcrypt() {
+ local dev ret mode foo
+
+ if [ -n "${target}" ] ; then
+ # let user set options, otherwise leave empty
+ : ${options:=' '}
+ elif [ -n "${swap}" ] ; then
+ if cryptsetup isLuks ${source} 2>/dev/null ; then
+ ewarn "The swap you have defined is a LUKS partition. Aborting crypt-swap setup."
+ return
+ fi
+ target=${swap}
+ # swap contents do not need to be preserved between boots, luks not required.
+ # suspend2 users should have initramfs's init handling their swap partition either way.
+ : ${options:='-c aes -h sha1 -d /dev/urandom'}
+ : ${pre_mount:='mkswap ${dev}'}
+ else
+ return
+ fi
+ if [ "x${source#UUID}" != "x${source}" ]; then
+ source=${source#UUID=}
+ source="$(blkid -U ${source})"
+ fi
+ if [ -z "${source}" ] && [ ! -e "${source}" ] ; then
+ ewarn "source \"${source}\" for ${target} missing, skipping..."
+ return
+ fi
+
+ if [ -n "${loop_file}" ] ; then
+ dev="/dev/mapper/${target}"
+ ebegin " Setting up loop device ${source}"
+ losetup ${source} ${loop_file}
+ fi
+
+ # cryptsetup:
+ # open <device> <name> # <device> is $source
+ # create <name> <device> # <name> is $target
+ local arg1="create" arg2="${target}" arg3="${source}"
+ if cryptsetup isLuks ${source} 2>/dev/null ; then
+ arg1="open"
+ arg2="${source}"
+ arg3="${target}"
+ fi
+
+ # Older versions reported:
+ # ${target} is active:
+ # Newer versions report:
+ # ${target} is active[ and is in use.]
+ if cryptsetup status ${target} | egrep -q ' is active' ; then
+ einfo "dm-crypt mapping ${target} is already configured"
+ return
+ fi
+ splash svc_input_begin ${SVCNAME} >/dev/null 2>&1
+
+ # Handle keys
+ if [ -n "${key}" ] ; then
+ read_abort() {
+ # some colors
+ local ans savetty resettty
+ [ -z "${NORMAL}" ] && eval $(eval_ecolors)
+ einfon " $1? (${WARN}yes${NORMAL}/${GOOD}No${NORMAL}) "
+ shift
+ # This is ugly as s**t. But POSIX doesn't provide `read -t`, so
+ # we end up having to implement our own crap with stty/etc...
+ savetty=$(stty -g)
+ resettty='stty ${savetty}; trap - EXIT HUP INT TERM'
+ trap 'eval "${resettty}"' EXIT HUP INT TERM
+ stty -icanon
+ [ "${1}" = -t ] && stty min 0 time "$(( $2 * 10 ))"
+ ans=$(dd count=1 bs=1 2>/dev/null) || ans=''
+ eval "${resettty}"
+ if [ -z "${ans}" ] ; then
+ printf '\r'
+ else
+ echo
+ fi
+ case ${ans} in
+ [yY]) return 0;;
+ *) return 1;;
+ esac
+ }
+
+ # Notes: sed not used to avoid case where /usr partition is encrypted.
+ mode=${key/*:/} && ( [ "${mode}" = "${key}" ] || [ -z "${mode}" ] ) && mode=reg
+ key=${key/:*/}
+ case "${mode}" in
+ gpg|reg)
+ # handle key on removable device
+ if [ -n "${remdev}" ] ; then
+ # temp directory to mount removable device
+ local mntrem="${RC_SVCDIR}/dm-crypt-remdev.$$"
+ if [ ! -d "${mntrem}" ] ; then
+ if ! mkdir -p "${mntrem}" ; then
+ ewarn "${source} will not be decrypted ..."
+ einfo "Reason: Unable to create temporary mount point '${mntrem}'"
+ return
+ fi
+ fi
+ i=0
+ einfo "Please insert removable device for ${target}"
+ while [ ${i} -lt ${dmcrypt_max_timeout:-120} ] ; do
+ foo=""
+ if mount -n -o ro "${remdev}" "${mntrem}" 2>/dev/null >/dev/null ; then
+ # keyfile exists?
+ if [ ! -e "${mntrem}${key}" ] ; then
+ umount -n "${mntrem}"
+ rmdir "${mntrem}"
+ einfo "Cannot find ${key} on removable media."
+ read_abort "Abort" ${read_timeout:--t 1} && return
+ else
+ key="${mntrem}${key}"
+ break
+ fi
+ else
+ [ -e "${remdev}" ] \
+ && foo="mount failed" \
+ || foo="mount source not found"
+ fi
+ : $((i += 1))
+ read_abort "Stop waiting after $i attempts (${foo})" -t 1 && return
+ done
+ else # keyfile ! on removable device
+ if [ ! -e "${key}" ] ; then
+ ewarn "${source} will not be decrypted ..."
+ einfo "Reason: keyfile ${key} does not exist."
+ return
+ fi
+ fi
+ ;;
+ *)
+ ewarn "${source} will not be decrypted ..."
+ einfo "Reason: mode ${mode} is invalid."
+ return
+ ;;
+ esac
+ else
+ mode=none
+ fi
+ ebegin " ${target} using: ${options} ${arg1} ${arg2} ${arg3}"
+ if [ "${mode}" = "gpg" ] ; then
+ : ${gpg_options:='-q -d'}
+ # gpg available ?
+ if type -p gpg >/dev/null ; then
+ for i in 0 1 2 ; do
+ # paranoid, don't store key in a variable, pipe it so it stays very little in ram unprotected.
+ # save stdin stdout stderr "values"
+ gpg ${gpg_options} ${key} 2>/dev/null | cryptsetup ${options} ${arg1} ${arg2} ${arg3}
+ ret=$?
+ [ ${ret} -eq 0 ] && break
+ done
+ eend ${ret} "failure running cryptsetup"
+ else
+ ewarn "${source} will not be decrypted ..."
+ einfo "Reason: cannot find gpg application."
+ einfo "You have to install app-crypt/gnupg first."
+ einfo "If you have /usr on its own partition, try copying gpg to /bin ."
+ fi
+ else
+ if [ "${mode}" = "reg" ] ; then
+ cryptsetup ${options} -d ${key} ${arg1} ${arg2} ${arg3}
+ ret=$?
+ eend ${ret} "failure running cryptsetup"
+ else
+ cryptsetup ${options} ${arg1} ${arg2} ${arg3}
+ ret=$?
+ eend ${ret} "failure running cryptsetup"
+ fi
+ fi
+ if [ -d "${mntrem}" ] ; then
+ umount -n ${mntrem} 2>/dev/null >/dev/null
+ rmdir ${mntrem} 2>/dev/null >/dev/null
+ fi
+ splash svc_input_end ${SVCNAME} >/dev/null 2>&1
+
+ if [ ${ret} -ne 0 ] ; then
+ cryptfs_status=1
+ else
+ if [ -n "${pre_mount}" ] ; then
+ dev="/dev/mapper/${target}"
+ ebegin " pre_mount: ${pre_mount}"
+ eval "${pre_mount}" > /dev/null
+ ewend $? || cryptfs_status=1
+ fi
+ fi
+}
+
+# Run any post_mount commands for an individual mount
+#
+# Note: This relies on variables localized in the main body below.
+dm_crypt_execute_localmount() {
+ local mount_point
+
+ [ -z "${target}" ] && [ -z "${post_mount}" ] && return
+
+ if ! cryptsetup status ${target} | egrep -q '\<active:' ; then
+ ewarn "Skipping unmapped target ${target}"
+ cryptfs_status=1
+ return
+ fi
+
+ mount_point=$(grep "/dev/mapper/${target}" /proc/mounts | cut -d' ' -f2)
+ if [ -z "${mount_point}" ] ; then
+ ewarn "Failed to find mount point for ${target}, skipping"
+ cryptfs_status=1
+ fi
+
+ if [ -n "${post_mount}" ] ; then
+ ebegin "Running post_mount commands for target ${target}"
+ eval "${post_mount}" >/dev/null
+ eend $? || cryptfs_status=1
+ fi
+}
+
+# Lookup optional bootparams
+get_bootparam_val() {
+ # We're given something like:
+ # foo=bar=cow
+ # Return the "bar=cow" part.
+ case $1 in
+ *\=*)
+ local key=$(echo "$1" | cut -f1 -d=)
+ echo "$1" | cut -c $(( ${#key} + 2 ))
+ ;;
+ esac
+}
+
+start() {
+ local header=true cryptfs_status=0
+ local gpg_options key loop_file target targetline options pre_mount post_mount source swap remdev
+
+ local x
+ for x in $(cat /proc/cmdline) ; do
+ case "${x}" in
+ key_timeout\=*)
+ local KEY_TIMEOUT=$(get_bootparam_val "${x}")
+ if [ ${KEY_TIMEOUT} -gt 0 ] ; then
+ read_timeout="-t ${KEY_TIMEOUT}"
+ fi
+ ;;
+ esac
+ done
+
+ while read -u 3 targetline ; do
+ case ${targetline} in
+ # skip comments and blank lines
+ ""|"#"*) continue ;;
+ # skip service-specific openrc configs #377927
+ rc_*) continue ;;
+ esac
+
+ ${header} && ebegin "Setting up dm-crypt mappings"
+ header=false
+
+ # check for the start of a new target/swap
+ case ${targetline} in
+ target=*|swap=*)
+ # If we have a target queued up, then execute it
+ ${execute_hook}
+
+ # Prepare for the next target/swap by resetting variables
+ unset gpg_options key loop_file target options pre_mount post_mount source swap remdev
+ ;;
+
+ gpg_options=*|remdev=*|key=*|loop_file=*|options=*|pre_mount=*|post_mount=*|source=*)
+ if [ -z "${target}${swap}" ] ; then
+ ewarn "Ignoring setting outside target/swap section: ${targetline}"
+ continue
+ fi
+ ;;
+
+ dmcrypt_max_timeout=*)
+ # ignore global options
+ continue
+ ;;
+
+ *)
+ ewarn "Skipping invalid line in ${conf_file}: ${targetline}"
+ ;;
+ esac
+
+ # Queue this setting for the next call to dm_crypt_execute_xxx
+ eval "${targetline}"
+ done 3< ${conf_file}
+
+ # If we have a target queued up, then execute it
+ ${execute_hook}
+
+ ewend ${cryptfs_status} "Failed to setup dm-crypt devices"
+}
+
+stop() {
+ local line header
+
+ # Break down all mappings
+ header=true
+ egrep "^(target|swap)=" ${conf_file} | \
+ while read line ; do
+ ${header} && einfo "Removing dm-crypt mappings"
+ header=false
+
+ target= swap=
+ eval ${line}
+
+ [ -n "${swap}" ] && target=${swap}
+ if [ -z "${target}" ] ; then
+ ewarn "invalid line in ${conf_file}: ${line}"
+ continue
+ fi
+
+ ebegin " ${target}"
+ cryptsetup remove ${target}
+ eend $?
+ done
+
+ # Break down loop devices
+ header=true
+ grep '^source=./dev/loop' ${conf_file} | \
+ while read line ; do
+ ${header} && einfo "Detaching dm-crypt loop devices"
+ header=false
+
+ source=
+ eval ${line}
+
+ ebegin " ${source}"
+ losetup -d "${source}"
+ eend $?
+ done
+
+ return 0
+}
diff --git a/pcr/openrc-base/anacron-1.0-initd b/pcr/openrc-base/anacron-1.0-initd
new file mode 100644
index 000000000..6462b900e
--- /dev/null
+++ b/pcr/openrc-base/anacron-1.0-initd
@@ -0,0 +1,18 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-process/cronie/files/anacron-1.0-initd,v 1.4 2014/03/04 00:17:58 polynomial-c Exp $
+
+# anacron forks itself when -d gets omitted. So s-s-d fails to create a valid
+# pidfile. DO NOT remove -d from command_args and let s-s-d start anacron
+# in background!
+
+command="/usr/sbin/anacron"
+command_args="-d -s -S /var/spool/anacron"
+pidfile="/var/run/anacron.pid"
+command_background="true"
+
+depend() {
+ use clock logger
+ need localmount
+}
diff --git a/pcr/openrc-base/cronie-1.3-initd b/pcr/openrc-base/cronie-1.3-initd
new file mode 100644
index 000000000..138530f5e
--- /dev/null
+++ b/pcr/openrc-base/cronie-1.3-initd
@@ -0,0 +1,14 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-process/cronie/files/cronie-1.3-initd,v 1.3 2014/03/04 00:17:58 polynomial-c Exp $
+
+command="/usr/sbin/crond"
+command_args="${CRONDARGS}"
+pidfile="/var/run/crond.pid"
+
+depend() {
+ use clock logger
+ need localmount
+ provide cron
+}
diff --git a/pcr/openrc-base/dbus.initd b/pcr/openrc-base/dbus.initd
new file mode 100644
index 000000000..65271f69c
--- /dev/null
+++ b/pcr/openrc-base/dbus.initd
@@ -0,0 +1,50 @@
+#!/sbin/runscript
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/dbus/files/dbus.initd,v 1.1 2011/11/05 13:56:10 ssuominen Exp $
+
+extra_started_commands="reload"
+
+depend() {
+ need localmount
+ after bootmisc
+}
+
+start() {
+ ebegin "Starting D-BUS system messagebus"
+ /usr/bin/dbus-uuidgen --ensure=/etc/machine-id
+
+ # We need to test if /var/run/dbus exists, since script will fail if it does not
+ [ ! -e /var/run/dbus ] && mkdir /var/run/dbus
+
+ start-stop-daemon --start --pidfile /var/run/dbus.pid --exec /usr/bin/dbus-daemon -- --system
+ eend $?
+}
+
+stop() {
+ local retval
+
+ ebegin "Stopping D-BUS system messagebus"
+
+ start-stop-daemon --stop --pidfile /var/run/dbus.pid
+ retval=$?
+
+ eend ${retval}
+
+ [ -S /var/run/dbus/system_bus_socket ] && rm -f /var/run/dbus/system_bus_socket
+
+ return ${retval}
+}
+
+reload() {
+ local retval
+
+ ebegin "Reloading D-BUS messagebus config"
+
+ /usr/bin/dbus-send --print-reply --system --type=method_call \
+ --dest=org.freedesktop.DBus \
+ / org.freedesktop.DBus.ReloadConfig > /dev/null
+ retval=$?
+ eend ${retval}
+ return ${retval}
+}
diff --git a/pcr/openrc-base/device-mapper.conf-1.02.22-r3 b/pcr/openrc-base/device-mapper.conf-1.02.22-r3
new file mode 100644
index 000000000..bc7a25158
--- /dev/null
+++ b/pcr/openrc-base/device-mapper.conf-1.02.22-r3
@@ -0,0 +1 @@
+RC_AFTER="lvm"
diff --git a/pcr/openrc-base/device-mapper.rc-2.02.105-r2 b/pcr/openrc-base/device-mapper.rc-2.02.105-r2
new file mode 100644
index 000000000..56e75037e
--- /dev/null
+++ b/pcr/openrc-base/device-mapper.rc-2.02.105-r2
@@ -0,0 +1,147 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/lvm2/files/device-mapper.rc-2.02.105-r2,v 1.1 2014/02/02 19:52:34 robbat2 Exp $
+
+depend() {
+ # As of .67-r1, we call ALL lvm start/stop scripts with --sysinit, that
+ # means dmeventd is NOT notified, as it cannot be safely running
+ before dmeventd checkfs fsck
+ after modules
+}
+
+dm_in_proc() {
+ local retval=0
+ for x in devices misc ; do
+ grep -qs 'device-mapper' /proc/${x}
+ retval=$((${retval} + $?))
+ done
+ return ${retval}
+}
+
+# char **build_dmsetup_command(volume)
+#
+# Returns complete dmsetup command given single volume name
+build_dmsetup_command() {
+ local count dmsetup_cmd
+
+ # Number of lines mentioning volume name
+ count=$(grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | grep -c ${1})
+
+ # If there's just one line:
+ if [ ${count} -eq 1 ] ; then
+ echo "echo $(grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | \
+ grep ${1} | awk '{$1=""; print $0}') | /sbin/dmsetup create ${1}"
+
+ # For all cases with more lines:
+ elif [ ${count} -gt 1 ] ; then
+ for c in $( seq 1 ${count} ) ; do
+ if [ ${c} -eq 1 ] ; then
+ # Heavy escaping in awk-statement because we cannot use apostrophes
+ dmsetup_cmd="echo -e $(grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | \
+ grep ${1} | awk NR==${c}\ \{\$1=\"\"\;\ print\ \$0\})"
+ else
+ # Append starting with newline
+ dmsetup_cmd="${dmsetup_cmd}\\\\n \
+ $(grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | \
+ grep ${1} | awk NR==${c}\ \{\$1=\"\"\;\ print\ \$0\})"
+ fi
+ done
+ echo "${dmsetup_cmd} | /sbin/dmsetup create ${1}"
+ fi
+
+ return 0
+}
+
+# char **get_new_dm_volumes(void)
+#
+# Return unique volumes from /etc/dmtab
+get_new_dm_volumes() {
+ local volume
+
+ # Filter comments and blank lines
+ grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | \
+ awk '{ print $1 }' | \
+ uniq | \
+ while read volume ; do
+ # If it exists, skip it
+ dmvolume_exists "${volume%:}" && continue
+
+ echo "${volume%:}"
+ done
+
+ return 0
+}
+
+# int dmvolume_exists(volume)
+#
+# Return true if volume exists in DM table
+dmvolume_exists() {
+ local x line volume=$1
+
+ [ -z "${volume}" ] && return 1
+
+ /sbin/dmsetup ls 2>/dev/null | \
+ while read line ; do
+ for x in ${line} ; do
+ # the following conditonal return only breaks out
+ # of the while loop, as it is running in a pipe.
+ [ "${x}" = "${volume}" ] && return 1
+ # We only want to check the volume name
+ break
+ done
+ done
+
+ # if 1 was returned from the above loop, then indicate that
+ # volume exists
+ [ $? = 1 ] && return 0
+
+ # otherwise the loop exited normally and the volume does not
+ # exist
+ return 1
+}
+
+# int is_empty_dm_volume(volume)
+#
+# Return true if the volume exists in DM table, but is empty/non-valid
+is_empty_dm_volume() {
+ local table volume=$1
+
+ set -- $(/sbin/dmsetup table 2>/dev/null | grep -e "^${volume}:")
+ [ "${volume}" = "$1" -a -z "$2" ]
+}
+
+
+start() {
+ if [ -e /proc/modules ] && ! dm_in_proc ; then
+ modprobe dm-mod 2>/dev/null
+ fi
+ # Ensure the dirs exist for locking and running
+ checkpath -q -d -m 0700 -o root:root /run/lvm /run/lock/lvm
+
+ local x volume
+
+ if [ -x /sbin/dmsetup -a -c /dev/mapper/control -a -f /etc/dmtab ] ; then
+ [ -n "$(get_new_dm_volumes)" ] && \
+ einfo " Setting up device-mapper volumes:"
+
+ get_new_dm_volumes | \
+ while read x ; do
+ [ -n "${x}" ] || continue
+
+ volume="${x##* }"
+
+ ebegin " Creating volume: ${volume}"
+ if ! eval $(build_dmsetup_command ${volume}) >/dev/null 2>/dev/null ; then
+ eend 1 " Error creating volume: ${volume}"
+ # dmsetup still adds an empty volume in some cases,
+ # so lets remove it
+ is_empty_dm_volume "${volume}" && \
+ /sbin/dmsetup remove "${volume}" 2>/dev/null
+ else
+ eend 0
+ fi
+ done
+ fi
+}
+
diff --git a/pcr/openrc-base/dhcpcd.initd b/pcr/openrc-base/dhcpcd.initd
new file mode 100644
index 000000000..d88b0610d
--- /dev/null
+++ b/pcr/openrc-base/dhcpcd.initd
@@ -0,0 +1,17 @@
+#!/sbin/runscript
+# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# All rights reserved. Released under the 2-clause BSD license.
+
+command=/sbin/dhcpcd
+pidfile=/var/run/dhcpcd.pid
+command_args=-q
+name="DHCP Client Daemon"
+
+depend()
+{
+ provide net
+ need localmount
+ use logger network
+ after bootmisc modules
+ before dns
+}
diff --git a/pcr/openrc-base/dmeventd.initd-2.02.67-r1 b/pcr/openrc-base/dmeventd.initd-2.02.67-r1
new file mode 100644
index 000000000..3c2f5f327
--- /dev/null
+++ b/pcr/openrc-base/dmeventd.initd-2.02.67-r1
@@ -0,0 +1,26 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/lvm2/files/dmeventd.initd-2.02.67-r1,v 1.3 2014/02/08 21:17:46 robbat2 Exp $
+
+PIDFILE=/run/dmeventd.pid
+BIN=/sbin/dmeventd
+
+depend() {
+ # As of .67-r1, we call ALL lvm start/stop scripts with --sysinit, that
+ # means dmeventd is NOT notified, as it cannot be safely running
+ after lvm device-mapper
+}
+
+start() {
+ ebegin "Starting dmeventd"
+ start-stop-daemon --start --exec $BIN --pidfile $PIDFILE
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping dmeventd"
+ start-stop-daemon --stop --exec $BIN --pidfile $PIDFILE
+ eend $?
+}
+
diff --git a/pcr/openrc-base/lvm-monitoring.initd-2.02.105-r2 b/pcr/openrc-base/lvm-monitoring.initd-2.02.105-r2
new file mode 100644
index 000000000..c53a60465
--- /dev/null
+++ b/pcr/openrc-base/lvm-monitoring.initd-2.02.105-r2
@@ -0,0 +1,39 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/lvm2/files/lvm-monitoring.initd-2.02.105-r2,v 1.1 2014/02/02 19:52:34 robbat2 Exp $
+
+# This script is based on upstream file
+# LVM2.2.02.67/scripts/lvm2_monitoring_init_red_hat.in
+
+depend() {
+ # As of .67-r1, we call ALL lvm start/stop scripts with --sysinit, that
+ # means dmeventd is NOT notified, as it cannot be safely running
+ need lvm dmeventd
+}
+
+VGCHANGE=/sbin/vgchange
+VGS=/sbin/vgs
+
+start() {
+ ret=0
+ # TODO do we want to separate out already active groups only?
+ VGSLIST=`$VGS --noheadings -o name --rows 2> /dev/null`
+ ebegin "Starting LVM monitoring for VGs ${VGSLIST}:"
+ $VGCHANGE --monitor y --poll y ${VGSLIST}
+ ret=$?
+ eend $ret
+ return $ret
+
+}
+
+stop() {
+ ret=0
+ # TODO do we want to separate out already active groups only?
+ VGSLIST=`$VGS --noheadings -o name --rows 2> /dev/null`
+ ebegin "Stopping LVM monitoring for VGs ${VGSLIST}:"
+ $VGCHANGE --monitor n ${VGSLIST}
+ ret=$?
+ eend $ret
+ return $ret
+}
diff --git a/pcr/openrc-base/lvm.confd-2.02.28-r2 b/pcr/openrc-base/lvm.confd-2.02.28-r2
new file mode 100644
index 000000000..2fbd8668c
--- /dev/null
+++ b/pcr/openrc-base/lvm.confd-2.02.28-r2
@@ -0,0 +1,5 @@
+# LVM should normally only be started after mdraid is available
+# this is because LVM physical volumes are very often MD devices.
+RC_AFTER="mdraid"
+
+# vim: ft=gentoo-conf-d
diff --git a/pcr/openrc-base/lvm.rc-2.02.105-r2 b/pcr/openrc-base/lvm.rc-2.02.105-r2
new file mode 100644
index 000000000..7fdf50e18
--- /dev/null
+++ b/pcr/openrc-base/lvm.rc-2.02.105-r2
@@ -0,0 +1,97 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/lvm2/files/lvm.rc-2.02.105-r2,v 1.1 2014/02/02 19:52:34 robbat2 Exp $
+
+depend() {
+ before checkfs fsck
+ after modules device-mapper
+ need lvmetad sysfs
+}
+
+config='global { locking_dir = "/run/lock/lvm" }'
+
+dm_in_proc() {
+ local retval=0
+ for x in devices misc ; do
+ grep -qs 'device-mapper' /proc/${x}
+ retval=$((${retval} + $?))
+ done
+ return ${retval}
+}
+
+start() {
+ # LVM support for /usr, /home, /opt ....
+ # This should be done *before* checking local
+ # volumes, or they never get checked.
+
+ # NOTE: Add needed modules for LVM or RAID, etc
+ # to /etc/modules.autoload if needed
+ for lvm_path in /bin/lvm /sbin/lvm ; do
+ [ -x "$lvm_path" ] && break
+ done
+ if [ ! -x "$lvm_path" ]; then
+ eerror "Cannot find lvm binary in /sbin or /bin!"
+ return 1
+ fi
+ if [ -z "${CDBOOT}" ] ; then
+ if [ -e /proc/modules ] && ! dm_in_proc ; then
+ modprobe dm-mod 2>/dev/null
+ fi
+ if [ -d /proc/lvm ] || dm_in_proc ; then
+ ebegin "Setting up the Logical Volume Manager"
+ #still echo stderr for debugging
+ lvm_commands="#! ${lvm_path} --config '${config}'\n"
+ # Extra PV find pass because some devices might not have been available until very recently
+ lvm_commands="${lvm_commands}pvscan\n"
+ # Now make the nodes
+ lvm_commands="${lvm_commands}vgscan --mknodes\n"
+ # And turn them on!
+ lvm_commands="${lvm_commands}vgchange --sysinit -a ly\n"
+ # Order of this is important, have to work around dash and LVM readline
+ printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
+ eend $? "Failed to setup the LVM"
+ fi
+ fi
+}
+
+stop() {
+ for lvm_path in /bin/lvm /sbin/lvm ; do
+ [ -x "$lvm_path" ] && break
+ done
+ if [ ! -x "$lvm_path" ]; then
+ eerror "Cannot find lvm binary in /sbin or /bin!"
+ return 1
+ fi
+# Stop LVM2
+if [ -x /sbin/vgs ] && \
+ [ -x /sbin/vgchange ] && \
+ [ -x /sbin/lvchange ] && \
+ [ -f /etc/lvmtab -o -d /etc/lvm ] && \
+ [ -d /proc/lvm -o "`grep device-mapper /proc/misc 2>/dev/null`" ]
+then
+ einfo "Shutting down the Logical Volume Manager"
+
+
+ VGS=$($lvm_path vgs --config "${config}" -o vg_name --noheadings --nosuffix --rows 2> /dev/null)
+
+ if [ "$VGS" ]
+ then
+ ebegin " Shutting Down LVs & VGs"
+ #still echo stderr for debugging
+ lvm_commands="#! ${lvm_path} --config '${config}'\n"
+ # Extra PV find pass because some devices might not have been available until very recently
+ lvm_commands="${lvm_commands}lvchange --sysinit -a ln ${VGS}\n"
+ # Now make the nodes
+ lvm_commands="${lvm_commands}vgchange --sysinit -a ln ${VGS}\n"
+ # Order of this is important, have to work around dash and LVM readline
+ printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
+ eend $? "Failed (possibly some LVs still needed for /usr or root)"
+ fi
+
+ einfo "Finished shutting down the Logical Volume Manager"
+ return 0
+fi
+}
+
+# vim:ts=4
diff --git a/pcr/openrc-base/lvmetad.initd-2.02.105-r2 b/pcr/openrc-base/lvmetad.initd-2.02.105-r2
new file mode 100644
index 000000000..e16d55c46
--- /dev/null
+++ b/pcr/openrc-base/lvmetad.initd-2.02.105-r2
@@ -0,0 +1,13 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/lvm2/files/lvmetad.initd-2.02.105-r2,v 1.2 2014/02/08 21:17:46 robbat2 Exp $
+
+pidfile="/run/lvmetad.pid"
+command="/sbin/lvmetad"
+command_args="${LVMETAD_OPTS:=-p ${pidfile}}"
+start_stop_daemon_args="--pidfile ${pidfile}"
+
+depend() {
+ :
+}
diff --git a/pcr/openrc-base/mdadm.confd b/pcr/openrc-base/mdadm.confd
new file mode 100644
index 000000000..a4ead14dc
--- /dev/null
+++ b/pcr/openrc-base/mdadm.confd
@@ -0,0 +1,7 @@
+# /etc/conf.d/mdadm: config file for /etc/init.d/mdadm
+
+# Misc options to pass to mdadm in monitor mode.
+# For more info, run `mdadm --monitor --help` or see
+# the mdadm(8) manpage.
+
+MDADM_OPTS="--syslog"
diff --git a/pcr/openrc-base/mdadm.rc b/pcr/openrc-base/mdadm.rc
new file mode 100644
index 000000000..c30004d0b
--- /dev/null
+++ b/pcr/openrc-base/mdadm.rc
@@ -0,0 +1,26 @@
+#!/sbin/runscript
+# Copyright 1999-2006 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/mdadm/files/mdadm.rc,v 1.2 2006/04/25 05:41:51 vapier Exp $
+
+depend() {
+ use logger dns net
+}
+
+start() {
+ ebegin "Starting mdadm monitor"
+ mdadm --monitor --scan \
+ --daemonise \
+ --pid-file /var/run/mdadm.pid \
+ ${MDADM_OPTS}
+ eend $?
+}
+
+stop() {
+ local ret
+ ebegin "Stopping mdadm monitor"
+ start-stop-daemon --stop --pidfile /var/run/mdadm.pid
+ ret=$?
+ rm -f /var/run/mdadm.pid
+ eend ${ret}
+}
diff --git a/pcr/openrc-base/mdraid.confd b/pcr/openrc-base/mdraid.confd
new file mode 100644
index 000000000..daa17abd8
--- /dev/null
+++ b/pcr/openrc-base/mdraid.confd
@@ -0,0 +1,5 @@
+# /etc/conf.d/mdraid: config file for /etc/init.d/mdraid
+
+# For people who run raid on top of some other layer (like
+# dmcrypt), use rc_need to specify that requirement. See
+# the runscript(8) man page for more information.
diff --git a/pcr/openrc-base/mdraid.rc b/pcr/openrc-base/mdraid.rc
new file mode 100644
index 000000000..27421e26e
--- /dev/null
+++ b/pcr/openrc-base/mdraid.rc
@@ -0,0 +1,40 @@
+#!/sbin/runscript
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/mdadm/files/mdraid.rc,v 1.6 2011/11/12 21:06:44 vapier Exp $
+
+depend() {
+ before checkfs fsck
+ after modules
+}
+
+start() {
+ local output
+
+ ebegin "Starting up RAID devices"
+ output=$(mdadm -As 2>&1)
+ eend $? "${output}"
+
+ local pat="/dev/md_d*"
+ set -- ${pat}
+ if [ "$*" != "${pat}" ] ; then
+ ebegin "Creating RAID device partitions"
+ blockdev "$@"
+ eend $?
+ # wait because vgscan runs next, and we want udev to fire
+ sleep 1
+ fi
+
+ return 0
+}
+
+stop() {
+ local output
+
+ # XXX: Maybe drop this check ?
+ [ ! -e /etc/mdadm/mdadm.conf ] && [ ! -e /etc/mdadm.conf ] && return 0
+
+ ebegin "Shutting down RAID devices (mdadm)"
+ output=$(mdadm -Ss 2>&1)
+ eend $? "${output}"
+}
diff --git a/pcr/openrc-base/nscd b/pcr/openrc-base/nscd
new file mode 100644
index 000000000..b102de070
--- /dev/null
+++ b/pcr/openrc-base/nscd
@@ -0,0 +1,64 @@
+#!/sbin/runscript
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/nscd,v 1.7 2007/02/23 12:09:39 uberlord Exp $
+
+depend() {
+ use dns ldap net slapd
+}
+
+checkconfig() {
+ if [ ! -d /var/run/nscd ] ; then
+ mkdir -p /var/run/nscd
+ chmod 755 /var/run/nscd
+ fi
+ if [ -z "${NSCD_PERMS_OK}" ] && [ "$(stat -c %a /var/run/nscd)" != "755" ] ; then
+ echo ""
+ ewarn "nscd run dir is not world readable, you should reset the perms:"
+ ewarn "chmod 755 /var/run/nscd"
+ ewarn "chmod a+rw /var/run/nscd/socket"
+ echo ""
+ ewarn "To disable this warning, set 'NSCD_PERMS_OK' in /etc/conf.d/nscd"
+ echo ""
+ fi
+}
+
+start() {
+ checkconfig
+
+ ebegin "Starting Name Service Cache Daemon"
+ local secure=`while read curline ; do
+ table=${curline%:*}
+ entries=${curline##$table:}
+ table=${table%%[^a-z]*}
+ case $table in
+ passwd*|group*|hosts)
+ for entry in $entries ; do
+ case $entry in
+ nisplus*)
+ /usr/sbin/nscd_nischeck $table || \
+ /echo "-S $table,yes"
+ ;;
+ esac
+ done
+ ;;
+ esac
+ done < /etc/nsswitch.conf`
+ local pidfile="$(strings /usr/sbin/nscd | grep nscd.pid)"
+ mkdir -p "$(dirname ${pidfile})"
+ save_options pidfile "${pidfile}"
+ start-stop-daemon --start --quiet \
+ --exec /usr/sbin/nscd --pidfile "${pidfile}" \
+ -- $secure
+ eend $?
+}
+
+stop() {
+ local pidfile="$(get_options pidfile)"
+ [ -n "${pidfile}" ] && pidfile="--pidfile ${pidfile}"
+ ebegin "Shutting down Name Service Cache Daemon"
+ start-stop-daemon --stop --quiet --exec /usr/sbin/nscd ${pidfile}
+ eend $?
+}
+
+# vim:ts=4
diff --git a/pcr/openrc-base/udev-postmount b/pcr/openrc-base/udev-postmount
new file mode 100644
index 000000000..e433736db
--- /dev/null
+++ b/pcr/openrc-base/udev-postmount
@@ -0,0 +1,55 @@
+#!/sbin/runscript
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend()
+{
+ need localmount
+ keyword -vserver -lxc
+}
+
+dir_writeable()
+{
+ touch "$1"/.test.$$ 2>/dev/null && rm "$1"/.test.$$
+}
+
+# store persistent-rules that got created while booting
+# when / was still read-only
+store_persistent_rules()
+{
+ # create /etc/udev/rules.d if it does not exist and /etc/udev is writable
+ [ -d /etc/udev/rules.d ] || \
+ dir_writeable /etc/udev && \
+ mkdir -p /etc/udev/rules.d
+
+ # only continue if rules-directory is writable
+ dir_writeable /etc/udev/rules.d || return 0
+
+ local file dest
+ for file in /run/udev/tmp-rules--*; do
+ dest=${file##*tmp-rules--}
+ [ "$dest" = '*' ] && break
+ type=${dest##70-persistent-}
+ type=${type%%.rules}
+ ebegin "Saving udev persistent ${type} rules to /etc/udev/rules.d"
+ cat "$file" >> /etc/udev/rules.d/"$dest" && rm -f "$file"
+ eend $? "Failed moving persistent rules!"
+ done
+}
+
+start()
+{
+ # check if this system uses udev
+ [ -d /run/udev ] || return 0
+
+ # store persistent-rules that got created while booting
+ # when / was still read-only
+ store_persistent_rules
+}
+
+stop()
+{
+ return 0
+}
+
+# vim:ts=4