Rework our folder structure so that we don't have OS specific dirs, making it easier to share init and conf files per OS.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
DIR= ${INITDIR}
|
||||
SRCS= bootmisc.in fsck.in halt.sh.in hostname.in local.in localmount.in \
|
||||
netmount.in root.in swap.in urandom.in
|
||||
netmount.in root.in swap.in sysctl.in urandom.in
|
||||
BIN= ${OBJS}
|
||||
|
||||
MK= ../mk
|
||||
include ${MK}/os.mk
|
||||
include Makefile.${OS}
|
||||
include ${MK}/scripts.mk
|
||||
|
1
init.d/Makefile.FreeBSD
Normal file
1
init.d/Makefile.FreeBSD
Normal file
@@ -0,0 +1 @@
|
||||
SRCS+= adjkerntz.in devd.in dumpon.in ipfw.in mixer.in nscd.in powerd.in syscons.in
|
2
init.d/Makefile.Linux
Normal file
2
init.d/Makefile.Linux
Normal file
@@ -0,0 +1,2 @@
|
||||
SRCS+= hwclock.in consolefont.in keymaps.in modules.in mtab.in numlock.in \
|
||||
procfs.in
|
6
init.d/Makefile.NetBSD
Normal file
6
init.d/Makefile.NetBSD
Normal file
@@ -0,0 +1,6 @@
|
||||
# Generic BSD scripts
|
||||
SRCS+= hostid.in moused.in newsyslog.in pf.in rarpd.in rc-enabled.in \
|
||||
rpcbind.in savecore.in sysctl.in syslogd.in
|
||||
|
||||
# These are NetBSD specific
|
||||
SRCS+= swap-blk.in ttys.in wscons.in
|
62
init.d/adjkerntz.in
Normal file
62
init.d/adjkerntz.in
Normal file
@@ -0,0 +1,62 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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()
|
||||
{
|
||||
provide clock
|
||||
# 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
|
||||
}
|
78
init.d/consolefont.in
Normal file
78
init.d/consolefont.in
Normal file
@@ -0,0 +1,78 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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 noopenvz noprefix nouml novserver 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}
|
||||
}
|
22
init.d/devd.in
Normal file
22
init.d/devd.in
Normal file
@@ -0,0 +1,22 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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
|
||||
}
|
25
init.d/dumpon.in
Normal file
25
init.d/dumpon.in
Normal file
@@ -0,0 +1,25 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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 $?
|
||||
}
|
78
init.d/hostid.in
Normal file
78
init.d/hostid.in
Normal file
@@ -0,0 +1,78 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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
|
||||
}
|
137
init.d/hwclock.in
Normal file
137
init.d/hwclock.in
Normal file
@@ -0,0 +1,137 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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()
|
||||
{
|
||||
provide clock
|
||||
if yesno ${clock_adjfile}; then
|
||||
use root
|
||||
else
|
||||
before *
|
||||
fi
|
||||
keyword noopenvz noprefix nouml novserver 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}
|
||||
}
|
149
init.d/ipfw.in
Normal file
149
init.d/ipfw.in
Normal file
@@ -0,0 +1,149 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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
|
||||
}
|
69
init.d/keymaps.in
Normal file
69
init.d/keymaps.in
Normal file
@@ -0,0 +1,69 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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 noopenvz noprefix nouml novserver 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
|
||||
}
|
47
init.d/mixer.in
Normal file
47
init.d/mixer.in
Normal file
@@ -0,0 +1,47 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# All rights reserved. Released under the 2-clause BSD license.
|
||||
|
||||
extra_commands="restore"
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
keyword nojail noprefix
|
||||
}
|
||||
|
||||
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}
|
||||
}
|
59
init.d/modules.in
Normal file
59
init.d/modules.in
Normal file
@@ -0,0 +1,59 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# All rights reserved. Released under the 2-clause BSD license.
|
||||
|
||||
description="Loads a user defined list of kernel modules."
|
||||
|
||||
depend()
|
||||
{
|
||||
use isapnp
|
||||
keyword noopenvz noprefix novserver
|
||||
}
|
||||
|
||||
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= xx= y= 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}"
|
||||
xx=$(shell_var "${x}")
|
||||
for y in "${KV}" \
|
||||
${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \
|
||||
${KV_MAJOR}.${KV_MINOR} \
|
||||
; do
|
||||
eval args=\$module_${xx}_args_$(shell_var "${y}")
|
||||
[ -n "${args}" ] && break
|
||||
done
|
||||
done
|
||||
[ -z "${args}" ] && eval args=\$module_${xx}_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
|
||||
}
|
62
init.d/moused.in
Normal file
62
init.d/moused.in
Normal file
@@ -0,0 +1,62 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# All rights reserved. Released under the 2-clause BSD license.
|
||||
|
||||
mouse=${RC_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"
|
||||
}
|
30
init.d/mtab.in
Normal file
30
init.d/mtab.in
Normal file
@@ -0,0 +1,30 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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
|
||||
}
|
18
init.d/newsyslog.in
Normal file
18
init.d/newsyslog.in
Normal file
@@ -0,0 +1,18 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# All rights reserved. Released under the 2-clause BSD license.
|
||||
|
||||
required_files="/etc/newsyslog.conf"
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
keyword noprefix
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
ebegin "Creating and/or trimming log files"
|
||||
newsyslog -s ${newsyslog_args}
|
||||
eend $?
|
||||
}
|
22
init.d/nscd.in
Normal file
22
init.d/nscd.in
Normal file
@@ -0,0 +1,22 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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 $?
|
||||
}
|
42
init.d/numlock.in
Normal file
42
init.d/numlock.in
Normal file
@@ -0,0 +1,42 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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 noopenvz noprefix novserver
|
||||
}
|
||||
|
||||
_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"
|
||||
}
|
59
init.d/pf.in
Normal file
59
init.d/pf.in
Normal file
@@ -0,0 +1,59 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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
|
||||
}
|
35
init.d/powerd.in
Normal file
35
init.d/powerd.in
Normal file
@@ -0,0 +1,35 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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 noprefix
|
||||
}
|
||||
|
||||
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
|
||||
}
|
89
init.d/procfs.in
Normal file
89
init.d/procfs.in
Normal file
@@ -0,0 +1,89 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# All rights reserved. Released under the 2-clause BSD license.
|
||||
|
||||
description="Mounts misc filesystems in /proc."
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
keyword noopenvz noprefix novserver
|
||||
}
|
||||
|
||||
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
|
||||
}
|
28
init.d/rarpd.in
Normal file
28
init.d/rarpd.in
Normal file
@@ -0,0 +1,28 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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
|
||||
}
|
54
init.d/rc-enabled.in
Normal file
54
init.d/rc-enabled.in
Normal file
@@ -0,0 +1,54 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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/* @PKG_PREFIX@/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 @SYSCONFDIR@/init.d/"${service}" ] && continue
|
||||
[ -x @PKG_PREFIX@/@SYSCONFDIR@/init.d/"${service}" ] && continue
|
||||
[ -x @LOCAL_PREFIX@/@SYSCONFDIR@/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
|
||||
}
|
21
init.d/rpcbind.in
Normal file
21
init.d/rpcbind.in
Normal file
@@ -0,0 +1,21 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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
|
||||
}
|
36
init.d/savecore.in
Normal file
36
init.d/savecore.in
Normal file
@@ -0,0 +1,36 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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 $?
|
||||
}
|
23
init.d/swap-blk.in
Normal file
23
init.d/swap-blk.in
Normal file
@@ -0,0 +1,23 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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
|
||||
}
|
83
init.d/syscons.in
Normal file
83
init.d/syscons.in
Normal file
@@ -0,0 +1,83 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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} </dev/console
|
||||
eend $?
|
||||
fi
|
||||
|
||||
if [ -n "${keyrate}" ]; then
|
||||
ebegin "Setting keyrate to ${keyrate}"
|
||||
kbdcontrol -r ${keyrate} </dev/console
|
||||
eend $?
|
||||
fi
|
||||
|
||||
if [ -n "${keychange}" ]; then
|
||||
ebegin "Changing function keys"
|
||||
eval set -- "${keychange}"
|
||||
eindent
|
||||
while [ $# -gt 0 ]; do
|
||||
veinfo "F$1 -> \`$2'"
|
||||
kbdcontrol -f "$1" "$2" </dev/console
|
||||
veend $?
|
||||
shift; shift
|
||||
done
|
||||
eoutdent
|
||||
fi
|
||||
|
||||
if [ -n "${cursor}" ]; then
|
||||
ebegin "Setting cursor"
|
||||
vidcontrol -c ${cursor}
|
||||
eend $?
|
||||
fi
|
||||
|
||||
local v= f=
|
||||
for v in font8x16 font8x14 font8x8; do
|
||||
f=$(eval \$"${v}")
|
||||
if [ -n "${f}" ]; then
|
||||
ebegin "Setting font ${f}"
|
||||
vidcontrol -f ${v##FONT} ${f}
|
||||
eend $?
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "${blanktime}" ]; then
|
||||
ebegin "Setting blanktime"
|
||||
vidcontrol -t ${blanktime}
|
||||
eend $?
|
||||
fi
|
||||
|
||||
if [ -n "${saver}" ]; then
|
||||
local i=
|
||||
for i in $(kldstat | sed -n -e 's/.* \(splash_.*\)/\1/p'); do
|
||||
kldunload "${i}"
|
||||
done
|
||||
kldstat -v | grep -q _saver || kldload ${saver}_saver
|
||||
fi
|
||||
|
||||
if [ -n "${kbdflags}" ]; then
|
||||
ebegin "Setting keyboard flags for all screens"
|
||||
for v in /dev/ttyv*; do
|
||||
kbdcontrol ${kbdflags} <${v}
|
||||
done
|
||||
eend $?
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
26
init.d/sysctl.in
Normal file
26
init.d/sysctl.in
Normal file
@@ -0,0 +1,26 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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 $?
|
||||
}
|
20
init.d/syslogd.in
Normal file
20
init.d/syslogd.in
Normal file
@@ -0,0 +1,20 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||
# 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
|
||||
keyword noprefix
|
||||
}
|
23
init.d/ttys.in
Normal file
23
init.d/ttys.in
Normal file
@@ -0,0 +1,23 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2008 Roy Marples <roy@marples.name>
|
||||
# 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
|
||||
}
|
100
init.d/wscons.in
Normal file
100
init.d/wscons.in
Normal file
@@ -0,0 +1,100 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2008 Roy Marples <roy@marples.name>
|
||||
# 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}"
|
||||
}
|
Reference in New Issue
Block a user