saving uncommitted changes in /etc prior to emerge run

This commit is contained in:
2015-02-27 01:58:55 +01:00
committed by root
commit b3cea8d893
2385 changed files with 507432 additions and 0 deletions

88
init.d/._cfg0000_alsasound Executable file
View File

@@ -0,0 +1,88 @@
#!/sbin/runscript
# $Header: /var/cvsroot/gentoo-x86/media-sound/alsa-utils/files/alsasound.initd-r6,v 1.1 2014/06/23 21:34:42 ssuominen Exp $
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
alsastatedir=/var/lib/alsa
alsascrdir=/etc/alsa.d
alsahomedir=/var/run/alsasound
extra_commands="save restore"
depend() {
need localmount
after bootmisc modules isapnp coldplug hotplug
}
restore() {
ebegin "Restoring Mixer Levels"
checkpath -q -d -m 0700 -o root:root ${alsahomedir} || return 1
if [ ! -r "${alsastatedir}/asound.state" ] ; then
ewarn "No mixer config in ${alsastatedir}/asound.state, you have to unmute your card!"
eend 0
return 0
fi
local cards="$(sed -n -e 's/ *\([[:digit:]]*\) .*/\1/p' /proc/asound/cards)"
local CARDNUM
for cardnum in ${cards}; do
[ -e /dev/snd/controlC${cardnum} ] || sleep 2
[ -e /dev/snd/controlC${cardnum} ] || sleep 2
[ -e /dev/snd/controlC${cardnum} ] || sleep 2
[ -e /dev/snd/controlC${cardnum} ] || sleep 2
alsactl -E HOME="${alsahomedir}" -I -f "${alsastatedir}/asound.state" restore ${cardnum} \
|| ewarn "Errors while restoring defaults, ignoring"
done
for ossfile in "${alsastatedir}"/oss/card*_pcm* ; do
[ -e "${ossfile}" ] || continue
# We use cat because I'm not sure if cp works properly on /proc
local procfile=${ossfile##${alsastatedir}/oss}
procfile="$(echo "${procfile}" | sed -e 's,_,/,g')"
if [ -e /proc/asound/"${procfile}"/oss ] ; then
cat "${ossfile}" > /proc/asound/"${procfile}"/oss
fi
done
eend 0
}
save() {
ebegin "Storing ALSA Mixer Levels"
checkpath -q -d -m 0700 -o root:root ${alsahomedir} || return 1
mkdir -p "${alsastatedir}"
if ! alsactl -E HOME="${alsahomedir}" -f "${alsastatedir}/asound.state" store; then
eerror "Error saving levels."
eend 1
return 1
fi
for ossfile in /proc/asound/card*/pcm*/oss; do
[ -e "${ossfile}" ] || continue
local device=${ossfile##/proc/asound/} ; device=${device%%/oss}
device="$(echo "${device}" | sed -e 's,/,_,g')"
mkdir -p "${alsastatedir}/oss/"
cp "${ossfile}" "${alsastatedir}/oss/${device}"
done
eend 0
}
start() {
if [ "${RESTORE_ON_START}" = "yes" ]; then
restore
fi
return 0
}
stop() {
if [ "${SAVE_ON_STOP}" = "yes" ]; then
save
fi
return 0
}

187
init.d/._cfg0000_apache2 Executable file
View File

@@ -0,0 +1,187 @@
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
extra_commands="configtest modules virtualhosts"
extra_started_commands="configdump fullstatus graceful gracefulstop reload"
description_configdump="Dumps the configuration of the runing apache server. Requires server-info to be enabled and www-client/lynx."
description_configtest="Run syntax tests for configuration files."
description_fullstatus="Gives the full status of the server. Requires lynx and server-status to be enabled."
description_graceful="A graceful restart advises the children to exit after the current request and reloads the configuration."
description_gracefulstop="A graceful stop advises the children to exit after the current request and stops the server."
description_modules="Dump a list of loaded Static and Shared Modules."
description_reload="Kills all children and reloads the configuration."
description_virtualhosts="Show the settings as parsed from the config file (currently only shows the virtualhost settings)."
description_stop="Kills all children and stops the server."
depend() {
need net
use mysql dns logger netmount postgresql
after sshd
}
configtest() {
ebegin "Checking ${SVCNAME} configuration"
checkconfig
eend $?
}
checkconfd() {
if [ ! -f /etc/init.d/sysfs ]; then
eerror "This init script works only with openrc (baselayout-2)."
eerror "If you still need baselayout-1.x, please, use"
eerror "apache2.initd-baselayout-1 from /usr/share/doc/apache2-*/"
fi
PIDFILE="${PIDFILE:-/var/run/apache2.pid}"
TIMEOUT=${TIMEOUT:-15}
SERVERROOT="${SERVERROOT:-/usr/lib64/apache2}"
if [ ! -d ${SERVERROOT} ]; then
eerror "SERVERROOT does not exist: ${SERVERROOT}"
return 1
fi
CONFIGFILE="${CONFIGFILE:-/etc/apache2/httpd.conf}"
[ "${CONFIGFILE#/}" = "${CONFIGFILE}" ] && CONFIGFILE="${SERVERROOT}/${CONFIGFILE}"
if [ ! -r "${CONFIGFILE}" ]; then
eerror "Unable to read configuration file: ${CONFIGFILE}"
return 1
fi
APACHE2_OPTS="${APACHE2_OPTS} -d ${SERVERROOT}"
APACHE2_OPTS="${APACHE2_OPTS} -f ${CONFIGFILE}"
[ -n "${STARTUPERRORLOG}" ] && APACHE2_OPTS="${APACHE2_OPTS} -E ${STARTUPERRORLOG}"
APACHE2="/usr/sbin/apache2"
}
checkconfig() {
checkconfd || return 1
${APACHE2} ${APACHE2_OPTS} -t 1>/dev/null 2>&1
ret=$?
if [ $ret -ne 0 ]; then
eerror "${SVCNAME} has detected an error in your setup:"
${APACHE2} ${APACHE2_OPTS} -t
fi
return $ret
}
start() {
checkconfig || return 1
ebegin "Starting ${SVCNAME}"
# Use start stop daemon to apply system limits #347301
start-stop-daemon --start -- ${APACHE2} ${APACHE2_OPTS} -k start
local i=0 retval=1
while [ $i -lt ${TIMEOUT} ] ; do
if [ -e "${PIDFILE}" ] ; then
retval=0
break
fi
sleep 1 && i=$(expr $i + 1)
done
eend ${retval}
}
stop() {
if [ "${RC_CMD}" = "restart" ]; then
checkconfig || return 1
else
checkconfd || return 1
fi
PID=$(cat "${PIDFILE}" 2>/dev/null)
if [ -z "${PID}" ]; then
einfo "${SVCNAME} not running (no pid file)"
return 0
fi
ebegin "Stopping ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k stop
local i=0 retval=0
while ( test -f "${PIDFILE}" || pgrep -P ${PID} apache2 >/dev/null ) \
&& [ $i -lt ${TIMEOUT} ]; do
sleep 1 && i=$(expr $i + 1)
done
[ -e "${PIDFILE}" ] && retval=1
eend ${retval}
}
reload() {
RELOAD_TYPE="${RELOAD_TYPE:-graceful}"
checkconfig || return 1
if [ "${RELOAD_TYPE}" = "restart" ]; then
ebegin "Restarting ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k restart
eend $?
elif [ "${RELOAD_TYPE}" = "graceful" ]; then
ebegin "Gracefully restarting ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k graceful
eend $?
else
eerror "${RELOAD_TYPE} is not a valid RELOAD_TYPE. Please edit /etc/conf.d/${SVCNAME}"
fi
}
graceful() {
checkconfig || return 1
ebegin "Gracefully restarting ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k graceful
eend $?
}
gracefulstop() {
checkconfig || return 1
ebegin "Gracefully stopping ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k graceful-stop
eend $?
}
modules() {
checkconfig || return 1
${APACHE2} ${APACHE2_OPTS} -M 2>&1
}
fullstatus() {
LYNX="${LYNX:-lynx -dump}"
STATUSURL="${STATUSURL:-http://localhost/server-status}"
if ! type -p $(set -- ${LYNX}; echo $1) 2>&1 >/dev/null; then
eerror "lynx not found! you need to emerge www-client/lynx"
else
${LYNX} ${STATUSURL}
fi
}
virtualhosts() {
checkconfig || return 1
${APACHE2} ${APACHE2_OPTS} -S
}
configdump() {
LYNX="${LYNX:-lynx -dump}"
INFOURL="${INFOURL:-http://localhost/server-info}"
checkconfd || return 1
if ! type -p $(set -- ${LYNX}; echo $1) 2>&1 >/dev/null; then
eerror "lynx not found! you need to emerge www-client/lynx"
else
echo "${APACHE2} started with '${APACHE2_OPTS}'"
for i in config server list; do
${LYNX} "${INFOURL}/?${i}" | sed '/Apache Server Information/d;/^[[:space:]]\+[_]\+$/Q'
done
fi
}
# vim: ts=4 filetype=gentoo-init-d

219
init.d/._cfg0000_bootmisc Executable file
View File

@@ -0,0 +1,219 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
depend()
{
need localmount
before logger
after clock root sysctl
keyword -prefix -timeout
}
: ${wipe_tmp:=${WIPE_TMP:-yes}}
: ${log_dmesg:=${LOG_DMESG:-yes}}
cleanup_tmp_dir()
{
local dir="$1"
if ! [ -d "$dir" ]; then
mkdir -p "$dir" || return $?
fi
checkpath -W "$dir" || return 1
chmod a+rwt "$dir" 2> /dev/null
cd "$dir" || return 1
if yesno $wipe_tmp; then
ebegin "Wiping $dir directory"
# Faster than raw find
if ! rm -rf -- [!ajlq\.]* 2>/dev/null ; then
# Blah, too many files
find . -maxdepth 1 -name '[!ajlq\.]*' -exec rm -rf -- {} +
fi
# pam_mktemp creates a .private directory within which
# each user gets a private directory with immutable
# bit set; remove the immutable bit before trying to
# remove it.
[ -d /tmp/.private ] && chattr -R -a /tmp/.private 2> /dev/null
# Prune the paths that are left
find . -maxdepth 1 \
! -name . \
! -name lost+found \
! -name quota.user \
! -name aquota.user \
! -name quota.group \
! -name aquota.group \
! -name journal \
-exec rm -rf -- {} +
eend 0
else
ebegin "Cleaning $dir directory"
rm -rf -- .X*-lock esrv* kio* \
jpsock.* .fam* .esd* \
orbit-* ssh-* ksocket-* \
.*-unix
eend 0
fi
}
cleanup_var_run_dir()
{
ebegin "Cleaning /var/run"
for x in $(find /var/run ! -type d ! -name utmp \
! -name random-seed ! -name dev.db \
! -name ld-elf.so.hints ! -name ld.so.hints);
do
# Clean stale sockets
if [ -S "$x" ]; then
if command -v fuser >/dev/null 2>&1; then
fuser "$x" >/dev/null 2>&1 || rm -- "$x"
else
rm -- "$x"
fi
fi
[ ! -f "$x" ] && continue
# Do not remove pidfiles of already running daemons
case "$x" in
*.pid)
start-stop-daemon --test --quiet \
--stop --pidfile "$x" && continue
;;
esac
rm -f -- "$x"
done
eend 0
}
mkutmp()
{
: >"$1"
# Not all systems have the utmp group
chgrp utmp "$1" 2>/dev/null
chmod 0664 "$1"
}
migrate_to_run()
{
src="$1"
dst="$2"
if [ -L $src -a "$(readlink -f $src)" != $dst ]; then
ewarn "$src does not point to $dst."
ewarn "Setting $src to point to $dst."
rm $src
elif [ ! -L $src -a -d $src ]; then
ebegin "Migrating $src to $dst"
cp -a $src/* $dst/
rm -rf $src
eend $?
fi
# If $src doesn't exist at all, just run this
if [ ! -e $src ]; then
ln -s $dst $src
fi
}
clean_run()
{
[ "$RC_SYS" = VSERVER -o "$RC_SYS" = LXC ] && return 0
local dir
dir=$(mktemp -d)
mount --bind / $dir
rm -rf $dir/run/*
umount $dir
rm -rf $dir
}
start()
{
# Remove any added console dirs
if checkpath -W "$RC_LIBEXECDIR"; then
rm -rf "$RC_LIBEXECDIR"/console/*
fi
local logw=false runw=false extra=
# Ensure that our basic dirs exist
if [ "$RC_UNAME" = Linux ]; then
# Satisfy Linux FHS
extra=/var/lib/misc
if [ ! -d /run ]; then
extra="/var/run $extra"
fi
else
extra=/var/run
fi
for x in /var/log /tmp $extra; do
if ! [ -d $x ]; then
if ! mkdir -p $x; then
eend 1 "failed to create needed directory $x"
return 1
fi
fi
done
if [ "$RC_UNAME" = Linux -a -d /run ]; then
migrate_to_run /var/lock /run/lock
migrate_to_run /var/run /run
clean_run
fi
if checkpath -W /var/run; then
ebegin "Creating user login records"
local xtra=
[ "$RC_UNAME" = NetBSD ] && xtra=x
for x in "" $xtra; do
mkutmp /var/run/utmp$x
done
[ -e /var/log/wtmp ] || mkutmp /var/log/wtmp
eend 0
mountinfo -q -f tmpfs /var/run || cleanup_var_run_dir
fi
# Clean up /tmp directories
local tmp=
for tmp in ${clean_tmp_dirs:-${wipe_tmp_dirs-/tmp}}; do
mountinfo -q -f tmpfs "$tmp" || cleanup_tmp_dir "$tmp"
done
if checkpath -W /tmp; then
# Make sure our X11 stuff have the correct permissions
# Omit the chown as bootmisc is run before network is up
# and users may be using lame LDAP auth #139411
rm -rf /tmp/.ICE-unix /tmp/.X11-unix
mkdir -p /tmp/.ICE-unix /tmp/.X11-unix
chmod 1777 /tmp/.ICE-unix /tmp/.X11-unix
if [ -x /sbin/restorecon ]; then
restorecon /tmp/.ICE-unix /tmp/.X11-unix
fi
fi
if yesno $log_dmesg; then
if $logw || checkpath -W /var/log; then
# Create an 'after-boot' dmesg log
if [ "$RC_SYS" != VSERVER -a "$RC_SYS" != OPENVZ -a "$RC_SYS" != LXC ]; then
dmesg > /var/log/dmesg
chmod 640 /var/log/dmesg
fi
fi
fi
return 0
}
stop()
{
# Write a halt record if we're shutting down
if [ "$RC_RUNLEVEL" = shutdown ]; then
[ "$RC_UNAME" = Linux ] && halt -w
if [ "$RC_SYS" = OPENVZ ]; then
yesno $RC_REBOOT && printf "" >/reboot
fi
fi
return 0
}
# vim: ft=sh

63
init.d/._cfg0000_consolefont Executable file
View File

@@ -0,0 +1,63 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Sets a font for the consoles."
depend()
{
need localmount termencoding
after hotplug bootmisc
keyword -openvz -prefix -uml -vserver -xenu -lxc
}
start()
{
ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
consolefont=${consolefont:-${CONSOLEFONT}}
unicodemap=${unicodemap:-${UNICODEMAP}}
consoletranslation=${consoletranslation:-${CONSOLETRANSLATION}}
if [ -z "$consolefont" ]; then
ebegin "Using the default console font"
eend 0
return 0
fi
if [ "$ttyn" = 0 ]; then
ebegin "Skipping font setup (rc_tty_number == 0)"
eend 0
return 0
fi
local x= param= sf_param= retval=0 ttydev=/dev/tty
# Get additional parameters
if [ -n "$consoletranslation" ]; then
param="$param -m $consoletranslation"
fi
if [ -n "${unicodemap}" ]; then
param="$param -u $unicodemap"
fi
# Set the console font
ebegin "Setting console font [$consolefont]"
[ -d /dev/vc ] && ttydev=/dev/vc/
x=1
while [ $x -le $ttyn ]; do
if ! setfont $consolefont $param -C $ttydev$x >/dev/null; then
retval=1
break
fi
: $(( x += 1 ))
done
eend $retval
# Store the font so we can use it ASAP on boot
if [ $retval -eq 0 ] && checkpath -W "$RC_LIBEXECDIR"; then
mkdir -p "$RC_LIBEXECDIR"/console
setfont -O "$RC_LIBEXECDIR"/console/font
fi
return $retval
}

121
init.d/._cfg0000_devfs Executable file
View File

@@ -0,0 +1,121 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Set up the /dev directory"
depend()
{
provide dev-mount
before dev
keyword -prefix -vserver -lxc
}
mount_dev()
{
local action=--mount devfstype msg=Mounting
# Some devices require exec, Bug #92921
local mountopts="exec,nosuid,mode=0755"
if yesno ${skip_mount_dev:-no} ; then
einfo "/dev will not be mounted due to user request"
return 0
fi
if mountinfo -q /dev; then
action=--remount
mountopts="remount,$mountopts"
msg=Remounting
fi
if fstabinfo -q /dev; then
ebegin "$msg /dev according to /etc/fstab"
fstabinfo -q $action /dev
eend $?
return 0
fi
if grep -q devtmpfs /proc/filesystems; then
devfstype=devtmpfs
mountopts="$mountopts,size=10M"
elif grep -q tmpfs /proc/filesystems; then
devfstype=tmpfs
mountopts="$mountopts,size=10M"
fi
if [ -n "$devfstype" ]; then
ebegin "$msg $devfstype on /dev"
mount -n -t $devfstype -o $mountopts dev /dev
eend $?
else
ewarn "This kernel does not have devtmpfs or tmpfs support, and there"
ewarn "is no entry for /dev in fstab."
ewarn "This means /dev will not be mounted."
ewarn "To avoid this message, set CONFIG_DEVTMPFS or CONFIG_TMPFS to y"
ewarn "in your kernel configuration or see /etc/conf.d/devfs"
fi
return 0
}
seed_dev()
{
# Seed /dev with some things that we know we need
# creating /dev/console, /dev/tty and /dev/tty1 to be able to write
# to $CONSOLE with/without bootsplash before udevd creates it
[ -c /dev/console ] || mknod -m 600 /dev/console c 5 1
[ -c /dev/tty1 ] || mknod -m 620 /dev/tty1 c 4 1
[ -c /dev/tty ] || mknod -m 666 /dev/tty c 5 0
# udevd will dup its stdin/stdout/stderr to /dev/null
# and we do not want a file which gets buffered in ram
[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3
# so udev can add its start-message to dmesg
[ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11
# extra symbolic links not provided by default
[ -e /dev/fd ] || ln -snf /proc/self/fd /dev/fd
[ -e /dev/stdin ] || ln -snf /proc/self/fd/0 /dev/stdin
[ -e /dev/stdout ] || ln -snf /proc/self/fd/1 /dev/stdout
[ -e /dev/stderr ] || ln -snf /proc/self/fd/2 /dev/stderr
[ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core
# Mount required directories as user may not have them in /etc/fstab
for x in \
"mqueue /dev/mqueue 1777 ,nodev mqueue" \
"devpts /dev/pts 0755 ,gid=5,mode=0620 devpts" \
"tmpfs /dev/shm 1777 ,nodev,mode=1777 shm" \
; do
set -- $x
grep -Eq "[[:space:]]+$1$" /proc/filesystems || continue
mountinfo -q $2 && continue
if [ ! -d $2 ]; then
mkdir -m $3 -p $2 >/dev/null 2>&1 || \
ewarn "Could not create $2!"
fi
if [ -d $2 ]; then
ebegin "Mounting $2"
if ! fstabinfo --mount $2; then
mount -n -t $1 -o noexec,nosuid$4 $5 $2
fi
eend $?
fi
done
}
restorecon_dev()
{
if [ -x /sbin/restorecon ]; then
ebegin "Restoring SELinux contexts in /dev"
restorecon -rF /dev >/dev/null 2>&1
eend $?
fi
return 0
}
start()
{
mount_dev
seed_dev
restorecon_dev
return 0
}

147
init.d/._cfg0000_device-mapper Executable file
View File

@@ -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
}

18
init.d/._cfg0000_dmesg Executable file
View File

@@ -0,0 +1,18 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Set the dmesg level for a cleaner boot"
depend()
{
before dev modules
keyword -lxc -prefix -vserver
}
start()
{
if [ -n "$dmesg_level" ]; then
dmesg -n$dmesg_level
fi
}

66
init.d/._cfg0000_dropbox Executable file
View File

@@ -0,0 +1,66 @@
#!/sbin/runscript
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/net-misc/dropbox/files/dropbox.initd,v 1.5 2014/10/18 02:09:07 naota Exp $
depend() {
need localmount net
after bootmisc
}
start() {
local tmpnice="${NICE:+"--nicelevel "}${NICE}"
local tmpionice="${IONICE:+"--ionice "}${IONICE}"
local started=""
ebegin "Starting dropbox"
for dbuser in ${DROPBOX_USERS}; do
local homedir=$(eval echo ~${dbuser})
if test -d "${homedir}" && \
echo 0 > ${homedir}/.dropbox/dropbox.pid && \
start-stop-daemon -S -b \
${tmpnice} ${tmpionice} \
-u ${dbuser} -v \
-p ${homedir}/.dropbox/dropbox.pid \
-e HOME=${homedir} \
-x /opt/bin/dropbox; then
started="${started} ${dbuser}"
else
eend $?
eerror "Failed to start dropbox for ${dbuser}"
if [ -n "${started}" ]; then
eerror "Stopping already started dropbox"
DROPBOX_USERS=${started} stop
fi
return 1
fi
done
if [ -z "${started}" ];then
eerror "No dropbox started"
eend 1
else
eend 0
fi
}
stop() {
local retval=0
ebegin "Stopping dropbox"
for dbuser in ${DROPBOX_USERS}; do
local homedir=$(eval echo ~${dbuser})
start-stop-daemon --stop \
--pidfile ${homedir}/.dropbox/dropbox.pid || retval=$?
done
eend ${retval}
}
status() {
for dbuser in ${DROPBOX_USERS}; do
local homedir=$(eval echo ~${dbuser})
if [ -e ${homedir}/.dropbox/dropbox.pid ] ; then
echo "dropboxd for USER $dbuser: running."
else
echo "dropboxd for USER $dbuser: not running."
fi
done
}

123
init.d/._cfg0000_fsck Executable file
View File

@@ -0,0 +1,123 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Check and repair filesystems according to /etc/fstab"
_IFS="
"
depend()
{
use dev clock modules
keyword -jail -openvz -prefix -timeout -vserver -lxc -uml
}
_abort() {
rc-abort
return 1
}
# We should only reboot when first booting
_reboot() {
if [ "$RC_RUNLEVEL" = "$RC_BOOTLEVEL" ]; then
reboot "$@"
_abort || return 1
fi
}
_forcefsck()
{
[ -e /forcefsck ] || get_bootparam forcefsck
}
start()
{
local fsck_opts= p= check_extra=
if [ -e /fastboot ]; then
ewarn "Skipping fsck due to /fastboot"
return 0
fi
if _forcefsck; then
fsck_opts="$fsck_opts -f"
check_extra="(check forced)"
elif ! yesno ${fsck_on_battery:-YES} && ! on_ac_power; then
ewarn "Skipping fsck due to not being on AC power"
return 0
fi
if [ -n "$fsck_passno" ]; then
check_extra="[passno $fsck_passno] $check_extra"
if [ -n "$fsck_mnt" ]; then
eerror "Only 1 of fsck_passno and fsck_mnt must be set!"
return 1
fi
fi
ebegin "Checking local filesystems $check_extra"
# Append passno mounts
for p in $fsck_passno; do
local IFS="$_IFS"
case "$p" in
[0-9]*) p="=$p";;
esac
set -- "$@" $(fstabinfo --passno "$p")
unset IFS
done
# Append custom mounts
for m in $fsck_mnt ; do
local IFS="$_IFS"
set -- "$@" "$m"
unset IFS
done
if [ "$RC_UNAME" = Linux ]; then
local skiptypes
skiptypes=$(printf 'no%s,' ${net_fs_list} ${extra_net_fs_list})
[ "${skiptypes}" = "no," ] && skiptypes=""
fsck_opts="$fsck_opts -C0 -T -t ${skiptypes}noopts=_netdev"
if [ -z "$fsck_passno" -a -z "$fsck_mnt" ]; then
fsck_args=${fsck_args:--A -p}
if echo 2>/dev/null >/.test.$$; then
rm -f /.test.$$
fsck_opts="$fsck_opts -R"
fi
fi
fi
trap : INT QUIT
fsck ${fsck_args:--p} $fsck_opts "$@"
case $? in
0) eend 0; return 0;;
1) ewend 1 "Filesystems repaired"; return 0;;
2|3) if [ "$RC_UNAME" = Linux ]; then
ewend 1 "Filesystems repaired, but reboot needed"
_reboot -f
else
ewend 1 "Filesystems still have errors;" \
"manual fsck required"
_abort
fi;;
4) if [ "$RC_UNAME" = Linux ]; then
ewend 1 "Fileystem errors left uncorrected, aborting"
_abort
else
ewend 1 "Filesystems repaired, but reboot needed"
_reboot
fi;;
8) ewend 1 "Operational error"; return 0;;
12) ewend 1 "fsck interrupted";;
*) eend 2 "Filesystems couldn't be fixed";;
esac
_abort || return 1
}
stop()
{
# Fake function so we always shutdown correctly.
_abort() { return 0; }
_reboot() { return 0; }
_forcefsck() { return 1; }
yesno $fsck_shutdown && start
return 0
}

19
init.d/._cfg0000_hostname Executable file
View File

@@ -0,0 +1,19 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Sets the hostname of the machine."
depend() {
keyword -prefix -lxc
}
start()
{
# HOSTNAME variable used to be defined in caps in conf.d/hostname.
# It is also a magic variable in bash.
hostname=${hostname-${HOSTNAME-localhost}} # checkbashisms: false positive
ebegin "Setting hostname to $hostname"
hostname "$hostname"
eend $? "Failed to set the hostname"
}

33
init.d/._cfg0000_hprofile Executable file
View File

@@ -0,0 +1,33 @@
#!/sbin/runscript
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the 2-clause BSD or GPL-2 license
# $Header: hprofile.initd,v 1.4 2014/10/10 13:05:23 -tclover Exp $
description="initialize hprofile boot profiles"
depend()
{
after modules
}
start()
{
for profile in $PROFILES; do
hprofile -f $profile
eend "$?" "Failed to start $profile profile"
done
return 0
}
stop()
{
for profile in $PROFILES; do
hprofile -s $profile
eend "$?" "Failed to stop $profile profile"
done
return 0
}
#
# vim:fenc=utf-8:ft=gentoo-init-d:ci:pi:sts=0:sw=4:ts=4:
#

141
init.d/._cfg0000_hwclock Executable file
View File

@@ -0,0 +1,141 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
extra_commands="save show"
description="Sets the local clock to UTC or Local Time."
description_save="Saves the current time in the BIOS."
description_show="Displays the current time in the BIOS."
: ${clock_adjfile:=${CLOCK_ADJFILE}}
: ${clock_args:=${CLOCK_OPTS}}
: ${clock_systohc:=${CLOCK_SYSTOHC}}
: ${clock:=${CLOCK:-UTC}}
if [ "$clock" = "UTC" ]; then
utc="UTC"
utc_cmd="--utc"
else
utc="Local Time"
utc_cmd="--localtime"
fi
depend()
{
provide clock
if yesno $clock_adjfile; then
use root
else
before *
fi
keyword -openvz -prefix -uml -vserver -xenu -lxc
}
setupopts()
{
case "$(uname -m)" in
s390*)
utc="s390"
;;
*)
if [ -e /proc/devices ] && \
grep -q " cobd$" /proc/devices
then
utc="coLinux"
fi
;;
esac
case "$utc" in
UTC|Local" "Time);;
*) unset utc_cmd;;
esac
}
# hwclock doesn't always return non zero on error
_hwclock()
{
local err="$(hwclock "$@" 2>&1 >/dev/null)"
[ -z "$err" ] && return 0
echo "${err}" >&2
return 1
}
start()
{
local retval=0 errstr=""
setupopts
if [ -z "$utc_cmd" ]; then
ewarn "Not setting clock for $utc system"
return 0
fi
ebegin "Setting system clock using the hardware clock [$utc]"
if [ -e /proc/modules ]; then
local rtc=
for rtc in /dev/rtc /dev/rtc[0-9]*; do
[ -e "$rtc" ] && break
done
if [ ! -e "${rtc}" ]; then
modprobe -q rtc-cmos || modprobe -q rtc || modprobe -q genrtc
fi
fi
# Always set the kernel's time zone.
_hwclock --systz $utc_cmd $clock_args
: $(( retval += $? ))
if [ -e /etc/adjtime ] && yesno $clock_adjfile; then
_hwclock --adjust $utc_cmd
: $(( retval += $? ))
fi
if yesno ${clock_hctosys:-YES}; then
_hwclock --hctosys $utc_cmd $clock_args
: $(( retval += $? ))
fi
eend $retval "Failed to set the system clock"
return 0
}
stop()
{
# Don't tweak the hardware clock on LiveCD halt.
[ -n "$CDBOOT" ] && return 0
yesno ${clock_systohc:-YES} || return 0
local retval=0 errstr=""
setupopts
[ -z "$utc_cmd" ] && return 0
ebegin "Setting hardware clock using the system clock" "[$utc]"
if ! yesno $clock_adjfile; then
# Some implementations don't handle adjustments
if LC_ALL=C hwclock --help 2>&1 | grep -q "\-\-noadjfile"; then
utc_cmd="$utc_cmd --noadjfile"
fi
fi
_hwclock --systohc $utc_cmd $clock_args
retval=$?
eend $retval "Failed to sync clocks"
}
save()
{
clock_systohc=yes
stop
}
show()
{
setupopts
hwclock --show "$utc_cmd" $clock_args
}

70
init.d/._cfg0000_keymaps Executable file
View File

@@ -0,0 +1,70 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Applies a keymap for the consoles."
depend()
{
need localmount termencoding
after bootmisc
keyword -openvz -prefix -uml -vserver -xenu -lxc
}
start()
{
ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
: ${unicode:=$UNICODE}
: ${keymap:=$KEYMAP}
: ${extended_keymaps:=$EXTENDED_KEYMAPS}
: ${windowkeys:=$SET_WINDOWSKEYS}
: ${fix_euro:=$FIX_EURO}
: ${dumpkeys_charset:=${DUMPKEYS_CHARSET}}
if [ -z "$keymap" ]; then
eerror "You need to setup keymap in /etc/conf.d/keymaps first"
return 1
fi
local ttydev=/dev/tty n=
[ -d /dev/vc ] && ttydev=/dev/vc/
# Force linux keycodes for PPC.
if [ -f /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes ]; then
echo 1 > /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes
fi
local wkeys= kmode="-a" msg="ASCII"
if yesno $unicode; then
kmode="-u"
msg="UTF-8"
fi
yesno $windowkeys && wkeys="windowkeys"
# Set terminal encoding to either ASCII or UNICODE.
# See utf-8(7) for more information.
ebegin "Setting keyboard mode [$msg]"
n=1
while [ $n -le $ttyn ]; do
kbd_mode $kmode -C $ttydev$n
: $(( n += 1 ))
done
eend 0
ebegin "Loading key mappings [$keymap]"
loadkeys -q $wkeys $keymap $extended_keymaps
eend $? "Error loading key mappings" || return $?
if yesno $fix_euro; then
ebegin "Fixing font for euro symbol"
# Fix some fonts displaying the Euro, #173528.
echo "altgr keycode 18 = U+20AC" | loadkeys -q -
eend $?
fi
# Save the keymapping for use immediately at boot
if checkpath -W "$RC_LIBEXECDIR"; then
mkdir -p "$RC_LIBEXECDIR"/console
dumpkeys >"$RC_LIBEXECDIR"/console/keymap
fi
}

22
init.d/._cfg0000_killprocs Executable file
View File

@@ -0,0 +1,22 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Kill all processes so we can unmount disks cleanly."
depend()
{
keyword -prefix
}
start()
{
ebegin "Terminating remaining processes"
killall5 -15 ${killall5_opts}
sleep 1
eend 0
ebegin "Killing remaining processes"
killall5 -9 ${killall5_opts}
sleep 1
eend 0
}

86
init.d/._cfg0000_local Executable file
View File

@@ -0,0 +1,86 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Executes user programs in /etc/local.d"
depend()
{
after *
keyword -timeout
}
start()
{
ebegin "Starting local"
local file has_errors=0 redirect retval
yesno $rc_verbose || redirect='> /dev/null 2>&1'
eindent
for file in /etc/local.d/*.start; do
if [ -x "${file}" ]; then
vebegin "Executing \"${file}\""
"${file}" $redirect
retval=$?
if [ ${retval} -ne 0 ]; then
has_errors=1
fi
veend ${retval} "Execution of \"${file}\" failed."
fi
done
eoutdent
if command -v local_start >/dev/null 2>&1; then
ewarn "\"/etc/conf.d/local\" should be removed."
ewarn "Please move the code from the local_start function"
ewarn "to executable scripts with an .start extension"
ewarn "in \"/etc/local.d\""
local_start
fi
eend ${has_errors}
# We have to end with a zero exit code, because a failed execution
# of an executable /etc/local.d/*.start file shouldn't result in
# marking the local service as failed. Otherwise we are unable to
# execute any executable /etc/local.d/*.stop file, because a failed
# marked service cannot be stopped (and the stop function would
# actually call the executable /etc/local.d/*.stop file(s)).
return 0
}
stop()
{
ebegin "Stopping local"
local file has_errors=0 redirect retval
yesno $rc_verbose || redirect='> /dev/null 2>&1'
eindent
for file in /etc/local.d/*.stop; do
if [ -x "${file}" ]; then
vebegin "Executing \"${file}\""
"${file}" $redirect
retval=$?
if [ ${retval} -ne 0 ]; then
has_errors=1
fi
veend ${retval} "Execution of \"${file}\" failed."
fi
done
eoutdent
if command -v local_stop >/dev/null 2>&1; then
ewarn "\"/etc/conf.d/local\" should be removed."
ewarn "Please move the code from the local_stop function"
ewarn "to executable scripts with an .stop extension"
ewarn "in \"/etc/local.d\""
local_stop
fi
eend ${has_errors}
# An executable /etc/local.d/*.stop file which failed with a
# non-zero exit status is not a reason to mark this service
# as failed, therefore we have to end with a zero exit code.
return 0
}

112
init.d/._cfg0000_localmount Executable file
View File

@@ -0,0 +1,112 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Mounts disks and swap according to /etc/fstab."
depend()
{
need fsck
use lvm modules mtab
after lvm modules
keyword -jail -prefix -vserver -lxc
}
start()
{
# Mount local filesystems in /etc/fstab.
local types="noproc" x= no_netdev=
for x in $net_fs_list $extra_net_fs_list; do
types="${types},no${x}"
done
if [ "$RC_UNAME" = Linux ]; then
no_netdev="-O no_netdev"
if mountinfo -q /usr; then
touch "$RC_SVCDIR"/usr_premounted
fi
fi
ebegin "Mounting local filesystems"
mount -at "$types" $no_netdev
eend $? "Some local filesystem failed to mount"
# Always return 0 - some local mounts may not be critical for boot
return 0
}
stop()
{
yesno $RC_GOINGDOWN || return 0
# We never unmount / or /dev or $RC_SVCDIR
# Bug 381783
local rc_svcdir=$(printf '%s\n' "$RC_SVCDIR" | sed 's:/lib\(32\|64\)\?/:/lib(32|64)?/:g')
local x= no_umounts_r="/|/dev|/dev/.*|${rc_svcdir}"
no_umounts_r="${no_umounts_r}|/bin|/sbin|/lib(32|64)?|/libexec"
# RC_NO_UMOUNTS is an env var that can be set by plugins
local IFS="$IFS:"
for x in $no_umounts $RC_NO_UMOUNTS; do
no_umounts_r="$no_umounts_r|$x"
done
if [ "$RC_UNAME" = Linux ]; then
no_umounts_r="$no_umounts_r|/proc|/proc/.*|/run|/sys|/sys/.*"
if [ -e "$rc_svcdir"/usr_premounted ]; then
no_umounts_r="$no_umounts_r|/usr"
fi
fi
no_umounts_r="^($no_umounts_r)$"
# Flush all pending disk writes now
sync
. "$RC_LIBEXECDIR"/sh/rc-mount.sh
if [ "$RC_UNAME" = Linux ] && [ -d /sys/fs/aufs ] ; then
#if / is aufs we remount it noxino during shutdown
if mountinfo -q -f '^aufs$' / ; then
mount -o remount,noxino,rw /
sync
fi
local aufs_branch aufs_mount_dir aufs_mount_point aufs_si_dir aufs_si_id
for aufs_si_dir in /sys/fs/aufs/*; do
aufs_mount_dir=${aufs_si_dir#/sys/fs/aufs/}
aufs_si_id="$(printf "%s" $aufs_mount_dir | sed 's/_/=/g')"
aufs_mount_point="$(mountinfo -o ${aufs_si_id})"
for x in $aufs_si_dir/br[0-9][0-9][0-9]; do
aufs_branch=$(sed 's/=.*//g' $x)
eindent
if ! mount -o "remount,del:$aufs_branch" "$aufs_mount_point" > /dev/null 2>&1; then
ewarn "Failed to remove branch $aufs_branch from aufs \
$aufs_mount_point"
fi
eoutdent
sync
done
done
fi
# Umount loop devices
einfo "Unmounting loop devices"
eindent
do_unmount "umount -d" --skip-point-regex "$no_umounts_r" \
--node-regex "^/dev/loop"
eoutdent
# Now everything else, except network filesystems as the
# network should be down by this point.
einfo "Unmounting filesystems"
eindent
local fs=
for x in $net_fs_list $extra_net_fs_list; do
fs="$fs${fs:+|}$x"
done
[ -n "$fs" ] && fs="^($fs)$"
do_unmount umount --skip-point-regex "$no_umounts_r" \
"${fs:+--skip-fstype-regex}" $fs --nonetdev
eoutdent
return 0
}

35
init.d/._cfg0000_loopback Executable file
View File

@@ -0,0 +1,35 @@
#!/sbin/openrc-run
# Copyright (c) 2013 William Hubbs <w.d.hubbs@gmail.com>
# Released under the 2-clause BSD license.
description="Configures the loopback interface."
depend()
{
keyword -jail -prefix -vserver
}
start()
{
if [ "$RC_UNAME" = Linux ]; then
ebegin "Bringing up network interface lo"
if command -v ip > /dev/null 2>&1; then
ip addr add 127.0.0.1/8 dev lo brd + scope host
ip route add 127.0.0.0/8 dev lo scope host
ip link set lo up
else
ifconfig lo 127.0.0.1 netmask 255.0.0.0
route add -net 127.0.0.0 netmask 255.0.0.0 gw 127.0.0.1
fi
else
ebegin "Bringing up network interface lo0"
ifconfig lo0 127.0.0.1 netmask 255.0.0.0
route -q add -inet 127.0.0.0 -netmask 255.0.0.0 127.0.0.1
fi
eend $?
}
stop()
{
return 0
}

97
init.d/._cfg0000_lvm Executable file
View File

@@ -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

39
init.d/._cfg0000_lvm-monitoring Executable file
View File

@@ -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
}

63
init.d/._cfg0000_modules Executable file
View File

@@ -0,0 +1,63 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Loads a user defined list of kernel modules."
depend()
{
use isapnp
keyword -openvz -prefix -vserver -lxc
}
start()
{
# Should not fail if kernel do not have module
# support compiled in ...
[ ! -f /proc/modules ] && return 0
local KV x y kv_variant_list
KV=$(uname -r)
# full $KV
kv_variant_list="${KV}"
# remove any KV_EXTRA options to just get the full version
x=${KV%%-*}
# now slowly strip them
while [ -n "$x" ] && [ "$x" != "$y" ]; do
kv_variant_list="${kv_variant_list} $x"
y=$x
x=${x%.*}
done
local list= x= xx= y= args= mpargs= cnt=0 a=
for x in $kv_variant_list ; do
eval list=\$modules_$(shell_var "$x")
[ -n "$list" ] && break
done
[ -z "$list" ] && list=$modules
for x in $list; do
a=${x#*:}
if [ "$a" = "$x" ]; then
unset mpargs
ebegin "Loading module $x"
else
x=${x%%:*}
mpargs="-o $a"
ebegin "Loading module $x as $a"
fi
aa=$(shell_var "$a")
xx=$(shell_var "$x")
for y in $kv_variant_list ; do
eval args=\$module_${aa}_args_$(shell_var "$y")
[ -n "${args}" ] && break
eval args=\$module_${xx}_args_$(shell_var "$y")
[ -n "${args}" ] && break
done
[ -z "$args" ] && eval args=\$module_${aa}_args
[ -z "$args" ] && eval args=\$module_${xx}_args
eval modprobe -q "$mpargs" "$x" "$args"
eend $? "Failed to load $x" && : $(( cnt += 1 ))
done
einfo "Autoloaded $cnt module(s)"
}

49
init.d/._cfg0000_mount-ro Executable file
View File

@@ -0,0 +1,49 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Re-mount filesytems read-only for a clean reboot."
depend()
{
need killprocs savecache
keyword -openvz -prefix -vserver -lxc
}
start()
{
local ret=0
# Flush all pending disk writes now
sync
ebegin "Remounting remaining filesystems read-only"
# We need the do_unmount function
. "$RC_LIBEXECDIR"/sh/rc-mount.sh
eindent
# Bug 381783
local rc_svcdir=$(echo $RC_SVCDIR | sed 's:/lib\(32\|64\)\?/:/lib(32|64)?/:g')
local m="/dev|/dev/.*|/proc|/proc.*|/sys|/sys/.*|/run|${rc_svcdir}" x= fs=
m="$m|/bin|/sbin|/lib(32|64)?|/libexec"
# RC_NO_UMOUNTS is an env var that can be set by plugins
local IFS="$IFS:"
for x in $no_umounts $RC_NO_UMOUNTS; do
m="$m|$x"
done
m="^($m)$"
fs=
for x in $net_fs_list $extra_net_fs_list; do
fs="$fs${fs:+|}$x"
done
[ -n "$fs" ] && fs="^($fs)$"
do_unmount "umount -r" \
--skip-point-regex "$m" \
"${fs:+--skip-fstype-regex}" $fs --nonetdev
ret=$?
eoutdent
eend $ret
}

39
init.d/._cfg0000_mtab Executable file
View File

@@ -0,0 +1,39 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Update /etc/mtab to match what the kernel knows about"
depend()
{
need root
keyword -prefix
}
start()
{
if [ -L /etc/mtab ]; then
return 0
fi
ebegin "Updating /etc/mtab"
vewarn "The support for updating /etc/mtab as a file is"
vewarn "deprecated and will be removed in the future."
vewarn "Please run the following command as root on your system."
vewarn
vewarn "ln -snf /proc/self/mounts /etc/mtab"
if ! echo 2>/dev/null >/etc/mtab; then
ewend 1 "/etc/mtab is not updateable"
return 0
fi
# With / as tmpfs we cannot umount -at tmpfs in localmount as that
# makes / readonly and dismounts all tmpfs even if in use which is
# not good. Luckily, umount uses /etc/mtab instead of /proc/mounts
# which allows this hack to work.
grep -v "^[! ]* / tmpfs " /proc/mounts > /etc/mtab
# Remove stale backups
rm -f /etc/mtab~ /etc/mtab~~
eend 0
}

160
init.d/._cfg0000_mysql Executable file
View File

@@ -0,0 +1,160 @@
#!/sbin/runscript
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/files/init.d-2.0,v 1.3 2014/09/23 01:23:27 grknight Exp $
extra_commands="checkconfig"
depend() {
use net.lo
# localmount needed for $basedir
need localmount
}
get_config() {
my_print_defaults --config-file="$1" mysqld |
sed -n -e "s/^--$2=//p"
}
mysql_svcname() {
local ebextra=
case "${SVCNAME}" in
mysql*) ;;
*) ebextra=" (mysql)" ;;
esac
echo "${SVCNAME}${ebextra}"
}
start() {
# Check for old conf.d variables that mean migration was not yet done.
set | egrep -sq '^(mysql_slot_|MYSQL_BLOG_PID_FILE|STOPTIMEOUT)'
rc=$?
# Yes, MYSQL_INIT_I_KNOW_WHAT_I_AM_DOING is a hidden variable.
# It does have a use in testing, as it is possible to build a config file
# that works with both the old and new init scripts simulateously.
if [ "${rc}" = 0 -a -z "${MYSQL_INIT_I_KNOW_WHAT_I_AM_DOING}" ]; then
eerror "You have not updated your conf.d for the new mysql-init-scripts-2 revamp."
eerror "Not proceeding because it may be dangerous."
return 1
fi
# Check the config or die
checkconfig || return 1
# Now we can startup
ebegin "Starting $(mysql_svcname)"
MY_CNF="${MY_CNF:-/etc/${SVCNAME}/my.cnf}"
if [ ! -r "${MY_CNF}" ] ; then
eerror "Cannot read the configuration file \`${MY_CNF}'"
return 1
fi
# tail -n1 is critical as these we only want the last instance of the option
local basedir=$(get_config "${MY_CNF}" basedir | tail -n1)
local datadir=$(get_config "${MY_CNF}" datadir | tail -n1)
local pidfile=$(get_config "${MY_CNF}" pid-file | tail -n1)
local socket=$(get_config "${MY_CNF}" socket | tail -n1)
local chroot=$(get_config "${MY_CNF}" chroot | tail -n1)
if [ -n "${chroot}" ] ; then
socket="${chroot}/${socket}"
pidfile="${chroot}/${pidfile}"
fi
if [ ! -d "${datadir}" ] ; then
eerror "MySQL datadir \`${datadir}' is empty or invalid"
eerror "Please check your config file \`${MY_CNF}'"
return 1
fi
if [ ! -d "${datadir}"/mysql ] ; then
# find which package is installed to report an error
local EROOT=$(portageq envvar EROOT)
local DBPKG_P=$(portageq match ${EROOT} $(portageq expand_virtual ${EROOT} virtual/mysql))
if [ -z ${DBPKG_P} ] ; then
eerror "You don't appear to have a server package installed yet."
else
eerror "You don't appear to have the mysql database installed yet."
eerror "Please run \`emerge --config =${DBPKG_P}\` to have this done..."
fi
return 1
fi
local piddir="${pidfile%/*}"
checkpath -d --owner mysql:mysql --mode 0755 "$piddir"
rc=$?
if [ $rc -ne 0 ]; then
eerror "Directory $piddir for pidfile does not exist and cannot be created"
return 1
fi
local startup_timeout=${STARTUP_TIMEOUT:-900}
local startup_early_timeout=${STARTUP_EARLY_TIMEOUT:-1000}
local tmpnice="${NICE:+"--nicelevel "}${NICE}"
local tmpionice="${IONICE:+"--ionice "}${IONICE}"
start-stop-daemon \
${DEBUG:+"--verbose"} \
--start \
--exec "${basedir}"/sbin/mysqld \
--pidfile "${pidfile}" \
--background \
--wait ${startup_early_timeout} \
${tmpnice} \
${tmpionice} \
-- --defaults-file="${MY_CNF}" ${MY_ARGS}
local ret=$?
if [ ${ret} -ne 0 ] ; then
eend ${ret}
return ${ret}
fi
ewaitfile ${startup_timeout} "${socket}"
eend $? || return 1
save_options pidfile "${pidfile}"
save_options basedir "${basedir}"
}
stop() {
ebegin "Stopping $(mysql_svcname)"
local pidfile="$(get_options pidfile)"
local basedir="$(get_options basedir)"
local stop_timeout=${STOP_TIMEOUT:-120}
start-stop-daemon \
${DEBUG:+"--verbose"} \
--stop \
--exec "${basedir}"/sbin/mysqld \
--pidfile "${pidfile}" \
--retry ${stop_timeout}
eend $?
}
checkconfig() {
local my_cnf="${MY_CNF:-/etc/${SVCNAME}/my.cnf}"
local basedir=$(get_config "${my_cnf}" basedir | tail -n1)
local svc_name=$(mysql_svcname)
ebegin "Checking mysqld configuration for ${svc_name}"
if [ ${RC_CMD} = "checkconfig" ] ; then
# We are calling checkconfig specifically. Print warnings regardless.
"${basedir}"/sbin/mysqld --defaults-file="${my_cnf}" --help --verbose > /dev/null
else
# Suppress output to check the return value
"${basedir}"/sbin/mysqld --defaults-file="${my_cnf}" --help --verbose > /dev/null 2>&1
# If the above command does not return 0,
# then there is an error to echo to the user
if [ $? -ne 0 ] ; then
"${basedir}"/sbin/mysqld --defaults-file="${my_cnf}" --help --verbose > /dev/null
fi
fi
eend $? "${svc_name} config check failed"
}
# vim: filetype=gentoo-init-d sw=2 ts=2 sts=2 noet:

62
init.d/._cfg0000_netmount Executable file
View File

@@ -0,0 +1,62 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Mounts network shares according to /etc/fstab."
depend()
{
config /etc/fstab
use afc-client amd nfsclient autofs openvpn
use dns
keyword -jail -prefix -vserver -lxc
}
start()
{
local x= fs= rc=
for x in $net_fs_list $extra_net_fs_list; do
fs="$fs${fs:+,}$x"
done
ebegin "Mounting network filesystems"
mount -at $fs
rc=$?
if [ "$RC_UNAME" = Linux ]; then
mount -a -O _netdev
rc=$?
fi
ewend $rc "Could not mount all network filesystems"
return 0
}
stop()
{
local x= fs=
ebegin "Unmounting network filesystems"
. "$RC_LIBEXECDIR"/sh/rc-mount.sh
for x in $net_fs_list $extra_net_fs_list; do
fs="$fs${fs:+,}$x"
done
if [ -n "$fs" ]; then
umount -at $fs || eerror "Failed to simply unmount filesystems"
fi
eindent
fs=
for x in $net_fs_list $extra_net_fs_list; do
fs="$fs${fs:+|}$x"
done
[ -n "$fs" ] && fs="^($fs)$"
do_unmount umount ${fs:+--fstype-regex} $fs --netdev
retval=$?
eoutdent
if [ "$RC_UNAME" = Linux ]; then
umount -a -O _netdev
retval=$?
fi
eend $retval "Failed to unmount network filesystems"
}

27
init.d/._cfg0000_nfsmount Executable file
View File

@@ -0,0 +1,27 @@
#!/sbin/runscript
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-fs/nfs-utils/files/nfsmount.initd-1.3.1,v 1.1 2015/02/02 17:45:45 robbat2 Exp $
# This is mostly as a fix for bug #537996, to avoid breaking existing users
# with nfsmount in their runlevels.
# If neither nfsclient nor netmount are in your runlevels, and you manually
# start netmount before nfsclient, then this will break. A real solution is
# forthcoming, but requires feature development, see bug #406021 for soft
# dependencies
depend() {
need nfsclient netmount
}
msg() {
ewarn "nfsmount is deprecated, please migrate as described in the news item: 2015-02-02-nfs-service-changes"
ewarn "This migration script will be removed not sooner than 2015/August/01"
}
start() {
msg
}
stop() {
msg
}

42
init.d/._cfg0000_numlock Executable file
View File

@@ -0,0 +1,42 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Turns numlock on for the consoles."
ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
depend()
{
need localmount
keyword -openvz -prefix -vserver -lxc
}
_setleds()
{
[ -z "$1" ] && return 1
local dev=/dev/tty t= i=1 retval=0
[ -d /dev/vc ] && dev=/dev/vc/
while [ $i -le $ttyn ]; do
setleds -D "$1"num < $dev$i || retval=1
: $(( i += 1 ))
done
return $retval
}
start()
{
ebegin "Enabling numlock on ttys"
_setleds +
eend $? "Failed to enable numlock"
}
stop()
{
ebegin "Disabling numlock on ttys"
_setleds -
eend $? "Failed to disable numlock"
}

145
init.d/._cfg0000_openconnect Executable file
View File

@@ -0,0 +1,145 @@
#!/sbin/runscript
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/openconnect/files/openconnect.init.in-r3,v 1.1 2014/12/09 00:14:37 floppym Exp $
VPN="${RC_SVCNAME#*.}"
VPNLOG="/var/log/openconnect/${VPN}"
VPNLOGFILE="${VPNLOG}/openconnect.log"
VPNERRFILE="${VPNLOG}/openconnect.err"
VPNPID="/run/openconnect/${VPN}.pid"
VPNDIR="/etc/openconnect/${VPN}"
PREUPSCRIPT="${VPNDIR}/preup.sh"
PREDOWNSCRIPT="${VPNDIR}/predown.sh"
POSTUPSCRIPT="${VPNDIR}/postup.sh"
POSTDOWNSCRIPT="${VPNDIR}/postdown.sh"
SERVER="server_${VPN}"
PASSWORD="password_${VPN}"
VPNOPTS="vpnopts_${VPN}"
depend() {
before netmount
}
checkconfig() {
if [ $VPN = "openconnect" ]; then
eerror "You cannot call openconnect directly. You must create a symbolic link to it with the vpn name:"
echo
eerror "ln -s /etc/init.d/openconnect /etc/init.d/openconnect.vpn0"
echo
eerror "And then call it instead:"
echo
eerror "/etc/init.d/openconnect.vpn0 start"
return 1
fi
}
checktuntap() {
if [ $(uname -s) = "Linux" ] ; then
if [ ! -e /dev/net/tun ]; then
if ! modprobe tun ; then
eerror "TUN/TAP support is not available in this kernel"
return 1
fi
fi
if [ -h /dev/net/tun ] && [ -c /dev/misc/net/tun ]; then
ebegin "Detected broken /dev/net/tun symlink, fixing..."
rm -f /dev/net/tun
ln -s /dev/misc/net/tun /dev/net/tun
eend $?
fi
fi
}
start() {
ebegin "Starting OpenConnect: ${VPN}"
local tmp_SERVER tmp_VPNOPTS tmp_PASSWORD
eval tmp_SERVER="\${${SERVER}}"
eval tmp_VPNOPTS="\${${VPNOPTS}}"
eval tmp_PASSWORD="\${${PASSWORD}}"
checkconfig || return 1
checktuntap || return 1
if [ "${tmp_SERVER}" = "vpn.server.tld" ]; then
eend 1 "${VPN} not configured"
return 1
fi
if [ ! -e "${VPNLOG}" ]; then
mkdir -p "${VPNLOG}"
fi
local piddir="${VPNPID%/*}"
if [ ! -d "$piddir" ] ; then
mkdir -p "$piddir"
if [ $? -ne 0 ]; then
eerror "Directory $piddir for pidfile does not exist and cannot be created"
return 1
fi
fi
if [ -x "${PREUPSCRIPT}" ] ; then
"${PREUPSCRIPT}"
fi
start-stop-daemon --start \
--make-pidfile \
--pidfile "${VPNPID}" \
--stderr "${VPNERRFILE}" \
--stdout "${VPNLOGFILE}" \
--background \
--exec /usr/sbin/openconnect -- \
--interface="${VPN}" \
--pid-file="${VPNPID}" \
${tmp_VPNOPTS} \
${tmp_SERVER} <<-E
${tmp_PASSWORD}
E
local retval=$?
if [ ! ${retval} -eq 0 ]; then
eend ${retval}
return ${retval}
fi
if [ -x "${POSTUPSCRIPT}" ] ; then
# wait until the interface is up and an ip address is set before running postup
while true; do
sleep 0.5
if [ -n "$(ip addr show $VPN 2> /dev/null | grep inet)" ]; then
"${POSTUPSCRIPT}"
break
fi
done
fi
eend $?
}
stop() {
ebegin "Stopping OpenConnect: ${VPN}"
checkconfig || return 1
if [ -x "${PREDOWNSCRIPT}" ] ; then
"${PREDOWNSCRIPT}"
fi
start-stop-daemon --pidfile "${VPNPID}" --stop /usr/sbin/openconnect
local retval=$?
if [ ! ${retval} -eq 0 ]; then
eend ${retval}
return ${retval}
fi
if [ -x "${POSTDOWNSCRIPT}" ] ; then
"${POSTDOWNSCRIPT}"
fi
eend $?
}

73
init.d/._cfg0000_procfs Executable file
View File

@@ -0,0 +1,73 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Mounts misc filesystems in /proc."
depend()
{
use modules devfs
need localmount
keyword -openvz -prefix -vserver -lxc
}
start()
{
# Make sure we insert usbcore if it's a module
if [ -f /proc/modules -a ! -d /sys/module/usbcore -a ! -d /proc/bus/usb ]; then
modprobe -q usbcore
fi
[ -e /proc/filesystems ] || return 0
# Setup Kernel Support for miscellaneous Binary Formats
if [ -d /proc/sys/fs/binfmt_misc -a ! -e /proc/sys/fs/binfmt_misc/register ]; then
if grep -qs binfmt_misc /proc/filesystems; then
ebegin "Mounting misc binary format filesystem"
mount -t binfmt_misc -o nodev,noexec,nosuid \
binfmt_misc /proc/sys/fs/binfmt_misc
if eend $? ; then
local fmts
ebegin "Loading custom binary format handlers"
fmts=$(grep -hsv -e '^[#;]' -e '^[[:space:]]*$' \
/run/binfmt.d/*.conf \
/etc/binfmt.d/*.conf \
""/usr/lib/binfmt.d/*.conf)
if [ -n "${fmts}" ]; then
echo "${fmts}" > /proc/sys/fs/binfmt_misc/register
fi
eend $?
fi
fi
fi
[ "$RC_SYS" = "OPENVZ" ] && return 0
# Check what USB fs the kernel support. Currently
# 2.5+ kernels, and later 2.4 kernels have 'usbfs',
# while older kernels have 'usbdevfs'.
if [ -d /proc/bus/usb -a ! -e /proc/bus/usb/devices ]; then
local usbfs=$(grep -Fow usbfs /proc/filesystems ||
grep -Fow usbdevfs /proc/filesystems)
if [ -n "$usbfs" ]; then
ebegin "Mounting USB device filesystem [$usbfs]"
local usbgid="$(getent group usb | \
sed -e 's/.*:.*:\(.*\):.*/\1/')"
mount -t $usbfs \
-o ${usbgid:+devmode=0664,devgid=$usbgid,}noexec,nosuid \
usbfs /proc/bus/usb
eend $?
fi
fi
# Setup Kernel Support for SELinux
if [ -d /sys/fs/selinux ] && ! mountinfo -q /sys/fs/selinux; then
if grep -qs selinuxfs /proc/filesystems; then
ebegin "Mounting SELinux filesystem"
mount -t selinuxfs selinuxfs /sys/fs/selinux
eend $?
fi
fi
return 0
}

25
init.d/._cfg0000_pydoc-2.7 Executable file
View File

@@ -0,0 +1,25 @@
#!/sbin/runscript
# Copyright 1999-2014 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public Licence v2
# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/files/pydoc.init,v 1.5 2014/10/12 12:37:07 djc Exp $
start() {
local pydoc_port="${PYDOC2_7_PORT-${PYDOC_PORT}}"
if [ -z "${pydoc_port}" ]; then
eerror "Port not set"
return 1
fi
ebegin "Starting pydoc server on port ${pydoc_port}"
start-stop-daemon --start --background --make-pidfile \
--pidfile /var/run/pydoc2.7.pid \
--exec /usr/bin/pydoc2.7 -- -p "${pydoc_port}"
eend $?
}
stop() {
ebegin "Stopping pydoc server"
start-stop-daemon --stop --quiet --pidfile /var/run/pydoc2.7.pid
eend $?
}

25
init.d/._cfg0000_pydoc-3.2 Executable file
View File

@@ -0,0 +1,25 @@
#!/sbin/runscript
# Copyright 1999-2014 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public Licence v2
# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/files/pydoc.init,v 1.5 2014/10/12 12:37:07 djc Exp $
start() {
local pydoc_port="${PYDOC3_2_PORT-${PYDOC_PORT}}"
if [ -z "${pydoc_port}" ]; then
eerror "Port not set"
return 1
fi
ebegin "Starting pydoc server on port ${pydoc_port}"
start-stop-daemon --start --background --make-pidfile \
--pidfile /var/run/pydoc3.2.pid \
--exec /usr/bin/pydoc3.2 -- -p "${pydoc_port}"
eend $?
}
stop() {
ebegin "Stopping pydoc server"
start-stop-daemon --stop --quiet --pidfile /var/run/pydoc3.2.pid
eend $?
}

25
init.d/._cfg0000_pydoc-3.3 Executable file
View File

@@ -0,0 +1,25 @@
#!/sbin/runscript
# Copyright 1999-2014 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public Licence v2
# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/files/pydoc.init,v 1.5 2014/10/12 12:37:07 djc Exp $
start() {
local pydoc_port="${PYDOC3_3_PORT-${PYDOC_PORT}}"
if [ -z "${pydoc_port}" ]; then
eerror "Port not set"
return 1
fi
ebegin "Starting pydoc server on port ${pydoc_port}"
start-stop-daemon --start --background --make-pidfile \
--pidfile /var/run/pydoc3.3.pid \
--exec /usr/bin/pydoc3.3 -- -p "${pydoc_port}"
eend $?
}
stop() {
ebegin "Stopping pydoc server"
start-stop-daemon --stop --quiet --pidfile /var/run/pydoc3.3.pid
eend $?
}

25
init.d/._cfg0000_pydoc-3.4 Executable file
View File

@@ -0,0 +1,25 @@
#!/sbin/runscript
# Copyright 1999-2014 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public Licence v2
# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/files/pydoc.init,v 1.5 2014/10/12 12:37:07 djc Exp $
start() {
local pydoc_port="${PYDOC3_4_PORT-${PYDOC_PORT}}"
if [ -z "${pydoc_port}" ]; then
eerror "Port not set"
return 1
fi
ebegin "Starting pydoc server on port ${pydoc_port}"
start-stop-daemon --start --background --make-pidfile \
--pidfile /var/run/pydoc3.4.pid \
--exec /usr/bin/pydoc3.4 -- -p "${pydoc_port}"
eend $?
}
stop() {
ebegin "Stopping pydoc server"
start-stop-daemon --stop --quiet --pidfile /var/run/pydoc3.4.pid
eend $?
}

139
init.d/._cfg0000_qemu-binfmt Executable file
View File

@@ -0,0 +1,139 @@
#!/sbin/runscript
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-emulation/qemu/files/qemu-binfmt.initd-r1,v 1.5 2014/08/04 06:47:22 vapier Exp $
# enable automatic i386/ARM/M68K/MIPS/SPARC/PPC/s390 program execution by the kernel
# Defaulting to OC should be safe because it comes down to:
# - do we trust the interp itself to not be malicious? yes; we built it.
# - do we trust the programs we're running? ish; same permission as native
# binaries apply. so if user can do bad stuff natively, cross isn't worse.
: ${QEMU_BINFMT_FLAGS:=OC}
depend() {
after procfs
}
start() {
ebegin "Registering qemu-user binaries (flags: ${QEMU_BINFMT_FLAGS})"
if [ ! -d /proc/sys/fs/binfmt_misc ] ; then
modprobe -q binfmt_misc
fi
if [ ! -d /proc/sys/fs/binfmt_misc ] ; then
eend $? "You need support for 'misc binaries' in your kernel!" || return
fi
if [ ! -f /proc/sys/fs/binfmt_misc/register ] ; then
mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc >/dev/null 2>&1
eend $? || return
fi
# probe cpu type
cpu=`uname -m`
case "$cpu" in
i386|i486|i586|i686|i86pc|BePC|x86_64)
cpu="i386"
;;
m68k)
cpu="m68k"
;;
mips*)
cpu="mips"
;;
"Power Macintosh"|ppc|ppc64)
cpu="ppc"
;;
armv[4-9]*)
cpu="arm"
;;
sparc*)
cpu="sparc"
;;
esac
# register the interpreter for each cpu except for the native one
if [ $cpu != "i386" -a -x "/usr/bin/qemu-i386" ] ; then
echo ':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-i386:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
echo ':i486:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-i386:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "alpha" -a -x "/usr/bin/qemu-alpha" ] ; then
echo ':alpha:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-alpha:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "arm" -a -x "/usr/bin/qemu-arm" ] ; then
echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x00\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "arm" -a -x "/usr/bin/qemu-armeb" ] ; then
echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-armeb:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "aarch64" -a -x "/usr/bin/qemu-aarch64" ] ; then
echo ':aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-aarch64:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "sparc" -a -x "/usr/bin/qemu-sparc" ] ; then
echo ':sparc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-sparc:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "ppc" -a -x "/usr/bin/qemu-ppc" ] ; then
echo ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-ppc:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "m68k" -a -x "/usr/bin/qemu-m68k" ] ; then
#echo 'Please check cpu value and header information for m68k!'
echo ':m68k:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-m68k:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "mips" -a -x "/usr/bin/qemu-mips" ] ; then
# FIXME: We could use the other endianness on a MIPS host.
echo ':mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-mips:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "mips" -a -x "/usr/bin/qemu-mipsel" ] ; then
echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mipsel:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "mips" -a -x "/usr/bin/qemu-mipsn32" ] ; then
echo ':mipsn32:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-mipsn32:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "mips" -a -x "/usr/bin/qemu-mipsn32el" ] ; then
echo ':mipsn32el:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mipsn32el:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "mips" -a -x "/usr/bin/qemu-mips64" ] ; then
echo ':mips64:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-mips64:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "mips" -a -x "/usr/bin/qemu-mips64el" ] ; then
echo ':mips64el:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mips64el:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "sh" -a -x "/usr/bin/qemu-sh4" ] ; then
echo ':sh4:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-sh4:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "sh" -a -x "/usr/bin/qemu-sh4eb" ] ; then
echo ':sh4eb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-sh4eb:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "s390x" -a -x "/usr/bin/qemu-s390x" ] ; then
echo ':s390x:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-s390x:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
eend $?
}
stop() {
ebegin "Unregistering qemu-user binaries"
local arches
arches="${arches} i386 i486"
arches="${arches} alpha"
arches="${arches} arm armeb"
arches="${arches} aarch64"
arches="${arches} sparc"
arches="${arches} ppc"
arches="${arches} m68k"
arches="${arches} mips mipsel mipsn32 mipsn32el mips64 mips64el"
arches="${arches} sh4 sh4eb"
arches="${arches} s390x"
for a in ${arches}; do
if [ -f /proc/sys/fs/binfmt_misc/$a ] ; then
echo '-1' > /proc/sys/fs/binfmt_misc/$a
fi
done
eend $?
}
# vim: ts=4 :

53
init.d/._cfg0000_root Executable file
View File

@@ -0,0 +1,53 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Mount the root fs read/write"
depend()
{
need fsck
keyword -jail -openvz -prefix -vserver -lxc
}
start()
{
case ",$(fstabinfo -o /)," in
*,ro,*)
;;
*)
# Check if the rootfs isn't already writable.
if checkpath -W /; then
rm -f /fastboot /forcefsck
else
ebegin "Remounting root filesystem read/write"
case "$RC_UNAME" in
Linux)
mount -n -o remount,rw /
;;
*)
mount -u -o rw /
;;
esac
eend $? "Root filesystem could not be mounted read/write"
if [ $? -eq 0 ]; then
rm -f /fastboot /forcefsck
fi
fi
;;
esac
ebegin "Remounting filesystems"
local mountpoint
for mountpoint in $(fstabinfo); do
case "${mountpoint}" in
/)
;;
/*)
mountinfo -q "${mountpoint}" && \
fstabinfo --remount "${mountpoint}"
;;
esac
done
eend 0
}

33
init.d/._cfg0000_rpc.statd Executable file
View File

@@ -0,0 +1,33 @@
#!/sbin/runscript
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-fs/nfs-utils/files/rpc.statd.initd,v 1.9 2015/02/02 13:47:41 radhermit Exp $
[ -e /etc/conf.d/nfs ] && . /etc/conf.d/nfs
rpc_bin=/sbin/rpc.statd
rpc_pid=/var/run/rpc.statd.pid
depend() {
use ypbind net
need portmap
after quota
}
start() {
# Don't start rpc.statd if already started by someone else ...
# Don't try and kill it if it's already dead ...
if killall -q -0 ${rpc_bin} ; then
return 0
fi
ebegin "Starting NFS statd"
start-stop-daemon --start --exec ${rpc_bin} -- --no-notify ${OPTS_RPC_STATD}
eend $?
}
stop() {
ebegin "Stopping NFS statd"
start-stop-daemon --stop --exec ${rpc_bin} --pidfile /var/run/rpc.statd.pid
eend $?
}

49
init.d/._cfg0000_savecache Executable file
View File

@@ -0,0 +1,49 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Saves the caches OpenRC uses to non volatile storage"
start()
{
if [ -e "$RC_SVCDIR"/clock-skewed ]; then
ewarn "WARNING: clock skew detected!"
if ! yesno "${RC_GOINGDOWN}"; then
eerror "Not saving deptree cache"
return 1
fi
fi
if ! checkpath -W "$RC_LIBEXECDIR"/cache; then
ewarn "WARNING: ${RC_LIBEXECDIR}/cache is not writable!"
if ! yesno "${RC_GOINGDOWN}"; then
ewarn "Unable to save deptree cache"
return 1
fi
return 0
fi
ebegin "Saving dependency cache"
local rc=
if [ ! -d "$RC_LIBEXECDIR"/cache ]; then
rm -rf "$RC_LIBEXECDIR"/cache
if ! mkdir "$RC_LIBEXECDIR"/cache; then
rc=$?
if yesno "${RC_GOINGDOWN}"; then
rc=0
fi
eend $rc
return $rc
fi
fi
local save=
for x in deptree depconfig shutdowntime softlevel nettree rc.log; do
[ -e "$RC_SVCDIR/$x" ] && save="$save $RC_SVCDIR/$x"
done
if [ -n "$save" ]; then
cp -p $save "$RC_LIBEXECDIR"/cache 2>/dev/null
fi
rc=$?
if yesno "${RC_GOINGDOWN}"; then
rc=0
fi
eend $rc
}

36
init.d/._cfg0000_swap Executable file
View File

@@ -0,0 +1,36 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
depend()
{
before localmount
keyword -jail -openvz -prefix -vserver -lxc
}
start()
{
ebegin "Activating swap devices"
case "$RC_UNAME" in
Linux) swapon -a -e >/dev/null;;
NetBSD|OpenBSD) swapctl -A -t noblk >/dev/null;;
*) swapon -a >/dev/null;;
esac
eend 0 # If swapon has nothing todo it errors, so always return 0
}
stop()
{
ebegin "Deactivating swap devices"
# Try to unmount all tmpfs filesystems not in use, else a deadlock may
# occur. As $RC_SVCDIR may also be tmpfs we cd to it to lock it
cd "$RC_SVCDIR"
umount -a -t tmpfs 2>/dev/null
case "$RC_UNAME" in
NetBSD|OpenBSD) swapctl -U -t noblk >/dev/null;;
*) swapoff -a >/dev/null;;
esac
eend 0
}

39
init.d/._cfg0000_swapfiles Executable file
View File

@@ -0,0 +1,39 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
depend()
{
need localmount
keyword -jail -openvz -prefix -vserver -lxc
}
start()
{
ebegin "Activating additional swap space"
case "$RC_UNAME" in
NetBSD|OpenBSD) swapctl -A -t noblk >/dev/null;;
*) swapon -a >/dev/null;;
esac
eend 0 # If swapon has nothing todo it errors, so always return 0
}
stop()
{
ebegin "Deactivating additional swap space"
case "$RC_UNAME" in
Linux)
if [ -e /proc/swaps ]; then
while read filename type rest; do
case "$type" in
file) swapoff $filename >/dev/null;;
esac
case "$filename" in
/dev/loop*) swapoff $filename >/dev/null;;
esac
done < /proc/swaps
fi
;;
esac
eend 0
}

30
init.d/._cfg0000_swclock Executable file
View File

@@ -0,0 +1,30 @@
#!/sbin/openrc-run
# Copyright (c) 2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Sets the local clock to the mtime of a given file."
depend()
{
before *
provide clock
keyword -openvz -prefix -uml -vserver -xenu -lxc
}
# swclock is an OpenRC built in
start()
{
ebegin "Setting the local clock based on last shutdown time"
if ! swclock 2> /dev/null; then
swclock --warn /sbin/openrc-run
fi
eend $?
}
stop()
{
ebegin "Saving the shutdown time"
swclock --save
eend $?
}

16
init.d/._cfg0000_sysctl Executable file
View File

@@ -0,0 +1,16 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
depend()
{
before bootmisc logger
keyword -prefix -vserver
}
start()
{
ebegin "Configuring kernel parameters"
sysctl --system
eend $? "Unable to configure some kernel parameters"
}

142
init.d/._cfg0000_sysfs Executable file
View File

@@ -0,0 +1,142 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Mount the sys filesystem."
sysfs_opts=nodev,noexec,nosuid
depend()
{
keyword -lxc -prefix -vserver
}
mount_sys()
{
grep -Eq "[[:space:]]+sysfs$" /proc/filesystems || return 1
mountinfo -q /sys && return 0
if [ ! -d /sys ]; then
if ! mkdir -m 0755 /sys; then
ewarn "Could not create /sys!"
return 1
fi
fi
ebegin "Mounting /sys"
if ! fstabinfo --mount /sys; then
mount -n -t sysfs -o ${sysfs_opts} sysfs /sys
fi
eend $?
}
mount_misc()
{
# Setup Kernel Support for securityfs
if [ -d /sys/kernel/security ] && \
! mountinfo -q /sys/kernel/security; then
if grep -qs securityfs /proc/filesystems; then
ebegin "Mounting security filesystem"
mount -n -t securityfs -o ${sysfs_opts} \
securityfs /sys/kernel/security
eend $?
fi
fi
# Setup Kernel Support for debugfs
if [ -d /sys/kernel/debug ] && ! mountinfo -q /sys/kernel/debug; then
if grep -qs debugfs /proc/filesystems; then
ebegin "Mounting debug filesystem"
mount -n -t debugfs -o ${sysfs_opts} debugfs /sys/kernel/debug
eend $?
fi
fi
# Setup Kernel Support for configfs
if [ -d /sys/kernel/config ] && ! mountinfo -q /sys/kernel/config; then
if grep -qs configfs /proc/filesystems; then
ebegin "Mounting config filesystem"
mount -n -t configfs -o ${sysfs_opts} configfs /sys/kernel/config
eend $?
fi
fi
# set up kernel support for cgroups
if [ -d /sys/fs/cgroup ] && ! mountinfo -q /sys/fs/cgroup; then
if grep -qs cgroup /proc/filesystems; then
ebegin "Mounting cgroup filesystem"
local opts="${sysfs_opts},mode=755,size=${rc_cgroupsize:-10m}"
mount -n -t tmpfs -o ${opts} cgroup_root /sys/fs/cgroup
eend $?
fi
fi
# set up kernel support for fusectl
if [ -d /sys/fs/fuse/connections ] \
&& ! mountinfo -q /sys/fs/fuse/connections; then
if grep -qs fusectl /proc/filesystems; then
ebegin "Mounting fuse control filesystem"
mount -n -t fusectl -o ${sysfs_opts} \
fusectl /sys/fs/fuse/connections
eend $?
fi
fi
# setup up kernel support for efivarfs
# slightly complicated, as if it's build as a module but NOT yet loaded,
# it will NOT appear in /proc/filesystems yet
if [ -d /sys/firmware/efi/efivars ] \
&& ! mountinfo -q /sys/firmware/efi/efivars; then
modprobe -q efivarfs
if grep -qs efivarfs /proc/filesystems; then
ebegin "Mounting efivarfs filesystem"
mount -n -t efivarfs -o ${sysfs_opts} \
efivarfs /sys/firmware/efi/efivars
eend $?
fi
fi
}
mount_cgroups()
{
mountinfo -q /sys/fs/cgroup || return 0
if ! mountinfo -q /sys/fs/cgroup/openrc; then
local agent="/lib64/rc/sh/cgroup-release-agent.sh"
mkdir /sys/fs/cgroup/openrc
mount -n -t cgroup \
-o none,${sysfs_opts},name=openrc,release_agent="$agent" \
openrc /sys/fs/cgroup/openrc
echo 1 > /sys/fs/cgroup/openrc/notify_on_release
fi
yesno ${rc_controller_cgroups:-YES} && [ -e /proc/cgroups ] || return 0
while read name hier groups enabled rest; do
case "${enabled}" in
1) mountinfo -q /sys/fs/cgroup/${name} && continue
mkdir /sys/fs/cgroup/${name}
mount -n -t cgroup -o ${sysfs_opts},${name} \
${name} /sys/fs/cgroup/${name}
;;
esac
done < /proc/cgroups
}
restorecon_sys()
{
if [ -x /sbin/restorecon ]; then
ebegin "Restoring SELinux contexts in /sys"
restorecon -F /sys/devices/system/cpu/online >/dev/null 2>&1
restorecon -rF /sys/fs/cgroup >/dev/null 2>&1
eend $?
fi
}
start()
{
mount_sys
mount_misc
mount_cgroups
restorecon_sys
return 0
}

48
init.d/._cfg0000_termencoding Executable file
View File

@@ -0,0 +1,48 @@
#!/sbin/openrc-run
# Copyright (c) 2008-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Configures terminal encoding."
ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
: ${unicode:=${UNICODE}}
depend()
{
keyword -lxc -openvz -prefix -uml -vserver -xenu
use root
after bootmisc
}
start()
{
local ttydev=/dev/tty n=
[ -d /dev/vc ] && ttydev=/dev/vc/
# Set terminal encoding to either ASCII or UNICODE.
# See utf-8(7) for more information.
local termencoding="%@" termmsg="ASCII"
if yesno ${unicode}; then
termencoding="%G"
termmsg="UTF-8"
fi
ebegin "Setting terminal encoding [$termmsg]"
n=1
while [ ${n} -le "$ttyn" ]; do
printf "\033%s" "$termencoding" >$ttydev$n
: $(( n += 1 ))
done
# Save the encoding for use immediately at boot
if checkpath -W "$RC_LIBEXECDIR"; then
mkdir -p "$RC_LIBEXECDIR"/console
if yesno ${unicode:-${UNICODE}}; then
echo "" > "$RC_LIBEXECDIR"/console/unicode
else
rm -f "$RC_LIBEXECDIR"/console/unicode
fi
fi
eend 0
}

20
init.d/._cfg0000_tmpfiles.dev Executable file
View File

@@ -0,0 +1,20 @@
#!/sbin/openrc-run
# Copyright 1999-2012 Gentoo Foundation
# Released under the 2-clause BSD license.
description="set up tmpfiles.d entries"
depend()
{
use dev-mount
before dev
keyword -prefix -vserver
}
start()
{
ebegin "setting up tmpfiles.d entries for /dev"
/lib64/rc/sh/tmpfiles.sh --prefix=/dev --create --boot ${tmpfiles_opts}
eend $?
return 0
}

19
init.d/._cfg0000_tmpfiles.setup Executable file
View File

@@ -0,0 +1,19 @@
#!/sbin/openrc-run
# Copyright 1999-2012 Gentoo Foundation
# Released under the 2-clause BSD license.
description="set up tmpfiles.d entries"
depend()
{
need localmount
}
start()
{
ebegin "setting up tmpfiles.d entries"
/lib64/rc/sh/tmpfiles.sh --exclude-prefix=/dev --create --remove --boot \
${tmpfiles_opts}
eend $?
return 0
}

81
init.d/._cfg0000_tor Executable file
View File

@@ -0,0 +1,81 @@
#!/sbin/runscript
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/tor/files/tor.initd-r7,v 1.1 2014/09/23 23:14:00 blueness Exp $
PIDFILE=/var/run/tor/tor.pid
CONFFILE=/etc/tor/torrc
GRACEFUL_TIMEOUT=${GRACEFUL_TIMEOUT:-60}
# See bug #523552, and https://trac.torproject.org/projects/tor/ticket/5525
# Graceful = wait 30 secs or so until all connections are properly closed.
extra_commands="checkconfig"
extra_started_commands="graceful gracefulstop reload"
description="Anonymizing overlay network for TCP"
description_checkconfig="Check for valid config file."
description_reload="Reload the configuration."
description_graceful="Gracefully restart."
description_gracefulstop="Gracefully stop."
depend() {
need net
}
checkconfig() {
# first check that it exists
if [ ! -f ${CONFFILE} ] ; then
eerror "You need to setup ${CONFFILE} first"
eerror "Example is in ${CONFFILE}.sample"
return 1
fi
# now verify whether the configuration is valid
/usr/bin/tor --verify-config -f ${CONFFILE} > /dev/null 2>&1
if [ $? -eq 0 ] ; then
einfo "Tor configuration (${CONFFILE}) is valid."
return 0
else
eerror "Tor configuration (${CONFFILE}) not valid."
/usr/bin/tor --verify-config -f ${CONFFILE}
return 1
fi
}
start() {
checkconfig || return 1
checkpath -d -m 0755 -o tor:tor /var/run/tor
ebegin "Starting Tor"
HOME=/var/lib/tor
start-stop-daemon --start --pidfile "${PIDFILE}" --quiet --exec /usr/bin/tor -- -f "${CONFFILE}" --runasdaemon 1 --PidFile "${PIDFILE}" > /dev/null 2>&1
eend $?
}
stop() {
ebegin "Stopping Tor"
start-stop-daemon --stop --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}"
eend $?
}
graceful() {
gracefulstop
start
eend $?
}
gracefulstop() {
ebegin "Gracefully stopping Tor"
ebegin "This can take up to ${GRACEFUL_TIMEOUT} seconds"
start-stop-daemon -P --stop --signal INT -R ${GRACEFUL_TIMEOUT} --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}"
eend $?
}
reload() {
if [ ! -f ${PIDFILE} ]; then
eerror "${SVCNAME} isn't running"
return 1
fi
checkconfig || return 1
ebegin "Reloading Tor configuration"
start-stop-daemon --signal HUP --pidfile ${PIDFILE}
eend $?
}

35
init.d/._cfg0000_tox-dht-daemon Executable file
View File

@@ -0,0 +1,35 @@
#!/sbin/runscript
PIDFILE=/run/tox-dht-bootstrap.pid
LOGDIR=/var/log/tox-dht-bootstrap
RUNDIR=/var/lib/tox-dht-bootstrap
depend() {
need net
}
start() {
ebegin "Starting tox-dht-bootstrap daemon"
[ -d "${LOGDIR}" ] || mkdir -p "${LOGDIR}"
[ -d "${RUNDIR}" ] || mkdir -p "${RUNDIR}"
chown -R nobody:nobody "${LOGDIR}" "${RUNDIR}"
start-stop-daemon --start \
--pidfile "${PIDFILE}" --make-pidfile --background \
--stdout "${LOGDIR}/stdout" --stderr "${LOGDIR}/stderr" \
--chdir "${RUNDIR}" \
--user=nobody --group=nobody \
--exec /usr/bin/DHT_bootstrap -- ${cmdline} ${ip} ${port} ${key}
eend $?
}
stop() {
ebegin "Stopping tox-dht-bootstrap daemon"
start-stop-daemon --stop \
--pidfile "${PIDFILE}"
eend $?
}

185
init.d/._cfg0000_udev Executable file
View File

@@ -0,0 +1,185 @@
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
command_args="--daemon ${udev_opts}"
description="udev manages device permissions and symbolic links in /dev"
extra_started_commands="reload"
description_reload="Reload the udev rules and databases"
udev_monitor="${udev_monitor:-no}"
udevmonitor_log=/run/udevmonitor.log
udevmonitor_pid=/run/udevmonitor.pid
depend()
{
provide dev
need sysfs dev-mount
before checkfs fsck
# udev does not work inside vservers
keyword -vserver -lxc
}
start_pre()
{
# make sure devtmpfs is in the kernel
if ! grep -qs devtmpfs /proc/filesystems; then
eerror "CONFIG_DEVTMPFS=y is required in your kernel configuration"
eerror "for this version of udev to run successfully."
eerror "This requires immediate attention."
if ! mountinfo -q /dev; then
mount -n -t tmpfs dev /dev
busybox mdev -s
mkdir /dev/pts
fi
return 1
fi
# make sure /dev is a mounted devtmpfs
if ! mountinfo -q -f devtmpfs /dev; then
eerror "Udev requires /dev to be a mounted devtmpfs."
eerror "Please reconfigure your system."
return 1
fi
# load unix domain sockets if built as module, Bug #221253
# and not yet loaded, Bug #363549
if [ ! -e /proc/net/unix ]; then
if ! modprobe unix; then
eerror "Cannot load the unix domain socket module"
return 1
fi
fi
bins="/sbin/udevd /lib/systemd/systemd-udevd /usr/lib/systemd/systemd-udevd"
for f in ${bins}; do
if [ -x "$f" -a ! -L "$f" ]; then
command="$f"
fi
done
if [ -z "$command" ]; then
eerror "Unable to find udev executable."
return 1
fi
if [ -e /proc/sys/kernel/hotplug ]; then
echo "" >/proc/sys/kernel/hotplug
fi
if yesno "${udev_debug:-NO}"; then
command_args="${command_args} --debug 2> /run/udevdebug.log"
fi
return 0
}
start_udevmonitor()
{
yesno "${udev_monitor}" || return 0
einfo "udev: Running udevadm monitor ${udev_monitor_opts} to log all events"
start-stop-daemon --start --stdout "${udevmonitor_log}" \
--make-pidfile --pidfile "${udevmonitor_pid}" \
--background --exec /bin/udevadm -- monitor ${udev_monitor_opts}
}
# This is here because some software expects /dev/root to exist.
# For more information, see this bug:
# https://bugs.gentoo.org/show_bug.cgi?id=438380
dev_root_link()
{
local RULESDIR=/run/udev/rules.d
[ -d $RULESDIR ] || mkdir -p $RULESDIR
eval $(udevadm info --export --export-prefix=ROOT_ --device-id-of-file=/ ||
true)
[ "$ROOT_MAJOR" -a "$ROOT_MINOR" ] || return 0
# btrfs filesystems have bogus major/minor numbers
[ "$ROOT_MAJOR" != 0 ] || return 0
echo 'ACTION=="add|change", SUBSYSTEM=="block", ENV{MAJOR}=="'$ROOT_MAJOR'", ENV{MINOR}=="'$ROOT_MINOR'", SYMLINK+="root"' > $RULESDIR/61-dev-root-link.rules
}
populate_dev()
{
if yesno ${rc_dev_root_symlink:-yes}; then
ebegin "Generating a rule to create a /dev/root symlink"
dev_root_link
eend $?
fi
get_bootparam "nocoldplug" && rc_coldplug="no"
if ! yesno ${rc_coldplug:-${RC_COLDPLUG:-yes}}; then
einfo "Setting /dev permissions and symbolic links"
udevadm trigger --attr-match=dev --action=add
udevadm trigger --subsystem-match=net --action=add
ewarn "Skipping udev coldplug sequence"
return 0
fi
ebegin "Populating /dev with existing devices through uevents"
udevadm trigger --type=subsystems --action=add
udevadm trigger --type=devices --action=add
eend $?
ebegin "Waiting for uevents to be processed"
udevadm settle --timeout=${udev_settle_timeout:-60}
eend $?
return 0
}
stop_udevmonitor()
{
yesno "${udev_monitor}" || return 0
if yesno "${udev_monitor_keep_running:-no}"; then
ewarn "udev: udevmonitor is still running and writing into ${udevmonitor_log}"
else
einfo "udev: Stopping udevmonitor: Log is in ${udevmonitor_log}"
start-stop-daemon --stop --pidfile "${udevmonitor_pid}" --exec /bin/udevadm
fi
}
display_hotplugged_services()
{
local svcfile= svc= services=
for svcfile in "${RC_SVCDIR}"/hotplugged/*; do
svc="${svcfile##*/}"
[ -x "${svcfile}" ] || continue
services="${services} ${svc}"
done
[ -n "${services}" ] && einfo "Device initiated services:${HILITE}${services}${NORMAL}"
}
start_post()
{
start_udevmonitor
populate_dev
stop_udevmonitor
display_hotplugged_services
return 0
}
stop()
{
local rc=0
ebegin "Stopping ${name:-$RC_SVCNAME}"
udevadm control --exit
rc=$?
if [ $rc -ne 0 ]; then
eend $rc "Failed to stop $RC_SVCNAME using udevadm"
ebegin "Trying with start-stop-daemon"
start-stop-daemon --stop --exec /sbin/udevd
rc=$?
fi
eend $rc "Failed to stop $RC_SVCNAME"
}
reload()
{
ebegin "reloading udev rules and databases"
udevadm control --reload
eend $?
}

View File

@@ -0,0 +1,50 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
PIDFILE="/var/run/$NAME.pid"
DAEMON="/usr/bin/unvanquished-server"
HOMEDIR="/var/lib/unvanquished-server"
description="Unvanquished dedicated server"
depend() {
need net
}
start() {
if [ "$START_DAEMON" != 1 ]; then
eerror "(not starting - disabled in /etc/default/unvanquished-server)"
return 1
fi
ebegin "Starting Unvanquished dedicated server"
env TERM="xterm" \
start-stop-daemon \
--start \
--quiet \
--make-pidfile \
--pidfile $PIDFILE \
--background \
--user unvanquished-server \
--env HOME="${HOMEDIR}" \
--group unvanquished-server \
--name unvanquished-server \
--exec /usr/bin/screen -- -D -m -S unvanquished-server $DAEMON $DAEMON_OPTS
eend $?
}
stop() {
ebegin "Stopping Unvanquished dedicated server"
start-stop-daemon \
--stop \
--signal 15 \
--quiet \
--pidfile $PIDFILE
eend $?
}
# todo: reload config on-the-fly

45
init.d/._cfg0000_urandom Executable file
View File

@@ -0,0 +1,45 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
: ${urandom_seed:=${URANDOM_SEED:-/var/lib/misc/random-seed}}
description="Initializes the random number generator."
depend()
{
need localmount
keyword -jail -lxc -openvz -prefix
}
save_seed()
{
local psz=1
if [ -e /proc/sys/kernel/random/poolsize ]; then
: $(( psz = $(cat /proc/sys/kernel/random/poolsize) / 4096 ))
fi
( # sub shell to prevent umask pollution
umask 077
dd if=/dev/urandom of="$urandom_seed" count=${psz} 2>/dev/null
)
}
start()
{
[ -c /dev/urandom ] || return
if [ -f "$urandom_seed" ]; then
ebegin "Initializing random number generator"
cat "$urandom_seed" > /dev/urandom
eend $? "Error initializing random number generator"
fi
rm -f "$urandom_seed" && save_seed
return 0
}
stop()
{
ebegin "Saving random seed"
save_seed
eend $? "Failed to save random seed"
}

231
init.d/._cfg0000_xdm Executable file
View File

@@ -0,0 +1,231 @@
#!/sbin/runscript
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2
# $Header: /var/cvsroot/gentoo-x86/x11-base/xorg-server/files/xdm.initd-11,v 1.1 2014/04/14 16:19:25 chithanh Exp $
# This is here to serve as a note to myself, and future developers.
#
# Any Display manager (gdm,kdm,xdm) has the following problem: if
# it is started before any getty, and no vt is specified, it will
# usually run on vt2. When the getty on vt2 then starts, and the
# DM is already started, the getty will take control of the keyboard,
# leaving us with a "dead" keyboard.
#
# Resolution: add the following line to /etc/inittab
#
# x:a:once:/etc/X11/startDM.sh
#
# and have /etc/X11/startDM.sh start the DM in daemon mode if
# a lock is present (with the info of what DM should be started),
# else just fall through.
#
# How this basically works, is the "a" runlevel is a additional
# runlevel that you can use to fork processes with init, but the
# runlevel never gets changed to this runlevel. Along with the "a"
# runlevel, the "once" key word means that startDM.sh will only be
# run when we specify it to run, thus eliminating respawning
# startDM.sh when "xdm" is not added to the default runlevel, as was
# done previously.
#
# This script then just calls "telinit a", and init will run
# /etc/X11/startDM.sh after the current runlevel completes (this
# script should only be added to the actual runlevel the user is
# using).
#
# Martin Schlemmer
# aka Azarah
# 04 March 2002
depend() {
need localmount xdm-setup
# this should start as early as possible
# we can't do 'before *' as that breaks it
# (#139824) Start after ypbind and autofs for network authentication
# (#145219 #180163) Could use lirc mouse as input device
# (#70689 comment #92) Start after consolefont to avoid display corruption
# (#291269) Start after quota, since some dm need readable home
# (#390609) gdm-3 will fail when dbus is not running
# (#366753) starting keymaps after X causes problems
after bootmisc consolefont modules netmount
after readahead-list ypbind autofs openvpn gpm lircmd
after quota keymaps
before alsasound
# Start before X
use consolekit dbus xfs
}
setup_dm() {
local MY_XDM
MY_XDM=$(echo "${DISPLAYMANAGER}" | tr '[:upper:]' '[:lower:]')
# Load our root path from profile.env
# Needed for kdm
PATH=${PATH}:$(. /etc/profile.env; echo "${ROOTPATH}")
NAME=
case "${MY_XDM}" in
kdm|kde)
EXE=/usr/bin/kdm
PIDFILE=/run/kdm.pid
;;
entrance*)
EXE=/usr/sbin/entrance
PIDFILE=/run/entrance.pid
;;
gdm|gnome)
# gdm-3 and above has different paths
if [ -f /usr/sbin/gdm ]; then
EXE=/usr/sbin/gdm
PIDFILE=/run/gdm/gdm.pid
START_STOP_ARGS="--background"
AUTOCLEAN_CGROUP="yes"
else
EXE=/usr/bin/gdm
PIDFILE=/run/gdm.pid
fi
[ "${RC_UNAME}" != "Linux" ] && NAME=gdm-binary
;;
wdm)
EXE=/usr/bin/wdm
PIDFILE=
;;
gpe)
EXE=/usr/bin/gpe-dm
PIDFILE=/run/gpe-dm.pid
;;
lxdm)
EXE=/usr/sbin/lxdm-binary
PIDFILE=/run/lxdm.pid
START_STOP_ARGS="--background"
;;
lightdm)
EXE=/usr/sbin/lightdm
PIDFILE=/run/lightdm.pid
START_STOP_ARGS="--background"
;;
sddm)
EXE="/usr/bin/sddm"
START_STOP_ARGS="-m --background"
PIDFILE=/run/sddm.pid
;;
*)
# first find out if there is such executable
EXE="$(command -v ${MY_XDM} 2>/dev/null)"
PIDFILE="/run/${MY_XDM}.pid"
# warn user that he is doing sick things if the exe was not found
if [ -z "${EXE}" ]; then
echo "ERROR: Your XDM value is invalid."
echo " No ${MY_XDM} executable could be found on your system."
fi
;;
esac
if ! [ -x "${EXE}" ]; then
EXE=/usr/bin/xdm
PIDFILE=/run/xdm.pid
if ! [ -x "/usr/bin/xdm" ]; then
echo "ERROR: Please set your DISPLAYMANAGER variable in /etc/conf.d/xdm,"
echo " or install x11-apps/xdm package"
eend 255
fi
fi
}
# Check to see if something is defined on our VT
vtstatic() {
if [ -e /etc/inittab ] ; then
grep -Eq "^[^#]+.*\<tty$1\>" /etc/inittab
elif [ -e /etc/ttys ] ; then
grep -q "^ttyv$(($1 - 1))" /etc/ttys
else
return 1
fi
}
start() {
local EXE NAME PIDFILE AUTOCLEAN_CGROUP
setup_dm
if [ -f /etc/.noxdm ]; then
einfo "Skipping ${EXE##*/}, /etc/.noxdm found or \"nox\" bootparam passed."
rm /etc/.noxdm
return 0
fi
ebegin "Setting up ${EXE##*/}"
# save the prefered DM
save_options "service" "${EXE}"
save_options "name" "${NAME}"
save_options "pidfile" "${PIDFILE}"
save_options "start_stop_args" "${START_STOP_ARGS}"
save_options "autoclean_cgroup" "${AUTOCLEAN_CGROUP:-no}"
if [ -n "${CHECKVT-y}" ] ; then
if vtstatic "${CHECKVT:-7}" ; then
if [ -x /sbin/telinit ] && [ "${SOFTLEVEL}" != "BOOT" ] && [ "${RC_SOFTLEVEL}" != "BOOT" ]; then
ewarn "Something is already defined on VT ${CHECKVT:-7}, will start X later"
telinit a >/dev/null 2>&1
return 0
else
eerror "Something is already defined on VT ${CHECKVT:-7}, not starting"
return 1
fi
fi
fi
/etc/X11/startDM.sh
eend 0
}
stop() {
local curvt retval
retval=0
if [ -t 0 ]; then
if type fgconsole >/dev/null 2>&1; then
curvt=$(fgconsole 2>/dev/null)
else
curvt=$(tty)
case "${curvt}" in
/dev/ttyv[0-9]*) curvt=${curvt#/dev/ttyv} ;;
*) curvt= ;;
esac
fi
fi
local myexe myname mypidfile myservice
myexe=$(get_options "service")
myname=$(get_options "name")
mypidfile=$(get_options "pidfile")
myservice=${myexe##*/}
yesno "${rc_cgroup_cleanup:-no}" || rc_cgroup_cleanup=$(get_options "autoclean_cgroup")
[ -z "${myexe}" ] && return 0
ebegin "Stopping ${myservice}"
if start-stop-daemon --quiet --test --stop --exec "${myexe}"; then
start-stop-daemon --stop --exec "${myexe}" --retry TERM/5/TERM/5 \
${mypidfile:+--pidfile} ${mypidfile} \
${myname:+--name} ${myname}
retval=${?}
fi
# switch back to original vt
if [ -n "${curvt}" ]; then
if type chvt >/dev/null 2>&1; then
chvt "${curvt}"
else
vidcontrol -s "$((curvt + 1))"
fi
fi
eend ${retval} "Error stopping ${myservice}"
return ${retval}
}
# vim: set ts=4 :

188
init.d/._cfg0001_apache2 Executable file
View File

@@ -0,0 +1,188 @@
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
extra_commands="configtest modules virtualhosts"
extra_started_commands="configdump fullstatus graceful gracefulstop reload"
description_configdump="Dumps the configuration of the runing apache server. Requires server-info to be enabled and www-client/lynx."
description_configtest="Run syntax tests for configuration files."
description_fullstatus="Gives the full status of the server. Requires lynx and server-status to be enabled."
description_graceful="A graceful restart advises the children to exit after the current request and reloads the configuration."
description_gracefulstop="A graceful stop advises the children to exit after the current request and stops the server."
description_modules="Dump a list of loaded Static and Shared Modules."
description_reload="Kills all children and reloads the configuration."
description_virtualhosts="Show the settings as parsed from the config file (currently only shows the virtualhost settings)."
description_stop="Kills all children and stops the server."
depend() {
need net
use mysql dns logger netmount postgresql
after sshd
}
configtest() {
ebegin "Checking ${SVCNAME} configuration"
checkconfig
eend $?
}
checkconfd() {
if [ ! -f /etc/init.d/sysfs ]; then
eerror "This init script works only with openrc (baselayout-2)."
eerror "If you still need baselayout-1.x, please, use"
eerror "apache2.initd-baselayout-1 from /usr/share/doc/apache2-*/"
fi
PIDFILE="${PIDFILE:-/var/run/apache2.pid}"
TIMEOUT=${TIMEOUT:-15}
SERVERROOT="${SERVERROOT:-/usr/lib64/apache2}"
if [ ! -d ${SERVERROOT} ]; then
eerror "SERVERROOT does not exist: ${SERVERROOT}"
return 1
fi
CONFIGFILE="${CONFIGFILE:-/etc/apache2/httpd.conf}"
[ "${CONFIGFILE#/}" = "${CONFIGFILE}" ] && CONFIGFILE="${SERVERROOT}/${CONFIGFILE}"
if [ ! -r "${CONFIGFILE}" ]; then
eerror "Unable to read configuration file: ${CONFIGFILE}"
return 1
fi
APACHE2_OPTS="${APACHE2_OPTS} -d ${SERVERROOT}"
APACHE2_OPTS="${APACHE2_OPTS} -f ${CONFIGFILE}"
[ -n "${STARTUPERRORLOG}" ] && APACHE2_OPTS="${APACHE2_OPTS} -E ${STARTUPERRORLOG}"
APACHE2="/usr/sbin/apache2"
}
checkconfig() {
checkpath --directory /run/apache_ssl_mutex
checkconfd || return 1
${APACHE2} ${APACHE2_OPTS} -t 1>/dev/null 2>&1
ret=$?
if [ $ret -ne 0 ]; then
eerror "${SVCNAME} has detected an error in your setup:"
${APACHE2} ${APACHE2_OPTS} -t
fi
return $ret
}
start() {
checkconfig || return 1
ebegin "Starting ${SVCNAME}"
# Use start stop daemon to apply system limits #347301
start-stop-daemon --start -- ${APACHE2} ${APACHE2_OPTS} -k start
local i=0 retval=1
while [ $i -lt ${TIMEOUT} ] ; do
if [ -e "${PIDFILE}" ] ; then
retval=0
break
fi
sleep 1 && i=$(expr $i + 1)
done
eend ${retval}
}
stop() {
if [ "${RC_CMD}" = "restart" ]; then
checkconfig || return 1
else
checkconfd || return 1
fi
PID=$(cat "${PIDFILE}" 2>/dev/null)
if [ -z "${PID}" ]; then
einfo "${SVCNAME} not running (no pid file)"
return 0
fi
ebegin "Stopping ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k stop
local i=0 retval=0
while ( test -f "${PIDFILE}" || pgrep -P ${PID} apache2 >/dev/null ) \
&& [ $i -lt ${TIMEOUT} ]; do
sleep 1 && i=$(expr $i + 1)
done
[ -e "${PIDFILE}" ] && retval=1
eend ${retval}
}
reload() {
RELOAD_TYPE="${RELOAD_TYPE:-graceful}"
checkconfig || return 1
if [ "${RELOAD_TYPE}" = "restart" ]; then
ebegin "Restarting ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k restart
eend $?
elif [ "${RELOAD_TYPE}" = "graceful" ]; then
ebegin "Gracefully restarting ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k graceful
eend $?
else
eerror "${RELOAD_TYPE} is not a valid RELOAD_TYPE. Please edit /etc/conf.d/${SVCNAME}"
fi
}
graceful() {
checkconfig || return 1
ebegin "Gracefully restarting ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k graceful
eend $?
}
gracefulstop() {
checkconfig || return 1
ebegin "Gracefully stopping ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k graceful-stop
eend $?
}
modules() {
checkconfig || return 1
${APACHE2} ${APACHE2_OPTS} -M 2>&1
}
fullstatus() {
LYNX="${LYNX:-lynx -dump}"
STATUSURL="${STATUSURL:-http://localhost/server-status}"
if ! type -p $(set -- ${LYNX}; echo $1) 2>&1 >/dev/null; then
eerror "lynx not found! you need to emerge www-client/lynx"
else
${LYNX} ${STATUSURL}
fi
}
virtualhosts() {
checkconfig || return 1
${APACHE2} ${APACHE2_OPTS} -S
}
configdump() {
LYNX="${LYNX:-lynx -dump}"
INFOURL="${INFOURL:-http://localhost/server-info}"
checkconfd || return 1
if ! type -p $(set -- ${LYNX}; echo $1) 2>&1 >/dev/null; then
eerror "lynx not found! you need to emerge www-client/lynx"
else
echo "${APACHE2} started with '${APACHE2_OPTS}'"
for i in config server list; do
${LYNX} "${INFOURL}/?${i}" | sed '/Apache Server Information/d;/^[[:space:]]\+[_]\+$/Q'
done
fi
}
# vim: ts=4 filetype=gentoo-init-d

84
init.d/._cfg0001_tor Executable file
View File

@@ -0,0 +1,84 @@
#!/sbin/runscript
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/tor/files/tor.initd-r7,v 1.2 2014/12/23 17:26:49 blueness Exp $
PIDFILE=/var/run/tor/tor.pid
CONFFILE=/etc/tor/torrc
GRACEFUL_TIMEOUT=${GRACEFUL_TIMEOUT:-60}
# See bug #523552, and https://trac.torproject.org/projects/tor/ticket/5525
# Graceful = wait 30 secs or so until all connections are properly closed.
extra_commands="checkconfig"
extra_started_commands="graceful gracefulstop reload"
description="Anonymizing overlay network for TCP"
description_checkconfig="Check for valid config file."
description_reload="Reload the configuration."
description_graceful="Gracefully restart."
description_gracefulstop="Gracefully stop."
depend() {
need net
}
checkconfig() {
# first check that it exists
if [ ! -f ${CONFFILE} ] ; then
eerror "You need to setup ${CONFFILE} first"
eerror "Example is in ${CONFFILE}.sample"
return 1
fi
# now verify whether the configuration is valid
/usr/bin/tor --verify-config -f ${CONFFILE} > /dev/null 2>&1
if [ $? -eq 0 ] ; then
einfo "Tor configuration (${CONFFILE}) is valid."
return 0
else
eerror "Tor configuration (${CONFFILE}) not valid."
/usr/bin/tor --verify-config -f ${CONFFILE}
return 1
fi
}
start() {
checkconfig || return 1
checkpath -d -m 0755 -o tor:tor /var/run/tor
ebegin "Starting Tor"
HOME=/var/lib/tor
start-stop-daemon --start --pidfile "${PIDFILE}" --quiet --exec /usr/bin/tor -- -f "${CONFFILE}" --runasdaemon 1 --PidFile "${PIDFILE}" > /dev/null 2>&1
eend $?
}
stop() {
ebegin "Stopping Tor"
start-stop-daemon --stop --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}"
eend $?
}
graceful() {
gracefulstop
start
eend $?
}
gracefulstop() {
local rc=0
ebegin "Gracefully stopping Tor"
ebegin "This can take up to ${GRACEFUL_TIMEOUT} seconds"
start-stop-daemon -P --stop --signal INT -R ${GRACEFUL_TIMEOUT} --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}"
rc=$?
eend "done"
eend $rc
}
reload() {
if [ ! -f ${PIDFILE} ]; then
eerror "${SVCNAME} isn't running"
return 1
fi
checkconfig || return 1
ebegin "Reloading Tor configuration"
start-stop-daemon --signal HUP --pidfile ${PIDFILE}
eend $?
}

31
init.d/._cfg0001_tox-dht-daemon Executable file
View File

@@ -0,0 +1,31 @@
#!/sbin/runscript
PIDDIR=/run/tox-dht-bootstrap
PIDFILE="${PIDDIR}"/tox-dht-bootstrap.pid
depend() {
need net
}
start() {
ebegin "Starting tox-dht-bootstrap daemon"
[ -d "${PIDDIR}" ] || mkdir -p "${PIDDIR}"
chown -R ${TOX_USER}:${TOX_GROUP} "${PIDDIR}"
start-stop-daemon --start \
--pidfile "${PIDFILE}" \
--user=${TOX_USER} --group=${TOX_GROUP} \
--exec /usr/bin/tox-bootstrapd -- /etc/tox-bootstrapd.conf
eend $?
}
stop() {
ebegin "Stopping tox-dht-bootstrap daemon"
start-stop-daemon --stop \
--pidfile "${PIDFILE}"
eend $?
}

21
init.d/acpid Executable file
View File

@@ -0,0 +1,21 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-power/acpid/files/acpid-2.0.16-init.d,v 1.1 2012/05/19 09:53:59 ssuominen Exp $
extra_started_commands="reload"
command="/usr/sbin/acpid"
command_args="${ACPID_ARGS}"
start_stop_daemon_args="--quiet"
description="Daemon for Advanced Configuration and Power Interface"
depend() {
need localmount
use logger
}
reload() {
ebegin "Reloading acpid configuration"
start-stop-daemon --exec $command --signal HUP
eend $?
}

83
init.d/alsasound Executable file
View File

@@ -0,0 +1,83 @@
#!/sbin/runscript
# $Header: /var/cvsroot/gentoo-x86/media-sound/alsa-utils/files/alsasound.initd-r5,v 1.1 2012/02/20 09:03:53 chainsaw Exp $
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
alsastatedir=/var/lib/alsa
alsascrdir=/etc/alsa.d
extra_commands="save restore"
depend() {
need localmount
after bootmisc modules isapnp coldplug hotplug
}
restore() {
ebegin "Restoring Mixer Levels"
if [ ! -r "${alsastatedir}/asound.state" ] ; then
ewarn "No mixer config in ${alsastatedir}/asound.state, you have to unmute your card!"
eend 0
return 0
fi
local cards="$(sed -n -e 's/ *\([[:digit:]]*\) .*/\1/p' /proc/asound/cards)"
local CARDNUM
for cardnum in ${cards}; do
[ -e /dev/snd/controlC${cardnum} ] || sleep 2
[ -e /dev/snd/controlC${cardnum} ] || sleep 2
[ -e /dev/snd/controlC${cardnum} ] || sleep 2
[ -e /dev/snd/controlC${cardnum} ] || sleep 2
alsactl -I -f "${alsastatedir}/asound.state" restore ${cardnum} \
|| ewarn "Errors while restoring defaults, ignoring"
done
for ossfile in "${alsastatedir}"/oss/card*_pcm* ; do
[ -e "${ossfile}" ] || continue
# We use cat because I'm not sure if cp works properly on /proc
local procfile=${ossfile##${alsastatedir}/oss}
procfile="$(echo "${procfile}" | sed -e 's,_,/,g')"
if [ -e /proc/asound/"${procfile}"/oss ] ; then
cat "${ossfile}" > /proc/asound/"${procfile}"/oss
fi
done
eend 0
}
save() {
ebegin "Storing ALSA Mixer Levels"
mkdir -p "${alsastatedir}"
if ! alsactl -f "${alsastatedir}/asound.state" store; then
eerror "Error saving levels."
eend 1
return 1
fi
for ossfile in /proc/asound/card*/pcm*/oss; do
[ -e "${ossfile}" ] || continue
local device=${ossfile##/proc/asound/} ; device=${device%%/oss}
device="$(echo "${device}" | sed -e 's,/,_,g')"
mkdir -p "${alsastatedir}/oss/"
cp "${ossfile}" "${alsastatedir}/oss/${device}"
done
eend 0
}
start() {
if [ "${RESTORE_ON_START}" = "yes" ]; then
restore
fi
return 0
}
stop() {
if [ "${SAVE_ON_STOP}" = "yes" ]; then
save
fi
return 0
}

187
init.d/apache2 Executable file
View File

@@ -0,0 +1,187 @@
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
extra_commands="configtest modules virtualhosts"
extra_started_commands="configdump fullstatus graceful gracefulstop reload"
description_configdump="Dumps the configuration of the runing apache server. Requires server-info to be enabled and www-client/lynx."
description_configtest="Run syntax tests for configuration files."
description_fullstatus="Gives the full status of the server. Requires lynx and server-status to be enabled."
description_graceful="A graceful restart advises the children to exit after the current request and reloads the configuration."
description_gracefulstop="A graceful stop advises the children to exit after the current request and stops the server."
description_modules="Dump a list of loaded Static and Shared Modules."
description_reload="Kills all children and reloads the configuration."
description_virtualhosts="Show the settings as parsed from the config file (currently only shows the virtualhost settings)."
description_stop="Kills all children and stops the server."
depend() {
need net
use mysql dns logger netmount postgresql
after sshd
}
configtest() {
ebegin "Checking ${SVCNAME} configuration"
checkconfig
eend $?
}
checkconfd() {
if [ ! -f /etc/init.d/sysfs ]; then
eerror "This init script works only with openrc (baselayout-2)."
eerror "If you still need baselayout-1.x, please, use"
eerror "apache2.initd-baselayout-1 from /usr/share/doc/apache2-*/"
fi
PIDFILE="${PIDFILE:-/var/run/apache2.pid}"
TIMEOUT=${TIMEOUT:-15}
SERVERROOT="${SERVERROOT:-/usr/lib64/apache2}"
if [ ! -d ${SERVERROOT} ]; then
eerror "SERVERROOT does not exist: ${SERVERROOT}"
return 1
fi
CONFIGFILE="${CONFIGFILE:-/etc/apache2/httpd.conf}"
[ "${CONFIGFILE#/}" = "${CONFIGFILE}" ] && CONFIGFILE="${SERVERROOT}/${CONFIGFILE}"
if [ ! -r "${CONFIGFILE}" ]; then
eerror "Unable to read configuration file: ${CONFIGFILE}"
return 1
fi
APACHE2_OPTS="${APACHE2_OPTS} -d ${SERVERROOT}"
APACHE2_OPTS="${APACHE2_OPTS} -f ${CONFIGFILE}"
[ -n "${STARTUPERRORLOG}" ] && APACHE2_OPTS="${APACHE2_OPTS} -E ${STARTUPERRORLOG}"
APACHE2="/usr/sbin/apache2"
}
checkconfig() {
checkconfd || return 1
${APACHE2} ${APACHE2_OPTS} -t 1>/dev/null 2>&1
ret=$?
if [ $ret -ne 0 ]; then
eerror "${SVCNAME} has detected an error in your setup:"
${APACHE2} ${APACHE2_OPTS} -t
fi
return $ret
}
start() {
checkconfig || return 1
ebegin "Starting ${SVCNAME}"
# Use start stop daemon to apply system limits #347301
start-stop-daemon --start -- ${APACHE2} ${APACHE2_OPTS} -k start
local i=0 retval=1
while [ $i -lt ${TIMEOUT} ] ; do
if [ -e "${PIDFILE}" ] ; then
retval=0
break
fi
sleep 1 && i=$(expr $i + 1)
done
eend ${retval}
}
stop() {
if [ "${RC_CMD}" = "restart" ]; then
checkconfig || return 1
else
checkconfd || return 1
fi
PID=$(cat "${PIDFILE}" 2>/dev/null)
if [ -z "${PID}" ]; then
einfo "${SVCNAME} not running (no pid file)"
return 0
fi
ebegin "Stopping ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k stop
local i=0 retval=0
while ( test -f "${PIDFILE}" && pgrep -P ${PID} apache2 >/dev/null ) \
&& [ $i -lt ${TIMEOUT} ]; do
sleep 1 && i=$(expr $i + 1)
done
[ -e "${PIDFILE}" ] && retval=1
eend ${retval}
}
reload() {
RELOAD_TYPE="${RELOAD_TYPE:-graceful}"
checkconfig || return 1
if [ "${RELOAD_TYPE}" = "restart" ]; then
ebegin "Restarting ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k restart
eend $?
elif [ "${RELOAD_TYPE}" = "graceful" ]; then
ebegin "Gracefully restarting ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k graceful
eend $?
else
eerror "${RELOAD_TYPE} is not a valid RELOAD_TYPE. Please edit /etc/conf.d/${SVCNAME}"
fi
}
graceful() {
checkconfig || return 1
ebegin "Gracefully restarting ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k graceful
eend $?
}
gracefulstop() {
checkconfig || return 1
ebegin "Gracefully stopping ${SVCNAME}"
${APACHE2} ${APACHE2_OPTS} -k graceful-stop
eend $?
}
modules() {
checkconfig || return 1
${APACHE2} ${APACHE2_OPTS} -M 2>&1
}
fullstatus() {
LYNX="${LYNX:-lynx -dump}"
STATUSURL="${STATUSURL:-http://localhost/server-status}"
if ! type -p $(set -- ${LYNX}; echo $1) 2>&1 >/dev/null; then
eerror "lynx not found! you need to emerge www-client/lynx"
else
${LYNX} ${STATUSURL}
fi
}
virtualhosts() {
checkconfig || return 1
${APACHE2} ${APACHE2_OPTS} -S
}
configdump() {
LYNX="${LYNX:-lynx -dump}"
INFOURL="${INFOURL:-http://localhost/server-info}"
checkconfd || return 1
if ! type -p $(set -- ${LYNX}; echo $1) 2>&1 >/dev/null; then
eerror "lynx not found! you need to emerge www-client/lynx"
else
echo "${APACHE2} started with '${APACHE2_OPTS}'"
for i in config server list; do
${LYNX} "${INFOURL}/?${i}" | sed '/Apache Server Information/d;/^[[:space:]]\+[_]\+$/Q'
done
fi
}
# vim: ts=4 filetype=gentoo-init-d

28
init.d/bitlbee Executable file
View File

@@ -0,0 +1,28 @@
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or
# later
# $Header: /var/cvsroot/gentoo-x86/net-im/bitlbee/files/bitlbee.initd,v 1.4 2013/01/08 14:25:21 cedk Exp $
DAEMON=/usr/sbin/bitlbee
PIDFILE=/var/run/bitlbee/bitlbee.pid
depend() {
need logger net
}
start () {
ebegin "Starting bitlbee"
checkpath -d -m 0755 -o bitlbee:bitlbee `dirname ${PIDFILE}`
start-stop-daemon --start --quiet \
-u bitlbee:bitlbee --exec ${DAEMON} -- -P ${PIDFILE} \
${BITLBEE_OPTS}
eend $?
}
stop() {
ebegin "Stopping bitlbee"
start-stop-daemon --stop --quiet --pidfile ${PIDFILE}
eend $?
}

217
init.d/bootmisc Executable file
View File

@@ -0,0 +1,217 @@
#!/sbin/runscript
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
depend()
{
need localmount
before logger
after clock sysctl
keyword -prefix -timeout
}
: ${wipe_tmp:=${WIPE_TMP:-yes}}
: ${log_dmesg:=${LOG_DMESG:-yes}}
cleanup_tmp_dir()
{
local dir="$1"
if ! [ -d "$dir" ]; then
mkdir -p "$dir" || return $?
fi
checkpath -W "$dir" || return 1
chmod a+rwt "$dir" 2> /dev/null
cd "$dir" || return 1
if yesno $wipe_tmp; then
ebegin "Wiping $dir directory"
# Faster than raw find
if ! rm -rf -- [!ajlq\.]* 2>/dev/null ; then
# Blah, too many files
find . -maxdepth 1 -name '[!ajlq\.]*' -exec rm -rf -- {} +
fi
# pam_mktemp creates a .private directory within which
# each user gets a private directory with immutable
# bit set; remove the immutable bit before trying to
# remove it.
[ -d /tmp/.private ] && chattr -R -a /tmp/.private 2> /dev/null
# Prune the paths that are left
find . -maxdepth 1 \
! -name . \
! -name lost+found \
! -name quota.user \
! -name aquota.user \
! -name quota.group \
! -name aquota.group \
! -name journal \
-exec rm -rf -- {} +
eend 0
else
ebegin "Cleaning $dir directory"
rm -rf -- .X*-lock esrv* kio* \
jpsock.* .fam* .esd* \
orbit-* ssh-* ksocket-* \
.*-unix
eend 0
fi
}
cleanup_var_run_dir()
{
ebegin "Cleaning /var/run"
for x in $(find /var/run ! -type d ! -name utmp \
! -name random-seed ! -name dev.db \
! -name ld-elf.so.hints ! -name ld.so.hints);
do
# Clean stale sockets
if [ -S "$x" ]; then
if type fuser >/dev/null 2>&1; then
fuser "$x" >/dev/null 2>&1 || rm -- "$x"
else
rm -- "$x"
fi
fi
[ ! -f "$x" ] && continue
# Do not remove pidfiles of already running daemons
case "$x" in
*.pid)
start-stop-daemon --test --quiet \
--stop --pidfile "$x" && continue
;;
esac
rm -f -- "$x"
done
eend 0
}
mkutmp()
{
: >"$1"
# Not all systems have the utmp group
chgrp utmp "$1" 2>/dev/null
chmod 0664 "$1"
}
migrate_to_run()
{
src="$1"
dst="$2"
if [ -L $src -a "$(readlink -f $src)" != $dst ]; then
ewarn "$src does not point to $dst."
ewarn "Setting $src to point to $dst."
rm $src
elif [ ! -L $src -a -d $src ]; then
ebegin "Migrating $src to $dst"
cp -a $src/* $dst/
rm -rf $src
eend $?
fi
# If $src doesn't exist at all, just run this
if [ ! -e $src ]; then
ln -s $dst $src
fi
}
clean_run()
{
[ "$RC_SYS" = VSERVER ] && return 0
local dir
dir=$(mktemp -d)
mount --bind / $dir
rm -rf $dir/run/*
umount $dir
rm -rf $dir
}
start()
{
# Remove any added console dirs
rm -rf "$RC_LIBEXECDIR"/console/*
local logw=false runw=false extra=
# Ensure that our basic dirs exist
if [ "$RC_UNAME" = Linux ]; then
# Satisfy Linux FHS
extra=/var/lib/misc
if [ ! -d /run ]; then
extra="/var/run $extra"
fi
else
extra=/var/run
fi
for x in /var/log /tmp $extra; do
if ! [ -d $x ]; then
if ! mkdir -p $x; then
eend 1 "failed to create needed directory $x"
return 1
fi
fi
done
if [ "$RC_UNAME" = Linux -a -d /run ]; then
migrate_to_run /var/lock /run/lock
migrate_to_run /var/run /run
clean_run
fi
if checkpath -W /var/run; then
ebegin "Creating user login records"
local xtra=
[ "$RC_UNAME" = NetBSD ] && xtra=x
for x in "" $xtra; do
mkutmp /var/run/utmp$x
done
[ -e /var/log/wtmp ] || mkutmp /var/log/wtmp
eend 0
mountinfo -q -f tmpfs /var/run || cleanup_var_run_dir
fi
# Clean up /tmp directories
local tmp=
for tmp in ${clean_tmp_dirs:-${wipe_tmp_dirs-/tmp}}; do
mountinfo -q -f tmpfs "$tmp" || cleanup_tmp_dir "$tmp"
done
if checkpath -W /tmp; then
# Make sure our X11 stuff have the correct permissions
# Omit the chown as bootmisc is run before network is up
# and users may be using lame LDAP auth #139411
rm -rf /tmp/.ICE-unix /tmp/.X11-unix
mkdir -p /tmp/.ICE-unix /tmp/.X11-unix
chmod 1777 /tmp/.ICE-unix /tmp/.X11-unix
if [ -x /sbin/restorecon ]; then
restorecon /tmp/.ICE-unix /tmp/.X11-unix
fi
fi
if yesno $log_dmesg; then
if $logw || checkpath -W /var/log; then
# Create an 'after-boot' dmesg log
if [ "$RC_SYS" != VSERVER -a "$RC_SYS" != OPENVZ -a "$RC_SYS" != LXC ]; then
dmesg > /var/log/dmesg
chmod 640 /var/log/dmesg
fi
fi
fi
return 0
}
stop()
{
# Write a halt record if we're shutting down
if [ "$RC_RUNLEVEL" = shutdown ]; then
[ "$RC_UNAME" = Linux ] && halt -w
if [ "$RC_SYS" = OPENVZ ]; then
yesno $RC_REBOOT && printf "" >/reboot
fi
fi
return 0
}
# vim: ft=sh

13
init.d/busybox-ntpd Executable file
View File

@@ -0,0 +1,13 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/busybox/files/ntpd.initd,v 1.2 2012/12/21 03:15:28 blueness Exp $
command="/bin/busybox ntpd"
command_args="${NTPD_OPTS}"
pidfile="/var/run/ntpd.pid"
depend() {
use net dns logger
after ntp-client
}

8
init.d/busybox-watchdog Executable file
View File

@@ -0,0 +1,8 @@
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/busybox/files/watchdog.initd,v 1.3 2013/04/27 07:47:23 vapier Exp $
command="/bin/busybox watchdog"
command_args="${WATCHDOG_OPTS}"
pidfile="/var/run/watchdog.pid"

63
init.d/consolefont Executable file
View File

@@ -0,0 +1,63 @@
#!/sbin/runscript
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Sets a font for the consoles."
depend()
{
need localmount termencoding
after hotplug bootmisc
keyword -openvz -prefix -uml -vserver -xenu -lxc
}
start()
{
ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
consolefont=${consolefont:-${CONSOLEFONT}}
unicodemap=${unicodemap:-${UNICODEMAP}}
consoletranslation=${consoletranslation:-${CONSOLETRANSLATION}}
if [ -z "$consolefont" ]; then
ebegin "Using the default console font"
eend 0
return 0
fi
if [ "$ttyn" = 0 ]; then
ebegin "Skipping font setup (rc_tty_number == 0)"
eend 0
return 0
fi
local x= param= sf_param= retval=0 ttydev=/dev/tty
# Get additional parameters
if [ -n "$consoletranslation" ]; then
param="$param -m $consoletranslation"
fi
if [ -n "${unicodemap}" ]; then
param="$param -u $unicodemap"
fi
# Set the console font
ebegin "Setting console font [$consolefont]"
[ -d /dev/vc ] && ttydev=/dev/vc/
x=1
while [ $x -le $ttyn ]; do
if ! setfont $consolefont $param -C $ttydev$x >/dev/null; then
retval=1
break
fi
: $(( x += 1 ))
done
eend $retval
# Store the font so we can use it ASAP on boot
if [ $retval -eq 0 ] && checkpath -W "$RC_LIBEXECDIR"; then
mkdir -p "$RC_LIBEXECDIR"/console
setfont -O "$RC_LIBEXECDIR"/console/font
fi
return $retval
}

26
init.d/consolekit Executable file
View File

@@ -0,0 +1,26 @@
#!/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-auth/consolekit/files/consolekit-0.2.rc,v 1.1 2011/10/20 19:14:47 axs Exp $
depend() {
need dbus
use logger
}
start() {
ebegin "Starting ConsoleKit daemon"
checkpath -q -d -m 0755 /var/run/ConsoleKit
start-stop-daemon --start -q \
--pidfile /var/run/ConsoleKit/pid \
--exec /usr/sbin/console-kit-daemon --
eend $?
}
stop() {
ebegin "Stopping ConsoleKit daemon"
start-stop-daemon --stop -q --pidfile /var/run/ConsoleKit/pid
eend $?
}

42
init.d/cpupower Executable file
View File

@@ -0,0 +1,42 @@
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-power/cpupower/files/init.d-r4,v 1.1 2013/12/25 11:46:32 ssuominen Exp $
CPUFREQ_SYSFS=/sys/devices/system/cpu/cpufreq
change() {
local c ret=0 opts="$1"
if [ -n "$opts" ] ; then
ebegin "Running cpupower -c all frequency-set ${opts}"
cpupower -c all frequency-set ${opts} >/dev/null 2>&1
: $(( ret += $? ))
eend ${ret}
if [ -d ${CPUFREQ_SYSFS} ] && [ -n "${SYSFS_EXTRA}" ] ; then
c=1
einfo "Setting extra options: ${SYSFS_EXTRA}"
if cd ${CPUFREQ_SYSFS} ; then
local o v
for o in ${SYSFS_EXTRA} ; do
v=${o#*=}
o=${o%%=*}
echo ${v} > ${o} || break
done
c=0
fi
eend ${c}
: $(( ret += c ))
fi
fi
return ${ret}
}
start() {
change "${START_OPTS}"
}
stop() {
change "${STOP_OPTS}"
}

20
init.d/cups-browsed Executable file
View File

@@ -0,0 +1,20 @@
#!/sbin/runscript
PIDFILE=/var/run/cups-browsed.pid
depend() {
need cupsd
}
start() {
ebegin "Starting cups-browsed"
start-stop-daemon --start --make-pidfile --pidfile "${PIDFILE}" \
--background --quiet --exec /usr/sbin/cups-browsed
eend $?
}
stop() {
ebegin "Stopping cups-browsed"
start-stop-daemon --stop --pidfile "${PIDFILE}" --quiet --exec /usr/sbin/cupsd
eend $?
}

26
init.d/cupsd Executable file
View File

@@ -0,0 +1,26 @@
#!/sbin/runscript
depend() {
use net
need dbus
before nfs
after logger
}
start() {
ebegin "Starting cupsd"
checkpath -q -d -m 0775 -o root:lp /var/cache/cups
checkpath -q -d -m 0775 -o root:lp /var/cache/cups/rss
checkpath -q -d -m 0755 -o root:lp /run/cups
checkpath -q -d -m 0511 -o lp:lpadmin /run/cups/certs
start-stop-daemon --start --quiet --exec /usr/sbin/cupsd
eend $?
}
stop() {
ebegin "Stopping cupsd"
start-stop-daemon --stop --quiet --exec /usr/sbin/cupsd
eend $?
}

23
init.d/cyrus Executable file
View File

@@ -0,0 +1,23 @@
#!/sbin/runscript
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-mail/cyrus-imapd/files/cyrus.rc6,v 1.8 2007/07/08 18:47:30 drac Exp $
depend() {
use net
use dns logger
after drac saslauthd
}
start() {
ebegin "Starting cyrus imapd"
start-stop-daemon --start --quiet --background \
--exec /usr/lib/cyrus/master -- ${CYRUS_OPTS}
eend $?
}
stop() {
ebegin "Stopping cyrus imapd"
start-stop-daemon --stop --quiet --pidfile /var/run/cyrus-master.pid
eend $?
}

50
init.d/dbus Executable file
View File

@@ -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}
}

38
init.d/devfs Executable file
View File

@@ -0,0 +1,38 @@
#!/sbin/runscript
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Mount system critical filesystems in /dev."
depend() {
use dev-mount
before dev
keyword -prefix -vserver -lxc
}
start() {
# Mount required stuff as user may not have then in /etc/fstab
for x in \
"mqueue /dev/mqueue 1777 ,nodev mqueue" \
"devpts /dev/pts 0755 ,gid=5,mode=0620 devpts" \
"tmpfs /dev/shm 1777 ,nodev shm" \
; do
set -- $x
grep -Eq "[[:space:]]+$1$" /proc/filesystems || continue
mountinfo -q $2 && continue
if [ ! -d $2 ]; then
mkdir -m $3 -p $2 >/dev/null 2>&1 || \
ewarn "Could not create $2!"
fi
if [ -d $2 ]; then
ebegin "Mounting $2"
if ! fstabinfo --mount $2; then
mount -n -t $1 -o noexec,nosuid$4 $5 $2
fi
eend $?
fi
done
return 0
}

111
init.d/device-mapper Executable file
View File

@@ -0,0 +1,111 @@
#!/sbin/runscript
# Copyright 1999-2013 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.95-r2,v 1.2 2013/04/09 11:00:26 ssuominen 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 **get_new_dm_volumes(void)
#
# Return dmsetup commands to setup volumes
get_new_dm_volumes() {
local volume params
# Filter comments and blank lines
grep -v -e '^[[:space:]]*\(#\|$\)' /etc/dmtab | \
while read volume params ; do
# If it exists, skip it
dmvolume_exists "${volume%:}" && continue
# Assemble the command to run to create volume
echo "echo ${params} | /sbin/dmsetup create ${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 "${x}" >/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
}

32
init.d/distccd Executable file
View File

@@ -0,0 +1,32 @@
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-devel/distcc/files/3.1/init,v 1.2 2011/12/27 16:09:23 ultrabug Exp $
depend() {
need net
use avahi-daemon ypbind
}
start() {
ebegin "Starting distccd"
if [ ! -e /var/run/distccd ] ; then
mkdir -p /var/run/distccd
chown distcc:daemon /var/run/distccd
fi
# Load PATH and GCC_SPECS from gcc-config, bug #262773
eval "$(gcc-config -E)"
start-stop-daemon --start --quiet --exec "${DISTCCD_EXEC}" --user distcc -- \
--daemon --pid-file "${DISTCCD_PIDFILE}" \
${DISTCCD_OPTS}
eend $?
}
stop() {
ebegin "Stopping distccd"
start-stop-daemon --stop --quiet --pidfile "${DISTCCD_PIDFILE}"
eend $?
}

353
init.d/dmcrypt Executable file
View File

@@ -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
}

18
init.d/dmesg Executable file
View File

@@ -0,0 +1,18 @@
#!/sbin/runscript
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Set the dmesg level for a cleaner boot"
depend()
{
before dev modules
keyword -lxc -prefix -vserver
}
start()
{
if [ -n "$dmesg_level" ]; then
dmesg -n$dmesg_level
fi
}

26
init.d/dmeventd Executable file
View File

@@ -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 $?
}

58
init.d/dovecot Executable file
View File

@@ -0,0 +1,58 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/net-mail/dovecot/files/dovecot.init-r4,v 1.1 2012/12/01 10:40:49 eras Exp $
extra_started_commands="reload"
depend() {
need localmount
before postfix
after bootmisc ldap mysql ntp-client ntpd postgresql saslauthd slapd
use logger net
}
checkconfig() {
DOVECOT_INSTANCE=${SVCNAME##*.}
if [ -n "${DOVECOT_INSTANCE}" -a "${SVCNAME}" != "dovecot" ]; then
DOVECOT_CONF=/etc/dovecot/dovecot.${DOVECOT_INSTANCE}.conf
else
DOVECOT_CONF=/etc/dovecot/dovecot.conf
fi
if [ ! -e ${DOVECOT_CONF} ]; then
eerror "You will need an ${DOVECOT_CONF} first"
return 1
fi
if [ -x /usr/sbin/dovecot ]; then
DOVECOT_BASEDIR=$(/usr/sbin/dovecot -c ${DOVECOT_CONF} -a | grep '^base_dir = ' | sed 's/^base_dir = //')
else
eerror "dovecot not executable"
return 1
fi
DOVECOT_BASEDIR=${DOVECOT_BASEDIR:-/var/run/dovecot}
DOVECOT_PIDFILE=${DOVECOT_BASEDIR}/master.pid
}
start() {
checkconfig || return 1
ebegin "Starting ${SVCNAME}"
start-stop-daemon --start --exec /usr/sbin/dovecot \
--pidfile "${DOVECOT_PIDFILE}" -- -c "${DOVECOT_CONF}"
eend $?
}
stop() {
checkconfig || return 1
ebegin "Stopping ${SVCNAME}"
start-stop-daemon --stop --exec /usr/sbin/dovecot \
--pidfile "${DOVECOT_PIDFILE}"
eend $?
}
reload() {
checkconfig || return 1
ebegin "Reloading ${SVCNAME} configs and restarting auth/login processes"
start-stop-daemon --signal HUP --exec /usr/sbin/dovecot \
--pidfile "${DOVECOT_PIDFILE}"
eend $?
}

68
init.d/dropbox Executable file
View File

@@ -0,0 +1,68 @@
#!/sbin/runscript
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/net-misc/dropbox/files/dropbox.initd,v 1.4 2014/03/22 07:31:57 naota Exp $
PID_DIR=/var/run/dropbox
depend() {
need localmount net
after bootmisc
}
start() {
local tmpnice="${NICE:+"--nicelevel "}${NICE}"
local tmpionice="${IONICE:+"--ionice "}${IONICE}"
local started=""
mkdir -p ${PID_DIR}
ebegin "Starting dropbox"
for dbuser in ${DROPBOX_USERS}; do
local homedir=$(eval echo ~${dbuser})
if test -d "${homedir}" && \
start-stop-daemon -S -b \
${tmpnice} ${tmpionice} \
-u ${dbuser} -v \
-e HOME=${homedir} \
-x /opt/bin/dropbox; then
started="${started} ${dbuser}"
else
eend $?
eerror "Failed to start dropbox for ${dbuser}"
if [ -n "${started}" ]; then
eerror "Stopping already started dropbox"
DROPBOX_USERS=${started} stop
fi
return 1
fi
done
if [ -z "${started}" ];then
eerror "No dropbox started"
eend 1
else
eend 0
fi
}
stop() {
local retval=0
ebegin "Stopping dropbox"
for dbuser in ${DROPBOX_USERS}; do
local homedir=$(eval echo ~${dbuser})
start-stop-daemon --stop \
--pidfile ${homedir}/.dropbox/dropbox.pid || retval=$?
done
eend ${retval}
}
status() {
for dbuser in ${DROPBOX_USERS}; do
local homedir=$(eval echo ~${dbuser})
if [ -e ${homedir}/.dropbox/dropbox.pid ] ; then
echo "dropboxd for USER $dbuser: running."
else
echo "dropboxd for USER $dbuser: not running."
fi
done
}

20
init.d/epmd Executable file
View File

@@ -0,0 +1,20 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the Erlang Public License 1.1
# $Header: /var/cvsroot/gentoo-x86/dev-lang/erlang/files/epmd.init,v 1.2 2012/12/31 09:24:49 djc Exp $
depend() {
need net
}
start() {
ebegin "Starting Erlang Port Mapper Daemon"
start-stop-daemon --start --quiet --user nobody --group nobody --exec /usr/bin/epmd -- -daemon
eend $?
}
stop() {
ebegin "Stopping Erlang Port Mapper Daemon"
/usr/bin/epmd -kill >/dev/null
eend $?
}

23
init.d/fancontrol Executable file
View File

@@ -0,0 +1,23 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/lm_sensors/files/fancontrol-init.d-2,v 1.1 2012/12/28 00:00:03 flameeyes Exp $
CONFIG=/etc/fancontrol
depend() {
need localmount
use lm_sensors
}
command=/usr/sbin/fancontrol
command_arguments="${CONFIG}"
start_stop_daemon_args="--background"
pidfile=/var/run/fancontrol.pid
start_pre() {
if [ ! -f ${CONFIG} ]; then
eerror "Configuration file ${CONFIG} not found"
return 1
fi
}

123
init.d/fsck Executable file
View File

@@ -0,0 +1,123 @@
#!/sbin/runscript
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Check and repair filesystems according to /etc/fstab"
_IFS="
"
depend()
{
use dev clock modules
keyword -jail -openvz -prefix -timeout -vserver -lxc -uml
}
_abort() {
rc-abort
return 1
}
# We should only reboot when first booting
_reboot() {
if [ "$RC_RUNLEVEL" = "$RC_BOOTLEVEL" ]; then
reboot "$@"
_abort || return 1
fi
}
_forcefsck()
{
[ -e /forcefsck ] || get_bootparam forcefsck
}
start()
{
local fsck_opts= p= check_extra=
if [ -e /fastboot ]; then
ewarn "Skipping fsck due to /fastboot"
return 0
fi
if _forcefsck; then
fsck_opts="$fsck_opts -f"
check_extra="(check forced)"
elif ! yesno ${fsck_on_battery:-YES} && ! on_ac_power; then
ewarn "Skipping fsck due to not being on AC power"
return 0
fi
if [ -n "$fsck_passno" ]; then
check_extra="[passno $fsck_passno] $check_extra"
if [ -n "$fsck_mnt" ]; then
eerror "Only 1 of fsck_passno and fsck_mnt must be set!"
return 1
fi
fi
ebegin "Checking local filesystems $check_extra"
# Append passno mounts
for p in $fsck_passno; do
local IFS="$_IFS"
case "$p" in
[0-9]*) p="=$p";;
esac
set -- "$@" $(fstabinfo --passno "$p")
unset IFS
done
# Append custom mounts
for m in $fsck_mnt ; do
local IFS="$_IFS"
set -- "$@" "$m"
unset IFS
done
if [ "$RC_UNAME" = Linux ]; then
local skiptypes
skiptypes=$(printf 'no%s,' ${net_fs_list} ${extra_net_fs_list})
[ "${skiptypes}" = "no," ] && skiptypes=""
fsck_opts="$fsck_opts -C0 -T -t ${skiptypes}noopts=_netdev"
if [ -z "$fsck_passno" -a -z "$fsck_mnt" ]; then
fsck_args=${fsck_args:--A -p}
if echo 2>/dev/null >/.test.$$; then
rm -f /.test.$$
fsck_opts="$fsck_opts -R"
fi
fi
fi
trap : INT QUIT
fsck ${fsck_args:--p} $fsck_opts "$@"
case $? in
0) eend 0; return 0;;
1) ewend 1 "Filesystems repaired"; return 0;;
2|3) if [ "$RC_UNAME" = Linux ]; then
ewend 1 "Filesystems repaired, but reboot needed"
_reboot -f
else
ewend 1 "Filesystems still have errors;" \
"manual fsck required"
_abort
fi;;
4) if [ "$RC_UNAME" = Linux ]; then
ewend 1 "Fileystem errors left uncorrected, aborting"
_abort
else
ewend 1 "Filesystems repaired, but reboot needed"
_reboot
fi;;
8) ewend 1 "Operational error"; return 0;;
12) ewend 1 "fsck interrupted";;
*) eend 2 "Filesystems couldn't be fixed";;
esac
_abort || return 1
}
stop()
{
# Fake function so we always shutdown correctly.
_abort() { return 0; }
_reboot() { return 0; }
_forcefsck() { return 1; }
yesno $fsck_shutdown && start
return 0
}

1
init.d/functions.sh Symbolic link
View File

@@ -0,0 +1 @@
/lib64/rc/sh/functions.sh

35
init.d/fuse Executable file
View File

@@ -0,0 +1,35 @@
#!/sbin/runscript
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
MOUNTPOINT=/sys/fs/fuse/connections
depend() {
need localmount
}
start() {
ebegin "Starting fuse"
if ! grep -qw fuse /proc/filesystems; then
modprobe fuse >/dev/null 2>&1 || eerror $? "Error loading fuse module"
fi
if grep -qw fusectl /proc/filesystems && \
! grep -qw $MOUNTPOINT /proc/mounts; then
mount -t fusectl none $MOUNTPOINT >/dev/null 2>&1 || \
eerror $? "Error mounting control filesystem"
fi
eend ${?}
}
stop() {
ebegin "Stopping fuse"
if grep -qw $MOUNTPOINT /proc/mounts; then
umount $MOUNTPOINT >/dev/null 2>&1 || \
eerror $? "Error unmounting control filesystem"
fi
eend ${?}
}

53
init.d/gentoo32-stable Executable file
View File

@@ -0,0 +1,53 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
depend() {
need localmount
need bootmisc
}
CHROOTDIR=/mnt/root/root32-stable
start() {
ebegin "Mounting 32bits chroot dirs"
mount -o bind /dev "${CHROOTDIR}"/dev >/dev/null
mount -o bind /dev/pts "${CHROOTDIR}"/dev/pts >/dev/null &
mount -o bind /dev/shm "${CHROOTDIR}"/dev/shm >/dev/null &
mount -o bind /proc "${CHROOTDIR}"/proc >/dev/null
# mount -o bind /proc/bus/usb "${CHROOTDIR}"/proc/bus/usb >/dev/null &
mount -o bind /sys "${CHROOTDIR}"/sys >/dev/null &
mount -o bind /tmp "${CHROOTDIR}"/tmp >/dev/null &
mount -o bind /usr/portage "${CHROOTDIR}"/usr/portage/ >/dev/null &
mount -o bind /home/distfiles "${CHROOTDIR}"/distfiles >/dev/null &
mount -o bind /usr/local/portage "${CHROOTDIR}"/usr/local/portage/ >/dev/null &
mount -o bind /var/lib/layman "${CHROOTDIR}"/var/lib/layman >/dev/null &
eend $? "An error occured while attempting to mount 32bit chroot directories"
ebegin "Copying 32bits chroot files"
cp -pf /etc/exclude.depclean "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/resolv.conf "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/passwd "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/shadow "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/group "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/gshadow "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/hosts "${CHROOTDIR}"/etc > /dev/null &
cp -Ppf /etc/localtime "${CHROOTDIR}"/etc >/dev/null &
eend $? "An error occured while attempting to copy 32 bits chroot files."
}
stop() {
ebegin "Unmounting 32bits chroot dirs"
umount -f "${CHROOTDIR}"/dev/pts >/dev/null
umount -f "${CHROOTDIR}"/dev/shm >/dev/null
umount -f "${CHROOTDIR}"/dev >/dev/null &
# umount -f "${CHROOTDIR}"/proc/bus/usb >/dev/null
umount -f "${CHROOTDIR}"/proc >/dev/null &
umount -f "${CHROOTDIR}"/sys >/dev/null &
umount -f "${CHROOTDIR}"/tmp >/dev/null &
umount -f "${CHROOTDIR}"/usr/portage >/dev/null &
umount -f "${CHROOTDIR}"/var/lib/layman >/dev/null &
umount -f "${CHROOTDIR}"/distfiles >/dev/null &
umount -f "${CHROOTDIR}"/usr/local/portage/ >/dev/null &
eend $? "An error occured while attempting to unmount 32bits chroot directories"
}

53
init.d/gentoo32-unstable Executable file
View File

@@ -0,0 +1,53 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
depend() {
need localmount
need bootmisc
}
CHROOTDIR=/mnt/root/root32-unstable
start() {
ebegin "Mounting 32bits chroot dirs"
mount -o bind /dev "${CHROOTDIR}"/dev >/dev/null
mount -o bind /dev/pts "${CHROOTDIR}"/dev/pts >/dev/null &
mount -o bind /dev/shm "${CHROOTDIR}"/dev/shm >/dev/null &
mount -o bind /proc "${CHROOTDIR}"/proc >/dev/null
# mount -o bind /proc/bus/usb "${CHROOTDIR}"/proc/bus/usb >/dev/null &
mount -o bind /sys "${CHROOTDIR}"/sys >/dev/null &
mount -o bind /tmp "${CHROOTDIR}"/tmp >/dev/null &
mount -o bind /usr/portage "${CHROOTDIR}"/usr/portage/ >/dev/null &
mount -o bind /home/distfiles "${CHROOTDIR}"/distfiles >/dev/null &
mount -o bind /usr/local/portage "${CHROOTDIR}"/usr/local/portage/ >/dev/null &
mount -o bind /var/lib/layman "${CHROOTDIR}"/var/lib/layman >/dev/null &
eend $? "An error occured while attempting to mount 32bit chroot directories"
ebegin "Copying 32bits chroot files"
cp -pf /etc/exclude.depclean "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/resolv.conf "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/passwd "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/shadow "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/group "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/gshadow "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/hosts "${CHROOTDIR}"/etc > /dev/null &
cp -Ppf /etc/localtime "${CHROOTDIR}"/etc >/dev/null &
eend $? "An error occured while attempting to copy 32 bits chroot files."
}
stop() {
ebegin "Unmounting 32bits chroot dirs"
umount -f "${CHROOTDIR}"/dev/pts >/dev/null
umount -f "${CHROOTDIR}"/dev/shm >/dev/null
umount -f "${CHROOTDIR}"/dev >/dev/null &
# umount -f "${CHROOTDIR}"/proc/bus/usb >/dev/null
umount -f "${CHROOTDIR}"/proc >/dev/null &
umount -f "${CHROOTDIR}"/sys >/dev/null &
umount -f "${CHROOTDIR}"/tmp >/dev/null &
umount -f "${CHROOTDIR}"/usr/portage >/dev/null &
umount -f "${CHROOTDIR}"/var/lib/layman >/dev/null &
umount -f "${CHROOTDIR}"/distfiles >/dev/null &
umount -f "${CHROOTDIR}"/usr/local/portage/ >/dev/null &
eend $? "An error occured while attempting to unmount 32bits chroot directories"
}

55
init.d/gentoo64-stable Executable file
View File

@@ -0,0 +1,55 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
depend() {
need localmount
need bootmisc
}
CHROOTDIR=/mnt/root/root64-stable
start() {
ebegin "Mounting 64bits chroot dirs"
mount -o bind /dev "${CHROOTDIR}"/dev >/dev/null
mount -o bind /dev/pts "${CHROOTDIR}"/dev/pts >/dev/null &
mount -o bind /dev/shm "${CHROOTDIR}"/dev/shm >/dev/null &
mount -o bind /proc "${CHROOTDIR}"/proc >/dev/null
# mount -o bind /proc/bus/usb "${CHROOTDIR}"/proc/bus/usb >/dev/null &
mount -o bind /sys "${CHROOTDIR}"/sys >/dev/null &
mount -o bind /tmp "${CHROOTDIR}"/tmp >/dev/null &
mount -o bind /usr/portage "${CHROOTDIR}"/usr/portage/ >/dev/null &
mount -o bind /home/distfiles "${CHROOTDIR}"/distfiles >/dev/null &
mount -o bind /home/packages "${CHROOTDIR}"/packages >/dev/null &
mount -o bind /usr/local/portage "${CHROOTDIR}"/usr/local/portage/ >/dev/null &
mount -o bind /var/lib/layman "${CHROOTDIR}"/var/lib/layman >/dev/null &
eend $? "An error occured while attempting to mount 64bit chroot directories"
ebegin "Copying 64bits chroot files"
cp -pf /etc/exclude.depclean "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/resolv.conf "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/passwd "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/shadow "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/group "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/gshadow "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/hosts "${CHROOTDIR}"/etc > /dev/null &
cp -Ppf /etc/localtime "${CHROOTDIR}"/etc >/dev/null &
eend $? "An error occured while attempting to copy 64 bits chroot files."
}
stop() {
ebegin "Unmounting 64bits chroot dirs"
umount -f "${CHROOTDIR}"/dev/pts >/dev/null
umount -f "${CHROOTDIR}"/dev/shm >/dev/null
umount -f "${CHROOTDIR}"/dev >/dev/null &
# umount -f "${CHROOTDIR}"/proc/bus/usb >/dev/null
umount -f "${CHROOTDIR}"/proc >/dev/null &
umount -f "${CHROOTDIR}"/sys >/dev/null &
umount -f "${CHROOTDIR}"/tmp >/dev/null &
umount -f "${CHROOTDIR}"/usr/portage/ >/dev/null &
umount -f "${CHROOTDIR}"/var/lib/layman >/dev/null &
umount -f "${CHROOTDIR}"/distfiles >/dev/null &
umount -f "${CHROOTDIR}"/packages >/dev/null &
umount -f "${CHROOTDIR}"/usr/local/portage/ >/dev/null &
eend $? "An error occured while attempting to unmount 64bits chroot directories"
}

55
init.d/gentoo64-unstable Executable file
View File

@@ -0,0 +1,55 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
depend() {
need localmount
need bootmisc
}
CHROOTDIR=/mnt/root/root64-unstable
start() {
ebegin "Mounting 64bits chroot dirs"
mount -o bind /dev "${CHROOTDIR}"/dev >/dev/null
mount -o bind /dev/pts "${CHROOTDIR}"/dev/pts >/dev/null &
mount -o bind /dev/shm "${CHROOTDIR}"/dev/shm >/dev/null &
mount -o bind /proc "${CHROOTDIR}"/proc >/dev/null
# mount -o bind /proc/bus/usb "${CHROOTDIR}"/proc/bus/usb >/dev/null &
mount -o bind /sys "${CHROOTDIR}"/sys >/dev/null &
mount -o bind /tmp "${CHROOTDIR}"/tmp >/dev/null &
mount -o bind /usr/portage "${CHROOTDIR}"/usr/portage/ >/dev/null &
mount -o bind /home/distfiles "${CHROOTDIR}"/distfiles >/dev/null &
mount -o bind /home/packages "${CHROOTDIR}"/packages >/dev/null &
mount -o bind /usr/local/portage "${CHROOTDIR}"/usr/local/portage/ >/dev/null &
mount -o bind /var/lib/layman "${CHROOTDIR}"/var/lib/layman >/dev/null &
eend $? "An error occured while attempting to mount 64bit chroot directories"
ebegin "Copying 64bits chroot files"
cp -pf /etc/exclude.depclean "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/resolv.conf "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/passwd "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/shadow "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/group "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/gshadow "${CHROOTDIR}"/etc >/dev/null &
cp -pf /etc/hosts "${CHROOTDIR}"/etc > /dev/null &
cp -Ppf /etc/localtime "${CHROOTDIR}"/etc >/dev/null &
eend $? "An error occured while attempting to copy 64 bits chroot files."
}
stop() {
ebegin "Unmounting 64bits chroot dirs"
umount -f "${CHROOTDIR}"/dev/pts >/dev/null
umount -f "${CHROOTDIR}"/dev/shm >/dev/null
umount -f "${CHROOTDIR}"/dev >/dev/null &
# umount -f "${CHROOTDIR}"/proc/bus/usb >/dev/null
umount -f "${CHROOTDIR}"/proc >/dev/null &
umount -f "${CHROOTDIR}"/sys >/dev/null &
umount -f "${CHROOTDIR}"/tmp >/dev/null &
umount -f "${CHROOTDIR}"/usr/portage/ >/dev/null &
umount -f "${CHROOTDIR}"/var/lib/layman >/dev/null &
umount -f "${CHROOTDIR}"/distfiles >/dev/null &
umount -f "${CHROOTDIR}"/packages >/dev/null &
umount -f "${CHROOTDIR}"/usr/local/portage/ >/dev/null &
eend $? "An error occured while attempting to unmount 64bits chroot directories"
}

13
init.d/git-daemon Executable file
View File

@@ -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/dev-vcs/git/files/git-daemon-r1.initd,v 1.4 2014/03/03 19:21:29 polynomial-c Exp $
pidfile="/var/run/git-daemon.pid"
command="/usr/bin/git"
command_args="daemon ${GITDAEMON_OPTS}"
start_stop_daemon_args="-e HOME= -e XDG_CONFIG_HOME= -b -m -p ${pidfile} -u ${GIT_USER:-nobody}:${GIT_GROUP:-nobody}"
depend() {
use logger
}

29
init.d/gpm Executable file
View File

@@ -0,0 +1,29 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-libs/gpm/files/gpm.rc6-2,v 1.2 2012/10/28 11:35:56 vapier Exp $
#NB: Config is in /etc/conf.d/gpm
command=/usr/sbin/gpm
command_args="
-m ${MOUSEDEV}
-t ${MOUSE}
${RESPONSIVENESS:+ -r ${RESPONSIVENESS}}
${REPEAT_TYPE:+ -R${REPEAT_TYPE}}
${APPEND}
"
pidfile=/var/run/gpm.pid
depend() {
need localmount
use hotplug logger
}
start_pre() {
if [ -z "${MOUSEDEV}" ] || [ -z "${MOUSE}" ] ; then
eerror "You need to setup MOUSEDEV and MOUSE in /etc/conf.d/gpm first"
return 1
fi
}

23
init.d/hddtemp Executable file
View File

@@ -0,0 +1,23 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-admin/hddtemp/files/hddtemp-init,v 1.7 2012/10/24 18:45:04 aidecoe Exp $
depend() {
need localmount
}
start() {
ebegin "Starting hddtemp daemon"
/sbin/start-stop-daemon --start --quiet --exec ${HDDTEMP_EXEC} \
-- -d ${HDDTEMP_OPTS} ${HDDTEMP_DRIVES}
eend $?
}
stop() {
ebegin "Stopping hddtemp daemon"
start-stop-daemon --stop --quiet --exec ${HDDTEMP_EXEC}
eend $?
}

61
init.d/hdparm Executable file
View File

@@ -0,0 +1,61 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/hdparm/files/hdparm-init-8,v 1.3 2012/04/29 00:30:18 vapier Exp $
depend() {
before bootmisc
}
do_hdparm() {
local e=
eval e=\$${extra_args}
[ -z "${args}${all_args}${e}" ] && return 0
if [ -n "${args:=${all_args} ${e}}" ] ; then
local orgdevice=$(readlink -f "${device}")
if [ -b "${orgdevice}" ] ; then
ebegin "Running hdparm on ${device}"
hdparm ${args} "${device}" > /dev/null
eend $?
fi
fi
}
scan_nondevfs() {
# non-devfs compatible system
local device
for device in /dev/hd* /dev/sd* /dev/cdrom* ; do
[ -e "${device}" ] || continue
case "${device}" in
*[0-9]) continue ;;
/dev/hd*) extra_args="pata_all_args" ;;
/dev/sd*) extra_args="sata_all_args" ;;
*) extra_args="_no_xtra_args" ;;
esac
# check that the block device really exists by
# opening it for reading
local errmsg= status= nomed=1
errmsg=$(export LC_ALL=C ; : 2>&1 <"${device}")
status=$?
case ${errmsg} in
*": No medium found") nomed=0;;
esac
if [ -b "${device}" ] && [ "${status}" = "0" -o "${nomed}" = "0" ] ; then
local conf_var="${device##*/}_args"
eval args=\$${conf_var}
do_hdparm
fi
done
}
start() {
if get_bootparam "nohdparm" ; then
ewarn "Skipping hdparm init as requested in kernel cmdline"
return 0
fi
scan_nondevfs
}

26
init.d/hiawatha Executable file
View File

@@ -0,0 +1,26 @@
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
depend() {
need net
}
start() {
ebegin "Starting ${SVCNAME}"
start-stop-daemon \
--start \
--exec "/usr/sbin/hiawatha" \
--pidfile "/var/run/hiawatha.pid"
eend $?
}
stop() {
ebegin "Stopping ${SVCNAME}"
start-stop-daemon \
--stop \
--exec "/usr/sbin/hiawatha" \
--pidfile "/var/run/hiawatha.pid"
eend $?
}

120
init.d/hibernate-cleanup Executable file
View File

@@ -0,0 +1,120 @@
#!/sbin/runscript
# This script invalidates any stale swsusp and TuxOnIce images. It
# searches all swap partitions on your machine, as well as TuxOnIce's
# filewriter files (by way of the hibernate script telling it where to find
# it).
#
# It should be called on boot, after mounting filesystems, but before enabling
# swap or clearing out /var/run. Copy this into /etc/init.d/ (or the appropriate
# place on your system), then add a symlink at the appropriate point on boot.
# On a Debian system, you would do this:
# update-rc.d hibernate-cleanup.sh start 31 S .
#
# On other SysV-based systems, you would do something like:
# ln -s ../init.d/hibernate-cleanup.sh /etc/rcS.d/S31hibernate-cleanup.sh
#
### BEGIN INIT INFO
# Provides: hibernate-cleanup
# Default-Start: S
# Default-Stop:
# Required-Start:
# Required-Stop:
# Short-Description: invalidates stale swsusp and TuxOnIce image
# Description: This script invalidates any stale swsusp and TuxOnIce images. It
# searches all swap partitions on your machine, as well as
# TuxOnIce's filewriter files (by way of the hibernate
# script telling it where to find it).
### END INIT INFO
HIBERNATE_FILEWRITER_TRAIL="/var/run/TuxOnIce_filewriter_image_exists"
clear_swap() {
local where wason
where=$1
wason=
swapoff $where 2>/dev/null && wason=yes
mkswap $where > /dev/null || msg_status " (failed: $?)"
[ -n "$wason" ] && swapon $where
}
check_swap_sig() {
local where what type rest p c
while read where what type rest ; do
test "$type" = "swap" || continue
case "$(dd if=$where bs=1 count=6 skip=4086 2>/dev/null)" in
S1SUSP|S2SUSP|ULSUSP|pmdisk|[zZ]*)
msg_status "$where"
clear_swap $where
msg_status ", "
esac
done < /etc/fstab
}
check_filewriter_sig() {
local target
[ -f "$HIBERNATE_FILEWRITER_TRAIL" ] || return 0
read target < $HIBERNATE_FILEWRITER_TRAIL
[ -f "$target" ] || return
case "`dd \"if=$target\" bs=8 count=1 2>/dev/null`" in
HaveImag)
/bin/echo -ne "TuxOnIce\n\0\0" | dd "of=$target" bs=11 count=1 conv=notrunc 2>/dev/null
msg_status -n "$target, "
rm -f $HIBERNATE_FILEWRITER_TRAIL
esac
}
do_start() {
check_swap_sig
check_filewriter_sig
}
do_stop() {
:
}
do_reload() {
:
}
msg_status() {
einfon "$1"
}
msg() {
einfo "$1"
}
extra_started_commands="reload"
depend() {
after modules
before localmount
}
start() {
ebegin "Invalidating stale software suspend images"
do_start
eend $?
}
stop() {
do_stop
}
reload() {
do_reload
}

19
init.d/hostname Executable file
View File

@@ -0,0 +1,19 @@
#!/sbin/runscript
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
description="Sets the hostname of the machine."
depend() {
keyword -prefix -lxc
}
start()
{
# HOSTNAME variable used to be defined in caps in conf.d/hostname.
# It is also a magic variable in bash.
hostname=${hostname-${HOSTNAME-localhost}} # checkbashisms: false positive
ebegin "Setting hostname to $hostname"
hostname "$hostname"
eend $? "Failed to set the hostname"
}

25
init.d/hprofile Executable file
View File

@@ -0,0 +1,25 @@
#!/sbin/runscript
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
depend() {
before modules
}
start() {
profile=$(/usr/sbin/hpdet boot)
ebegin "Selecting hardware profile ${profile}"
/usr/sbin/hprofile boot
eend $?
}
stop() {
profile=$(/usr/sbin/hprofile -c boot)
ebegin "Stopping hardware profile ${profile}"
/usr/sbin/hprofile -s boot
eend $?
}
# vim:ts=4

23
init.d/hprunlevel Executable file
View File

@@ -0,0 +1,23 @@
#!/sbin/runscript
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
depend() {
after *
}
start() {
# Change runlevel if necessary
profile=$(/usr/sbin/hpdet boot)
runlevel=$(/usr/sbin/hprunlevel "${profile}")
if [ runlevel != "" ]
then
ebegin "Setting runlevel for hardware profile ${profile}"
/sbin/init "${runlevel}"
eend $?
fi
}
# vim:ts=4

13
init.d/hprunlevel-warning Executable file
View File

@@ -0,0 +1,13 @@
#!/sbin/runscript
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
start() {
profile=$(/usr/sbin/hpdet boot)
level=$(/usr/sbin/hprunlevel "${profile}")
ewarn "The current hardware profile, ${profile}, implies runlevel ${level}"
}
# vim:ts=4

20
init.d/hsqldb Executable file
View File

@@ -0,0 +1,20 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/hsqldb/files/hsqldb,v 1.2 2007/12/19 21:58:05 caster Exp $
depend() {
use net
}
start() {
ebegin "Starting HSQL Database"
hsqldb_enable=yes /var/lib/hsqldb/bin/hsqldb start
eend $?
}
stop() {
ebegin "Stopping HSQL Database"
hsqldb_enable=yes /var/lib/hsqldb/bin/hsqldb stop
eend $?
}

21
init.d/htpdate Executable file
View File

@@ -0,0 +1,21 @@
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/htpdate/files/htpdate.init-r1,v 1.1 2013/08/12 07:43:25 pinkbyte Exp $
description="Synchronizes local system with time offered by remote webservers over HTTP"
pidfile="/run/htpdate.pid"
command="/usr/sbin/htpdate"
command_args="${HTPDATE_OPTS} ${PROXY} ${SERVERS}"
depend() {
need net
use dns logger
}
start_pre() {
if [ -z "${SERVERS}" ] ; then
eerror "You need to set at least one http server to use in /etc/conf.d/htpdate"
return 1
fi
}

146
init.d/hwclock Executable file
View File

@@ -0,0 +1,146 @@
#!/sbin/runscript
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
extra_commands="save show"
description="Sets the local clock to UTC or Local Time."
description_save="Saves the current time in the BIOS."
description_show="Displays the current time in the BIOS."
: ${clock_adjfile:=${CLOCK_ADJFILE}}
: ${clock_args:=${CLOCK_OPTS}}
: ${clock_systohc:=${CLOCK_SYSTOHC}}
: ${clock:=${CLOCK:-UTC}}
if [ "$clock" = "UTC" ]; then
utc="UTC"
utc_cmd="--utc"
else
utc="Local Time"
utc_cmd="--localtime"
fi
depend()
{
provide clock
if yesno $clock_adjfile; then
use root
else
before *
fi
keyword -openvz -prefix -uml -vserver -xenu -lxc
}
setupopts()
{
case "$(uname -m)" in
s390*)
utc="s390"
;;
*)
if [ -e /proc/devices ] && \
grep -q " cobd$" /proc/devices
then
utc="coLinux"
fi
;;
esac
case "$utc" in
UTC|Local" "Time);;
*) unset utc_cmd;;
esac
}
# hwclock doesn't always return non zero on error
_hwclock()
{
local err="$(hwclock "$@" 2>&1 >/dev/null)"
[ -z "$err" ] && return 0
echo "${err}" >&2
return 1
}
start()
{
local retval=0 errstr=""
setupopts
if [ -z "$utc_cmd" ]; then
ewarn "Not setting clock for $utc system"
return 0
fi
ebegin "Setting system clock using the hardware clock [$utc]"
if [ -e /proc/modules ]; then
local rtc=
for rtc in /dev/rtc /dev/rtc[0-9]*; do
[ -e "$rtc" ] && break
done
if [ ! -e "${rtc}" ]; then
modprobe -q rtc-cmos || modprobe -q rtc || modprobe -q genrtc
fi
fi
if [ -e /etc/adjtime ] && yesno $clock_adjfile; then
_hwclock --adjust $utc_cmd
: $(( retval += $? ))
fi
# If setting UTC, don't bother to run hwclock when first booting
# as that's the default
if [ "$PREVLEVEL" != N -o \
"$utc_cmd" != --utc -o \
-n "$clock_args" ];
then
if yesno ${clock_hctosys:-YES}; then
_hwclock --hctosys $utc_cmd $clock_args
else
_hwclock --systz $utc_cmd $clock_args
fi
: $(( retval += $? ))
fi
eend $retval "Failed to set the system clock"
return 0
}
stop()
{
# Don't tweak the hardware clock on LiveCD halt.
[ -n "$CDBOOT" ] && return 0
yesno ${clock_systohc:-YES} || return 0
local retval=0 errstr=""
setupopts
[ -z "$utc_cmd" ] && return 0
ebegin "Setting hardware clock using the system clock" "[$utc]"
if ! yesno $clock_adjfile; then
# Some implementations don't handle adjustments
if LC_ALL=C hwclock --help 2>&1 | grep -q "\-\-noadjfile"; then
utc_cmd="$utc_cmd --noadjfile"
fi
fi
_hwclock --systohc $utc_cmd $clock_args
retval=$?
eend $retval "Failed to sync clocks"
}
save()
{
clock_systohc=yes
stop
}
show()
{
setupopts
hwclock --show "$utc_cmd" $clock_args
}

130
init.d/ip6tables Executable file
View File

@@ -0,0 +1,130 @@
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-firewall/iptables/files/iptables-1.4.13-r1.init,v 1.3 2013/04/27 17:29:09 vapier Exp $
extra_commands="check save panic"
extra_started_commands="reload"
iptables_name=${SVCNAME}
case ${iptables_name} in
iptables|ip6tables) ;;
*) iptables_name="iptables" ;;
esac
iptables_bin="/sbin/${iptables_name}"
case ${iptables_name} in
iptables) iptables_proc="/proc/net/ip_tables_names"
iptables_save=${IPTABLES_SAVE};;
ip6tables) iptables_proc="/proc/net/ip6_tables_names"
iptables_save=${IP6TABLES_SAVE};;
esac
depend() {
need localmount #434774
before net
}
set_table_policy() {
local chains table=$1 policy=$2
case ${table} in
nat) chains="PREROUTING POSTROUTING OUTPUT";;
mangle) chains="PREROUTING INPUT FORWARD OUTPUT POSTROUTING";;
filter) chains="INPUT FORWARD OUTPUT";;
*) chains="";;
esac
local chain
for chain in ${chains} ; do
${iptables_bin} -t ${table} -P ${chain} ${policy}
done
}
checkkernel() {
if [ ! -e ${iptables_proc} ] ; then
eerror "Your kernel lacks ${iptables_name} support, please load"
eerror "appropriate modules and try again."
return 1
fi
return 0
}
checkconfig() {
if [ ! -f ${iptables_save} ] ; then
eerror "Not starting ${iptables_name}. First create some rules then run:"
eerror "/etc/init.d/${iptables_name} save"
return 1
fi
return 0
}
start() {
checkconfig || return 1
ebegin "Loading ${iptables_name} state and starting firewall"
${iptables_bin}-restore ${SAVE_RESTORE_OPTIONS} < "${iptables_save}"
eend $?
}
stop() {
if [ "${SAVE_ON_STOP}" = "yes" ] ; then
save || return 1
fi
checkkernel || return 1
ebegin "Stopping firewall"
local a
for a in $(cat ${iptables_proc}) ; do
set_table_policy $a ACCEPT
${iptables_bin} -F -t $a
${iptables_bin} -X -t $a
done
eend $?
}
reload() {
checkkernel || return 1
checkrules || return 1
ebegin "Flushing firewall"
local a
for a in $(cat ${iptables_proc}) ; do
${iptables_bin} -F -t $a
${iptables_bin} -X -t $a
done
eend $?
start
}
checkrules() {
ebegin "Checking rules"
${iptables_bin}-restore --test ${SAVE_RESTORE_OPTIONS} < "${iptables_save}"
eend $?
}
check() {
# Short name for users of init.d script.
checkrules
}
save() {
ebegin "Saving ${iptables_name} state"
checkpath -q -d "$(dirname "${iptables_save}")"
checkpath -q -m 0600 -f "${iptables_save}"
${iptables_bin}-save ${SAVE_RESTORE_OPTIONS} > "${iptables_save}"
eend $?
}
panic() {
checkkernel || return 1
if service_started ${iptables_name}; then
rc-service ${iptables_name} stop
fi
local a
ebegin "Dropping all packets"
for a in $(cat ${iptables_proc}) ; do
${iptables_bin} -F -t $a
${iptables_bin} -X -t $a
set_table_policy $a DROP
done
eend $?
}

130
init.d/iptables Executable file
View File

@@ -0,0 +1,130 @@
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-firewall/iptables/files/iptables-1.4.13-r1.init,v 1.3 2013/04/27 17:29:09 vapier Exp $
extra_commands="check save panic"
extra_started_commands="reload"
iptables_name=${SVCNAME}
case ${iptables_name} in
iptables|ip6tables) ;;
*) iptables_name="iptables" ;;
esac
iptables_bin="/sbin/${iptables_name}"
case ${iptables_name} in
iptables) iptables_proc="/proc/net/ip_tables_names"
iptables_save=${IPTABLES_SAVE};;
ip6tables) iptables_proc="/proc/net/ip6_tables_names"
iptables_save=${IP6TABLES_SAVE};;
esac
depend() {
need localmount #434774
before net
}
set_table_policy() {
local chains table=$1 policy=$2
case ${table} in
nat) chains="PREROUTING POSTROUTING OUTPUT";;
mangle) chains="PREROUTING INPUT FORWARD OUTPUT POSTROUTING";;
filter) chains="INPUT FORWARD OUTPUT";;
*) chains="";;
esac
local chain
for chain in ${chains} ; do
${iptables_bin} -t ${table} -P ${chain} ${policy}
done
}
checkkernel() {
if [ ! -e ${iptables_proc} ] ; then
eerror "Your kernel lacks ${iptables_name} support, please load"
eerror "appropriate modules and try again."
return 1
fi
return 0
}
checkconfig() {
if [ ! -f ${iptables_save} ] ; then
eerror "Not starting ${iptables_name}. First create some rules then run:"
eerror "/etc/init.d/${iptables_name} save"
return 1
fi
return 0
}
start() {
checkconfig || return 1
ebegin "Loading ${iptables_name} state and starting firewall"
${iptables_bin}-restore ${SAVE_RESTORE_OPTIONS} < "${iptables_save}"
eend $?
}
stop() {
if [ "${SAVE_ON_STOP}" = "yes" ] ; then
save || return 1
fi
checkkernel || return 1
ebegin "Stopping firewall"
local a
for a in $(cat ${iptables_proc}) ; do
set_table_policy $a ACCEPT
${iptables_bin} -F -t $a
${iptables_bin} -X -t $a
done
eend $?
}
reload() {
checkkernel || return 1
checkrules || return 1
ebegin "Flushing firewall"
local a
for a in $(cat ${iptables_proc}) ; do
${iptables_bin} -F -t $a
${iptables_bin} -X -t $a
done
eend $?
start
}
checkrules() {
ebegin "Checking rules"
${iptables_bin}-restore --test ${SAVE_RESTORE_OPTIONS} < "${iptables_save}"
eend $?
}
check() {
# Short name for users of init.d script.
checkrules
}
save() {
ebegin "Saving ${iptables_name} state"
checkpath -q -d "$(dirname "${iptables_save}")"
checkpath -q -m 0600 -f "${iptables_save}"
${iptables_bin}-save ${SAVE_RESTORE_OPTIONS} > "${iptables_save}"
eend $?
}
panic() {
checkkernel || return 1
if service_started ${iptables_name}; then
rc-service ${iptables_name} stop
fi
local a
ebegin "Dropping all packets"
for a in $(cat ${iptables_proc}) ; do
${iptables_bin} -F -t $a
${iptables_bin} -X -t $a
set_table_policy $a DROP
done
eend $?
}

165
init.d/kexec Executable file
View File

@@ -0,0 +1,165 @@
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/files/kexec.init-2.0.4-r2,v 1.1 2013/09/21 11:35:53 jlec Exp $
depend() {
need localmount
}
image_path() {
local x= kver=$(uname -r) karch=$(uname -m)
BOOTPART="${BOOTPART:-/boot}"
KNAME="${KNAME:-bzImage}"
if [ -e "${KNAME}" ]; then
echo "${KNAME}"
return 0
fi
for x in "${KNAME#${BOOTPART}}" vmlinuz \
bzImage-${kver} vmlinuz-${kver} \
kernel-genkernel-${karch}-${kver} \
kernel-${kver} kernel-${karch}; do
if [ -e "${BOOTPART}/${x}" ]; then
echo "${BOOTPART}/${x}"
return 0
fi
done
return 1
}
initrd_path() {
local x= kver=$(uname -r) karch=$(uname -m)
BOOTPART="${BOOTPART:-/boot}"
INITRD="${INITRD:-initrd}"
if [ -e "${INITRD}" ]; then
echo "${INITRD}"
return 0
fi
for x in "${INITRD#${BOOTPART}}" \
initrd.img-${kver} initrd-${kver}.img \
initrd-${kver} initramfs-${kver}.img \
initramfs-genkernel-${karch}-${kver} ; do
if [ -e "${BOOTPART}/${x}" ]; then
echo "${BOOTPART}/${x}"
return 0
fi
done
return 1
}
mount_boot(){
local ret
[ -n "${DONT_MOUNT_BOOT}" ] && return 1
grep -q " ${BOOTPART:-/boot} " /proc/mounts && return 1
BOOTPART="${BOOTPART:-/boot}"
ebegin "Mounting ${BOOTPART}"
mount "${BOOTPART}"; ret=$?
eend ${ret}
return ${ret}
}
load_image() {
local ret
if [ "${KNAME}" = "-" ]; then
ebegin "Disabling kexec"
kexec -u; ret=$?
eend ${ret}
return ${ret}
fi
BOOTPART="${BOOTPART:-/boot}"
local img= initrd="$(initrd_path)" mounted=false initrdopt=
if ! img="$(image_path)"; then
if mount_boot; then
if img="$(image_path)"; then
mounted=true
initrd="$(initrd_path)"
else
eerror "No kernel image found in ${BOOTPART}!"
umount "${BOOTPART}"
return 1
fi
else
eerror "No kernel image found in ${BOOTPART}!"
return 1
fi
fi
if [ -n "${INITRD}" ] && \
! [ "${BOOTPART}/${INITRD#${BOOTPART}}" = "${initrd}" ]; then
eerror "Requested initrd: ${INITRD#${BOOTPART}}"
eerror "could not be found"
return 1
fi
[ -n "${ROOTPART}" ] || \
ROOTPART="$(readlink -f "$(sed -n '/^\/[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /proc/mounts)")"
[ -n "${KPARAM}" ] || KEXEC_OPT_ARGS="${KEXEC_OPT_ARGS} --reuse-cmdline"
[ -n "${initrd}" ] && [ -e "${initrd}" ] && initrdopt="--initrd=${initrd}"
local msg=
[ -n "${initrd}" ] && \
msg="with ${initrd}"
einfo "Using kernel image ${img} ${msg} for kexec"
ebegin "Setting kexec with ${KEXEC_OPT_ARGS} -l ${img} root=${ROOTPART} ${KPARAM} ${initrdopt}"
kexec ${KEXEC_OPT_ARGS} -l "${img}" --append="root=${ROOTPART} ${KPARAM}" ${initrdopt}
local res=$?
${mounted} && umount "${BOOTPART}"
eend ${res}
return ${res}
}
start() {
if [ "${LOAD_DURING_SHUTDOWN:-yes}" = "yes" ]; then
local ret=0
BOOTPART="${BOOTPART:-/boot}"
if mount_boot; then
mounted=true
fi
if ! image_path > /dev/null; then
ewarn "Cannot find kernel image!"
ewarn "Please make sure a valid kernel image is present before reboot."
return 0
fi
if [ -n "${mounted}" ]; then
ebegin "Unmounting ${BOOTPART}"
umount "${BOOTPART}"; ret=$?
eend ${ret}
fi
return ${ret}
else
ebegin "Configuring kexec"
load_image
eend $?
fi
}
stop() {
[ "${LOAD_DURING_SHUTDOWN:-yes}" != "yes" ] && return 0
if ! yesno $RC_REBOOT; then
einfo "Not rebooting, so disabling"
kexec -u
return 0
fi
if [ -f /nokexec ]; then
einfo "Not using kexec during reboot"
rm -f /nokexec
kexec -u
return 0
fi
ebegin "Configuring kexec"
load_image
eend $?
}

Some files were not shown because too many files have changed in this diff Show More