From a12dbdc6c93a7d63591610378e3e570b7c7d2143 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Sun, 2 Mar 2008 21:13:21 +0000 Subject: Don't check for root in prefix. --- init.d.BSD/hostid | 78 ----------------------- init.d.BSD/hostid.in | 78 +++++++++++++++++++++++ init.d.BSD/moused | 62 ------------------ init.d.BSD/moused.in | 62 ++++++++++++++++++ init.d.BSD/newsyslog | 17 ----- init.d.BSD/newsyslog.in | 17 +++++ init.d.BSD/pf | 59 ------------------ init.d.BSD/pf.in | 59 ++++++++++++++++++ init.d.BSD/rarpd | 28 --------- init.d.BSD/rarpd.in | 28 +++++++++ init.d.BSD/rc-enabled | 52 ---------------- init.d.BSD/rc-enabled.in | 53 ++++++++++++++++ init.d.BSD/rpcbind | 21 ------- init.d.BSD/rpcbind.in | 21 +++++++ init.d.BSD/savecore | 36 ----------- init.d.BSD/savecore.in | 36 +++++++++++ init.d.BSD/swap-blk | 23 ------- init.d.BSD/swap-blk.in | 23 +++++++ init.d.BSD/sysctl | 25 -------- init.d.BSD/sysctl.in | 26 ++++++++ init.d.BSD/syslogd | 19 ------ init.d.BSD/syslogd.in | 19 ++++++ init.d.FreeBSD/clock | 61 ------------------ init.d.FreeBSD/clock.in | 61 ++++++++++++++++++ init.d.FreeBSD/devd | 22 ------- init.d.FreeBSD/devd.in | 22 +++++++ init.d.FreeBSD/dumpon | 25 -------- init.d.FreeBSD/dumpon.in | 25 ++++++++ init.d.FreeBSD/ipfw | 149 -------------------------------------------- init.d.FreeBSD/ipfw.in | 149 ++++++++++++++++++++++++++++++++++++++++++++ init.d.FreeBSD/mixer | 47 -------------- init.d.FreeBSD/mixer.in | 47 ++++++++++++++ init.d.FreeBSD/nscd | 22 ------- init.d.FreeBSD/nscd.in | 22 +++++++ init.d.FreeBSD/powerd | 35 ----------- init.d.FreeBSD/powerd.in | 35 +++++++++++ init.d.FreeBSD/syscons | 83 ------------------------ init.d.FreeBSD/syscons.in | 83 ++++++++++++++++++++++++ init.d.Linux/clock | 136 ---------------------------------------- init.d.Linux/clock.in | 136 ++++++++++++++++++++++++++++++++++++++++ init.d.Linux/consolefont | 78 ----------------------- init.d.Linux/consolefont.in | 78 +++++++++++++++++++++++ init.d.Linux/keymaps | 69 -------------------- init.d.Linux/keymaps.in | 69 ++++++++++++++++++++ init.d.Linux/modules | 50 --------------- init.d.Linux/modules.in | 50 +++++++++++++++ init.d.Linux/mtab | 29 --------- init.d.Linux/mtab.in | 30 +++++++++ init.d.Linux/numlock | 41 ------------ init.d.Linux/numlock.in | 42 +++++++++++++ init.d.Linux/procfs | 88 -------------------------- init.d.Linux/procfs.in | 89 ++++++++++++++++++++++++++ init.d.Linux/sysctl | 18 ------ init.d.Linux/sysctl.in | 18 ++++++ init.d.NetBSD/ttys | 17 ----- init.d.NetBSD/ttys.in | 23 +++++++ init.d.NetBSD/wscons | 99 ----------------------------- init.d.NetBSD/wscons.in | 100 +++++++++++++++++++++++++++++ init.d/bootmisc | 131 -------------------------------------- init.d/bootmisc.in | 132 +++++++++++++++++++++++++++++++++++++++ init.d/fsck | 76 ---------------------- init.d/fsck.in | 76 ++++++++++++++++++++++ init.d/hostname | 13 ---- init.d/hostname.in | 17 +++++ init.d/local | 43 ------------- init.d/local.in | 43 +++++++++++++ init.d/localmount | 87 -------------------------- init.d/localmount.in | 87 ++++++++++++++++++++++++++ init.d/netmount | 96 ---------------------------- init.d/netmount.in | 96 ++++++++++++++++++++++++++++ init.d/root | 26 -------- init.d/root.in | 26 ++++++++ init.d/swap | 23 ------- init.d/swap.in | 23 +++++++ init.d/urandom | 46 -------------- init.d/urandom.in | 46 ++++++++++++++ src/rc/rc.c | 2 + src/rc/runscript.c | 2 + 78 files changed, 2051 insertions(+), 2030 deletions(-) delete mode 100644 init.d.BSD/hostid create mode 100644 init.d.BSD/hostid.in delete mode 100644 init.d.BSD/moused create mode 100644 init.d.BSD/moused.in delete mode 100644 init.d.BSD/newsyslog create mode 100644 init.d.BSD/newsyslog.in delete mode 100644 init.d.BSD/pf create mode 100644 init.d.BSD/pf.in delete mode 100644 init.d.BSD/rarpd create mode 100644 init.d.BSD/rarpd.in delete mode 100644 init.d.BSD/rc-enabled create mode 100644 init.d.BSD/rc-enabled.in delete mode 100644 init.d.BSD/rpcbind create mode 100644 init.d.BSD/rpcbind.in delete mode 100755 init.d.BSD/savecore create mode 100644 init.d.BSD/savecore.in delete mode 100644 init.d.BSD/swap-blk create mode 100644 init.d.BSD/swap-blk.in delete mode 100644 init.d.BSD/sysctl create mode 100644 init.d.BSD/sysctl.in delete mode 100644 init.d.BSD/syslogd create mode 100644 init.d.BSD/syslogd.in delete mode 100644 init.d.FreeBSD/clock create mode 100644 init.d.FreeBSD/clock.in delete mode 100644 init.d.FreeBSD/devd create mode 100644 init.d.FreeBSD/devd.in delete mode 100644 init.d.FreeBSD/dumpon create mode 100644 init.d.FreeBSD/dumpon.in delete mode 100644 init.d.FreeBSD/ipfw create mode 100644 init.d.FreeBSD/ipfw.in delete mode 100644 init.d.FreeBSD/mixer create mode 100644 init.d.FreeBSD/mixer.in delete mode 100644 init.d.FreeBSD/nscd create mode 100644 init.d.FreeBSD/nscd.in delete mode 100644 init.d.FreeBSD/powerd create mode 100644 init.d.FreeBSD/powerd.in delete mode 100644 init.d.FreeBSD/syscons create mode 100644 init.d.FreeBSD/syscons.in delete mode 100755 init.d.Linux/clock create mode 100644 init.d.Linux/clock.in delete mode 100755 init.d.Linux/consolefont create mode 100644 init.d.Linux/consolefont.in delete mode 100755 init.d.Linux/keymaps create mode 100644 init.d.Linux/keymaps.in delete mode 100755 init.d.Linux/modules create mode 100644 init.d.Linux/modules.in delete mode 100644 init.d.Linux/mtab create mode 100644 init.d.Linux/mtab.in delete mode 100755 init.d.Linux/numlock create mode 100644 init.d.Linux/numlock.in delete mode 100644 init.d.Linux/procfs create mode 100644 init.d.Linux/procfs.in delete mode 100644 init.d.Linux/sysctl create mode 100644 init.d.Linux/sysctl.in delete mode 100644 init.d.NetBSD/ttys create mode 100644 init.d.NetBSD/ttys.in delete mode 100644 init.d.NetBSD/wscons create mode 100644 init.d.NetBSD/wscons.in delete mode 100755 init.d/bootmisc create mode 100644 init.d/bootmisc.in delete mode 100644 init.d/fsck create mode 100644 init.d/fsck.in delete mode 100755 init.d/hostname create mode 100644 init.d/hostname.in delete mode 100755 init.d/local create mode 100644 init.d/local.in delete mode 100755 init.d/localmount create mode 100644 init.d/localmount.in delete mode 100755 init.d/netmount create mode 100644 init.d/netmount.in delete mode 100644 init.d/root create mode 100644 init.d/root.in delete mode 100644 init.d/swap create mode 100644 init.d/swap.in delete mode 100755 init.d/urandom create mode 100644 init.d/urandom.in diff --git a/init.d.BSD/hostid b/init.d.BSD/hostid deleted file mode 100644 index 3eb4c4f..0000000 --- a/init.d.BSD/hostid +++ /dev/null @@ -1,78 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -extra_commands="reset" -hostid_file=${hostid_file:-/etc/hostid} - -depend() -{ - need root - before devd net - keyword nojail -} - -_set() -{ - local id=0 - - if [ -n "$1" ]; then - id=$(echo "$1" | md5) - id="0x${id%????????????????????????}" - fi - ebegin "Setting Host ID: ${id}" - sysctl -w kern.hostid="${id}" >/dev/null - eend $? || return 1 - - if sysctl -n kern.hostuuid >/dev/null 2>&1; then - [ -n "$1" ] && id=$1 - ebegin "Setting Host UUID: ${id}" - sysctl kern.hostuuid="${id}" >/dev/null - eend $? || return 1 - fi - -} - -# First we check to see if there is a system UUID -# If so then we use that and erase the hostid file, -# otherwise we generate a random UUID. -reset() -{ - local uuid=$(kenv smbios.system.uuid 2>/dev/null) - local x="[0-9a-f]" - local y="${x}${x}${x}${x}" - case "${uuid}" in - ${y}${y}-${y}-${y}-${y}-${y}${y}${y});; - *) uuid=;; - esac - - if [ -n "${uuid}" ]; then - rm -f "${hostid_file}" - else - uuid=$(uuidgen) - if [ -z "${uuid}" ]; then - eerror "Unable to generate a UUID" - return 1 - fi - if ! echo "${uuid}" > "${hostid_file}"; then - eerror "Failed to store UUID in \`${hostid_file}'" - return 1 - fi - fi - - _set "${uuid}" -} - -start() -{ - if [ -r "${hostid_file}" ]; then - _set $(cat "${hostid_file}") - else - reset - fi -} - -stop() -{ - _set -} diff --git a/init.d.BSD/hostid.in b/init.d.BSD/hostid.in new file mode 100644 index 0000000..7d093a4 --- /dev/null +++ b/init.d.BSD/hostid.in @@ -0,0 +1,78 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +extra_commands="reset" +hostid_file=${hostid_file:-/etc/hostid} + +depend() +{ + need root + before devd net + keyword nojail noprefix +} + +_set() +{ + local id=0 + + if [ -n "$1" ]; then + id=$(echo "$1" | md5) + id="0x${id%????????????????????????}" + fi + ebegin "Setting Host ID: ${id}" + sysctl -w kern.hostid="${id}" >/dev/null + eend $? || return 1 + + if sysctl -n kern.hostuuid >/dev/null 2>&1; then + [ -n "$1" ] && id=$1 + ebegin "Setting Host UUID: ${id}" + sysctl kern.hostuuid="${id}" >/dev/null + eend $? || return 1 + fi + +} + +# First we check to see if there is a system UUID +# If so then we use that and erase the hostid file, +# otherwise we generate a random UUID. +reset() +{ + local uuid=$(kenv smbios.system.uuid 2>/dev/null) + local x="[0-9a-f]" + local y="${x}${x}${x}${x}" + case "${uuid}" in + ${y}${y}-${y}-${y}-${y}-${y}${y}${y});; + *) uuid=;; + esac + + if [ -n "${uuid}" ]; then + rm -f "${hostid_file}" + else + uuid=$(uuidgen) + if [ -z "${uuid}" ]; then + eerror "Unable to generate a UUID" + return 1 + fi + if ! echo "${uuid}" > "${hostid_file}"; then + eerror "Failed to store UUID in \`${hostid_file}'" + return 1 + fi + fi + + _set "${uuid}" +} + +start() +{ + if [ -r "${hostid_file}" ]; then + _set $(cat "${hostid_file}") + else + reset + fi +} + +stop() +{ + _set +} diff --git a/init.d.BSD/moused b/init.d.BSD/moused deleted file mode 100644 index 94c6812..0000000 --- a/init.d.BSD/moused +++ /dev/null @@ -1,62 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -mouse=${SVCNAME##*.} -if [ -n "${name}" -a "${mouse}" != "moused" ]; then - moused_device=/dev/"${mouse}" - pidfile=/var/run/moused-"${mouse}".pid -else - pidfile=/var/run/moused.pid -fi -name="Console Mouse Daemon" -[ -n "${moused_device}" ] && name="${name} (${moused_device})" - -depend() -{ - need localmount - after bootmisc - keyword nojail -} - -start() -{ - ebegin "Starting ${name}" - - if [ -z "${moused_device}" ]; then - local dev= - for dev in /dev/psm[0-9]* /dev/ums[0-9]*; do - [ -c "${dev}" ] || continue - [ -e /var/run/moused-"${dev##*/}".pid ] && continue - moused_device=${dev} - eindent - einfo "Using mouse on ${moused_device}" - eoutdent - break - done - fi - - if [ -z "${moused_device}" ]; then - eend 1 "No mouse device found" - return 1 - fi - - local args= - eval args=\$moused_args_${moused_device##*/} - [ -z "${args}" ] && args=${moused_args} - - start-stop-daemon --start --exec /usr/sbin/moused \ - --pidfile "${pidfile}" \ - -- ${args} -p "${moused_device}" -I "${pidfile}" - local retval=$? - - if [ ${retval} = 0 ]; then - local ttyv= - for ttyv in /dev/ttyv*; do - vidcontrol < "${ttyv}" -m on - : $((retval+= $?)) - done - fi - - eend ${retval} "Failed to start moused" -} diff --git a/init.d.BSD/moused.in b/init.d.BSD/moused.in new file mode 100644 index 0000000..9e8c20f --- /dev/null +++ b/init.d.BSD/moused.in @@ -0,0 +1,62 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +mouse=${SVCNAME##*.} +if [ -n "${name}" -a "${mouse}" != "moused" ]; then + moused_device=/dev/"${mouse}" + pidfile=/var/run/moused-"${mouse}".pid +else + pidfile=/var/run/moused.pid +fi +name="Console Mouse Daemon" +[ -n "${moused_device}" ] && name="${name} (${moused_device})" + +depend() +{ + need localmount + after bootmisc + keyword nojail noprefix +} + +start() +{ + ebegin "Starting ${name}" + + if [ -z "${moused_device}" ]; then + local dev= + for dev in /dev/psm[0-9]* /dev/ums[0-9]*; do + [ -c "${dev}" ] || continue + [ -e /var/run/moused-"${dev##*/}".pid ] && continue + moused_device=${dev} + eindent + einfo "Using mouse on ${moused_device}" + eoutdent + break + done + fi + + if [ -z "${moused_device}" ]; then + eend 1 "No mouse device found" + return 1 + fi + + local args= + eval args=\$moused_args_${moused_device##*/} + [ -z "${args}" ] && args=${moused_args} + + start-stop-daemon --start --exec /usr/sbin/moused \ + --pidfile "${pidfile}" \ + -- ${args} -p "${moused_device}" -I "${pidfile}" + local retval=$? + + if [ ${retval} = 0 ]; then + local ttyv= + for ttyv in /dev/ttyv*; do + vidcontrol < "${ttyv}" -m on + : $((retval+= $?)) + done + fi + + eend ${retval} "Failed to start moused" +} diff --git a/init.d.BSD/newsyslog b/init.d.BSD/newsyslog deleted file mode 100644 index 4f7ade8..0000000 --- a/init.d.BSD/newsyslog +++ /dev/null @@ -1,17 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -required_files="/etc/newsyslog.conf" - -depend() -{ - need localmount -} - -start() -{ - ebegin "Creating and/or trimming log files" - newsyslog -s ${newsyslog_args} - eend $? -} diff --git a/init.d.BSD/newsyslog.in b/init.d.BSD/newsyslog.in new file mode 100644 index 0000000..4f7ade8 --- /dev/null +++ b/init.d.BSD/newsyslog.in @@ -0,0 +1,17 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +required_files="/etc/newsyslog.conf" + +depend() +{ + need localmount +} + +start() +{ + ebegin "Creating and/or trimming log files" + newsyslog -s ${newsyslog_args} + eend $? +} diff --git a/init.d.BSD/pf b/init.d.BSD/pf deleted file mode 100644 index 0b6208e..0000000 --- a/init.d.BSD/pf +++ /dev/null @@ -1,59 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -name="Packet Filter" -pf_conf=${pf_conf:-${pf_rules:-/etc/pf.conf}} -required_files=${pf_conf} - -extra_commands="checkconfig showstatus" -extra_started_commands="reload" - -depend() { - need localmount - keyword nojail -} - -start() -{ - ebegin "Starting ${name}" - if type kldload >/dev/null 2>&1; then - kldload pf 2>/dev/null - fi - pfctl -q -F all - pfctl -q -f "${pf_conf}" ${pf_args} - pfctl -q -e - eend $? -} - -stop() -{ - ebegin "Stopping ${name}" - pfctl -q -d - eend $? -} - -checkconfig() -{ - ebegin "Checking ${name} configuration" - pfctl -n -f "${pf_conf}" - eend $? -} - -reload() -{ - ebegin "Reloading ${name} rules." - pfctl -q -n -f "${pf_conf}" && \ - { - # Flush everything but existing state entries that way when - # rules are read in, it doesn't break established connections. - pfctl -q -Fnat -Fqueue -Frules -FSources -Finfo -FTables -Fosfp - pfctl -q -f "${pf_conf}" ${pf_args} - } - eend $? -} - -showstatus() -{ - pfctl -s info -} diff --git a/init.d.BSD/pf.in b/init.d.BSD/pf.in new file mode 100644 index 0000000..daca82a --- /dev/null +++ b/init.d.BSD/pf.in @@ -0,0 +1,59 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +name="Packet Filter" +pf_conf=${pf_conf:-${pf_rules:-/etc/pf.conf}} +required_files=${pf_conf} + +extra_commands="checkconfig showstatus" +extra_started_commands="reload" + +depend() { + need localmount + keyword nojail noprefix +} + +start() +{ + ebegin "Starting ${name}" + if type kldload >/dev/null 2>&1; then + kldload pf 2>/dev/null + fi + pfctl -q -F all + pfctl -q -f "${pf_conf}" ${pf_args} + pfctl -q -e + eend $? +} + +stop() +{ + ebegin "Stopping ${name}" + pfctl -q -d + eend $? +} + +checkconfig() +{ + ebegin "Checking ${name} configuration" + pfctl -n -f "${pf_conf}" + eend $? +} + +reload() +{ + ebegin "Reloading ${name} rules." + pfctl -q -n -f "${pf_conf}" && \ + { + # Flush everything but existing state entries that way when + # rules are read in, it doesn't break established connections. + pfctl -q -Fnat -Fqueue -Frules -FSources -Finfo -FTables -Fosfp + pfctl -q -f "${pf_conf}" ${pf_args} + } + eend $? +} + +showstatus() +{ + pfctl -s info +} diff --git a/init.d.BSD/rarpd b/init.d.BSD/rarpd deleted file mode 100644 index 837e020..0000000 --- a/init.d.BSD/rarpd +++ /dev/null @@ -1,28 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -command=/usr/sbin/rarpd -command_args="-f ${rarpd_args}" -pidfile=/var/run/rarpd.pid -name="Reverse ARP Daemon" -required_files="/etc/ethers" - -if [ -z "${rarpd_interface}" ]; then - command_args="${command_args} -a" -else - command_args="${command_args} ${rarpd_interface}" -fi -command_background="YES" - -depend() -{ - need localmount - after bootmisc - - if [ -z "${rarpd_interface}" ]; then - need net - else - net net."${rarpd_interface}" - fi -} diff --git a/init.d.BSD/rarpd.in b/init.d.BSD/rarpd.in new file mode 100644 index 0000000..837e020 --- /dev/null +++ b/init.d.BSD/rarpd.in @@ -0,0 +1,28 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +command=/usr/sbin/rarpd +command_args="-f ${rarpd_args}" +pidfile=/var/run/rarpd.pid +name="Reverse ARP Daemon" +required_files="/etc/ethers" + +if [ -z "${rarpd_interface}" ]; then + command_args="${command_args} -a" +else + command_args="${command_args} ${rarpd_interface}" +fi +command_background="YES" + +depend() +{ + need localmount + after bootmisc + + if [ -z "${rarpd_interface}" ]; then + need net + else + net net."${rarpd_interface}" + fi +} diff --git a/init.d.BSD/rc-enabled b/init.d.BSD/rc-enabled deleted file mode 100644 index f30dd28..0000000 --- a/init.d.BSD/rc-enabled +++ /dev/null @@ -1,52 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -depend() -{ - need localmount net - after * - before local -} - -start() -{ - ebegin "Starting local rc services" - local svc= enabled= retval=0 service= - for svc in $(rcorder /etc/rc.d/* /usr/local/etc/rc.d/* 2>/dev/null); do - [ -x "$svc" ] || continue - service=${svc##*/} - - # Skip these services - for s in cleartmp moused; do - [ "${s}" = "${service}" ] && continue 2 - done - - # If we have an init script for this service, continue - [ -x /etc/init.d/"${service}" ] && continue - [ -x /usr/local/etc/init.d/"${service}" ] && continue - - # Ensure that the users rc.conf will start us - ignore the defaults - eval enabled=\$${svc##*/}_enable - yesno ${enabled} || yesno ${svc##*/} || continue - - # Good to go! - "$svc" start && started="${started} ${svc}" - : $((retval += $?)) - done - service_set_value started "${started}" - eend $retval "Some local rc services failed to start" - return 0 -} - -stop() -{ - ebegin "Stopping local rc services" - local svc= retval=0 - for svc in $(rcorder $(service_get_value started) 2>/dev/null | sort -r); do - "${svc}" stop - : $((retval += $?)) - done - eend $retval "Some local rc services failed to stop" - return 0 -} diff --git a/init.d.BSD/rc-enabled.in b/init.d.BSD/rc-enabled.in new file mode 100644 index 0000000..77366f2 --- /dev/null +++ b/init.d.BSD/rc-enabled.in @@ -0,0 +1,53 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +depend() +{ + need localmount net + after * + before local + keyword noprefix +} + +start() +{ + ebegin "Starting local rc services" + local svc= enabled= retval=0 service= + for svc in $(rcorder /etc/rc.d/* /usr/local/etc/rc.d/* 2>/dev/null); do + [ -x "$svc" ] || continue + service=${svc##*/} + + # Skip these services + for s in cleartmp moused; do + [ "${s}" = "${service}" ] && continue 2 + done + + # If we have an init script for this service, continue + [ -x /etc/init.d/"${service}" ] && continue + [ -x /usr/local/etc/init.d/"${service}" ] && continue + + # Ensure that the users rc.conf will start us - ignore the defaults + eval enabled=\$${svc##*/}_enable + yesno ${enabled} || yesno ${svc##*/} || continue + + # Good to go! + "$svc" start && started="${started} ${svc}" + : $((retval += $?)) + done + service_set_value started "${started}" + eend $retval "Some local rc services failed to start" + return 0 +} + +stop() +{ + ebegin "Stopping local rc services" + local svc= retval=0 + for svc in $(rcorder $(service_get_value started) 2>/dev/null | sort -r); do + "${svc}" stop + : $((retval += $?)) + done + eend $retval "Some local rc services failed to stop" + return 0 +} diff --git a/init.d.BSD/rpcbind b/init.d.BSD/rpcbind deleted file mode 100644 index 1ac3873..0000000 --- a/init.d.BSD/rpcbind +++ /dev/null @@ -1,21 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -command=/usr/sbin/rpcbind -command_args=${rpcbind_args} -name="RPC program number mapper" - -depend() -{ - provide rpc - need localmount - use net logger dns - before inetd xinetd ntpd ntp-client -} - -stop_post() -{ - # rpcbind returns too fast, so sleep for a second - sleep 1 -} diff --git a/init.d.BSD/rpcbind.in b/init.d.BSD/rpcbind.in new file mode 100644 index 0000000..1ac3873 --- /dev/null +++ b/init.d.BSD/rpcbind.in @@ -0,0 +1,21 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +command=/usr/sbin/rpcbind +command_args=${rpcbind_args} +name="RPC program number mapper" + +depend() +{ + provide rpc + need localmount + use net logger dns + before inetd xinetd ntpd ntp-client +} + +stop_post() +{ + # rpcbind returns too fast, so sleep for a second + sleep 1 +} diff --git a/init.d.BSD/savecore b/init.d.BSD/savecore deleted file mode 100755 index 6784a1d..0000000 --- a/init.d.BSD/savecore +++ /dev/null @@ -1,36 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Saves a kernel dump." - -depend() -{ - need localmount - keyword nojail -} - -start() -{ - local dump_dir=${dump_dir:-/var/crash} - if ! [ -d "${dump_dir}" ]; then - mkdir -p "${dump_dir}" - chmod 700 "${dump_dir}" - fi - - if [ "${RC_UNAME}" = "FreeBSD" ]; then - # Don't quote ${dump_device}, so that if it's unset, - # savecore will check on the partitions listed in fstab - # without errors in the output - savecore -C "${dump_dir}" ${dump_device} >/dev/null - else - ls "${dump_dir}"/bsd* > /dev/null 2>&1 - fi - [ $? = 0 ] || return 0 - - local sopts="${dump_dir} ${dump_device}" - yesno ${dump_compress} && sopts="-z ${sopts}" - ebegin "Saving kernel core dump in ${dump_dir}" - savecore ${sopts} >/dev/null - eend $? -} diff --git a/init.d.BSD/savecore.in b/init.d.BSD/savecore.in new file mode 100644 index 0000000..f37e0d2 --- /dev/null +++ b/init.d.BSD/savecore.in @@ -0,0 +1,36 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Saves a kernel dump." + +depend() +{ + need localmount + keyword nojail noprefix +} + +start() +{ + local dump_dir=${dump_dir:-/var/crash} + if ! [ -d "${dump_dir}" ]; then + mkdir -p "${dump_dir}" + chmod 700 "${dump_dir}" + fi + + if [ "${RC_UNAME}" = "FreeBSD" ]; then + # Don't quote ${dump_device}, so that if it's unset, + # savecore will check on the partitions listed in fstab + # without errors in the output + savecore -C "${dump_dir}" ${dump_device} >/dev/null + else + ls "${dump_dir}"/bsd* > /dev/null 2>&1 + fi + [ $? = 0 ] || return 0 + + local sopts="${dump_dir} ${dump_device}" + yesno ${dump_compress} && sopts="-z ${sopts}" + ebegin "Saving kernel core dump in ${dump_dir}" + savecore ${sopts} >/dev/null + eend $? +} diff --git a/init.d.BSD/swap-blk b/init.d.BSD/swap-blk deleted file mode 100644 index a308f5e..0000000 --- a/init.d.BSD/swap-blk +++ /dev/null @@ -1,23 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -depend() -{ - before fsck - keyword nojail -} - -start() -{ - ebegin "Activating block swap devices" - swapctl -A -t blk >/dev/null - eend 0 # If swapon has nothing todo it errors, so always return 0 -} - -stop() -{ - ebegin "Deactivating block swap devices" - swapctl -U -t blk >/dev/null - eend 0 -} diff --git a/init.d.BSD/swap-blk.in b/init.d.BSD/swap-blk.in new file mode 100644 index 0000000..a38bae9 --- /dev/null +++ b/init.d.BSD/swap-blk.in @@ -0,0 +1,23 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +depend() +{ + before fsck + keyword nojail noprefix +} + +start() +{ + ebegin "Activating block swap devices" + swapctl -A -t blk >/dev/null + eend 0 # If swapon has nothing todo it errors, so always return 0 +} + +stop() +{ + ebegin "Deactivating block swap devices" + swapctl -U -t blk >/dev/null + eend 0 +} diff --git a/init.d.BSD/sysctl b/init.d.BSD/sysctl deleted file mode 100644 index f963571..0000000 --- a/init.d.BSD/sysctl +++ /dev/null @@ -1,25 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -depend() -{ - use hostname - before bootmisc logger -} - -start() -{ - [ -e /etc/sysctl.conf ] || return 0 - - ebegin "Configuring kernel parameters" - local retval=0 var= comments= - while read var comments; do - case "${var}" in - ""|"#"*) continue;; - esac - sysctl -w "${var}" >/dev/null || retval=1 - done < /etc/sysctl.conf - eend ${retval} "Some errors were encountered" - eend $? -} diff --git a/init.d.BSD/sysctl.in b/init.d.BSD/sysctl.in new file mode 100644 index 0000000..1de4c93 --- /dev/null +++ b/init.d.BSD/sysctl.in @@ -0,0 +1,26 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +depend() +{ + use hostname + before bootmisc logger + keyword noprefix +} + +start() +{ + [ -e /etc/sysctl.conf ] || return 0 + + ebegin "Configuring kernel parameters" + local retval=0 var= comments= + while read var comments; do + case "${var}" in + ""|"#"*) continue;; + esac + sysctl -w "${var}" >/dev/null || retval=1 + done < /etc/sysctl.conf + eend ${retval} "Some errors were encountered" + eend $? +} diff --git a/init.d.BSD/syslogd b/init.d.BSD/syslogd deleted file mode 100644 index e90ba1a..0000000 --- a/init.d.BSD/syslogd +++ /dev/null @@ -1,19 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -command=/usr/sbin/syslogd -command_args=${syslogd_args} -case "${RC_UNAME}" in - FreeBSD|DragonFly) pidfile=/var/run/syslog.pid;; - *) pidfile=/var/run/syslogd.pid;; -esac -name="System Logger Daemon" - -depend() -{ - provide logger - use net newsyslog - need localmount - after bootmisc -} diff --git a/init.d.BSD/syslogd.in b/init.d.BSD/syslogd.in new file mode 100644 index 0000000..e90ba1a --- /dev/null +++ b/init.d.BSD/syslogd.in @@ -0,0 +1,19 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +command=/usr/sbin/syslogd +command_args=${syslogd_args} +case "${RC_UNAME}" in + FreeBSD|DragonFly) pidfile=/var/run/syslog.pid;; + *) pidfile=/var/run/syslogd.pid;; +esac +name="System Logger Daemon" + +depend() +{ + provide logger + use net newsyslog + need localmount + after bootmisc +} diff --git a/init.d.FreeBSD/clock b/init.d.FreeBSD/clock deleted file mode 100644 index 7fcb025..0000000 --- a/init.d.FreeBSD/clock +++ /dev/null @@ -1,61 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -extra_commands="save" - -description="Sets the local clock to UTC or Local Time." -description_save="Saves the current time in the BIOS." - -clock=${clock:-${CLOCK:-UTC}} -if [ "${clock}" = "UTC" ]; then - utc="UTC" -else - utc="Local Time" -fi - -depend() -{ - # BSD adjkerntz needs to be able to write to /etc - if [ "${clock}" = "UTC" -a -e /etc/wall_cmos_clock ] || - [ "${clock}" != "UTC" -a ! -e /etc/wall_cmos_clock ]; then - need root - fi - keyword nojail -} - -start() -{ - ebegin "Starting the System Clock Adjuster [${utc}]" - if [ "${clock}" != "UTC" ]; then - echo >/etc/wall_cmos_clock - start-stop-daemon --start --exec /sbin/adjkerntz -- -i - else - rm -f /etc/wall_cmos_clock - /sbin/adjkerntz -i - fi - eend $? -} - -save() -{ - ebegin "Setting hardware clock using the system clock [${utc}]" - adjkerntz -a - eend $? -} - -stop() -{ - # Don't tweak the hardware clock on LiveCD halt. - if yesno "${clock_systohc:-${CLOCK_SYSTOHC}}"; then - [ -z "${CDBOOT}" ] && save - fi - - ebegin "Stopping the System Clock Adjuster" - if start-stop-daemon --test --quiet --stop --exec /sbin/adjkerntz; then - start-stop-daemon --stop --exec /sbin/adjkerntz - eend $? - else - eend 0 - fi -} diff --git a/init.d.FreeBSD/clock.in b/init.d.FreeBSD/clock.in new file mode 100644 index 0000000..3a2c050 --- /dev/null +++ b/init.d.FreeBSD/clock.in @@ -0,0 +1,61 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +extra_commands="save" + +description="Sets the local clock to UTC or Local Time." +description_save="Saves the current time in the BIOS." + +clock=${clock:-${CLOCK:-UTC}} +if [ "${clock}" = "UTC" ]; then + utc="UTC" +else + utc="Local Time" +fi + +depend() +{ + # BSD adjkerntz needs to be able to write to /etc + if [ "${clock}" = "UTC" -a -e /etc/wall_cmos_clock ] || + [ "${clock}" != "UTC" -a ! -e /etc/wall_cmos_clock ]; then + need root + fi + keyword nojail noprefix +} + +start() +{ + ebegin "Starting the System Clock Adjuster [${utc}]" + if [ "${clock}" != "UTC" ]; then + echo >/etc/wall_cmos_clock + start-stop-daemon --start --exec /sbin/adjkerntz -- -i + else + rm -f /etc/wall_cmos_clock + /sbin/adjkerntz -i + fi + eend $? +} + +save() +{ + ebegin "Setting hardware clock using the system clock [${utc}]" + adjkerntz -a + eend $? +} + +stop() +{ + # Don't tweak the hardware clock on LiveCD halt. + if yesno "${clock_systohc:-${CLOCK_SYSTOHC}}"; then + [ -z "${CDBOOT}" ] && save + fi + + ebegin "Stopping the System Clock Adjuster" + if start-stop-daemon --test --quiet --stop --exec /sbin/adjkerntz; then + start-stop-daemon --stop --exec /sbin/adjkerntz + eend $? + else + eend 0 + fi +} diff --git a/init.d.FreeBSD/devd b/init.d.FreeBSD/devd deleted file mode 100644 index 04ed3af..0000000 --- a/init.d.FreeBSD/devd +++ /dev/null @@ -1,22 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -command=/sbin/devd -command_args=${devd_args} -name="Device State Change Daemon" - -depend() { - need localmount - after bootmisc - before net.lo0 - keyword nojail -} - -start_pre() { - sysctl hw.bus.devctl_disable=0 >/dev/null -} - -stop_post() { - sysctl hw.bus.devctl_disable=1 >/dev/null -} diff --git a/init.d.FreeBSD/devd.in b/init.d.FreeBSD/devd.in new file mode 100644 index 0000000..3c31284 --- /dev/null +++ b/init.d.FreeBSD/devd.in @@ -0,0 +1,22 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +command=/sbin/devd +command_args=${devd_args} +name="Device State Change Daemon" + +depend() { + need localmount + after bootmisc + before net.lo0 + keyword nojail noprefix +} + +start_pre() { + sysctl hw.bus.devctl_disable=0 >/dev/null +} + +stop_post() { + sysctl hw.bus.devctl_disable=1 >/dev/null +} diff --git a/init.d.FreeBSD/dumpon b/init.d.FreeBSD/dumpon deleted file mode 100644 index b69e4ff..0000000 --- a/init.d.FreeBSD/dumpon +++ /dev/null @@ -1,25 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Configures a specific kernel dump device." - -depend() { - need swap - keyword nojail -} - -start() { - # Setup any user requested dump device - if [ -n "${dump_device}" ]; then - ebegin "Activating kernel core dump device (${dump_device})" - dumpon ${dump_device} - eend $? - fi -} - -stop() { - ebegin "Deactiving kernel core dump device" - dumpon off - eend $? -} diff --git a/init.d.FreeBSD/dumpon.in b/init.d.FreeBSD/dumpon.in new file mode 100644 index 0000000..c34c76c --- /dev/null +++ b/init.d.FreeBSD/dumpon.in @@ -0,0 +1,25 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Configures a specific kernel dump device." + +depend() { + need swap + keyword nojail noprefix +} + +start() { + # Setup any user requested dump device + if [ -n "${dump_device}" ]; then + ebegin "Activating kernel core dump device (${dump_device})" + dumpon ${dump_device} + eend $? + fi +} + +stop() { + ebegin "Deactiving kernel core dump device" + dumpon off + eend $? +} diff --git a/init.d.FreeBSD/ipfw b/init.d.FreeBSD/ipfw deleted file mode 100644 index 200b9ce..0000000 --- a/init.d.FreeBSD/ipfw +++ /dev/null @@ -1,149 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -# This is based on /etc/rc.firewall and /etc/rc.firewall6 from FreeBSD - -ipfw_ip_in=${ipfw_ip_in-any} -ipfw_ports_in=${ipfw_ports_in-auth ssh} -ipfw_ports_nolog=${ipfw_ports_nolog-135-139,445 1026,1027 1433,1434} - -opts="panic showstatus" - -depend() { - before net - provide firewall - keyword nojail -} - -ipfw() { - /sbin/ipfw -f -q "$@" -} - -init() { - # Load the kernel module - if ! sysctl net.inet.ip.fw.enable=1 >/dev/null 2>&1; then - if ! kldload ipfw; then - eend 1 "Unable to load firewall module" - return 1 - fi - fi - - # Now all rules and give a good base - ipfw flush - - ipfw add pass all from any to any via lo0 - ipfw add deny all from any to 127.0.0.0/8 - ipfw add deny ip from 127.0.0.0/8 to any - - ipfw add pass ip6 from any to any via lo0 - ipfw add deny ip6 from any to ::1 - ipfw add deny ip6 from ::1 to any - - ipfw add pass ip6 from :: to ff02::/16 proto ipv6-icmp - ipfw add pass ip6 from fe80::/10 to fe80::/10 proto ipv6-icmp - ipfw add pass ip6 from fe80::/10 to ff02::/16 proto ipv6-icmp -} - -start() { - local i= p= log= - ebegin "Starting firewall rules" - if ! init; then - eend 1 "Failed to flush firewall ruleset" - return 1 - fi - - # Use a statefull firewall - ipfw add check-state - ipfw add pass tcp from me to any established - - # Allow any connection out, adding state for each. - ipfw add pass tcp from me to any setup keep-state - ipfw add pass udp from me to any keep-state - ipfw add pass icmp from me to any keep-state - - ipfw add pass tcp from me6 to any setup keep-state - ipfw add pass udp from me6 to any keep-state - ipfw add pass icmp from me6 to any keep-state - - # Allow DHCP. - ipfw add pass udp from 0.0.0.0 68 to 255.255.255.255 67 out - ipfw add pass udp from any 67 to me 68 in - ipfw add pass udp from any 67 to 255.255.255.255 68 in - # Some servers will ping the IP while trying to decide if it's - # still in use. - ipfw add pass icmp from any to any icmptype 8 - - # Allow "mandatory" ICMP in. - ipfw add pass icmp from any to any icmptype 3,4,11 - - # Allow ICMPv6 destination unreach - ipfw add pass ip6 from any to any icmp6types 1 proto ipv6-icmp - - # Allow NS/NA/toobig (don't filter it out) - ipfw add pass ip6 from any to any icmp6types 2,135,136 proto ipv6-icmp - - # Add permits for this workstations published services below - # Only IPs and nets in firewall_allowservices is allowed in. - for i in ${ipfw_ip_in}; do - for p in ${ipfw_ports_in}; do - ipfw add pass tcp from ${i} to me ${p} - done - done - - # Allow all connections from trusted IPs. - # Playing with the content of firewall_trusted could seriously - # degrade the level of protection provided by the firewall. - for i in ${ipfw_ip_trust}; do - ipfw add pass ip from ${i} to me - done - - ipfw add 65000 count ip from any to any - - # Drop packets to ports where we don't want logging - for p in ${ipfw_ports_nolog}; do - ipfw add deny { tcp or udp } from any to any ${p} in - done - - # Broadcasts and muticasts - ipfw add deny ip from any to 255.255.255.255 - ipfw add deny ip from any to 224.0.0.0/24 - - # Noise from routers - ipfw add deny udp from any to any 520 in - - # Noise from webbrowsing. - # The statefull filter is a bit agressive, and will cause some - # connection teardowns to be logged. - ipfw add deny tcp from any 80,443 to any 1024-65535 in - - # Deny and (if wanted) log the rest unconditionally. - if yesno ${ipfw_log_deny:-no}; then - log="log" - sysctl net.inet.ip.fw.verbose=1 >/dev/null - fi - ipfw add deny ${log} ip from any to any - - eend 0 -} - -stop() { - ebegin "Stopping firewall rules" - # We don't unload the kernel module as that action - # can cause memory leaks as of FreeBSD 6.x - sysctl net.inet.ip.fw.enable=0 >/dev/null - eend $? -} - -panic() { - ebegin "Stopping firewall rules - hard" - if ! init; then - eend 1 "Failed to flush firewall ruleset" - return 1 - fi - eend 0 -} - -showstatus() { - ipfw show -} diff --git a/init.d.FreeBSD/ipfw.in b/init.d.FreeBSD/ipfw.in new file mode 100644 index 0000000..200b9ce --- /dev/null +++ b/init.d.FreeBSD/ipfw.in @@ -0,0 +1,149 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +# This is based on /etc/rc.firewall and /etc/rc.firewall6 from FreeBSD + +ipfw_ip_in=${ipfw_ip_in-any} +ipfw_ports_in=${ipfw_ports_in-auth ssh} +ipfw_ports_nolog=${ipfw_ports_nolog-135-139,445 1026,1027 1433,1434} + +opts="panic showstatus" + +depend() { + before net + provide firewall + keyword nojail +} + +ipfw() { + /sbin/ipfw -f -q "$@" +} + +init() { + # Load the kernel module + if ! sysctl net.inet.ip.fw.enable=1 >/dev/null 2>&1; then + if ! kldload ipfw; then + eend 1 "Unable to load firewall module" + return 1 + fi + fi + + # Now all rules and give a good base + ipfw flush + + ipfw add pass all from any to any via lo0 + ipfw add deny all from any to 127.0.0.0/8 + ipfw add deny ip from 127.0.0.0/8 to any + + ipfw add pass ip6 from any to any via lo0 + ipfw add deny ip6 from any to ::1 + ipfw add deny ip6 from ::1 to any + + ipfw add pass ip6 from :: to ff02::/16 proto ipv6-icmp + ipfw add pass ip6 from fe80::/10 to fe80::/10 proto ipv6-icmp + ipfw add pass ip6 from fe80::/10 to ff02::/16 proto ipv6-icmp +} + +start() { + local i= p= log= + ebegin "Starting firewall rules" + if ! init; then + eend 1 "Failed to flush firewall ruleset" + return 1 + fi + + # Use a statefull firewall + ipfw add check-state + ipfw add pass tcp from me to any established + + # Allow any connection out, adding state for each. + ipfw add pass tcp from me to any setup keep-state + ipfw add pass udp from me to any keep-state + ipfw add pass icmp from me to any keep-state + + ipfw add pass tcp from me6 to any setup keep-state + ipfw add pass udp from me6 to any keep-state + ipfw add pass icmp from me6 to any keep-state + + # Allow DHCP. + ipfw add pass udp from 0.0.0.0 68 to 255.255.255.255 67 out + ipfw add pass udp from any 67 to me 68 in + ipfw add pass udp from any 67 to 255.255.255.255 68 in + # Some servers will ping the IP while trying to decide if it's + # still in use. + ipfw add pass icmp from any to any icmptype 8 + + # Allow "mandatory" ICMP in. + ipfw add pass icmp from any to any icmptype 3,4,11 + + # Allow ICMPv6 destination unreach + ipfw add pass ip6 from any to any icmp6types 1 proto ipv6-icmp + + # Allow NS/NA/toobig (don't filter it out) + ipfw add pass ip6 from any to any icmp6types 2,135,136 proto ipv6-icmp + + # Add permits for this workstations published services below + # Only IPs and nets in firewall_allowservices is allowed in. + for i in ${ipfw_ip_in}; do + for p in ${ipfw_ports_in}; do + ipfw add pass tcp from ${i} to me ${p} + done + done + + # Allow all connections from trusted IPs. + # Playing with the content of firewall_trusted could seriously + # degrade the level of protection provided by the firewall. + for i in ${ipfw_ip_trust}; do + ipfw add pass ip from ${i} to me + done + + ipfw add 65000 count ip from any to any + + # Drop packets to ports where we don't want logging + for p in ${ipfw_ports_nolog}; do + ipfw add deny { tcp or udp } from any to any ${p} in + done + + # Broadcasts and muticasts + ipfw add deny ip from any to 255.255.255.255 + ipfw add deny ip from any to 224.0.0.0/24 + + # Noise from routers + ipfw add deny udp from any to any 520 in + + # Noise from webbrowsing. + # The statefull filter is a bit agressive, and will cause some + # connection teardowns to be logged. + ipfw add deny tcp from any 80,443 to any 1024-65535 in + + # Deny and (if wanted) log the rest unconditionally. + if yesno ${ipfw_log_deny:-no}; then + log="log" + sysctl net.inet.ip.fw.verbose=1 >/dev/null + fi + ipfw add deny ${log} ip from any to any + + eend 0 +} + +stop() { + ebegin "Stopping firewall rules" + # We don't unload the kernel module as that action + # can cause memory leaks as of FreeBSD 6.x + sysctl net.inet.ip.fw.enable=0 >/dev/null + eend $? +} + +panic() { + ebegin "Stopping firewall rules - hard" + if ! init; then + eend 1 "Failed to flush firewall ruleset" + return 1 + fi + eend 0 +} + +showstatus() { + ipfw show +} diff --git a/init.d.FreeBSD/mixer b/init.d.FreeBSD/mixer deleted file mode 100644 index b8c8f3a..0000000 --- a/init.d.FreeBSD/mixer +++ /dev/null @@ -1,47 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -extra_commands="restore" - -depend() -{ - need localmount - keyword nojail -} - -restore() -{ - local mixer= retval=0 - ebegin "Restoring mixer settings" - eindent - for mixer in /dev/mixer*; do - if [ -r "/var/db/${mixer#/dev/}-state" ]; then - vebegin "${mixer}" - mixer -f "${mixer}" \ - $(cat "/var/db/${mixer#/dev/}-state") >/dev/null - veend $? - : $((retval += $?)) - fi - done -} - -start() -{ - restore -} - -stop() -{ - local mixer= retval=0 - ebegin "Saving mixer settings" - eindent - for mixer in /dev/mixer*; do - vebegin "${mixer}" - mixer -f "${mixer}" -s >/var/db/"${mixer#/dev/}"-state - veend $? - : $((retval += $?)) - done - eoutdent - eend ${retval} -} diff --git a/init.d.FreeBSD/mixer.in b/init.d.FreeBSD/mixer.in new file mode 100644 index 0000000..b8c8f3a --- /dev/null +++ b/init.d.FreeBSD/mixer.in @@ -0,0 +1,47 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +extra_commands="restore" + +depend() +{ + need localmount + keyword nojail +} + +restore() +{ + local mixer= retval=0 + ebegin "Restoring mixer settings" + eindent + for mixer in /dev/mixer*; do + if [ -r "/var/db/${mixer#/dev/}-state" ]; then + vebegin "${mixer}" + mixer -f "${mixer}" \ + $(cat "/var/db/${mixer#/dev/}-state") >/dev/null + veend $? + : $((retval += $?)) + fi + done +} + +start() +{ + restore +} + +stop() +{ + local mixer= retval=0 + ebegin "Saving mixer settings" + eindent + for mixer in /dev/mixer*; do + vebegin "${mixer}" + mixer -f "${mixer}" -s >/var/db/"${mixer#/dev/}"-state + veend $? + : $((retval += $?)) + done + eoutdent + eend ${retval} +} diff --git a/init.d.FreeBSD/nscd b/init.d.FreeBSD/nscd deleted file mode 100644 index e75f5dc..0000000 --- a/init.d.FreeBSD/nscd +++ /dev/null @@ -1,22 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -command=/usr/sbin/nscd -command_args="${nscd_args}" -pidfile=/var/run/nscd.pid -name="Name Service Cache Daemon" - -extra_started_commands="flush" - -depend() { - need localmount - use net dns ldap ypbind - after bootmisc -} - -flush() { - ebegin "Flushing ${name}" - nscd -I all >/dev/null - eend $? -} diff --git a/init.d.FreeBSD/nscd.in b/init.d.FreeBSD/nscd.in new file mode 100644 index 0000000..e75f5dc --- /dev/null +++ b/init.d.FreeBSD/nscd.in @@ -0,0 +1,22 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +command=/usr/sbin/nscd +command_args="${nscd_args}" +pidfile=/var/run/nscd.pid +name="Name Service Cache Daemon" + +extra_started_commands="flush" + +depend() { + need localmount + use net dns ldap ypbind + after bootmisc +} + +flush() { + ebegin "Flushing ${name}" + nscd -I all >/dev/null + eend $? +} diff --git a/init.d.FreeBSD/powerd b/init.d.FreeBSD/powerd deleted file mode 100644 index 106962a..0000000 --- a/init.d.FreeBSD/powerd +++ /dev/null @@ -1,35 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -command=/usr/sbin/powerd -command_args=${powerd_args} -pidfile=/var/run/powerd.pid -name="Power Control Daemon" - -depend() -{ - need localmount - use logger - after bootmisc - keyword nojail -} - -start_pre() -{ - if [ -n "${powerd_battery_mode}" ]; then - command_args="${command_args} -b ${powerd_battery_mode}" - fi - if [ -n "${powerd_ac_mode}" ]; then - command_args="${command_args} -a ${powerd_ac_mode}" - fi -} - -stop_post() -{ - local level=$(sysctl -n dev.cpu.0.freq_levels | - sed -e 's:/.*::') - if [ -n "${level}" ]; then - sysctl dev.cpu.0.freq="${level}" >/dev/null - fi -} diff --git a/init.d.FreeBSD/powerd.in b/init.d.FreeBSD/powerd.in new file mode 100644 index 0000000..106962a --- /dev/null +++ b/init.d.FreeBSD/powerd.in @@ -0,0 +1,35 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +command=/usr/sbin/powerd +command_args=${powerd_args} +pidfile=/var/run/powerd.pid +name="Power Control Daemon" + +depend() +{ + need localmount + use logger + after bootmisc + keyword nojail +} + +start_pre() +{ + if [ -n "${powerd_battery_mode}" ]; then + command_args="${command_args} -b ${powerd_battery_mode}" + fi + if [ -n "${powerd_ac_mode}" ]; then + command_args="${command_args} -a ${powerd_ac_mode}" + fi +} + +stop_post() +{ + local level=$(sysctl -n dev.cpu.0.freq_levels | + sed -e 's:/.*::') + if [ -n "${level}" ]; then + sysctl dev.cpu.0.freq="${level}" >/dev/null + fi +} diff --git a/init.d.FreeBSD/syscons b/init.d.FreeBSD/syscons deleted file mode 100644 index 45ed5b0..0000000 --- a/init.d.FreeBSD/syscons +++ /dev/null @@ -1,83 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -depend() { - need localmount - keyword nojail -} - -start() { - if [ -n "${allscreen_flags}" ]; then - ebegin "Setting mode to ${allscreen_flags} for all screens" - for v in /dev/ttyv*; do - vidcontrol ${allscreen_flags} <"${v}" - done - eend $? - fi - - if [ -n "${keymap}" ]; then - ebegin "Setting keymap to ${keymap}" - kbdcontrol -l ${keymap} \`$2'" - kbdcontrol -f "$1" "$2" +# All rights reserved. Released under the 2-clause BSD license. + +depend() { + need localmount + keyword nojail noprefix +} + +start() { + if [ -n "${allscreen_flags}" ]; then + ebegin "Setting mode to ${allscreen_flags} for all screens" + for v in /dev/ttyv*; do + vidcontrol ${allscreen_flags} <"${v}" + done + eend $? + fi + + if [ -n "${keymap}" ]; then + ebegin "Setting keymap to ${keymap}" + kbdcontrol -l ${keymap} \`$2'" + kbdcontrol -f "$1" "$2" -# All rights reserved. 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_ADJFILE}} -clock_args=${clock_args:-${CLOCK_OPTS}} -clock_systohc=${clock_systohc:-${CLOCK_SYSTOHC}} - -clock=${clock:-${CLOCK:-UTC}} -if [ "${clock}" = "UTC" ]; then - utc="UTC" - utc_cmd="--utc" -else - utc="Local Time" - utc_cmd="--localtime" -fi - -depend() -{ - if yesno ${clock_adjfile}; then - use root - else - before * - fi - keyword nouml novps noxenu -} - -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 -a ! -e /dev/rtc ]; then - modprobe -q rtc || modprobe -q genrtc - fi - - if [ -e /etc/adjtime ] && yesno ${clock_adjfile}; then - _hwclock --adjust ${utc_cmd} - retval=$((${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 - _hwclock --hctosys ${utc_cmd} ${clock_args} - retval=$((${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} || 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 | 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} -} diff --git a/init.d.Linux/clock.in b/init.d.Linux/clock.in new file mode 100644 index 0000000..ea7ad2b --- /dev/null +++ b/init.d.Linux/clock.in @@ -0,0 +1,136 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. 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_ADJFILE}} +clock_args=${clock_args:-${CLOCK_OPTS}} +clock_systohc=${clock_systohc:-${CLOCK_SYSTOHC}} + +clock=${clock:-${CLOCK:-UTC}} +if [ "${clock}" = "UTC" ]; then + utc="UTC" + utc_cmd="--utc" +else + utc="Local Time" + utc_cmd="--localtime" +fi + +depend() +{ + if yesno ${clock_adjfile}; then + use root + else + before * + fi + keyword noprefix nouml novps noxenu +} + +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 -a ! -e /dev/rtc ]; then + modprobe -q rtc || modprobe -q genrtc + fi + + if [ -e /etc/adjtime ] && yesno ${clock_adjfile}; then + _hwclock --adjust ${utc_cmd} + retval=$((${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 + _hwclock --hctosys ${utc_cmd} ${clock_args} + retval=$((${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} || 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 | 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} +} diff --git a/init.d.Linux/consolefont b/init.d.Linux/consolefont deleted file mode 100755 index 7bf6bfc..0000000 --- a/init.d.Linux/consolefont +++ /dev/null @@ -1,78 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Sets a font for the consoles." - -depend() -{ - need localmount - need keymaps # sets up terminal encoding scheme - after hotplug - keyword nouml novps noxenu -} - -start() -{ - # Forget about any font until we are successful - rm -rf "${RC_LIBDIR}"/console - - 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= - - # 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 user font" - [ -d /dev/vc ] \ - && ttydev=/dev/vc/ \ - || ttydev=/dev/tty - - x=1 - while [ ${x} -le ${ttyn} ]; do - setfont ${consolefont} ${param} -C ${ttydev}${x} >/dev/null - retval=$((${retval} + $?)) - x=$((${x} + 1)) - done - eend ${retval} - - # Store the last font so we can use it ASAP on boot - if [ ${retval} -eq 0 -a -w "${RC_LIBDIR}" ]; then - mkdir -p "${RC_LIBDIR}"/console - - for font in /usr/share/consolefonts/"${consolefont}".*; do - : - done - cp "${font}" "${RC_LIBDIR}"/console - echo "${font##*/}" > "${RC_LIBDIR}"/console/font - if yesno ${unicode:-${UNICODE}}; then - cp /dev/null "${RC_LIBDIR}"/console/unicode - else - rm -f "${RC_LIBDIR}"/console/unicode - fi - fi - - return ${retval} -} diff --git a/init.d.Linux/consolefont.in b/init.d.Linux/consolefont.in new file mode 100644 index 0000000..37f1fee --- /dev/null +++ b/init.d.Linux/consolefont.in @@ -0,0 +1,78 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Sets a font for the consoles." + +depend() +{ + need localmount + need keymaps # sets up terminal encoding scheme + after hotplug + keyword noprefix nouml novps noxenu +} + +start() +{ + # Forget about any font until we are successful + rm -rf "${RC_LIBDIR}"/console + + 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= + + # 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 user font" + [ -d /dev/vc ] \ + && ttydev=/dev/vc/ \ + || ttydev=/dev/tty + + x=1 + while [ ${x} -le ${ttyn} ]; do + setfont ${consolefont} ${param} -C ${ttydev}${x} >/dev/null + retval=$((${retval} + $?)) + x=$((${x} + 1)) + done + eend ${retval} + + # Store the last font so we can use it ASAP on boot + if [ ${retval} -eq 0 -a -w "${RC_LIBDIR}" ]; then + mkdir -p "${RC_LIBDIR}"/console + + for font in /usr/share/consolefonts/"${consolefont}".*; do + : + done + cp "${font}" "${RC_LIBDIR}"/console + echo "${font##*/}" > "${RC_LIBDIR}"/console/font + if yesno ${unicode:-${UNICODE}}; then + cp /dev/null "${RC_LIBDIR}"/console/unicode + else + rm -f "${RC_LIBDIR}"/console/unicode + fi + fi + + return ${retval} +} diff --git a/init.d.Linux/keymaps b/init.d.Linux/keymaps deleted file mode 100755 index b09137d..0000000 --- a/init.d.Linux/keymaps +++ /dev/null @@ -1,69 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Applies a keymap for the consoles." - -ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} -unicode=${unicode:-${UNICODE}} -keymap=${keymap:-${KEYMAP}} -extended_keymaps=${extended_keymaps:-${EXTENDED_KEYMAPS}} -windowskeys=${windowskeys:-${SET_WINDOWSKEYS}} -fix_euro=${fix_euro:-${FIX_EURO}} -dumpkeys_charset=${dumpkeys_charset:-${DUMPKEYS_CHARSET}} - -depend() -{ - need localmount - keyword nouml novps noxenu -} - -start() -{ - if [ -z "${keymap}" ]; then - eerror "You need to setup keymap in /etc/conf.d/keymaps first" - return 1 - fi - - local ttydev= n= - [ -d /dev/vc ] \ - && ttydev=/dev/vc/ \ - || ttydev=/dev/tty - - # 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 - - ebegin "Loading key mappings" - local loadkeys_uni= wkeys= - yesno ${unicode} && loadkeys_uni="--unicode" - yesno ${windowskeys} && wkeys="windowkeys" - loadkeys -q ${loadkeys_uni} ${wkeys} ${keymap} ${extended_keymaps} - eend $? "Error loading key mappings" || return $? - - if yesno ${fix_euro}; then - # Fix some fonts displaying the Euro, #173528. - echo "altgr keycode 18 = U+20AC" | loadkeys -q - fi - - # Set terminal encoding to either ASCII or UNICODE. - # See utf-8(7) for more information. - local termencoding="%@" termmsg="ASCII" kmode="-a" - if yesno ${unicode}; then - dumpkeys ${dumpkeys_charset:+-c} \ - ${dumpkeys_charset} | loadkeys --unicode - termencoding="%G" - termmsg="UTF-8" - kmode="-u" - fi - - ebegin "Setting terminal encoding to" ${termmsg} - n=1 - while [ ${n} -le "${ttyn}" ]; do - printf "\033%s" "${termencoding}" >"${ttydev}${n}" - kbd_mode "${kmode}" -C "${ttydev}${n}" - n=$((${n} + 1)) - done - eend 0 -} diff --git a/init.d.Linux/keymaps.in b/init.d.Linux/keymaps.in new file mode 100644 index 0000000..827b550 --- /dev/null +++ b/init.d.Linux/keymaps.in @@ -0,0 +1,69 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Applies a keymap for the consoles." + +ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} +unicode=${unicode:-${UNICODE}} +keymap=${keymap:-${KEYMAP}} +extended_keymaps=${extended_keymaps:-${EXTENDED_KEYMAPS}} +windowskeys=${windowskeys:-${SET_WINDOWSKEYS}} +fix_euro=${fix_euro:-${FIX_EURO}} +dumpkeys_charset=${dumpkeys_charset:-${DUMPKEYS_CHARSET}} + +depend() +{ + need localmount + keyword noprefix nouml novps noxenu +} + +start() +{ + if [ -z "${keymap}" ]; then + eerror "You need to setup keymap in /etc/conf.d/keymaps first" + return 1 + fi + + local ttydev= n= + [ -d /dev/vc ] \ + && ttydev=/dev/vc/ \ + || ttydev=/dev/tty + + # 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 + + ebegin "Loading key mappings" + local loadkeys_uni= wkeys= + yesno ${unicode} && loadkeys_uni="--unicode" + yesno ${windowskeys} && wkeys="windowkeys" + loadkeys -q ${loadkeys_uni} ${wkeys} ${keymap} ${extended_keymaps} + eend $? "Error loading key mappings" || return $? + + if yesno ${fix_euro}; then + # Fix some fonts displaying the Euro, #173528. + echo "altgr keycode 18 = U+20AC" | loadkeys -q + fi + + # Set terminal encoding to either ASCII or UNICODE. + # See utf-8(7) for more information. + local termencoding="%@" termmsg="ASCII" kmode="-a" + if yesno ${unicode}; then + dumpkeys ${dumpkeys_charset:+-c} \ + ${dumpkeys_charset} | loadkeys --unicode + termencoding="%G" + termmsg="UTF-8" + kmode="-u" + fi + + ebegin "Setting terminal encoding to" ${termmsg} + n=1 + while [ ${n} -le "${ttyn}" ]; do + printf "\033%s" "${termencoding}" >"${ttydev}${n}" + kbd_mode "${kmode}" -C "${ttydev}${n}" + n=$((${n} + 1)) + done + eend 0 +} diff --git a/init.d.Linux/modules b/init.d.Linux/modules deleted file mode 100755 index c3064d1..0000000 --- a/init.d.Linux/modules +++ /dev/null @@ -1,50 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Loads a user defined list of kernel modules." - -depend() -{ - use isapnp - keyword novps -} - -start() -{ - # Should not fail if kernel do not have module - # support compiled in ... - [ ! -f /proc/modules ] && return 0 - - local KV=$(uname -r) - local KV_MAJOR=${KV%%.*} - local x=${KV#*.} - local KV_MINOR=${x%%.*} - x=${KV#*.*.} - local KV_MICRO=${x%%-*} - - local list= x= args= cnt=0 - for x in "${KV}" \ - ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \ - ${KV_MAJOR}.${KV_MINOR} \ - ; do - eval list=\$modules_$(shell_var "${x}") - [ -n "${list}" ] && break - done - [ -z "${list}" ] && list=${modules} - - for x in ${list}; do - ebegin "Loading module ${x}" - eval args=\$module_$(shell_var "${x}")_args - eval modprobe -q "${x}" "${args}" - eend $? "Failed to load ${x}" && cnt=$((${cnt} + 1)) - done - einfo "Autoloaded ${cnt} module(s)" - - # Just in case a sysadmin prefers generic symbolic links in - # /lib/modules/boot for boot time modules we will load these modules - [ -n "$(modprobe -l -t boot)" ] && modprobe -a -t boot \* 2>/dev/null - - # Above test clobbers the return - return 0 -} diff --git a/init.d.Linux/modules.in b/init.d.Linux/modules.in new file mode 100644 index 0000000..825ca49 --- /dev/null +++ b/init.d.Linux/modules.in @@ -0,0 +1,50 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Loads a user defined list of kernel modules." + +depend() +{ + use isapnp + keyword noprefix novps +} + +start() +{ + # Should not fail if kernel do not have module + # support compiled in ... + [ ! -f /proc/modules ] && return 0 + + local KV=$(uname -r) + local KV_MAJOR=${KV%%.*} + local x=${KV#*.} + local KV_MINOR=${x%%.*} + x=${KV#*.*.} + local KV_MICRO=${x%%-*} + + local list= x= args= cnt=0 + for x in "${KV}" \ + ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \ + ${KV_MAJOR}.${KV_MINOR} \ + ; do + eval list=\$modules_$(shell_var "${x}") + [ -n "${list}" ] && break + done + [ -z "${list}" ] && list=${modules} + + for x in ${list}; do + ebegin "Loading module ${x}" + eval args=\$module_$(shell_var "${x}")_args + eval modprobe -q "${x}" "${args}" + eend $? "Failed to load ${x}" && cnt=$((${cnt} + 1)) + done + einfo "Autoloaded ${cnt} module(s)" + + # Just in case a sysadmin prefers generic symbolic links in + # /lib/modules/boot for boot time modules we will load these modules + [ -n "$(modprobe -l -t boot)" ] && modprobe -a -t boot \* 2>/dev/null + + # Above test clobbers the return + return 0 +} diff --git a/init.d.Linux/mtab b/init.d.Linux/mtab deleted file mode 100644 index abb9492..0000000 --- a/init.d.Linux/mtab +++ /dev/null @@ -1,29 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Update /etc/mtab to match what the kernel knows about" - -depend() -{ - need root -} - -start() -{ - ebegin "Updating /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 -} diff --git a/init.d.Linux/mtab.in b/init.d.Linux/mtab.in new file mode 100644 index 0000000..cd3e1b9 --- /dev/null +++ b/init.d.Linux/mtab.in @@ -0,0 +1,30 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Update /etc/mtab to match what the kernel knows about" + +depend() +{ + need root + keyword noprefix +} + +start() +{ + ebegin "Updating /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 +} diff --git a/init.d.Linux/numlock b/init.d.Linux/numlock deleted file mode 100755 index 6327361..0000000 --- a/init.d.Linux/numlock +++ /dev/null @@ -1,41 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. 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 -} - -_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=$((${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" -} diff --git a/init.d.Linux/numlock.in b/init.d.Linux/numlock.in new file mode 100644 index 0000000..5f9d55d --- /dev/null +++ b/init.d.Linux/numlock.in @@ -0,0 +1,42 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. 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 noprefix +} + +_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=$((${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" +} diff --git a/init.d.Linux/procfs b/init.d.Linux/procfs deleted file mode 100644 index 9e55d88..0000000 --- a/init.d.Linux/procfs +++ /dev/null @@ -1,88 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Mounts misc filesystems in /proc." - -depend() -{ - need localmount -} - -start() -{ - # Make sure we insert usbcore if its a module - if [ -f /proc/modules -a ! -d /proc/bus/usb ]; then - modprobe -q usbcore - fi - - [ -e /proc/filesystems ] || 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 the NFS daemon status - if [ -d /proc/fs/nfsd ] && ! mountinfo -q /proc/fs/nfsd; then - if grep -qs nfsd /proc/filesystems; then - ebegin "Mounting nfsd filesystem" - mount -t nfsd -o nodev,noexec,nosuid \ - nfsd /proc/fs/nfsd - eend $? - fi - fi - - # Setup Kernel Support for miscellaneous Binary Formats - if [ -d /proc/sys/fs/binfmt_misc ] && ! mountinfo -q /proc/sys/fs/binfmt_misc; 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 - eend $? - fi - fi - - # 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 -t securityfs -o nodev,noexec,nosuid \ - 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 -t debugfs -o nodev,noexec,nosuid \ - debugfs /sys/kernel/debug - eend $? - fi - fi - - # Setup Kernel Support for SELinux - if [ -d /selinux ] && ! mountinfo -q /selinux; then - if grep -qs selinuxfs /proc/filesystems; then - ebegin "Mounting SELinux filesystem" - mount -t selinuxfs selinuxfs /selinux - eend $? - fi - fi - - return 0 -} diff --git a/init.d.Linux/procfs.in b/init.d.Linux/procfs.in new file mode 100644 index 0000000..4087863 --- /dev/null +++ b/init.d.Linux/procfs.in @@ -0,0 +1,89 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Mounts misc filesystems in /proc." + +depend() +{ + need localmount + keyword noprefix +} + +start() +{ + # Make sure we insert usbcore if its a module + if [ -f /proc/modules -a ! -d /proc/bus/usb ]; then + modprobe -q usbcore + fi + + [ -e /proc/filesystems ] || 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 the NFS daemon status + if [ -d /proc/fs/nfsd ] && ! mountinfo -q /proc/fs/nfsd; then + if grep -qs nfsd /proc/filesystems; then + ebegin "Mounting nfsd filesystem" + mount -t nfsd -o nodev,noexec,nosuid \ + nfsd /proc/fs/nfsd + eend $? + fi + fi + + # Setup Kernel Support for miscellaneous Binary Formats + if [ -d /proc/sys/fs/binfmt_misc ] && ! mountinfo -q /proc/sys/fs/binfmt_misc; 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 + eend $? + fi + fi + + # 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 -t securityfs -o nodev,noexec,nosuid \ + 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 -t debugfs -o nodev,noexec,nosuid \ + debugfs /sys/kernel/debug + eend $? + fi + fi + + # Setup Kernel Support for SELinux + if [ -d /selinux ] && ! mountinfo -q /selinux; then + if grep -qs selinuxfs /proc/filesystems; then + ebegin "Mounting SELinux filesystem" + mount -t selinuxfs selinuxfs /selinux + eend $? + fi + fi + + return 0 +} diff --git a/init.d.Linux/sysctl b/init.d.Linux/sysctl deleted file mode 100644 index 0a49040..0000000 --- a/init.d.Linux/sysctl +++ /dev/null @@ -1,18 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -depend() -{ - use hostname - before bootmisc logger - keyword novps -} - -start() -{ - [ -e /etc/sysctl.conf ] || return 0 - ebegin "Configuring kernel parameters" - sysctl -p /etc/sysctl.conf >/dev/null - eend $? -} diff --git a/init.d.Linux/sysctl.in b/init.d.Linux/sysctl.in new file mode 100644 index 0000000..be0b539 --- /dev/null +++ b/init.d.Linux/sysctl.in @@ -0,0 +1,18 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +depend() +{ + use hostname + before bootmisc logger + keyword noprefix novps +} + +start() +{ + [ -e /etc/sysctl.conf ] || return 0 + ebegin "Configuring kernel parameters" + sysctl -p /etc/sysctl.conf >/dev/null + eend $? +} diff --git a/init.d.NetBSD/ttys b/init.d.NetBSD/ttys deleted file mode 100644 index 59b6674..0000000 --- a/init.d.NetBSD/ttys +++ /dev/null @@ -1,17 +0,0 @@ -#!/sbin/runscript -# Copyright 2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -start() -{ - ebegin "Setting tty flags" - ttyflags -a - eend $? || return $? - - if [ -c /dev/ttyp0 ]; then - chmod 666 /dev/tty[p-uw-zP-T][0-9a-zA-Z] - fi - if [ -c /dev/ttyv1 ]; then - chmod 666 /dev/ttyv[0-9a-zA-Z] - fi -} diff --git a/init.d.NetBSD/ttys.in b/init.d.NetBSD/ttys.in new file mode 100644 index 0000000..3e07de3 --- /dev/null +++ b/init.d.NetBSD/ttys.in @@ -0,0 +1,23 @@ +#!/sbin/runscript +# Copyright 2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +depend() +{ + after fsck + keyword noprefix +} + +start() +{ + ebegin "Setting tty flags" + ttyflags -a + eend $? || return $? + + if [ -c /dev/ttyp0 ]; then + chmod 666 /dev/tty[p-uw-zP-T][0-9a-zA-Z] + fi + if [ -c /dev/ttyv1 ]; then + chmod 666 /dev/ttyv[0-9a-zA-Z] + fi +} diff --git a/init.d.NetBSD/wscons b/init.d.NetBSD/wscons deleted file mode 100644 index 7859f5f..0000000 --- a/init.d.NetBSD/wscons +++ /dev/null @@ -1,99 +0,0 @@ -#!/sbin/runscript -# Copyright 2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -depend() -{ - need localmount -} - -start() -{ - wscfg=/usr/sbin/wsconscfg - wsfld=/usr/sbin/wsfontload - wsctl=/sbin/wsconsctl - config=/etc/wscons.conf - - # args mean: - # screen idx scr emul - # font name width height enc file - while read type arg1 arg2 arg3 arg4 arg5; do - case "${type}" in - \#*|"") - continue - ;; - - font) - cmd=${wsfld} - [ "${arg2}" != "-" ] && cmd="${cmd} -w ${arg2}" - [ "${arg3}" != "-" ] && cmd="${cmd} -h ${arg3}" - [ "${arg4}" != "-" ] && cmd="${cmd} -e ${arg4}" - cmd="${cmd} -N ${arg1} ${arg5}" - eval "${cmd}" - ;; - - screen) - cmd=${wscfg} - [ "${arg2}" != "-" ] && cmd="${cmd} -t ${arg2}" - [ "${arg3}" != "-" ] && cmd="${cmd} -e ${arg3}" - cmd="${cmd} ${arg1}" - eval "${cmd}" - ;; - - keyboard) - cmd=${wscfg} - case "${arg1}" in - -|auto) - cmd="${cmd} -k" - ;; - *) - cmd="${cmd} -k ${arg1}" - ;; - esac - ${cmd} - ;; - - encoding) - eval ${wsctl} -w "\"encoding=${arg1}\"" - ;; - - mapfile) - local entry= - while read entry; do - case "${entry}" in - \#*|"") - continue - ;; - *) - cmd="${wsctl} -w \"map+=${entry}\"" - eval "${cmd} >/dev/null" - ;; - esac - done < "${arg1}" - ;; - - mux) - eval "${wscfg} -m ${arg1}" - ;; - - setvar) - case "${arg1}" in - keyboard) - cmd="${wsctl} -kw ${arg2}" - ;; - display) - cmd="${wsctl} -dw ${arg2}" - ;; - mouse) - cmd="${wsctl} -mw ${arg2}" - ;; - *) - cmd="${wsctl} -w ${arg1}" - ;; - esac - eval "${cmd}" - ;; - - esac - done < "${config}" -} diff --git a/init.d.NetBSD/wscons.in b/init.d.NetBSD/wscons.in new file mode 100644 index 0000000..6fee03d --- /dev/null +++ b/init.d.NetBSD/wscons.in @@ -0,0 +1,100 @@ +#!/sbin/runscript +# Copyright 2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +depend() +{ + need localmount + keyword noprefix +} + +start() +{ + wscfg=/usr/sbin/wsconscfg + wsfld=/usr/sbin/wsfontload + wsctl=/sbin/wsconsctl + config=/etc/wscons.conf + + # args mean: + # screen idx scr emul + # font name width height enc file + while read type arg1 arg2 arg3 arg4 arg5; do + case "${type}" in + \#*|"") + continue + ;; + + font) + cmd=${wsfld} + [ "${arg2}" != "-" ] && cmd="${cmd} -w ${arg2}" + [ "${arg3}" != "-" ] && cmd="${cmd} -h ${arg3}" + [ "${arg4}" != "-" ] && cmd="${cmd} -e ${arg4}" + cmd="${cmd} -N ${arg1} ${arg5}" + eval "${cmd}" + ;; + + screen) + cmd=${wscfg} + [ "${arg2}" != "-" ] && cmd="${cmd} -t ${arg2}" + [ "${arg3}" != "-" ] && cmd="${cmd} -e ${arg3}" + cmd="${cmd} ${arg1}" + eval "${cmd}" + ;; + + keyboard) + cmd=${wscfg} + case "${arg1}" in + -|auto) + cmd="${cmd} -k" + ;; + *) + cmd="${cmd} -k ${arg1}" + ;; + esac + ${cmd} + ;; + + encoding) + eval ${wsctl} -w "\"encoding=${arg1}\"" + ;; + + mapfile) + local entry= + while read entry; do + case "${entry}" in + \#*|"") + continue + ;; + *) + cmd="${wsctl} -w \"map+=${entry}\"" + eval "${cmd} >/dev/null" + ;; + esac + done < "${arg1}" + ;; + + mux) + eval "${wscfg} -m ${arg1}" + ;; + + setvar) + case "${arg1}" in + keyboard) + cmd="${wsctl} -kw ${arg2}" + ;; + display) + cmd="${wsctl} -dw ${arg2}" + ;; + mouse) + cmd="${wsctl} -mw ${arg2}" + ;; + *) + cmd="${wsctl} -w ${arg1}" + ;; + esac + eval "${cmd}" + ;; + + esac + done < "${config}" +} diff --git a/init.d/bootmisc b/init.d/bootmisc deleted file mode 100755 index a66c93f..0000000 --- a/init.d/bootmisc +++ /dev/null @@ -1,131 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -depend() -{ - use hostname - need localmount - before logger - after clock sysctl -} - -cleanup_tmp_dir() -{ - local dir=$1 - - mkdir -p "${dir}" - cd "${dir}" - if yesno ${wipe_tmp:-${WIPE_TMP:-yes}}; then - ebegin "Wiping ${dir} directory" - local startopts="-x . -depth" delete="-exec rm -rf -- {} ;" - - if [ "${RC_UNAME}" = "Linux" ]; then - startopts=". -xdev -depth" - # busybox find / rm cannot handle -- - delete="-delete" - fi - - # Faster than find - rm -rf -- [b-ikm-pr-zA-Z0-9\.]* - - find ${startopts} ! -name . \ - ! -path ./lost+found \ - ! -path "./lost+found/*" \ - ! -path ./quota.user \ - ! -path "./quota.user/*" \ - ! -path ./aquota.user \ - ! -path "./aquota.user/*" \ - ! -path ./quota.group \ - ! -path "./quota.group/*" \ - ! -path ./aquota.group \ - ! -path "./aquota.group/*" \ - ! -path ./journal \ - ! -path "./journal/*" \ - ${delete} \ - -type d -prune - eend 0 - else - ebegin "Cleaning ${dir} directory" - rm -rf -- "${dir}"/.X*-lock "${dir}"/esrv* "${dir}"/kio* \ - "${dir}"/jpsock.* "${dir}"/.fam* "${dir}"/.esd* \ - "${dir}"/orbit-* "${dir}"/ssh-* "${dir}"/ksocket-* \ - "${dir}"/.*-unix - eend 0 - fi -} - -start() -{ - if ! mkdir /.test.$$ 2>/dev/null; then - ewarn "Skipping /var and /tmp initialization (ro root?)" - return 0 - fi - rmdir /.test.$$ - - # Ensure that our basic dirs exist - for x in /var/log /var/run /tmp; do - if ! [ -d "${x}" ]; then - if ! mkdir -p "${x}"; then - eend 1 "failed to create needed directory ${x}" - return 1 - fi - fi - done - - ebegin "Creating user login records" - cp /dev/null /var/run/utmp - [ -e /var/log/wtmp ] || cp /dev/null /var/log/wtmp - chmod 0644 /var/run/utmp /var/log/wtmp - eend 0 - - ebegin "Cleaning /var/run" - for x in $(find /var/run ! -type d ! -name utmp ! -name random-seed \ - ! -name ld-elf.so.hints ! -name ld.so.hints); - do - [ ! -f "${x}" ] && continue - # Do not remove pidfiles of already running daemons - case "${x}" in - *.pid) - start-stop-daemon --test --quiet --stop \ - --pidfile "${x}" - [ $? -eq 0 ] && continue - ;; - esac - rm -f -- "${x}" - done - eend 0 - - # Clean up /tmp directories - local tmp= - for tmp in ${wipe_tmp_dirs-/tmp}; do - cleanup_tmp_dir "${tmp}" - done - chmod +t /tmp /var/tmp - - # 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 - [ -x /sbin/restorecon ] && restorecon /tmp/.ICE-unix /tmp/.X11-unix - - # Create an 'after-boot' dmesg log - if [ "${RC_SYS}" != "VPS" ]; then - dmesg > /var/log/dmesg - chmod 640 /var/log/dmesg - fi - - rm -f /etc/nologin -} - -stop() -{ - # Write a halt record if we're shutting down - case "${RC_SOFTLEVEL}" in - reboot|shutdown) [ "${RC_UNAME}" = "Linux" ] && halt -w;; - esac - - return 0 -} diff --git a/init.d/bootmisc.in b/init.d/bootmisc.in new file mode 100644 index 0000000..a14a2c7 --- /dev/null +++ b/init.d/bootmisc.in @@ -0,0 +1,132 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +depend() +{ + use hostname + need localmount + before logger + after clock sysctl + keyword noprefix +} + +cleanup_tmp_dir() +{ + local dir=$1 + + mkdir -p "${dir}" + cd "${dir}" + if yesno ${wipe_tmp:-${WIPE_TMP:-yes}}; then + ebegin "Wiping ${dir} directory" + local startopts="-x . -depth" delete="-exec rm -rf -- {} ;" + + if [ "${RC_UNAME}" = "Linux" ]; then + startopts=". -xdev -depth" + # busybox find / rm cannot handle -- + delete="-delete" + fi + + # Faster than find + rm -rf -- [b-ikm-pr-zA-Z0-9\.]* + + find ${startopts} ! -name . \ + ! -path ./lost+found \ + ! -path "./lost+found/*" \ + ! -path ./quota.user \ + ! -path "./quota.user/*" \ + ! -path ./aquota.user \ + ! -path "./aquota.user/*" \ + ! -path ./quota.group \ + ! -path "./quota.group/*" \ + ! -path ./aquota.group \ + ! -path "./aquota.group/*" \ + ! -path ./journal \ + ! -path "./journal/*" \ + ${delete} \ + -type d -prune + eend 0 + else + ebegin "Cleaning ${dir} directory" + rm -rf -- "${dir}"/.X*-lock "${dir}"/esrv* "${dir}"/kio* \ + "${dir}"/jpsock.* "${dir}"/.fam* "${dir}"/.esd* \ + "${dir}"/orbit-* "${dir}"/ssh-* "${dir}"/ksocket-* \ + "${dir}"/.*-unix + eend 0 + fi +} + +start() +{ + if ! mkdir /.test.$$ 2>/dev/null; then + ewarn "Skipping /var and /tmp initialization (ro root?)" + return 0 + fi + rmdir /.test.$$ + + # Ensure that our basic dirs exist + for x in /var/log /var/run /tmp; do + if ! [ -d "${x}" ]; then + if ! mkdir -p "${x}"; then + eend 1 "failed to create needed directory ${x}" + return 1 + fi + fi + done + + ebegin "Creating user login records" + cp /dev/null /var/run/utmp + [ -e /var/log/wtmp ] || cp /dev/null /var/log/wtmp + chmod 0644 /var/run/utmp /var/log/wtmp + eend 0 + + ebegin "Cleaning /var/run" + for x in $(find /var/run ! -type d ! -name utmp ! -name random-seed \ + ! -name ld-elf.so.hints ! -name ld.so.hints); + do + [ ! -f "${x}" ] && continue + # Do not remove pidfiles of already running daemons + case "${x}" in + *.pid) + start-stop-daemon --test --quiet --stop \ + --pidfile "${x}" + [ $? -eq 0 ] && continue + ;; + esac + rm -f -- "${x}" + done + eend 0 + + # Clean up /tmp directories + local tmp= + for tmp in ${wipe_tmp_dirs-/tmp}; do + cleanup_tmp_dir "${tmp}" + done + chmod +t /tmp /var/tmp + + # 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 + [ -x /sbin/restorecon ] && restorecon /tmp/.ICE-unix /tmp/.X11-unix + + # Create an 'after-boot' dmesg log + if [ "${RC_SYS}" != "VPS" ]; then + dmesg > /var/log/dmesg + chmod 640 /var/log/dmesg + fi + + rm -f /etc/nologin +} + +stop() +{ + # Write a halt record if we're shutting down + case "${RC_SOFTLEVEL}" in + reboot|shutdown) [ "${RC_UNAME}" = "Linux" ] && halt -w;; + esac + + return 0 +} diff --git a/init.d/fsck b/init.d/fsck deleted file mode 100644 index fec912b..0000000 --- a/init.d/fsck +++ /dev/null @@ -1,76 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Check and repair filesystems according to /etc/fstab" -_ISF=" -" - -depend() -{ - after clock modules - keyword nojail notimeout -} - -_abort() { - rc-abort - return 1 -} - -# We should only reboot when first booting -_reboot() { - if [ "${RC_SOFTLEVEL}" = "${RC_BOOTLEVEL}" ]; then - reboot "$@" - _abort || return 1 - fi -} - -start() -{ - local reboot_opts= fsck_opts= p= - - ebegin "Checking local filesystems" - for p in ${fsck_passno}; do - local IFS="${_IFS}" - case "${p}" in - [0-9]*) p="=${p}";; - esac - set -- "$@" "$(fstabinfo --passno "${p}")" - unset IFS - done - - if [ "${RC_UNAME}" = "Linux" ]; then - fsck_opts="-C0 -T" - if [ -z "${fsck_passno}" ]; then - fsck_args=${fsck_args--A -p} - if echo 2>/dev/null >/.test.$$; then - rm -f /.test.$$ - fsck_opts="${fsck_args} -R" - fi - fi - reboot_opts="-f" - fi - - trap : QUIT - fsck ${fsck_args--p} ${fsck_opts} "$@" - case $? in - 0) eend 0; return 0;; - 1) ewend 1 "Filesystems repaired"; return 0;; - 2|3|4) ewend 1 "Filesystems repaired, but reboot needed" - _reboot ${reboot_opts} || return 1;; - 8) ewend 1 "Operational error"; return 0;; - 12) ewend 1 "fsck interupted"; return 1;; - *) eend 2 "Filesystems couldn't be fixed" - _abort || return 1;; - esac -} - -stop() -{ - # Fake function so we always shutdown correctly. - _abort() { return 0; } - _reboot() { return 0; } - - yesno "${fsck_shutdown}" && start - return 0 -} diff --git a/init.d/fsck.in b/init.d/fsck.in new file mode 100644 index 0000000..f34a852 --- /dev/null +++ b/init.d/fsck.in @@ -0,0 +1,76 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Check and repair filesystems according to /etc/fstab" +_ISF=" +" + +depend() +{ + after clock modules + keyword nojail noprefix notimeout +} + +_abort() { + rc-abort + return 1 +} + +# We should only reboot when first booting +_reboot() { + if [ "${RC_SOFTLEVEL}" = "${RC_BOOTLEVEL}" ]; then + reboot "$@" + _abort || return 1 + fi +} + +start() +{ + local reboot_opts= fsck_opts= p= + + ebegin "Checking local filesystems" + for p in ${fsck_passno}; do + local IFS="${_IFS}" + case "${p}" in + [0-9]*) p="=${p}";; + esac + set -- "$@" "$(fstabinfo --passno "${p}")" + unset IFS + done + + if [ "${RC_UNAME}" = "Linux" ]; then + fsck_opts="-C0 -T" + if [ -z "${fsck_passno}" ]; then + fsck_args=${fsck_args--A -p} + if echo 2>/dev/null >/.test.$$; then + rm -f /.test.$$ + fsck_opts="${fsck_args} -R" + fi + fi + reboot_opts="-f" + fi + + trap : QUIT + fsck ${fsck_args--p} ${fsck_opts} "$@" + case $? in + 0) eend 0; return 0;; + 1) ewend 1 "Filesystems repaired"; return 0;; + 2|3|4) ewend 1 "Filesystems repaired, but reboot needed" + _reboot ${reboot_opts} || return 1;; + 8) ewend 1 "Operational error"; return 0;; + 12) ewend 1 "fsck interupted"; return 1;; + *) eend 2 "Filesystems couldn't be fixed" + _abort || return 1;; + esac +} + +stop() +{ + # Fake function so we always shutdown correctly. + _abort() { return 0; } + _reboot() { return 0; } + + yesno "${fsck_shutdown}" && start + return 0 +} diff --git a/init.d/hostname b/init.d/hostname deleted file mode 100755 index a777cb3..0000000 --- a/init.d/hostname +++ /dev/null @@ -1,13 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Sets the hostname of the machine." - -start() -{ - hostname=${hostname-${HOSTNAME-localhost}} - ebegin "Setting hostname to ${hostname}" - hostname "${hostname}" - eend $? "Failed to set the hostname" -} diff --git a/init.d/hostname.in b/init.d/hostname.in new file mode 100644 index 0000000..646ceb8 --- /dev/null +++ b/init.d/hostname.in @@ -0,0 +1,17 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Sets the hostname of the machine." + +depend() { + keyword noprefix +} + +start() +{ + hostname=${hostname-${HOSTNAME-localhost}} + ebegin "Setting hostname to ${hostname}" + hostname "${hostname}" + eend $? "Failed to set the hostname" +} diff --git a/init.d/local b/init.d/local deleted file mode 100755 index 9b83752..0000000 --- a/init.d/local +++ /dev/null @@ -1,43 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Executes user commands in /etc/conf.d/local" - -depend() -{ - after * - keyword notimeout -} - -start() -{ - ebegin "Starting local" - - if type local_start >/dev/null 2>&1; then - local_start - fi - - # Support old configs - if [ -e /etc/conf.d/local.start ]; then - . /etc/conf.d/local.start - fi - - eend $? "Failed to start local" -} - -stop() -{ - ebegin "Stopping local" - - if type local_start >/dev/null 2>&1; then - local_stop - fi - - # Support old configs - if [ -e /etc/conf.d/local.stop ]; then - . /etc/conf.d/local.stop - fi - - eend $? $"Failed to stop local" -} diff --git a/init.d/local.in b/init.d/local.in new file mode 100644 index 0000000..9b83752 --- /dev/null +++ b/init.d/local.in @@ -0,0 +1,43 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Executes user commands in /etc/conf.d/local" + +depend() +{ + after * + keyword notimeout +} + +start() +{ + ebegin "Starting local" + + if type local_start >/dev/null 2>&1; then + local_start + fi + + # Support old configs + if [ -e /etc/conf.d/local.start ]; then + . /etc/conf.d/local.start + fi + + eend $? "Failed to start local" +} + +stop() +{ + ebegin "Stopping local" + + if type local_start >/dev/null 2>&1; then + local_stop + fi + + # Support old configs + if [ -e /etc/conf.d/local.stop ]; then + . /etc/conf.d/local.stop + fi + + eend $? $"Failed to stop local" +} diff --git a/init.d/localmount b/init.d/localmount deleted file mode 100755 index a598a71..0000000 --- a/init.d/localmount +++ /dev/null @@ -1,87 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Mounts disks and swap according to /etc/fstab." - -depend() -{ - need fsck - use modules mtab - keyword nojail -} - -start() -{ - # Mount local filesystems in /etc/fstab. - local types="noproc" x= - for x in ${net_fs_list}; do - types="${types},${x}" - done - - ebegin "Mounting local filesystems" - mount -at "${types}" - eend $? "Some local filesystem failed to mount" - - # Always return 0 - some local mounts may not be critical for boot - return 0 -} - -stop() -{ - # Don't unmount anything for VPS systems - [ "${RC_SYS}" = "VPS" ] && return 0 - - # We never unmount / or /dev or $RC_SVCDIR - local x= no_umounts="/|/dev|/dev/.*|${RC_SVCDIR}" - - # RC_NO_UMOUNTS is an env var that can be set by plugins - OIFS=${IFS} SIFS=${IFS-y} - IFS=$IFS: - for x in ${no_umounts} ${RC_NO_UMOUNTS}; do - no_umounts="${no_umounts}|${x}" - done - if [ "${SIFS}" = "y" ]; then - IFS=$OIFS - else - unset IFS - fi - - if [ "${RC_UNAME}" = "Linux" ]; then - no_umounts="${no_umounts}|/proc|/proc/.*|/sys|/sys/.*" - fi - no_umounts="^(${no_umounts})$" - - # Flush all pending disk writes now - sync; sync - - # Try to unmount all tmpfs filesystems not in use, else a deadlock may - # occure, bug #13599. - # As $RC_SVCDIR may also be tmpfs we cd to it to lock it - cd "${RC_SVCDIR}" - umount -a -t tmpfs 2>/dev/null - - . "${RC_LIBDIR}"/sh/rc-mount.sh - - # Umount loopback devices - einfo "Unmounting loopback devices" - eindent - do_unmount "umount -d" --skip-point-regex "${no_umounts}" \ - --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}; do - fs="${fs}${fs:+|}${x}" - done - [ -n "${fs}" ] && fs="^(${fs})$" - do_unmount "umount" --skip-point-regex "${no_umounts}" \ - ${fs:+--skip-fstype-regex} ${fs} --nonetdev - eoutdent - - return 0 -} diff --git a/init.d/localmount.in b/init.d/localmount.in new file mode 100644 index 0000000..bc16f70 --- /dev/null +++ b/init.d/localmount.in @@ -0,0 +1,87 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Mounts disks and swap according to /etc/fstab." + +depend() +{ + need fsck + use modules mtab + keyword nojail noprefix +} + +start() +{ + # Mount local filesystems in /etc/fstab. + local types="noproc" x= + for x in ${net_fs_list}; do + types="${types},${x}" + done + + ebegin "Mounting local filesystems" + mount -at "${types}" + eend $? "Some local filesystem failed to mount" + + # Always return 0 - some local mounts may not be critical for boot + return 0 +} + +stop() +{ + # Don't unmount anything for VPS systems + [ "${RC_SYS}" = "VPS" ] && return 0 + + # We never unmount / or /dev or $RC_SVCDIR + local x= no_umounts="/|/dev|/dev/.*|${RC_SVCDIR}" + + # RC_NO_UMOUNTS is an env var that can be set by plugins + OIFS=${IFS} SIFS=${IFS-y} + IFS=$IFS: + for x in ${no_umounts} ${RC_NO_UMOUNTS}; do + no_umounts="${no_umounts}|${x}" + done + if [ "${SIFS}" = "y" ]; then + IFS=$OIFS + else + unset IFS + fi + + if [ "${RC_UNAME}" = "Linux" ]; then + no_umounts="${no_umounts}|/proc|/proc/.*|/sys|/sys/.*" + fi + no_umounts="^(${no_umounts})$" + + # Flush all pending disk writes now + sync; sync + + # Try to unmount all tmpfs filesystems not in use, else a deadlock may + # occure, bug #13599. + # As $RC_SVCDIR may also be tmpfs we cd to it to lock it + cd "${RC_SVCDIR}" + umount -a -t tmpfs 2>/dev/null + + . "${RC_LIBDIR}"/sh/rc-mount.sh + + # Umount loopback devices + einfo "Unmounting loopback devices" + eindent + do_unmount "umount -d" --skip-point-regex "${no_umounts}" \ + --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}; do + fs="${fs}${fs:+|}${x}" + done + [ -n "${fs}" ] && fs="^(${fs})$" + do_unmount "umount" --skip-point-regex "${no_umounts}" \ + ${fs:+--skip-fstype-regex} ${fs} --nonetdev + eoutdent + + return 0 +} diff --git a/init.d/netmount b/init.d/netmount deleted file mode 100755 index 688b0f4..0000000 --- a/init.d/netmount +++ /dev/null @@ -1,96 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Mounts network shares according to /etc/fstab." - -need_portmap() -{ - local opts= - local IFS=" -" - set -- $(fstabinfo --options --fstype nfs,nfs4) - for opts; do - case ,${opts}, in - *,noauto,*|*,nolock,*);; - *) return 0;; - esac - done - return 1 -} - -depend() -{ - # Only have portmap as a dependency if there is a nfs mount in fstab - # that is set to mount at boot - local pmap="" - if need_portmap; then - pmap="${pmap} rpc.statd" - [ -x /etc/init.d/rpcbind ] \ - && pmap="rpcbind" \ - || pmap="portmap" - fi - - config /etc/fstab - need net ${pmap} - use afc-client amd autofs dns nfs nfsmount portmap rpcbind rpc.statd - keyword nojail -} - -start() -{ - local myneed= myuse= pmap="portmap" nfsmounts= - [ -x /etc/init.d/rpcbind ] && pmap="rpcbind" - - local x= fs= - for x in ${net_fs_list}; do - case "${x}" in - nfs|nfs4) - # If the nfsmount script took care of the nfs - # filesystems, then there's no point in trying - # them twice - service_started nfsmount && continue - - # Only try to mount NFS filesystems if portmap was - # started. This is to fix "hang" problems for new - # users who do not add portmap to the default runlevel. - if need_portmap && ! service_started "${pmap}"; then - continue - fi - ;; - esac - fs="${fs}${fs:+,}${x}" - done - - ebegin "Mounting network filesystems" - mount -at ${fs} - ewend $? "Could not mount all network filesystems" - return 0 -} - -stop() -{ - local x= fs= - - ebegin "Unmounting network filesystems" - . "${RC_LIBDIR}/sh/rc-mount.sh" - - for x in ${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}; do - fs="${fs}${fs:+|}${x}" - done - [ -n "${fs}" ] && fs="^(${fs})$" - do_unmount "umount" ${fs:+--fstype-regex} ${fs} --netdev - retval=$? - - eoutdent - eend ${retval} "Failed to unmount network filesystems" -} diff --git a/init.d/netmount.in b/init.d/netmount.in new file mode 100644 index 0000000..3aa46e1 --- /dev/null +++ b/init.d/netmount.in @@ -0,0 +1,96 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Mounts network shares according to /etc/fstab." + +need_portmap() +{ + local opts= + local IFS=" +" + set -- $(fstabinfo --options --fstype nfs,nfs4) + for opts; do + case ,${opts}, in + *,noauto,*|*,nolock,*);; + *) return 0;; + esac + done + return 1 +} + +depend() +{ + # Only have portmap as a dependency if there is a nfs mount in fstab + # that is set to mount at boot + local pmap="" + if need_portmap; then + pmap="${pmap} rpc.statd" + [ -x /etc/init.d/rpcbind ] \ + && pmap="rpcbind" \ + || pmap="portmap" + fi + + config /etc/fstab + need net ${pmap} + use afc-client amd autofs dns nfs nfsmount portmap rpcbind rpc.statd + keyword nojail noprefix +} + +start() +{ + local myneed= myuse= pmap="portmap" nfsmounts= + [ -x /etc/init.d/rpcbind ] && pmap="rpcbind" + + local x= fs= + for x in ${net_fs_list}; do + case "${x}" in + nfs|nfs4) + # If the nfsmount script took care of the nfs + # filesystems, then there's no point in trying + # them twice + service_started nfsmount && continue + + # Only try to mount NFS filesystems if portmap was + # started. This is to fix "hang" problems for new + # users who do not add portmap to the default runlevel. + if need_portmap && ! service_started "${pmap}"; then + continue + fi + ;; + esac + fs="${fs}${fs:+,}${x}" + done + + ebegin "Mounting network filesystems" + mount -at ${fs} + ewend $? "Could not mount all network filesystems" + return 0 +} + +stop() +{ + local x= fs= + + ebegin "Unmounting network filesystems" + . "${RC_LIBDIR}/sh/rc-mount.sh" + + for x in ${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}; do + fs="${fs}${fs:+|}${x}" + done + [ -n "${fs}" ] && fs="^(${fs})$" + do_unmount "umount" ${fs:+--fstype-regex} ${fs} --netdev + retval=$? + + eoutdent + eend ${retval} "Failed to unmount network filesystems" +} diff --git a/init.d/root b/init.d/root deleted file mode 100644 index ff4726b..0000000 --- a/init.d/root +++ /dev/null @@ -1,26 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -description="Mount the root fs read/write" - -depend() -{ - need fsck - keyword nojail -} - -start() -{ - if echo 2>/dev/null >/.test.$$; then - rm -f /.test.$$ - return 0 - fi - - 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" -} diff --git a/init.d/root.in b/init.d/root.in new file mode 100644 index 0000000..b7ffbf8 --- /dev/null +++ b/init.d/root.in @@ -0,0 +1,26 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +description="Mount the root fs read/write" + +depend() +{ + need fsck + keyword nojail noprefix +} + +start() +{ + if echo 2>/dev/null >/.test.$$; then + rm -f /.test.$$ + return 0 + fi + + 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" +} diff --git a/init.d/swap b/init.d/swap deleted file mode 100644 index c8b1ab8..0000000 --- a/init.d/swap +++ /dev/null @@ -1,23 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -depend() -{ - need localmount - keyword nojail -} - -start() -{ - ebegin "Activating swap" - swapon -a >/dev/null - eend 0 # If swapon has nothing todo it errors, so always return 0 -} - -stop() -{ - ebegin "Deactivating swap" - swapoff -a >/dev/null - eend 0 -} diff --git a/init.d/swap.in b/init.d/swap.in new file mode 100644 index 0000000..b9f4fc9 --- /dev/null +++ b/init.d/swap.in @@ -0,0 +1,23 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +depend() +{ + need localmount + keyword nojail noprefix +} + +start() +{ + ebegin "Activating swap" + swapon -a >/dev/null + eend 0 # If swapon has nothing todo it errors, so always return 0 +} + +stop() +{ + ebegin "Deactivating swap" + swapoff -a >/dev/null + eend 0 +} diff --git a/init.d/urandom b/init.d/urandom deleted file mode 100755 index 3fc0a6d..0000000 --- a/init.d/urandom +++ /dev/null @@ -1,46 +0,0 @@ -#!/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -urandom_seed=${urandom_seed:-${URANDOM_SEED:-/var/run/random-seed}} - -description="Initializes the random number generator." - -depend() -{ - need localmount - keyword nojail -} - -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" -} diff --git a/init.d/urandom.in b/init.d/urandom.in new file mode 100644 index 0000000..6e90100 --- /dev/null +++ b/init.d/urandom.in @@ -0,0 +1,46 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +urandom_seed=${urandom_seed:-${URANDOM_SEED:-/var/run/random-seed}} + +description="Initializes the random number generator." + +depend() +{ + need localmount + keyword nojail noprefix +} + +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" +} diff --git a/src/rc/rc.c b/src/rc/rc.c index 102461d..dbe975d 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -760,10 +760,12 @@ int main (int argc, char **argv) newlevel = argv[optind++]; +#ifndef PREFIX /* OK, so we really are the main RC process * Only root should be able to run us */ if (geteuid () != 0) eerrorx ("%s: root access required", applet); +#endif /* Enable logging */ setenv ("EINFO_LOG", "rc", 1); diff --git a/src/rc/runscript.c b/src/rc/runscript.c index 33f814d..b0982f6 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -1271,8 +1271,10 @@ int runscript (int argc, char **argv) if (retval & RC_SERVICE_STARTED) retval = 0; } else { +#ifndef PREFIX if (geteuid () != 0) eerrorx ("%s: root access required", applet); +#endif if (strcmp (optarg, "conditionalrestart") == 0 || strcmp (optarg, "condrestart") == 0) -- cgit v1.2.3