Adopt a more C style for scripts and remove vim settings.

This commit is contained in:
Roy Marples
2008-01-11 12:13:46 +00:00
parent 1f4422c72f
commit 3bf49a9bd1
38 changed files with 264 additions and 213 deletions

View File

@@ -5,12 +5,14 @@
extra_commands="reset" extra_commands="reset"
hostid_file=${hostid_file:-/etc/hostid} hostid_file=${hostid_file:-/etc/hostid}
depend() { depend()
{
need checkroot need checkroot
before devd net before devd net
} }
_set() { _set()
{
local id=0 local id=0
if [ -n "$1" ]; then if [ -n "$1" ]; then
@@ -33,7 +35,8 @@ _set() {
# First we check to see if there is a system UUID # First we check to see if there is a system UUID
# If so then we use that and erase the hostid file, # If so then we use that and erase the hostid file,
# otherwise we generate a random UUID. # otherwise we generate a random UUID.
reset() { reset()
{
local uuid=$(kenv smbios.system.uuid 2>/dev/null) local uuid=$(kenv smbios.system.uuid 2>/dev/null)
local x="[0-9a-f]" local x="[0-9a-f]"
local y="${x}${x}${x}${x}" local y="${x}${x}${x}${x}"
@@ -68,6 +71,7 @@ start()
fi fi
} }
stop() { stop()
{
_set _set
} }

View File

@@ -4,29 +4,34 @@
extra_commands="restore" extra_commands="restore"
depend() { depend()
{
need localmount need localmount
} }
restore() { restore()
{
local mixer= retval=0 local mixer= retval=0
ebegin "Restoring mixer settings" ebegin "Restoring mixer settings"
eindent eindent
for mixer in /dev/mixer*; do for mixer in /dev/mixer*; do
if [ -r "/var/db/${mixer#/dev/}-state" ]; then if [ -r "/var/db/${mixer#/dev/}-state" ]; then
vebegin "${mixer}" vebegin "${mixer}"
mixer -f "${mixer}" $(cat "/var/db/${mixer#/dev/}-state") >/dev/null mixer -f "${mixer}" \
$(cat "/var/db/${mixer#/dev/}-state") >/dev/null
veend $? veend $?
: $((retval += $?)) : $((retval += $?))
fi fi
done done
} }
start() { start()
{
restore restore
} }
stop() { stop()
{
local mixer= retval=0 local mixer= retval=0
ebegin "Saving mixer settings" ebegin "Saving mixer settings"
eindent eindent

View File

@@ -12,12 +12,14 @@ fi
name="Console Mouse Daemon" name="Console Mouse Daemon"
[ -n "${moused_device}" ] && name="${name} (${moused_device})" [ -n "${moused_device}" ] && name="${name} (${moused_device})"
depend() { depend()
{
need localmount need localmount
after bootmisc after bootmisc
} }
start() { start()
{
ebegin "Starting ${name}" ebegin "Starting ${name}"
if [ -z "${moused_device}" ]; then if [ -z "${moused_device}" ]; then
@@ -57,5 +59,3 @@ start() {
eend ${retval} "Failed to start moused" eend ${retval} "Failed to start moused"
} }
# vim: set ts=4 :

View File

@@ -4,11 +4,13 @@
required_files="/etc/newsyslog.conf" required_files="/etc/newsyslog.conf"
depend() { depend()
{
need localmount need localmount
} }
start() { start()
{
ebegin "Creating and/or trimming log files" ebegin "Creating and/or trimming log files"
newsyslog ${newsyslog_args} newsyslog ${newsyslog_args}
eend $? eend $?

View File

@@ -7,13 +7,15 @@ command_args=${powerd_args}
pidfile=/var/run/powerd.pid pidfile=/var/run/powerd.pid
name="Power Control Daemon" name="Power Control Daemon"
depend() { depend()
{
need localmount need localmount
use logger use logger
after bootmisc after bootmisc
} }
start_pre() { start_pre()
{
if [ -n "${powerd_battery_mode}" ]; then if [ -n "${powerd_battery_mode}" ]; then
command_args="${command_args} -b ${powerd_battery_mode}" command_args="${command_args} -b ${powerd_battery_mode}"
fi fi

View File

@@ -15,7 +15,8 @@ else
fi fi
command_background="YES" command_background="YES"
depend() { depend()
{
need localmount need localmount
after bootmisc after bootmisc

View File

@@ -2,13 +2,15 @@
# Copyright 2007-2008 Roy Marples # Copyright 2007-2008 Roy Marples
# All rights reserved # All rights reserved
depend() { depend()
{
need localmount net need localmount net
after * after *
before local before local
} }
start() { start()
{
ebegin "Starting local rc services" ebegin "Starting local rc services"
local svc= enabled= retval=0 service= local svc= enabled= retval=0 service=
for svc in $(rcorder /etc/rc.d/* /usr/local/etc/rc.d/* 2>/dev/null); do for svc in $(rcorder /etc/rc.d/* /usr/local/etc/rc.d/* 2>/dev/null); do
@@ -37,7 +39,8 @@ start() {
return 0 return 0
} }
stop() { stop()
{
ebegin "Stopping local rc services" ebegin "Stopping local rc services"
local svc= retval=0 local svc= retval=0
for svc in $(rcorder $(service_get_value started) 2>/dev/null | sort -r); do for svc in $(rcorder $(service_get_value started) 2>/dev/null | sort -r); do

View File

@@ -6,14 +6,16 @@ command=/usr/sbin/rpcbind
command_args=${rpcbind_args} command_args=${rpcbind_args}
name="RPC program number mapper" name="RPC program number mapper"
depend() { depend()
{
provide rpc provide rpc
need localmount need localmount
use net logger dns use net logger dns
before inetd xinetd ntpd ntp-client before inetd xinetd ntpd ntp-client
} }
stop_post() { stop_post()
{
# rpcbind returns too fast, so sleep for a second # rpcbind returns too fast, so sleep for a second
sleep 1 sleep 1
} }

View File

@@ -4,12 +4,14 @@
description="Saves a kernel dump." description="Saves a kernel dump."
depend() { depend()
{
need checkfs need checkfs
before swap before swap
} }
start() { start()
{
local dump_dir=${dump_dir:-/var/crash} local dump_dir=${dump_dir:-/var/crash}
if ! [ -d "${dump_dir}" ]; then if ! [ -d "${dump_dir}" ]; then
mkdir -p "${dump_dir}" mkdir -p "${dump_dir}"

View File

@@ -2,12 +2,14 @@
# Copyright 2007-2008 Roy Marples # Copyright 2007-2008 Roy Marples
# All rights reserved # All rights reserved
depend() { depend()
{
use hostname use hostname
before bootmisc logger before bootmisc logger
} }
start() { start()
{
[ -e /etc/sysctl.conf ] || return 0 [ -e /etc/sysctl.conf ] || return 0
ebegin "Configuring kernel parameters" ebegin "Configuring kernel parameters"

View File

@@ -7,7 +7,8 @@ command_args=${syslogd_args}
pidfile=/var/run/syslog.pid pidfile=/var/run/syslog.pid
name="System Logger Daemon" name="System Logger Daemon"
depend() { depend()
{
provide logger provide logger
use net use net
need localmount need localmount

View File

@@ -21,7 +21,8 @@ else
utc_cmd="--localtime" utc_cmd="--localtime"
fi fi
depend() { depend()
{
if yesno ${clock_adjfile}; then if yesno ${clock_adjfile}; then
use checkroot use checkroot
else else
@@ -29,7 +30,8 @@ depend() {
fi fi
} }
setupopts() { setupopts()
{
case "${RC_SYS}" in case "${RC_SYS}" in
UML|VPS|XENU) UML|VPS|XENU)
utc="${RC_SYS}" utc="${RC_SYS}"
@@ -55,7 +57,8 @@ setupopts() {
} }
# hwclock doesn't always return non zero on error # hwclock doesn't always return non zero on error
_hwclock() { _hwclock()
{
local err="$(hwclock "$@" 2>&1 >/dev/null)" local err="$(hwclock "$@" 2>&1 >/dev/null)"
[ -z "${err}" ] && return 0 [ -z "${err}" ] && return 0
@@ -63,7 +66,8 @@ _hwclock() {
return 1 return 1
} }
start() { start()
{
local retval=0 errstr="" local retval=0 errstr=""
setupopts setupopts
@@ -97,7 +101,8 @@ start() {
return 0 return 0
} }
stop() { stop()
{
# Don't tweak the hardware clock on LiveCD halt. # Don't tweak the hardware clock on LiveCD halt.
[ -n "${CDBOOT}" ] && return 0 [ -n "${CDBOOT}" ] && return 0
yesno ${clock_systohc} || return 0 yesno ${clock_systohc} || return 0
@@ -122,14 +127,14 @@ stop() {
eend ${retval} "Failed to sync clocks" eend ${retval} "Failed to sync clocks"
} }
save() { save()
{
clock_systohc="yes" clock_systohc="yes"
stop stop
} }
show() { show()
{
setupopts setupopts
hwclock --show "${utc_cmd}" ${clock_args} hwclock --show "${utc_cmd}" ${clock_args}
} }
# vim: set ts=4 :

View File

@@ -4,13 +4,15 @@
description="Sets a font for the consoles." description="Sets a font for the consoles."
depend() { depend()
{
need localmount need localmount
need keymaps # sets up terminal encoding scheme need keymaps # sets up terminal encoding scheme
after hotplug after hotplug
} }
start() { start()
{
# Forget about any font until we are successful # Forget about any font until we are successful
rm -rf "${RC_LIBDIR}"/console rm -rf "${RC_LIBDIR}"/console
@@ -66,7 +68,9 @@ start() {
if [ ${retval} -eq 0 -a -w "${RC_LIBDIR}" ]; then if [ ${retval} -eq 0 -a -w "${RC_LIBDIR}" ]; then
mkdir -p "${RC_LIBDIR}"/console mkdir -p "${RC_LIBDIR}"/console
for font in /usr/share/consolefonts/"${consolefont}".*; do :; done for font in /usr/share/consolefonts/"${consolefont}".*; do
:
done
cp "${font}" "${RC_LIBDIR}"/console cp "${font}" "${RC_LIBDIR}"/console
echo "${font##*/}" > "${RC_LIBDIR}"/console/font echo "${font##*/}" > "${RC_LIBDIR}"/console/font
if yesno ${unicode:-${UNICODE}}; then if yesno ${unicode:-${UNICODE}}; then
@@ -78,5 +82,3 @@ start() {
return ${retval} return ${retval}
} }
# vim: set ts=4 :

View File

@@ -12,11 +12,13 @@ windowskeys=${windowskeys:-${SET_WINDOWSKEYS}}
fix_euro=${fix_euro:-${FIX_EURO}} fix_euro=${fix_euro:-${FIX_EURO}}
dumpkeys_charset=${dumpkeys_charset:-${DUMPKEYS_CHARSET}} dumpkeys_charset=${dumpkeys_charset:-${DUMPKEYS_CHARSET}}
depend() { depend()
{
need localmount need localmount
} }
start() { start()
{
case "${RC_SYS}" in case "${RC_SYS}" in
UML|VPS|XENU) UML|VPS|XENU)
ewarn "Not loading keymaps for ${RC_SYS} systems" ewarn "Not loading keymaps for ${RC_SYS} systems"
@@ -64,7 +66,8 @@ start() {
# See utf-8(7) for more information. # See utf-8(7) for more information.
local termencoding= termmsg= local termencoding= termmsg=
if yesno ${unicode}; then if yesno ${unicode}; then
dumpkeys ${dumpkeys_charset:+-c} ${dumpkeys_charset} | loadkeys --unicode dumpkeys ${dumpkeys_charset:+-c} \
${dumpkeys_charset} | loadkeys --unicode
termencoding="%G" termencoding="%G"
termmsg="UTF-8" termmsg="UTF-8"
else else
@@ -80,5 +83,3 @@ start() {
done done
eend 0 eend 0
} }
# vim: set ts=4 :

View File

@@ -4,12 +4,14 @@
description="Loads a user defined list of kernel modules." description="Loads a user defined list of kernel modules."
depend() { depend()
{
need checkroot need checkroot
use isapnp use isapnp
} }
start() { start()
{
# Should not fail if kernel do not have module # Should not fail if kernel do not have module
# support compiled in ... # support compiled in ...
[ ! -f /proc/modules -o "${RC_SYS}" = "VPS" ] && return 0 [ ! -f /proc/modules -o "${RC_SYS}" = "VPS" ] && return 0
@@ -22,7 +24,10 @@ start() {
local KV_MICRO=${x%%-*} local KV_MICRO=${x%%-*}
local list= x= args= cnt=0 local list= x= args= cnt=0
for x in "${KV}" ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} ${KV_MAJOR}.${KV_MINOR}; do for x in "${KV}" \
${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \
${KV_MAJOR}.${KV_MINOR} \
; do
eval list=\$modules_$(shell_var "${x}") eval list=\$modules_$(shell_var "${x}")
[ -n "${list}" ] && break [ -n "${list}" ] && break
done done
@@ -43,5 +48,3 @@ start() {
# Above test clobbers the return # Above test clobbers the return
return 0 return 0
} }
# vim: set ts=4 :

View File

@@ -6,11 +6,13 @@ description="Turns numlock on for the consoles."
ttyn=${rc_tty_number:-${RC_TTY_NUMBER}:-12} ttyn=${rc_tty_number:-${RC_TTY_NUMBER}:-12}
depend() { depend()
{
need localmount need localmount
} }
_setleds() { _setleds()
{
[ -z "$1" ] && return 1 [ -z "$1" ] && return 1
local dev=/dev/tty t= i=1 retval=0 local dev=/dev/tty t= i=1 retval=0
@@ -24,16 +26,16 @@ _setleds() {
return ${retval} return ${retval}
} }
start() { start()
{
ebegin "Enabling numlock on ttys" ebegin "Enabling numlock on ttys"
_setleds + _setleds +
eend $? "Failed to enable numlock" eend $? "Failed to enable numlock"
} }
stop() { stop()
{
ebegin "Disabling numlock on ttys" ebegin "Disabling numlock on ttys"
_setleds - _setleds -
eend $? "Failed to disable numlock" eend $? "Failed to disable numlock"
} }
# vim: set ts=4 :

View File

@@ -4,11 +4,13 @@
description="Mounts misc filesystems in /proc." description="Mounts misc filesystems in /proc."
depend() { depend()
{
need checkfs need checkfs
} }
start() { start()
{
# Make sure we insert usbcore if its a module # Make sure we insert usbcore if its a module
if [ -f /proc/modules -a ! -d /proc/bus/usb ]; then if [ -f /proc/modules -a ! -d /proc/bus/usb ]; then
modprobe -q usbcore modprobe -q usbcore
@@ -84,5 +86,3 @@ start() {
return 0 return 0
} }
# vim: set ts=4 :

View File

@@ -2,17 +2,17 @@
# Copyright 2007-2008 Roy Marples # Copyright 2007-2008 Roy Marples
# All rights reserved # All rights reserved
depend() { depend()
{
use hostname use hostname
before bootmisc logger before bootmisc logger
} }
start() { start()
{
[ "${RC_SYS}" = "VPS" ] && return 0 [ "${RC_SYS}" = "VPS" ] && return 0
[ -e /etc/sysctl.conf ] || return 0 [ -e /etc/sysctl.conf ] || return 0
ebegin "Configuring kernel parameters" ebegin "Configuring kernel parameters"
sysctl -p /etc/sysctl.conf >/dev/null sysctl -p /etc/sysctl.conf >/dev/null
eend $? eend $?
} }
# vim: set ts=4 :

View File

@@ -2,14 +2,16 @@
# Copyright 2007-2008 Roy Marples # Copyright 2007-2008 Roy Marples
# All rights reserved # All rights reserved
depend() { depend()
{
use hostname use hostname
need localmount need localmount
before logger before logger
after clock sysctl after clock sysctl
} }
cleanup_tmp_dir() { cleanup_tmp_dir()
{
local dir=$1 local dir=$1
mkdir -p "${dir}" mkdir -p "${dir}"
@@ -48,7 +50,8 @@ cleanup_tmp_dir() {
fi fi
} }
start() { start()
{
if ! mkdir /.test.$$ 2>/dev/null; then if ! mkdir /.test.$$ 2>/dev/null; then
ewarn "Skipping /var and /tmp initialization (ro root?)" ewarn "Skipping /var and /tmp initialization (ro root?)"
return 0 return 0
@@ -73,12 +76,14 @@ start() {
ebegin "Cleaning /var/run" ebegin "Cleaning /var/run"
for x in $(find /var/run ! -type d ! -name utmp ! -name innd.pid \ for x in $(find /var/run ! -type d ! -name utmp ! -name innd.pid \
! -name random-seed ! -name ld-elf.so.hints ! -name ld.so.hints); do ! -name random-seed ! -name ld-elf.so.hints \
! -name ld.so.hints); do
[ ! -f "${x}" ] && continue [ ! -f "${x}" ] && continue
# Do not remove pidfiles of already running daemons # Do not remove pidfiles of already running daemons
case "${x}" in case "${x}" in
*.pid) *.pid)
start-stop-daemon --test --quiet --stop --pidfile "${x}" start-stop-daemon --test --quiet --stop \
--pidfile "${x}"
[ $? -eq 0 ] && continue [ $? -eq 0 ] && continue
;; ;;
esac esac
@@ -110,7 +115,8 @@ start() {
rm -f /etc/nologin rm -f /etc/nologin
} }
stop() { stop()
{
# Write a halt record if we're shutting down # Write a halt record if we're shutting down
case "${RC_SOFTLEVEL}" in case "${RC_SOFTLEVEL}" in
reboot|shutdown) [ "${RC_UNAME}" = "Linux" ] && halt -w;; reboot|shutdown) [ "${RC_UNAME}" = "Linux" ] && halt -w;;
@@ -118,5 +124,3 @@ stop() {
return 0 return 0
} }
# vim: set ts=4 :

View File

@@ -5,13 +5,15 @@
description="Check filesystems according to /etc/fstab for errors and \ description="Check filesystems according to /etc/fstab for errors and \
optionally repair them." optionally repair them."
depend() { depend()
{
need checkroot need checkroot
after modules after modules
keywords notimeout keywords notimeout
} }
do_checkfs() { do_checkfs()
{
local retval=0 mode="-p" opts= parts= local retval=0 mode="-p" opts= parts=
ebegin "Checking all filesystems" ebegin "Checking all filesystems"
@@ -56,16 +58,16 @@ do_checkfs() {
return ${retval} return ${retval}
} }
start() { start()
{
do_checkfs do_checkfs
} }
stop() { stop()
{
# fsck on shutdown if we need to # fsck on shutdown if we need to
if yesno "${fsck_shutdown:-${FSCK_SHUTDOWN}}"; then if yesno "${fsck_shutdown:-${FSCK_SHUTDOWN}}"; then
do_checkfs do_checkfs
fi fi
return 0 return 0
} }
# vim: set ts=4 :

View File

@@ -5,11 +5,13 @@
description="Check the root filesystem according to /etc/fstab for errors \ description="Check the root filesystem according to /etc/fstab for errors \
and optionally repair them." and optionally repair them."
depend() { depend()
{
keywords notimeout keywords notimeout
} }
do_mtab() { do_mtab()
{
# Don't create mtab if /etc is readonly # Don't create mtab if /etc is readonly
if ! echo 2>/dev/null >/etc/mtab; then if ! echo 2>/dev/null >/etc/mtab; then
ewarn "Skipping /etc/mtab initialization (ro root)" ewarn "Skipping /etc/mtab initialization (ro root)"
@@ -28,12 +30,14 @@ do_mtab() {
eend 0 eend 0
} }
root_rw() { root_rw()
{
echo 2>/dev/null >/.test.$$ || return 1 echo 2>/dev/null >/.test.$$ || return 1
rm -f /.test.$$ rm -f /.test.$$
} }
do_fsck() { do_fsck()
{
local retval=0 opts= root= local retval=0 opts= root=
case "${RC_UNAME}" in case "${RC_UNAME}" in
FreeBSD) opts="-F";; FreeBSD) opts="-F";;
@@ -104,7 +108,8 @@ do_fsck() {
fi fi
} }
start() { start()
{
do_fsck || return 1 do_fsck || return 1
if ! root_rw; then if ! root_rw; then
@@ -123,5 +128,3 @@ start() {
# We got here, so return 0 # We got here, so return 0
return 0 return 0
} }
# vim: set ts=4 :

View File

@@ -97,5 +97,3 @@ fi
# Always exit 0 here # Always exit 0 here
exit 0 exit 0
# vim: set ts=4 :

View File

@@ -4,15 +4,15 @@
description="Sets the hostname of the machine." description="Sets the hostname of the machine."
depend() { depend()
{
need checkroot need checkroot
} }
start() { start()
{
hostname=${hostname-${HOSTNAME-localhost}} hostname=${hostname-${HOSTNAME-localhost}}
ebegin "Setting hostname to ${hostname}" ebegin "Setting hostname to ${hostname}"
hostname "${hostname}" hostname "${hostname}"
eend $? "Failed to set the hostname" eend $? "Failed to set the hostname"
} }
# vim: set ts=4 :

View File

@@ -4,12 +4,14 @@
description="Executes user commands in /etc/conf.d/local" description="Executes user commands in /etc/conf.d/local"
depend() { depend()
{
after * after *
keywords notimeout keywords notimeout
} }
start() { start()
{
ebegin "Starting local" ebegin "Starting local"
if type local_start >/dev/null 2>&1; then if type local_start >/dev/null 2>&1; then
@@ -24,7 +26,8 @@ start() {
eend $? "Failed to start local" eend $? "Failed to start local"
} }
stop() { stop()
{
ebegin "Stopping local" ebegin "Stopping local"
if type local_start >/dev/null 2>&1; then if type local_start >/dev/null 2>&1; then
@@ -38,5 +41,3 @@ stop() {
eend $? $"Failed to stop local" eend $? $"Failed to stop local"
} }
# vim: set ts=4 :

View File

@@ -4,11 +4,13 @@
description="Mounts disks and swap according to /etc/fstab." description="Mounts disks and swap according to /etc/fstab."
depend() { depend()
{
need checkfs need checkfs
} }
start() { start()
{
# Mount local filesystems in /etc/fstab. # Mount local filesystems in /etc/fstab.
local types="noproc" x= local types="noproc" x=
for x in ${net_fs_list}; do for x in ${net_fs_list}; do
@@ -23,7 +25,8 @@ start() {
return 0 return 0
} }
stop() { stop()
{
# Don't unmount anything for VPS systems # Don't unmount anything for VPS systems
[ "${RC_SYS}" = "VPS" ] && return 0 [ "${RC_SYS}" = "VPS" ] && return 0
@@ -80,5 +83,3 @@ stop() {
return 0 return 0
} }
# vim: set ts=4 :

View File

@@ -4,7 +4,8 @@
description="Mounts network shares according to /etc/fstab." description="Mounts network shares according to /etc/fstab."
need_portmap() { need_portmap()
{
local opts= local opts=
local IFS=" local IFS="
" "
@@ -18,9 +19,10 @@ need_portmap() {
return 1 return 1
} }
depend() { depend()
# Only have portmap as a dependency if there is a nfs mount in fstab that {
# is set to mount at boot # Only have portmap as a dependency if there is a nfs mount in fstab
# that is set to mount at boot
local pmap="" local pmap=""
if need_portmap; then if need_portmap; then
pmap="${pmap} rpc.statd" pmap="${pmap} rpc.statd"
@@ -34,7 +36,8 @@ depend() {
use afc-client amd autofs dns nfs nfsmount portmap rpcbind rpc.statd use afc-client amd autofs dns nfs nfsmount portmap rpcbind rpc.statd
} }
start() { start()
{
local myneed= myuse= pmap="portmap" nfsmounts= local myneed= myuse= pmap="portmap" nfsmounts=
[ -x /etc/init.d/rpcbind ] && pmap="rpcbind" [ -x /etc/init.d/rpcbind ] && pmap="rpcbind"
@@ -42,17 +45,18 @@ start() {
for x in ${net_fs_list}; do for x in ${net_fs_list}; do
case "${x}" in case "${x}" in
nfs|nfs4) nfs|nfs4)
# If the nfsmount script took care of the nfs filesystems, # If the nfsmount script took care of the nfs
# then there's no point in trying them twice # filesystems, then there's no point in trying
service_started nfsmount && continue # them twice
service_started nfsmount && continue
# Only try to mount NFS filesystems if portmap was started. # Only try to mount NFS filesystems if portmap was
# This is to fix "hang" problems for new users who do not # started. This is to fix "hang" problems for new
# add portmap to the default runlevel. # users who do not add portmap to the default runlevel.
if need_portmap && ! service_started "${pmap}"; then if need_portmap && ! service_started "${pmap}"; then
continue continue
fi fi
;; ;;
esac esac
fs="${fs}${fs:+,}${x}" fs="${fs}${fs:+,}${x}"
done done
@@ -63,7 +67,8 @@ start() {
return 0 return 0
} }
stop() { stop()
{
local x= fs= local x= fs=
ebegin "Unmounting network filesystems" ebegin "Unmounting network filesystems"
@@ -73,7 +78,7 @@ stop() {
fs="${fs}${fs:+,}${x}" fs="${fs}${fs:+,}${x}"
done done
if [ -n "${fs}" ]; then if [ -n "${fs}" ]; then
umount -at ${fs} || eerror "Failed to simply unmount filesystems" umount -at ${fs} || eerror "Failed to simply unmount filesystems"
fi fi
eindent eindent
@@ -88,5 +93,3 @@ stop() {
eoutdent eoutdent
eend ${retval} "Failed to unmount network filesystems" eend ${retval} "Failed to unmount network filesystems"
} }
# vim: set ts=4 :

View File

@@ -2,17 +2,20 @@
# Copyright 2007-2008 Roy Marples # Copyright 2007-2008 Roy Marples
# All rights reserved # All rights reserved
depend() { depend()
{
need localmount need localmount
} }
start() { start()
{
ebegin "Activating swap" ebegin "Activating swap"
swapon -a >/dev/null swapon -a >/dev/null
eend 0 # If swapon has nothing todo it errors, so always return 0 eend 0 # If swapon has nothing todo it errors, so always return 0
} }
stop() { stop()
{
ebegin "Deactivating swap" ebegin "Deactivating swap"
swapoff -a >/dev/null swapoff -a >/dev/null
eend 0 eend 0

View File

@@ -6,24 +6,27 @@ urandom_seed=${urandom_seed:-${URANDOM_SEED:-/var/run/random-seed}}
description="Initializes the random number generator." description="Initializes the random number generator."
depend() { depend()
{
need localmount need localmount
} }
save_seed() { save_seed()
local poolsize=1 {
local psz=1
if [ -e /proc/sys/kernel/random/poolsize ]; then if [ -e /proc/sys/kernel/random/poolsize ]; then
poolsize=$(($(cat /proc/sys/kernel/random/poolsize) / 4096)) psz=$(($(cat /proc/sys/kernel/random/poolsize) / 4096))
fi fi
( # sub shell to prevent umask pollution ( # sub shell to prevent umask pollution
umask 077 umask 077
dd if=/dev/urandom of="${urandom_seed}" count=${poolsize} 2>/dev/null dd if=/dev/urandom of="${urandom_seed}" count=${psz} 2>/dev/null
) )
} }
start() { start()
{
[ -c /dev/urandom ] || return [ -c /dev/urandom ] || return
if [ -f "${urandom_seed}" ]; then if [ -f "${urandom_seed}" ]; then
ebegin "Initializing random number generator" ebegin "Initializing random number generator"
@@ -34,10 +37,9 @@ start() {
return 0 return 0
} }
stop() { stop()
{
ebegin "Saving random seed" ebegin "Saving random seed"
save_seed save_seed
eend $? "Failed to save random seed" eend $? "Failed to save random seed"
} }
# vim: set ts=4 :

View File

@@ -4,7 +4,8 @@
# void single_user() # void single_user()
# Drop to a shell, remount / ro, and then reboot # Drop to a shell, remount / ro, and then reboot
single_user() { single_user()
{
exit 1 exit 1
} }
@@ -14,7 +15,8 @@ single_user() {
# be fairly small and we unmount them after the boot level is done anyway # be fairly small and we unmount them after the boot level is done anyway
# NOTE we don't set a size for Linux either # NOTE we don't set a size for Linux either
# FreeBSD-7 supports tmpfs now :) # FreeBSD-7 supports tmpfs now :)
mount_svcdir() { mount_svcdir()
{
local dotmp=false release=false local dotmp=false release=false
if [ -e "${RC_SVCDIR}"/deptree ]; then if [ -e "${RC_SVCDIR}"/deptree ]; then
dotmp=true dotmp=true
@@ -47,5 +49,3 @@ mount_svcdir() {
[ "${RC_UNAME}" = "FreeBSD" ] && sysctl hw.bus.devctl_disable=1 >/dev/null [ "${RC_UNAME}" = "FreeBSD" ] && sysctl hw.bus.devctl_disable=1 >/dev/null
. "${RC_LIBDIR}"/sh/init-common-post.sh . "${RC_LIBDIR}"/sh/init-common-post.sh
# vim: set ts=4 :

View File

@@ -1,28 +1,7 @@
#!/bin/sh #!/bin/sh
# Copyright 2007 Roy Marples # Copyright 2007-2008 Roy Marples
# All rights reserved # All rights reserved
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# Try and set a font and as early as we can # Try and set a font and as early as we can
if [ -e /etc/runlevels/"${RC_DEFAULTLEVEL}"/consolefont \ if [ -e /etc/runlevels/"${RC_DEFAULTLEVEL}"/consolefont \
-o -e /etc/runlevels/"${RC_BOOTLEVEL}"/consolefont ]; then -o -e /etc/runlevels/"${RC_BOOTLEVEL}"/consolefont ]; then

View File

@@ -4,12 +4,14 @@
# All rights reserved # All rights reserved
# udev needs these functions still :/ # udev needs these functions still :/
try() { try()
{
"$@" "$@"
} }
_rc_get_kv_cache= _rc_get_kv_cache=
get_KV() { get_KV()
{
[ -z "${_rc_get_kv_cache}" ] \ [ -z "${_rc_get_kv_cache}" ] \
&& _rc_get_kv_cache="$(uname -r)" && _rc_get_kv_cache="$(uname -r)"
@@ -18,7 +20,8 @@ get_KV() {
return $? return $?
} }
KV_to_int() { KV_to_int()
{
[ -z $1 ] && return 1 [ -z $1 ] && return 1
local x=${1%%-*} local x=${1%%-*}
@@ -36,7 +39,8 @@ KV_to_int() {
echo "${KV_int}" echo "${KV_int}"
} }
single_user() { single_user()
{
if [ "${RC_SYS}" = "VPS" ]; then if [ "${RC_SYS}" = "VPS" ]; then
einfo "Halting" einfo "Halting"
halt -f halt -f
@@ -58,7 +62,8 @@ single_user() {
# which allows us to run depscan.sh # which allows us to run depscan.sh
# The tricky part is finding something our kernel supports # The tricky part is finding something our kernel supports
# tmpfs and ramfs are easy, so force one or the other # tmpfs and ramfs are easy, so force one or the other
mount_svcdir() { mount_svcdir()
{
local fs= fsopts="-o rw,noexec,nodev,nosuid" devdir="none" devtmp="none" x= local fs= fsopts="-o rw,noexec,nodev,nosuid" devdir="none" devtmp="none" x=
local svcsize=${svcsize:-1024} local svcsize=${svcsize:-1024}
@@ -257,5 +262,3 @@ if [ -f /sbin/livecd-functions.sh -a -n "${CDBOOT}" ]; then
fi fi
. "${RC_LIBDIR}"/sh/init-common-post.sh . "${RC_LIBDIR}"/sh/init-common-post.sh
# vim: set ts=4 :

View File

@@ -6,13 +6,15 @@
RC_GOT_FUNCTIONS="yes" RC_GOT_FUNCTIONS="yes"
eindent() { eindent()
{
EINFO_INDENT=$((${EINFO_INDENT:-0} + 2)) EINFO_INDENT=$((${EINFO_INDENT:-0} + 2))
[ "${EINFO_INDENT}" -gt 40 ] && EINFO_INDENT=40 [ "${EINFO_INDENT}" -gt 40 ] && EINFO_INDENT=40
export EINFO_INDENT export EINFO_INDENT
} }
eoutdent() { eoutdent()
{
EINFO_INDENT=$((${EINFO_INDENT:-0} - 2)) EINFO_INDENT=$((${EINFO_INDENT:-0} - 2))
[ "${EINFO_INDENT}" -lt 0 ] && EINFO_INDENT=0 [ "${EINFO_INDENT}" -lt 0 ] && EINFO_INDENT=0
return 0 return 0
@@ -36,7 +38,8 @@ yesno()
esac esac
} }
_sanitize_path() { _sanitize_path()
{
local IFS=":" p= path= local IFS=":" p= path=
for p in ${PATH}; do for p in ${PATH}; do
case "${p}" in case "${p}" in
@@ -81,5 +84,3 @@ else
export EINFO_LASTCMD=${_e}; return \$_r; }" export EINFO_LASTCMD=${_e}; return \$_r; }"
done done
fi fi
# vim: set ts=4 :

View File

@@ -49,11 +49,15 @@ for _dir in /etc/init.d /usr/local/etc/init.d; do
_rc_c=${SVCNAME%%.*} _rc_c=${SVCNAME%%.*}
if [ -n "${_rc_c}" -a "${_rc_c}" != "${SVCNAME}" ]; then if [ -n "${_rc_c}" -a "${_rc_c}" != "${SVCNAME}" ]; then
[ -e "${_dir}/../conf.d/${_rc_c}" ] && . "${_dir}/../conf.d/${_rc_c}" if [ -e "${_dir}/../conf.d/${_rc_c}" ]; then
. "${_dir}/../conf.d/${_rc_c}"
fi
fi fi
unset _rc_c unset _rc_c
[ -e "${_dir}/../conf.d/${SVCNAME}" ] && . "${_dir}/../conf.d/${SVCNAME}" if [ -e "${_dir}/../conf.d/${SVCNAME}" ]; then
. "${_dir}/../conf.d/${SVCNAME}"
fi
[ -e /etc/rc.conf ] && . /etc/rc.conf [ -e /etc/rc.conf ] && . /etc/rc.conf
@@ -71,5 +75,3 @@ for _dir in /etc/init.d /usr/local/etc/init.d; do
) )
done done
done done
# vim: set ts=4 :

View File

@@ -23,5 +23,3 @@ echo "sysinit" > "${RC_SVCDIR}/softlevel"
[ -e /dev/.rcsysinit ] && rm -f /dev/.rcsysinit [ -e /dev/.rcsysinit ] && rm -f /dev/.rcsysinit
exit 0 exit 0
# vim: set ts=4 :

View File

@@ -13,7 +13,8 @@ description="Configures network interfaces."
# Handy var so we don't have to embed new lines everywhere for array splitting # Handy var so we don't have to embed new lines everywhere for array splitting
__IFS=" __IFS="
" "
depend() { depend()
{
local IFACE=${SVCNAME#*.} local IFACE=${SVCNAME#*.}
local IFVAR=$(shell_var "${IFACE}") local IFVAR=$(shell_var "${IFACE}")
@@ -43,7 +44,8 @@ depend() {
} }
# Support bash arrays - sigh # Support bash arrays - sigh
_get_array() { _get_array()
{
local _a= local _a=
if [ -n "${BASH}" ]; then if [ -n "${BASH}" ]; then
case "$(declare -p "$1" 2>/dev/null)" in case "$(declare -p "$1" 2>/dev/null)" in
@@ -64,7 +66,8 @@ _get_array() {
} }
# Flatten bash arrays to simple strings # Flatten bash arrays to simple strings
_flatten_array() { _flatten_array()
{
if [ -n "${BASH}" ]; then if [ -n "${BASH}" ]; then
case "$(declare -p "$1" 2>/dev/null)" in case "$(declare -p "$1" 2>/dev/null)" in
"declare -a "*) "declare -a "*)
@@ -83,7 +86,8 @@ _flatten_array() {
[ -n "${_a}" ] [ -n "${_a}" ]
} }
_wait_for_carrier() { _wait_for_carrier()
{
local timeout= efunc=einfon local timeout= efunc=einfon
_has_carrier && return 0 _has_carrier && return 0
@@ -112,7 +116,8 @@ _wait_for_carrier() {
return 1 return 1
} }
_netmask2cidr() { _netmask2cidr()
{
# Some shells cannot handle hex arithmetic, so we massage it slightly # Some shells cannot handle hex arithmetic, so we massage it slightly
# Buggy shells include FreeBSD sh, dash and busybox. # Buggy shells include FreeBSD sh, dash and busybox.
# bash and NetBSD sh don't need this. # bash and NetBSD sh don't need this.
@@ -140,7 +145,8 @@ _netmask2cidr() {
echo "${len}" echo "${len}"
} }
_configure_variables() { _configure_variables()
{
local var= v= t= local var= v= t=
for var in ${_config_vars}; do for var in ${_config_vars}; do
@@ -155,12 +161,14 @@ _configure_variables() {
done done
} }
_show_address() { _show_address()
{
einfo "received address $(_get_inet_address "${IFACE}")" einfo "received address $(_get_inet_address "${IFACE}")"
} }
# Basically sorts our modules into order and saves the list # Basically sorts our modules into order and saves the list
_gen_module_list() { _gen_module_list()
{
local x= f= force=$1 local x= f= force=$1
if ! ${force} && [ -s "${MODULESLIST}" -a "${MODULESLIST}" -nt "${MODULESDIR}" ]; then if ! ${force} && [ -s "${MODULESLIST}" -a "${MODULESLIST}" -nt "${MODULESDIR}" ]; then
local update=false local update=false
@@ -269,7 +277,8 @@ _gen_module_list() {
return 0 return 0
} }
_load_modules() { _load_modules()
{
local starting=$1 mymods= local starting=$1 mymods=
# Ensure our list is up to date # Ensure our list is up to date
@@ -380,7 +389,8 @@ _load_modules() {
veinfo "Loaded modules: ${MODULES}" veinfo "Loaded modules: ${MODULES}"
} }
_load_config() { _load_config()
{
local config="$(_get_array "config_${IFVAR}")" local config="$(_get_array "config_${IFVAR}")"
local fallback="$(_get_array fallback_${IFVAR})" local fallback="$(_get_array fallback_${IFVAR})"
@@ -437,7 +447,8 @@ _load_config() {
config_index=-1 config_index=-1
} }
start() { start()
{
local IFACE=${SVCNAME#*.} oneworked=false module= local IFACE=${SVCNAME#*.} oneworked=false module=
local IFVAR=$(shell_var "${IFACE}") cmd= our_metric= local IFVAR=$(shell_var "${IFACE}") cmd= our_metric=
local metric=0 local metric=0
@@ -612,7 +623,8 @@ ${routes}"
return 0 return 0
} }
stop() { stop()
{
local IFACE=${SVCNAME#*.} module= local IFACE=${SVCNAME#*.} module=
local IFVAR=$(shell_var "${IFACE}") opts= local IFVAR=$(shell_var "${IFACE}") opts=
@@ -677,5 +689,3 @@ stop() {
return 0 return 0
} }
# vim: set ts=4 sw=4 :

View File

@@ -2,11 +2,13 @@
# Copyright 2007-2008 Roy Marples # Copyright 2007-2008 Roy Marples
# All rights reserved # All rights reserved
has_addon() { has_addon()
{
[ -e "${RC_LIBDIR}/addons/$1.sh" ] || [ -e /lib/rcscripts/addons/"$1".sh ] [ -e "${RC_LIBDIR}/addons/$1.sh" ] || [ -e /lib/rcscripts/addons/"$1".sh ]
} }
import_addon() { import_addon()
{
if [ -e "${RC_LIBDIR}/addons/$1.sh" ]; then if [ -e "${RC_LIBDIR}/addons/$1.sh" ]; then
. "${RC_LIBDIR}/addons/$1.sh" . "${RC_LIBDIR}/addons/$1.sh"
elif [ -e /lib/rcscripts/addons/"$1".sh ]; then elif [ -e /lib/rcscripts/addons/"$1".sh ]; then
@@ -16,16 +18,19 @@ import_addon() {
fi fi
} }
start_addon() { start_addon()
{
( import_addon "$1-start" ) ( import_addon "$1-start" )
} }
stop_addon() { stop_addon()
{
( import_addon "$1-stop" ) ( import_addon "$1-stop" )
} }
net_fs_list="afs cifs coda davfs fuse gfs ncpfs nfs nfs4 ocfs2 shfs smbfs" net_fs_list="afs cifs coda davfs fuse gfs ncpfs nfs nfs4 ocfs2 shfs smbfs"
is_net_fs() { is_net_fs()
{
[ -z "$1" ] && return 1 [ -z "$1" ] && return 1
# Check OS specific flags to see if we're local or net mounted # Check OS specific flags to see if we're local or net mounted
@@ -40,12 +45,14 @@ is_net_fs() {
return 1 return 1
} }
is_union_fs() { is_union_fs()
{
[ ! -x /sbin/unionctl ] && return 1 [ ! -x /sbin/unionctl ] && return 1
unionctl "$1" --list >/dev/null 2>&1 unionctl "$1" --list >/dev/null 2>&1
} }
get_bootparam() { get_bootparam()
{
local match="$1" local match="$1"
[ -z "${match}" -o ! -r /proc/cmdline ] && return 1 [ -z "${match}" -o ! -r /proc/cmdline ] && return 1
@@ -71,5 +78,3 @@ case "${PATH}" in
/lib/rc/sbin|/lib/rc/sbin:*);; /lib/rc/sbin|/lib/rc/sbin:*);;
*) export PATH="/lib/rc/sbin:${PATH}";; *) export PATH="/lib/rc/sbin:${PATH}";;
esac esac
# vim: set ts=4 :

View File

@@ -5,7 +5,8 @@
# mountinfo is a C program to actually find our mounts on our supported OS's # mountinfo is a C program to actually find our mounts on our supported OS's
# We rely on fuser being preset, so if it's not then we don't unmount anything. # We rely on fuser being preset, so if it's not then we don't unmount anything.
# This isn't a real issue for the BSD's, but it is for Linux. # This isn't a real issue for the BSD's, but it is for Linux.
do_unmount() { do_unmount()
{
type fuser >/dev/null 2>&1 || return 0 type fuser >/dev/null 2>&1 || return 0
local cmd="$1" retval=0 retry= local cmd="$1" retval=0 retry=
@@ -73,5 +74,3 @@ do_unmount() {
done done
return ${retval} return ${retval}
} }
# vim: set ts=4 :

View File

@@ -19,7 +19,8 @@ if [ -z "$1" -o -z "$2" ]; then
fi fi
# Descript the init script to the user # Descript the init script to the user
describe() { describe()
{
if [ -n "${description}" ]; then if [ -n "${description}" ]; then
einfo "${description}" einfo "${description}"
else else
@@ -135,10 +136,11 @@ while [ -n "$1" ]; do
${extra_started_commands}; do ${extra_started_commands}; do
if [ "${_cmd}" = "$1" ]; then if [ "${_cmd}" = "$1" ]; then
if type "$1" >/dev/null 2>&1; then if type "$1" >/dev/null 2>&1; then
# If we're in the background, we may wish to fake some # If we're in the background, we may wish to
# commands. We do this so we can "start" ourselves from # fake some commands. We do this so we can
# inactive which then triggers other services to start # "start" ourselves from inactive which then
# which depend on us. A good example of this is openvpn. # triggers other services to start which depend
# on us. A good example of this is openvpn.
if yesno ${IN_BACKGROUND}; then if yesno ${IN_BACKGROUND}; then
for _cmd in ${in_background_fake}; do for _cmd in ${in_background_fake}; do
if [ "${_cmd}" = "$1" ]; then if [ "${_cmd}" = "$1" ]; then
@@ -147,8 +149,8 @@ while [ -n "$1" ]; do
fi fi
done done
fi fi
# Check to see if we need to be started before we can run # Check to see if we need to be started before
# this command # we can run this command
for _cmd in ${extra_started_commands}; do for _cmd in ${extra_started_commands}; do
if [ "${_cmd}" = "$1" ]; then if [ "${_cmd}" = "$1" ]; then
if ! service_started "${SVCNAME}"; then if ! service_started "${SVCNAME}"; then
@@ -180,5 +182,3 @@ while [ -n "$1" ]; do
eerror "${SVCNAME}: unknown function \`$1'" eerror "${SVCNAME}: unknown function \`$1'"
exit 1 exit 1
done done
# vim: set ts=4 :