From 55eb3794fb4ad563102d5ab30c1d5337a599b2e5 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Tue, 25 Mar 2008 14:06:05 +0000 Subject: Rework our folder structure so that we don't have OS specific dirs, making it easier to share init and conf files per OS. --- conf.d.BSD/Makefile | 5 - conf.d.BSD/localmount | 29 ---- conf.d.BSD/moused | 16 -- conf.d.BSD/powerd | 7 - conf.d.BSD/rarpd | 3 - conf.d.FreeBSD/Makefile | 5 - conf.d.FreeBSD/syscons | 19 --- conf.d.Linux/Makefile | 6 - conf.d.Linux/clock | 9 -- conf.d.Linux/consolefont | 17 -- conf.d.Linux/keymaps | 21 --- conf.d.Linux/modules | 15 -- conf.d/Makefile | 2 +- conf.d/Makefile.FreeBSD | 1 + conf.d/Makefile.Linux | 1 + conf.d/Makefile.NetBSD | 1 + conf.d/adjkerntz | 10 ++ conf.d/clock | 10 -- conf.d/consolefont | 17 ++ conf.d/hwclock | 14 ++ conf.d/keymaps | 21 +++ conf.d/modules | 15 ++ conf.d/moused | 16 ++ conf.d/powerd | 7 + conf.d/rarpd | 3 + conf.d/savecore | 25 +++ conf.d/syscons | 19 +++ etc.BSD/.gitignore | 2 - etc.BSD/Makefile | 10 -- etc.BSD/Makefile.FreeBSD | 1 - etc.BSD/Makefile.NetBSD | 1 - etc.BSD/rc.in | 22 --- etc.BSD/rc.shutdown.in | 26 --- etc.FreeBSD/Makefile | 6 - etc.FreeBSD/devd.conf | 315 ------------------------------------- etc.FreeBSD/rc.devd | 31 ---- etc.Linux/Makefile | 5 - etc.Linux/rc.conf | 25 --- etc/Makefile | 2 + etc/Makefile.FreeBSD | 4 + etc/Makefile.Linux | 6 + etc/Makefile.NetBSD | 2 + etc/devd.conf | 315 +++++++++++++++++++++++++++++++++++++ etc/rc.conf | 91 ----------- etc/rc.conf.Linux | 25 +++ etc/rc.conf.in | 91 +++++++++++ etc/rc.devd | 31 ++++ etc/rc.in | 22 +++ etc/rc.shutdown.in | 26 +++ init.d.BSD/.gitignore | 10 -- init.d.BSD/Makefile | 7 - init.d.BSD/hostid.in | 78 --------- init.d.BSD/moused.in | 62 -------- init.d.BSD/newsyslog.in | 18 --- init.d.BSD/pf.in | 59 ------- init.d.BSD/rarpd.in | 28 ---- init.d.BSD/rc-enabled.in | 54 ------- init.d.BSD/rpcbind.in | 21 --- init.d.BSD/savecore.in | 36 ----- init.d.BSD/sysctl.in | 26 --- init.d.BSD/syslogd.in | 20 --- init.d.FreeBSD/.gitignore | 8 - init.d.FreeBSD/Makefile | 6 - init.d.FreeBSD/clock.in | 61 ------- init.d.FreeBSD/devd.in | 22 --- init.d.FreeBSD/dumpon.in | 25 --- init.d.FreeBSD/ipfw.in | 149 ------------------ init.d.FreeBSD/mixer.in | 47 ------ init.d.FreeBSD/nscd.in | 22 --- init.d.FreeBSD/powerd.in | 35 ----- init.d.FreeBSD/syscons.in | 83 ---------- init.d.Linux/.gitignore | 8 - init.d.Linux/Makefile | 7 - init.d.Linux/clock.in | 136 ---------------- init.d.Linux/consolefont.in | 78 --------- init.d.Linux/keymaps.in | 69 -------- init.d.Linux/modules.in | 59 ------- init.d.Linux/mtab.in | 30 ---- init.d.Linux/numlock.in | 42 ----- init.d.Linux/procfs.in | 89 ----------- init.d.Linux/sysctl.in | 18 --- init.d.NetBSD/.gitignore | 3 - init.d.NetBSD/Makefile | 6 - init.d.NetBSD/swap-blk.in | 23 --- init.d.NetBSD/ttys.in | 23 --- init.d.NetBSD/wscons.in | 100 ------------ init.d/Makefile | 4 +- init.d/Makefile.FreeBSD | 1 + init.d/Makefile.Linux | 2 + init.d/Makefile.NetBSD | 6 + init.d/adjkerntz.in | 62 ++++++++ init.d/consolefont.in | 78 +++++++++ init.d/devd.in | 22 +++ init.d/dumpon.in | 25 +++ init.d/hostid.in | 78 +++++++++ init.d/hwclock.in | 137 ++++++++++++++++ init.d/ipfw.in | 149 ++++++++++++++++++ init.d/keymaps.in | 69 ++++++++ init.d/mixer.in | 47 ++++++ init.d/modules.in | 59 +++++++ init.d/moused.in | 62 ++++++++ init.d/mtab.in | 30 ++++ init.d/newsyslog.in | 18 +++ init.d/nscd.in | 22 +++ init.d/numlock.in | 42 +++++ init.d/pf.in | 59 +++++++ init.d/powerd.in | 35 +++++ init.d/procfs.in | 89 +++++++++++ init.d/rarpd.in | 28 ++++ init.d/rc-enabled.in | 54 +++++++ init.d/rpcbind.in | 21 +++ init.d/savecore.in | 36 +++++ init.d/swap-blk.in | 23 +++ init.d/syscons.in | 83 ++++++++++ init.d/sysctl.in | 26 +++ init.d/syslogd.in | 20 +++ init.d/ttys.in | 23 +++ init.d/wscons.in | 100 ++++++++++++ mk/scripts.mk | 31 ++-- net.NetBSD/Makefile | 5 - net.NetBSD/ifwatchd.sh | 60 ------- net/Makefile | 2 + net/Makefile.FreeBSD | 0 net/Makefile.Linux | 0 net/Makefile.NetBSD | 1 + net/ifwatchd.sh | 60 +++++++ runlevels/Makefile | 1 - runlevels/Makefile.FreeBSD | 6 +- runlevels/Makefile.Linux | 2 +- runlevels/Makefile.NetBSD | 6 +- sh.BSD/.gitignore | 1 - sh.BSD/Makefile | 6 - sh.BSD/init.sh.in | 51 ------ sh.Linux/.gitignore | 2 - sh.Linux/Makefile | 6 - sh.Linux/init-early.sh.in | 20 --- sh.Linux/init.sh.in | 185 ---------------------- sh.NetBSD/.gitignore | 2 - sh.NetBSD/Makefile | 6 - sh.NetBSD/ifwatchd-carrier.sh.in | 5 - sh.NetBSD/ifwatchd-nocarrier.sh.in | 5 - sh/Makefile | 6 +- sh/Makefile.BSD | 1 - sh/Makefile.FreeBSD | 8 + sh/Makefile.Linux | 9 +- sh/Makefile.NetBSD | 10 ++ sh/ifwatchd-carrier.sh.in | 5 + sh/ifwatchd-nocarrier.sh.in | 5 + sh/init-early.Linux.sh.in | 20 +++ sh/init.BSD.sh.in | 51 ++++++ sh/init.Linux.sh.in | 185 ++++++++++++++++++++++ 151 files changed, 2570 insertions(+), 2644 deletions(-) delete mode 100644 conf.d.BSD/Makefile delete mode 100644 conf.d.BSD/localmount delete mode 100644 conf.d.BSD/moused delete mode 100644 conf.d.BSD/powerd delete mode 100644 conf.d.BSD/rarpd delete mode 100644 conf.d.FreeBSD/Makefile delete mode 100644 conf.d.FreeBSD/syscons delete mode 100644 conf.d.Linux/Makefile delete mode 100644 conf.d.Linux/clock delete mode 100644 conf.d.Linux/consolefont delete mode 100644 conf.d.Linux/keymaps delete mode 100644 conf.d.Linux/modules create mode 100644 conf.d/Makefile.FreeBSD create mode 100644 conf.d/Makefile.Linux create mode 100644 conf.d/Makefile.NetBSD create mode 100644 conf.d/adjkerntz delete mode 100644 conf.d/clock create mode 100644 conf.d/consolefont create mode 100644 conf.d/hwclock create mode 100644 conf.d/keymaps create mode 100644 conf.d/modules create mode 100644 conf.d/moused create mode 100644 conf.d/powerd create mode 100644 conf.d/rarpd create mode 100644 conf.d/savecore create mode 100644 conf.d/syscons delete mode 100644 etc.BSD/.gitignore delete mode 100644 etc.BSD/Makefile delete mode 100644 etc.BSD/Makefile.FreeBSD delete mode 100644 etc.BSD/Makefile.NetBSD delete mode 100644 etc.BSD/rc.in delete mode 100644 etc.BSD/rc.shutdown.in delete mode 100644 etc.FreeBSD/Makefile delete mode 100644 etc.FreeBSD/devd.conf delete mode 100644 etc.FreeBSD/rc.devd delete mode 100644 etc.Linux/Makefile delete mode 100644 etc.Linux/rc.conf create mode 100644 etc/Makefile.FreeBSD create mode 100644 etc/Makefile.Linux create mode 100644 etc/Makefile.NetBSD create mode 100644 etc/devd.conf delete mode 100644 etc/rc.conf create mode 100644 etc/rc.conf.Linux create mode 100644 etc/rc.conf.in create mode 100644 etc/rc.devd create mode 100644 etc/rc.in create mode 100644 etc/rc.shutdown.in delete mode 100644 init.d.BSD/.gitignore delete mode 100644 init.d.BSD/Makefile delete mode 100644 init.d.BSD/hostid.in delete mode 100644 init.d.BSD/moused.in delete mode 100644 init.d.BSD/newsyslog.in delete mode 100644 init.d.BSD/pf.in delete mode 100644 init.d.BSD/rarpd.in delete mode 100644 init.d.BSD/rc-enabled.in delete mode 100644 init.d.BSD/rpcbind.in delete mode 100644 init.d.BSD/savecore.in delete mode 100644 init.d.BSD/sysctl.in delete mode 100644 init.d.BSD/syslogd.in delete mode 100644 init.d.FreeBSD/.gitignore delete mode 100644 init.d.FreeBSD/Makefile delete mode 100644 init.d.FreeBSD/clock.in delete mode 100644 init.d.FreeBSD/devd.in delete mode 100644 init.d.FreeBSD/dumpon.in delete mode 100644 init.d.FreeBSD/ipfw.in delete mode 100644 init.d.FreeBSD/mixer.in delete mode 100644 init.d.FreeBSD/nscd.in delete mode 100644 init.d.FreeBSD/powerd.in delete mode 100644 init.d.FreeBSD/syscons.in delete mode 100644 init.d.Linux/.gitignore delete mode 100644 init.d.Linux/Makefile delete mode 100644 init.d.Linux/clock.in delete mode 100644 init.d.Linux/consolefont.in delete mode 100644 init.d.Linux/keymaps.in delete mode 100644 init.d.Linux/modules.in delete mode 100644 init.d.Linux/mtab.in delete mode 100644 init.d.Linux/numlock.in delete mode 100644 init.d.Linux/procfs.in delete mode 100644 init.d.Linux/sysctl.in delete mode 100644 init.d.NetBSD/.gitignore delete mode 100644 init.d.NetBSD/Makefile delete mode 100644 init.d.NetBSD/swap-blk.in delete mode 100644 init.d.NetBSD/ttys.in delete mode 100644 init.d.NetBSD/wscons.in create mode 100644 init.d/Makefile.FreeBSD create mode 100644 init.d/Makefile.Linux create mode 100644 init.d/Makefile.NetBSD create mode 100644 init.d/adjkerntz.in create mode 100644 init.d/consolefont.in create mode 100644 init.d/devd.in create mode 100644 init.d/dumpon.in create mode 100644 init.d/hostid.in create mode 100644 init.d/hwclock.in create mode 100644 init.d/ipfw.in create mode 100644 init.d/keymaps.in create mode 100644 init.d/mixer.in create mode 100644 init.d/modules.in create mode 100644 init.d/moused.in create mode 100644 init.d/mtab.in create mode 100644 init.d/newsyslog.in create mode 100644 init.d/nscd.in create mode 100644 init.d/numlock.in create mode 100644 init.d/pf.in create mode 100644 init.d/powerd.in create mode 100644 init.d/procfs.in create mode 100644 init.d/rarpd.in create mode 100644 init.d/rc-enabled.in create mode 100644 init.d/rpcbind.in create mode 100644 init.d/savecore.in create mode 100644 init.d/swap-blk.in create mode 100644 init.d/syscons.in create mode 100644 init.d/sysctl.in create mode 100644 init.d/syslogd.in create mode 100644 init.d/ttys.in create mode 100644 init.d/wscons.in delete mode 100644 net.NetBSD/Makefile delete mode 100644 net.NetBSD/ifwatchd.sh create mode 100644 net/Makefile.FreeBSD create mode 100644 net/Makefile.Linux create mode 100644 net/Makefile.NetBSD create mode 100644 net/ifwatchd.sh delete mode 100644 sh.BSD/.gitignore delete mode 100644 sh.BSD/Makefile delete mode 100644 sh.BSD/init.sh.in delete mode 100644 sh.Linux/.gitignore delete mode 100644 sh.Linux/Makefile delete mode 100644 sh.Linux/init-early.sh.in delete mode 100644 sh.Linux/init.sh.in delete mode 100644 sh.NetBSD/.gitignore delete mode 100644 sh.NetBSD/Makefile delete mode 100644 sh.NetBSD/ifwatchd-carrier.sh.in delete mode 100644 sh.NetBSD/ifwatchd-nocarrier.sh.in delete mode 100644 sh/Makefile.BSD create mode 100644 sh/Makefile.FreeBSD create mode 100644 sh/Makefile.NetBSD create mode 100644 sh/ifwatchd-carrier.sh.in create mode 100644 sh/ifwatchd-nocarrier.sh.in create mode 100644 sh/init-early.Linux.sh.in create mode 100644 sh/init.BSD.sh.in create mode 100644 sh/init.Linux.sh.in diff --git a/conf.d.BSD/Makefile b/conf.d.BSD/Makefile deleted file mode 100644 index 7131f675..00000000 --- a/conf.d.BSD/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -DIR= ${CONFDIR} -CONF= localmount moused powerd rarpd - -MK= ../mk -include ${MK}/scripts.mk diff --git a/conf.d.BSD/localmount b/conf.d.BSD/localmount deleted file mode 100644 index 61f2d1b9..00000000 --- a/conf.d.BSD/localmount +++ /dev/null @@ -1,29 +0,0 @@ -# Kernel core dump options for FreeBSD kernel. -# Unless you're a FreeBSD kernel developer or driver writer then this won't -# be of any interest to you at all. - -# The following options allow to configure the kernel's core dump -# facilities. Please read -# http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/kerneldebug.html -# for more information about Kernel core dumps and kernel debugging. - -# KERNEL_DUMP_DEVICE variable is used to specify which device will be -# used by the kernel to write the dump down. This has to be a swap -# partition, and has to be at least big enough to contain the whole -# physical memory (see hw.physmem sysctl(8) variable). -# When the variable is commented out, no core dump will be enabled for -# the kernel. -#KERNEL_DUMP_DEVICE="/dev/ad0s1b" - -# KERNEL_DUMP_DIR variable is used to tell savecore(8) utility where -# to save the kernel core dump once it's restored from the dump -# device. If unset, /var/crash will be used, as the default of -# FreeBSD. -#KERNEL_DUMP_DIR="/var/crash" - -# KERNEL_DUMP_COMPRESS variable decide whether to compress with -# gzip(1) the dump or leave it of its original size (the size of the -# physical memory present on the system). If set to yes, the -z option -# will be passed to savecore(8) that will proceed on compressing the -# dump. -#KERNEL_DUMP_COMPRESS="NO" diff --git a/conf.d.BSD/moused b/conf.d.BSD/moused deleted file mode 100644 index a9d2d401..00000000 --- a/conf.d.BSD/moused +++ /dev/null @@ -1,16 +0,0 @@ -# See the moused man page for available settings. - -# Set to your mouse device psm[0-9] for PS/2 ports, ums[0-9] for USB ports -# Leave blank to try to autodetect it -#moused_device="/dev/psm0" - -# Any additional arguments required for a specific port -#moused_args_psm0="" -# or for all mice -#moused_args="" - -# You can also multiplex the init script for each device like so -# ln -s moused /etc/init.d/moused.ums0 -# This enables you to have a config file per mouse (forces moused_device -# to ums0 in this case) and control each mouse. -# devd can also start and stop these mice, which laptop users will find handy. diff --git a/conf.d.BSD/powerd b/conf.d.BSD/powerd deleted file mode 100644 index df5fb700..00000000 --- a/conf.d.BSD/powerd +++ /dev/null @@ -1,7 +0,0 @@ -# Mode allowed: maximum, minimum, adaptive -# Default unless specified is adaptive -powerd_ac_mode="maximum" -#powerd_battery_mode="minimum" - -# Addiditonal arguments for powerd - see the man page for details -powerd_args="" diff --git a/conf.d.BSD/rarpd b/conf.d.BSD/rarpd deleted file mode 100644 index 60d71a45..00000000 --- a/conf.d.BSD/rarpd +++ /dev/null @@ -1,3 +0,0 @@ -# To start rarpd only for a given interface, set the -# following variable. Otherwise we listen on all interfaces. -#rarpd_interface="rl0" diff --git a/conf.d.FreeBSD/Makefile b/conf.d.FreeBSD/Makefile deleted file mode 100644 index ed58826f..00000000 --- a/conf.d.FreeBSD/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -DIR= ${CONFDIR} -CONF= syscons - -MK= ../mk -include ${MK}/scripts.mk diff --git a/conf.d.FreeBSD/syscons b/conf.d.FreeBSD/syscons deleted file mode 100644 index cd012df6..00000000 --- a/conf.d.FreeBSD/syscons +++ /dev/null @@ -1,19 +0,0 @@ -# Example syscons config file. This is the place to set things like keymap, etc. - -# Set the video mode - you should check the vidcontrol man page for valid modes -# NOTE:- This will blank the screen after this command is run -# NOTE:- You can get more modes if you load the vesa kernel module, but this -# may require the SC_PIXEL_MODE kernel option -#allscreen_flags="VGA_80x30" - -# Set the keymap to "uk.iso". -#keymap="uk.iso" - -# Set the keyboard rate to 250ms delay, and 34 repeat rate. -#keyrate="250.34" - -# Change the behaviour of F-unction keys (see kbdcontrol(1)). -#keychange="10 'ssh myhost'" - -# See vidcontrol(1) -t -#blanktime="off" diff --git a/conf.d.Linux/Makefile b/conf.d.Linux/Makefile deleted file mode 100644 index 57922a20..00000000 --- a/conf.d.Linux/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -DIR= ${CONFDIR} -CONF= consolefont keymaps modules -CONF_APPEND= clock - -MK= ../mk -include ${MK}/scripts.mk diff --git a/conf.d.Linux/clock b/conf.d.Linux/clock deleted file mode 100644 index 4a5cb84c..00000000 --- a/conf.d.Linux/clock +++ /dev/null @@ -1,9 +0,0 @@ - -# Set clock_adjtime if you wish hwclock to try and handle clock drift. -# Don't set this if you run a ntp service or anything else that handles -# clock drift. -clock_adjtime="NO" - -# If you wish to pass any other arguments to hwclock during bootup, -# you may do so here. Alpha users may wish to use --arc or --srm here. -clock_args="" diff --git a/conf.d.Linux/consolefont b/conf.d.Linux/consolefont deleted file mode 100644 index c7fe898a..00000000 --- a/conf.d.Linux/consolefont +++ /dev/null @@ -1,17 +0,0 @@ -# consolefont specifies the default font that you'd like Linux to use on the -# console. You can find a good selection of fonts in /usr/share/consolefonts; -# you shouldn't specify the trailing ".psf.gz", just the font name below. -# To use the default console font, comment out the CONSOLEFONT setting below. -# This setting is used by the /etc/init.d/consolefont script (NOTE: if you do -# not want to use it, run "rc-update del consolefont" as root). -consolefont="default8x16" - -# consoletranslation is the charset map file to use. Leave commented to use -# the default one. Have a look in /usr/share/consoletrans for a selection of -# map files you can use. -#consoletranslation="8859-1_to_uni" - -# unicodemap is the unicode map file to use. Leave commented to use the -# default one. Have a look in /usr/share/unimaps for a selection of map files -# you can use. -#unicodemap="iso01" diff --git a/conf.d.Linux/keymaps b/conf.d.Linux/keymaps deleted file mode 100644 index 842803bb..00000000 --- a/conf.d.Linux/keymaps +++ /dev/null @@ -1,21 +0,0 @@ -# Use KEYMAP to specify the default console keymap. There is a complete tree -# of keymaps in /usr/share/keymaps to choose from. -keymap="us" - -# Should we first load the 'windowkeys' console keymap? Most x86 users will -# say "yes" here. Note that non-x86 users should leave it as "no". -windowkeys="NO" - -# The maps to load for extended keyboards. Most users will leave this as is. -extended_keymaps="" -#extended_keymaps="backspace keypad euro2" - -# Tell dumpkeys(1) to interpret character action codes to be -# from the specified character set. -# This only matters if you set unicode="yes" in /etc/rc.conf. -# For a list of valid sets, run `dumpkeys --help` -dumpkeys_charset="" - -# Some fonts map AltGr-E to the currency symbol ¤ instead of the Euro € -# To fix this, set to "yes" -fix_euro="NO" diff --git a/conf.d.Linux/modules b/conf.d.Linux/modules deleted file mode 100644 index 2fc26cf3..00000000 --- a/conf.d.Linux/modules +++ /dev/null @@ -1,15 +0,0 @@ -# You can define a list modules for a specific kernel version, -# a released kernel version, a main kernel version or just a list. -#modules_2_6_23_gentoo_r5="ieee1394 ohci1394" -#modules_2_6_23="tun ieee1394" -#modules_2_6="tun" -#modules="ohci1394" - -# Give the modules some arguments if needed, per version if necessary. -#module_ieee1394_args="debug" -#module_ieee1394_args_2_6_23_gentoo_r5="ieee1394 ohci1394" -#module_ieee1394_args_2_6_23="tun ieee1394" -#module_ieee1394_args_2_6="tun" - -# You should consult your kernel documentation and configuration -# for a list of modules and their options. diff --git a/conf.d/Makefile b/conf.d/Makefile index 9d1891f5..96b0a6eb 100644 --- a/conf.d/Makefile +++ b/conf.d/Makefile @@ -1,5 +1,5 @@ DIR= ${CONFDIR} -CONF= bootmisc clock fsck hostname local net urandom +CONF= bootmisc fsck hostname local net urandom MK= ../mk include ${MK}/scripts.mk diff --git a/conf.d/Makefile.FreeBSD b/conf.d/Makefile.FreeBSD new file mode 100644 index 00000000..ea0c701e --- /dev/null +++ b/conf.d/Makefile.FreeBSD @@ -0,0 +1 @@ +CONF+= moused powerd rarpd savecore syscons diff --git a/conf.d/Makefile.Linux b/conf.d/Makefile.Linux new file mode 100644 index 00000000..628636b0 --- /dev/null +++ b/conf.d/Makefile.Linux @@ -0,0 +1 @@ +CONF+= consolefont hwclock keymaps modules diff --git a/conf.d/Makefile.NetBSD b/conf.d/Makefile.NetBSD new file mode 100644 index 00000000..1af0433d --- /dev/null +++ b/conf.d/Makefile.NetBSD @@ -0,0 +1 @@ +CONF+= moused powerd rarpd savecore diff --git a/conf.d/adjkerntz b/conf.d/adjkerntz new file mode 100644 index 00000000..4dab74f7 --- /dev/null +++ b/conf.d/adjkerntz @@ -0,0 +1,10 @@ +# Set CLOCK to "UTC" if your system clock is set to UTC (also known as +# Greenwich Mean Time). If your clock is set to the local time, then +# set CLOCK to "local". Note that if you dual boot with Windows, then +# you should set it to "local". +clock="UTC" + +# If you want to set the Hardware Clock to the current System Time +# during shutdown, then say "YES" here. +# You normally don't need to do this if you run a ntp daemon. +clock_systohc="NO" diff --git a/conf.d/clock b/conf.d/clock deleted file mode 100644 index 4dab74f7..00000000 --- a/conf.d/clock +++ /dev/null @@ -1,10 +0,0 @@ -# Set CLOCK to "UTC" if your system clock is set to UTC (also known as -# Greenwich Mean Time). If your clock is set to the local time, then -# set CLOCK to "local". Note that if you dual boot with Windows, then -# you should set it to "local". -clock="UTC" - -# If you want to set the Hardware Clock to the current System Time -# during shutdown, then say "YES" here. -# You normally don't need to do this if you run a ntp daemon. -clock_systohc="NO" diff --git a/conf.d/consolefont b/conf.d/consolefont new file mode 100644 index 00000000..c7fe898a --- /dev/null +++ b/conf.d/consolefont @@ -0,0 +1,17 @@ +# consolefont specifies the default font that you'd like Linux to use on the +# console. You can find a good selection of fonts in /usr/share/consolefonts; +# you shouldn't specify the trailing ".psf.gz", just the font name below. +# To use the default console font, comment out the CONSOLEFONT setting below. +# This setting is used by the /etc/init.d/consolefont script (NOTE: if you do +# not want to use it, run "rc-update del consolefont" as root). +consolefont="default8x16" + +# consoletranslation is the charset map file to use. Leave commented to use +# the default one. Have a look in /usr/share/consoletrans for a selection of +# map files you can use. +#consoletranslation="8859-1_to_uni" + +# unicodemap is the unicode map file to use. Leave commented to use the +# default one. Have a look in /usr/share/unimaps for a selection of map files +# you can use. +#unicodemap="iso01" diff --git a/conf.d/hwclock b/conf.d/hwclock new file mode 100644 index 00000000..fe94df03 --- /dev/null +++ b/conf.d/hwclock @@ -0,0 +1,14 @@ +# Set CLOCK to "UTC" if your system clock is set to UTC (also known as +# Greenwich Mean Time). If your clock is set to the local time, then +# set CLOCK to "local". Note that if you dual boot with Windows, then +# you should set it to "local". +clock="UTC" + +# If you want to set the Hardware Clock to the current System Time +# during shutdown, then say "YES" here. +# You normally don't need to do this if you run a ntp daemon. +clock_systohc="NO" + +# If you wish to pass any other arguments to hwclock during bootup, +# you may do so here. Alpha users may wish to use --arc or --srm here. +clock_args="" diff --git a/conf.d/keymaps b/conf.d/keymaps new file mode 100644 index 00000000..842803bb --- /dev/null +++ b/conf.d/keymaps @@ -0,0 +1,21 @@ +# Use KEYMAP to specify the default console keymap. There is a complete tree +# of keymaps in /usr/share/keymaps to choose from. +keymap="us" + +# Should we first load the 'windowkeys' console keymap? Most x86 users will +# say "yes" here. Note that non-x86 users should leave it as "no". +windowkeys="NO" + +# The maps to load for extended keyboards. Most users will leave this as is. +extended_keymaps="" +#extended_keymaps="backspace keypad euro2" + +# Tell dumpkeys(1) to interpret character action codes to be +# from the specified character set. +# This only matters if you set unicode="yes" in /etc/rc.conf. +# For a list of valid sets, run `dumpkeys --help` +dumpkeys_charset="" + +# Some fonts map AltGr-E to the currency symbol ¤ instead of the Euro € +# To fix this, set to "yes" +fix_euro="NO" diff --git a/conf.d/modules b/conf.d/modules new file mode 100644 index 00000000..2fc26cf3 --- /dev/null +++ b/conf.d/modules @@ -0,0 +1,15 @@ +# You can define a list modules for a specific kernel version, +# a released kernel version, a main kernel version or just a list. +#modules_2_6_23_gentoo_r5="ieee1394 ohci1394" +#modules_2_6_23="tun ieee1394" +#modules_2_6="tun" +#modules="ohci1394" + +# Give the modules some arguments if needed, per version if necessary. +#module_ieee1394_args="debug" +#module_ieee1394_args_2_6_23_gentoo_r5="ieee1394 ohci1394" +#module_ieee1394_args_2_6_23="tun ieee1394" +#module_ieee1394_args_2_6="tun" + +# You should consult your kernel documentation and configuration +# for a list of modules and their options. diff --git a/conf.d/moused b/conf.d/moused new file mode 100644 index 00000000..a9d2d401 --- /dev/null +++ b/conf.d/moused @@ -0,0 +1,16 @@ +# See the moused man page for available settings. + +# Set to your mouse device psm[0-9] for PS/2 ports, ums[0-9] for USB ports +# Leave blank to try to autodetect it +#moused_device="/dev/psm0" + +# Any additional arguments required for a specific port +#moused_args_psm0="" +# or for all mice +#moused_args="" + +# You can also multiplex the init script for each device like so +# ln -s moused /etc/init.d/moused.ums0 +# This enables you to have a config file per mouse (forces moused_device +# to ums0 in this case) and control each mouse. +# devd can also start and stop these mice, which laptop users will find handy. diff --git a/conf.d/powerd b/conf.d/powerd new file mode 100644 index 00000000..df5fb700 --- /dev/null +++ b/conf.d/powerd @@ -0,0 +1,7 @@ +# Mode allowed: maximum, minimum, adaptive +# Default unless specified is adaptive +powerd_ac_mode="maximum" +#powerd_battery_mode="minimum" + +# Addiditonal arguments for powerd - see the man page for details +powerd_args="" diff --git a/conf.d/rarpd b/conf.d/rarpd new file mode 100644 index 00000000..60d71a45 --- /dev/null +++ b/conf.d/rarpd @@ -0,0 +1,3 @@ +# To start rarpd only for a given interface, set the +# following variable. Otherwise we listen on all interfaces. +#rarpd_interface="rl0" diff --git a/conf.d/savecore b/conf.d/savecore new file mode 100644 index 00000000..99eaefc9 --- /dev/null +++ b/conf.d/savecore @@ -0,0 +1,25 @@ +# Unless you're a kernel developer or driver writer then this won't +# be of any interest to you at all. +# The following options allow to configure the kernel's core dump +# facilities. + +# The dump_device variable is used to specify which device will be +# used by the kernel to write the dump down. This has to be a swap +# partition, and has to be at least big enough to contain the whole +# physical memory (see hw.physmem sysctl(8) variable). +# When the variable is commented out, no core dump will be enabled for +# the kernel. +#dump_device=/dev/ad0s1b + +# The dump_dir variable is used to tell savecore(8) utility where +# to save the kernel core dump once it's restored from the dump +# device. If unset, /var/crash will be used, as the default of +# FreeBSD. +#dump_dir=/var/crash + +# The dump_compress variable decide whether to compress with +# gzip(1) the dump or leave it of its original size (the size of the +# physical memory present on the system). If set to yes, the -z option +# will be passed to savecore(8) that will proceed on compressing the +# dump. +#dump_compress=NO diff --git a/conf.d/syscons b/conf.d/syscons new file mode 100644 index 00000000..cd012df6 --- /dev/null +++ b/conf.d/syscons @@ -0,0 +1,19 @@ +# Example syscons config file. This is the place to set things like keymap, etc. + +# Set the video mode - you should check the vidcontrol man page for valid modes +# NOTE:- This will blank the screen after this command is run +# NOTE:- You can get more modes if you load the vesa kernel module, but this +# may require the SC_PIXEL_MODE kernel option +#allscreen_flags="VGA_80x30" + +# Set the keymap to "uk.iso". +#keymap="uk.iso" + +# Set the keyboard rate to 250ms delay, and 34 repeat rate. +#keyrate="250.34" + +# Change the behaviour of F-unction keys (see kbdcontrol(1)). +#keychange="10 'ssh myhost'" + +# See vidcontrol(1) -t +#blanktime="off" diff --git a/etc.BSD/.gitignore b/etc.BSD/.gitignore deleted file mode 100644 index fe38bc1f..00000000 --- a/etc.BSD/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -rc -rc.shutdown diff --git a/etc.BSD/Makefile b/etc.BSD/Makefile deleted file mode 100644 index 5ce049f4..00000000 --- a/etc.BSD/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -DIR= ${SYSCONFDIR} -CONF= rc rc.shutdown - -MK= ../mk -include ${MK}/scripts.mk -include Makefile.${OS} - -.SUFFIXES: .in -.in: - sed -e 's:@SHELL@:${SHELL}:' -e 's:@TERM@:${DEFTERM}:' $< > $@ diff --git a/etc.BSD/Makefile.FreeBSD b/etc.BSD/Makefile.FreeBSD deleted file mode 100644 index 6f80f3be..00000000 --- a/etc.BSD/Makefile.FreeBSD +++ /dev/null @@ -1 +0,0 @@ -DEFTERM= cons25 diff --git a/etc.BSD/Makefile.NetBSD b/etc.BSD/Makefile.NetBSD deleted file mode 100644 index 1f9e18b8..00000000 --- a/etc.BSD/Makefile.NetBSD +++ /dev/null @@ -1 +0,0 @@ -DEFTERM= wsvt25 diff --git a/etc.BSD/rc.in b/etc.BSD/rc.in deleted file mode 100644 index aab7cbb8..00000000 --- a/etc.BSD/rc.in +++ /dev/null @@ -1,22 +0,0 @@ -#!@SHELL@ -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -# If $TERM is not set then assume default of @TERM@ -# This gives us a nice colour boot :) -[ -z "$TERM" -o "$TERM" = "dumb" ] && export TERM="@TERM@" - -# Handle interrupts -trap : SIGINT -trap "echo 'Boot interrupted'; exit 1" SIGQUIT - -# BSD's init works somewhat differently to sysvinit. -# This block should 'translate' from the way init calls it to the way it would -# be called by sysvinit on linux. -RUNLEVEL="1" /sbin/rc sysinit || exit 1 -RUNLEVEL="1" /sbin/rc boot || exit 1 -PREVLEVEL="1" /sbin/rc default - -# We don't actually care if rc default worked or not, we should exit 0 -# to allow logins -exit 0 diff --git a/etc.BSD/rc.shutdown.in b/etc.BSD/rc.shutdown.in deleted file mode 100644 index e26e8468..00000000 --- a/etc.BSD/rc.shutdown.in +++ /dev/null @@ -1,26 +0,0 @@ -#!@SHELL@ -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -# Handle interrupts -trap : SIGINT SIGQUIT - -# Try and use stuff in /lib over anywhere else so we can shutdown -# local mounts correctly. -export LD_LIBRARY_PATH="/lib${LD_LIBRARY_PATH:+:}${LDLIBRARY_PATH}" - -# If $TERM is not set then assume default of @TERM@ -# This gives us a nice colour boot :) -[ -z "$TERM" -o "$TERM" = "dumb" ] && export TERM="@TERM@" - -action=${1:-shutdown} - -# BSD's init works somewhat differently to sysvinit. -# This block should 'translate' from the way init calls it to the way it would -# be called by sysvinit on linux. -case "${action}" in - reboot) export RUNLEVEL=6;; - single) export RUNLEVEL=S;; - *) export RUNLEVEL=0;; -esac -exec /sbin/rc "${action}" diff --git a/etc.FreeBSD/Makefile b/etc.FreeBSD/Makefile deleted file mode 100644 index b4e8b069..00000000 --- a/etc.FreeBSD/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -DIR= /etc -CONF= devd.conf -BIN= rc.devd - -MK= ../mk -include ${MK}/scripts.mk diff --git a/etc.FreeBSD/devd.conf b/etc.FreeBSD/devd.conf deleted file mode 100644 index 3cd262cf..00000000 --- a/etc.FreeBSD/devd.conf +++ /dev/null @@ -1,315 +0,0 @@ -# $FreeBSD: src/etc/devd.conf,v 1.38 2007/06/21 22:50:36 njl Exp $ -# -# Refer to devd.conf(5) and devd(8) man pages for the details on how to -# run and configure devd. -# - -# NB: All regular expressions have an implicit ^$ around them. -# NB: device-name is shorthand for 'match device-name' - -options { - # Each directory directive adds a directory the list of directories - # that we scan for files. Files are read-in in the order that they - # are returned from readdir(3). The rule-sets are combined to - # create a DFA that's used to match events to actions. - directory "/etc/devd"; - directory "/usr/local/etc/devd"; - pid-file "/var/run/devd.pid"; - - # Setup some shorthand for regex that we use later in the file. - #XXX Yes, these are gross -- imp - set scsi-controller-regex - "(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\ - esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\ - [0-9]+"; -}; - -# Note that the attach/detach with the highest value wins, so that one can -# override these general rules. - -# -# Configure the interface on attach. Due to a historical accident, this -# script is called pccard_ether. -# -notify 0 { - match "system" "IFNET"; - match "type" "ATTACH"; - action "/etc/rc.devd net.$subsystem start"; -}; - -notify 0 { - match "system" "IFNET"; - match "type" "DETACH"; - action "/etc/rc.devd net.$subsystem stop"; -}; - -# -# Try to configure the interface when the network comes up and deconfigure -# when it goes down -# -notify 0 { - match "system" "IFNET"; - match "type" "LINK_UP"; - media-type "ethernet"; - action "/etc/rc.devd net.$subsystem start"; -}; - -notify 0 { - match "system" "IFNET"; - match "type" "LINK_DOWN"; - media-type "ethernet"; - action "/etc/rc.devd net.$subsystem stop"; -}; -# -# Like Ethernet devices, but separate because -# they have a different media type. We may want -# to exploit this later. -# -detach 0 { - media-type "802.11"; - action "/etc/rc.devd net.$device-name stop"; -}; -attach 0 { - media-type "802.11"; - action "/etc/rc.devd net.$device-name start"; -}; -notify 0 { - match "system" "IFNET"; - match "type" "LINK_UP"; - media-type "802.11"; - action "/etc/rc.devd net.$subsystem start"; -}; -notify 0 { - match "system" "IFNET"; - match "type" "LINK_DOWN"; - media-type "802.11"; - action "/etc/rc.devd net.$subsystem stop"; -}; - -# An entry like this might be in a different file, but is included here -# as an example of how to override things. Normally 'ed50' would match -# the above attach/detach stuff, but the value of 100 makes it -# hard wired to 1.2.3.4. -attach 100 { - device-name "ed50"; - action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000"; -}; -detach 100 { - device-name "ed50"; -}; - -# When a USB Bluetooth dongle appears activate it -attach 100 { - device-name "ubt[0-9]+"; - action "/etc/rc.d/bluetooth start $device-name"; -}; -detach 100 { - device-name "ubt[0-9]+"; - action "/etc/rc.d/bluetooth stop $device-name"; -}; - -# When a USB keyboard arrives, attach it as the console keyboard. -attach 100 { - device-name "ukbd0"; - action "/etc/rc.d/syscons setkeyboard /dev/ukbd0"; -}; -detach 100 { - device-name "ukbd0"; - action "/etc/rc.d/syscons setkeyboard /dev/kbd0"; -}; - -# The entry below starts moused when a mouse is plugged in. Moused -# stops automatically (actually it bombs :) when the device disappears. -attach 100 { - device-name "ums[0-9]+"; - action "/etc/rc.devd moused.$device-name start"; -}; - -# Firmware download into the ActiveWire board. After the firmware download is -# done the device detaches and reappears as something new and shiny -# automatically. -attach 100 { - match "vendor" "0x0854"; - match "product" "0x0100"; - match "release" "0x0000"; - action "/usr/local/bin/ezdownload -f /usr/local/share/usb/firmware/0854.0100.0_01.hex $device-name"; -}; - -# Firmware download for Entrega Serial DB25 adapter. -attach 100 { - match "vendor" "0x1645"; - match "product" "0x8001"; - match "release" "0x0101"; - action "if ! kldstat -n usio > /dev/null 2>&1 ; then kldload usio; fi /usr/sbin/ezdownload -v -f /usr/share/usb/firmware/1645.8001.0101 /dev/$device-name"; -}; - -# This entry starts the ColdSync tool in daemon mode. Make sure you have an up -# to date /usr/local/etc/palms. We override the 'listen' settings for port and -# type in /usr/local/etc/coldsync.conf. -attach 100 { - device-name "ugen[0-9]+"; - match "vendor" "0x082d"; - match "product" "0x0100"; - match "release" "0x0100"; - action "/usr/local/bin/coldsync -md -p /dev/$device-name -t usb"; -}; - -# -# Rescan scsi device-names on attach, but not detach. However, it is -# disabled by default due to reports of problems. -# -attach 0 { - device-name "$scsi-controller-regex"; -// action "camcontrol rescan all"; -}; - -# Don't even try to second guess what to do about drivers that don't -# match here. Instead, pass it off to syslog. Commented out for the -# moment, as the pnpinfo variable isn't set in devd yet. Individual -# variables within the bus supplied pnpinfo are set. -nomatch 0 { -# action "logger Unknown device: $pnpinfo $location $bus"; -}; - -# Various logging of unknown devices. -nomatch 10 { - match "bus" "uhub[0-9]+"; - action "logger Unknown USB device: vendor $vendor product $product \ - bus $bus"; -}; - -# Some PC-CARDs don't offer numerical manufacturer/product IDs, just -# show the CIS info there. -nomatch 20 { - match "bus" "pccard[0-9]+"; - match "manufacturer" "0xffffffff"; - match "product" "0xffffffff"; - action "logger Unknown PCCARD device: CISproduct $cisproduct \ - CIS-vendor $cisvendor bus $bus"; -}; - -nomatch 10 { - match "bus" "pccard[0-9]+"; - action "logger Unknown PCCARD device: manufacturer $manufacturer \ - product $product CISproduct $cisproduct CIS-vendor \ - $cisvendor bus $bus"; -}; - -nomatch 10 { - match "bus" "cardbus[0-9]+"; - action "logger Unknown Cardbus device: device $device class $class \ - vendor $vendor bus $bus"; -}; - -# Switch power profiles when the AC line state changes. -notify 10 { - match "system" "ACPI"; - match "subsystem" "ACAD"; - action "/etc/rc.d/power_profile $notify"; -}; - -# Notify all users before beginning emergency shutdown when we get -# a _CRT or _HOT thermal event and we're going to power down the system -# very soon. -notify 10 { - match "system" "ACPI"; - match "subsystem" "Thermal"; - match "notify" "0xcc"; - action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'"; -}; - -# Sample ZFS problem reports handling. -notify 10 { - match "system" "ZFS"; - match "type" "zpool"; - action "logger -p kern.err 'ZFS: failed to load zpool $pool'"; -}; - -notify 10 { - match "system" "ZFS"; - match "type" "vdev"; - action "logger -p kern.err 'ZFS: vdev failure, zpool=$pool type=$type'"; -}; - -notify 10 { - match "system" "ZFS"; - match "type" "data"; - action "logger -p kern.warn 'ZFS: zpool I/O failure, zpool=$pool error=$zio_err'"; -}; - -notify 10 { - match "system" "ZFS"; - match "type" "io"; - action "logger -p kern.warn 'ZFS: vdev I/O failure, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size error=$zio_err'"; -}; - -notify 10 { - match "system" "ZFS"; - match "type" "checksum"; - action "logger -p kern.warn 'ZFS: checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'"; -}; - -# User requested suspend, so perform preparation steps and then execute -# the actual suspend process. -notify 10 { - match "system" "ACPI"; - match "subsystem" "Suspend"; - action "/etc/rc.suspend acpi $notify"; -}; -notify 10 { - match "system" "ACPI"; - match "subsystem" "Resume"; - action "/etc/rc.resume acpi $notify"; -}; - -/* EXAMPLES TO END OF FILE - -# The following might be an example of something that a vendor might -# install if you were to add their device. This might reside in -# /usr/local/etc/devd/deqna.conf. A deqna is, in this hypothetical -# example, a pccard ethernet-like device. Students of history may -# know other devices by this name, and will get the in-jokes in this -# entry. -nomatch 10 { - match "bus" "pccard[0-9]+"; - match "manufacturer" "0x1234"; - match "product" "0x2323"; - action "kldload if_deqna"; -}; -attach 10 { - device-name "deqna[0-9]+"; - action "/etc/pccard_ether $device-name start"; -}; -detach 10 { - device-name "deqna[0-9]+"; - action "/etc/pccard_ether $device-name stop"; -}; - -# Examples of notify hooks. A notify is a generic way for a kernel -# subsystem to send event notification to userland. -# -# Here are some examples of ACPI notify handlers. ACPI subsystems that -# generate notifies include the AC adapter, power/sleep buttons, -# control method batteries, lid switch, and thermal zones. -# -# Information returned is not always the same as the ACPI notify -# events. See the ACPI specification for more information about -# notifies. Here is the information returned for each subsystem: -# -# ACAD: AC line state (0 is offline, 1 is online) -# Button: Button pressed (0 for power, 1 for sleep) -# CMBAT: ACPI battery events -# Lid: Lid state (0 is closed, 1 is open) -# Suspend, Resume: Suspend and resume notification -# Thermal: ACPI thermal zone events -# -# This example calls a script when the AC state changes, passing the -# notify value as the first argument. If the state is 0x00, it might -# call some sysctls to implement economy mode. If 0x01, it might set -# the mode to performance. -notify 10 { - match "system" "ACPI"; - match "subsystem" "ACAD"; - action "/etc/acpi_ac $notify"; -}; -*/ diff --git a/etc.FreeBSD/rc.devd b/etc.FreeBSD/rc.devd deleted file mode 100644 index f44d9acb..00000000 --- a/etc.FreeBSD/rc.devd +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -# Inform RC that we are in the background and hotplugged -export IN_BACKGROUND=yes -export IN_HOTPLUG=yes - -getmedia() { - ifconfig "$1" | while read line; do - case "${line}" in - media:" "*) echo "${line}"; return;; - esac - done -} - -# Try and create an init script for network interfaces -if [ ! -e /etc/init.d/"$1" -a ! -e /usr/local/init.d/"$1" ]; then - base=${1%%.*} - if [ "${base}" = "net" ]; then - # We only create links for pyhsical interfaces - [ -n "$(getmedia ${1#*.})" ] || exit 1 - base="net.lo0" - fi - if [ -e /etc/init.d/"${base}" -a "${base}" != "$1" ]; then - ln -s "${base}" /etc/init.d/"$1" - fi -fi - -# Run the init script -exec /etc/init.d/"$1" "$2" diff --git a/etc.Linux/Makefile b/etc.Linux/Makefile deleted file mode 100644 index 51f1f42d..00000000 --- a/etc.Linux/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -DIR= ${SYSCONFDIR} -CONF_APPEND= rc.conf - -MK= ../mk -include ${MK}/scripts.mk diff --git a/etc.Linux/rc.conf b/etc.Linux/rc.conf deleted file mode 100644 index d1c216f3..00000000 --- a/etc.Linux/rc.conf +++ /dev/null @@ -1,25 +0,0 @@ - -############################################################################## -# LINUX SPECIFIC OPTIONS - -# This is the number of tty's used in most of the rc-scripts (like -# consolefont, numlock, etc ...) -rc_tty_number=12 - -# Use this variable to control the /dev management behavior. -# devfs - use devfs (requires sys-fs/devfsd) -# mdev - use mdev (requires sys-apps/busybox) -# udev - use udev (requires sys-fs/udev) -# static - let the user manage /dev (YOU need to create ALL device nodes) -# Leave it blank to let rc work it out (udev, mdev, devfs, static) -#rc_devices="" - -# UDEV OPTION: -# Set to "yes" if you want to save /dev to a tarball on shutdown -# and restore it on startup. This is useful if you have a lot of -# custom device nodes that udev does not handle/know about. -rc_device_tarball="NO" - -# Sets the level at which logging of messages is done to the -# console. See dmesg(8) for more info. -dmesg_level="1" diff --git a/etc/Makefile b/etc/Makefile index 77262595..8b43544c 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -2,4 +2,6 @@ DIR= ${SYSCONFDIR} CONF= rc.conf MK= ../mk +include ${MK}/os.mk +include Makefile.${OS} include ${MK}/scripts.mk diff --git a/etc/Makefile.FreeBSD b/etc/Makefile.FreeBSD new file mode 100644 index 00000000..4b6d75f2 --- /dev/null +++ b/etc/Makefile.FreeBSD @@ -0,0 +1,4 @@ +SED_EXTRA= -e 's:@TERM@:cons25:g' +SRCS+= rc.conf.in rc.in rc.shutdown.in +CONF+= devd.conf +BIN+= rc.devd diff --git a/etc/Makefile.Linux b/etc/Makefile.Linux new file mode 100644 index 00000000..9ac0bc25 --- /dev/null +++ b/etc/Makefile.Linux @@ -0,0 +1,6 @@ +SED_EXTRA= -e 's:@TERM@:wsvt25:g' +SRCS+= rc.in rc.shutdown.in + +rc.conf: + cp rc.conf.in rc.conf + cat rc.conf.Linux >> rc.conf diff --git a/etc/Makefile.NetBSD b/etc/Makefile.NetBSD new file mode 100644 index 00000000..5b562947 --- /dev/null +++ b/etc/Makefile.NetBSD @@ -0,0 +1,2 @@ +SED_EXTRA= -e 's:@TERM@:wsvt25:g' +SRCS+= rc.conf.in rc.in rc.shutdown.in diff --git a/etc/devd.conf b/etc/devd.conf new file mode 100644 index 00000000..3cd262cf --- /dev/null +++ b/etc/devd.conf @@ -0,0 +1,315 @@ +# $FreeBSD: src/etc/devd.conf,v 1.38 2007/06/21 22:50:36 njl Exp $ +# +# Refer to devd.conf(5) and devd(8) man pages for the details on how to +# run and configure devd. +# + +# NB: All regular expressions have an implicit ^$ around them. +# NB: device-name is shorthand for 'match device-name' + +options { + # Each directory directive adds a directory the list of directories + # that we scan for files. Files are read-in in the order that they + # are returned from readdir(3). The rule-sets are combined to + # create a DFA that's used to match events to actions. + directory "/etc/devd"; + directory "/usr/local/etc/devd"; + pid-file "/var/run/devd.pid"; + + # Setup some shorthand for regex that we use later in the file. + #XXX Yes, these are gross -- imp + set scsi-controller-regex + "(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\ + esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\ + [0-9]+"; +}; + +# Note that the attach/detach with the highest value wins, so that one can +# override these general rules. + +# +# Configure the interface on attach. Due to a historical accident, this +# script is called pccard_ether. +# +notify 0 { + match "system" "IFNET"; + match "type" "ATTACH"; + action "/etc/rc.devd net.$subsystem start"; +}; + +notify 0 { + match "system" "IFNET"; + match "type" "DETACH"; + action "/etc/rc.devd net.$subsystem stop"; +}; + +# +# Try to configure the interface when the network comes up and deconfigure +# when it goes down +# +notify 0 { + match "system" "IFNET"; + match "type" "LINK_UP"; + media-type "ethernet"; + action "/etc/rc.devd net.$subsystem start"; +}; + +notify 0 { + match "system" "IFNET"; + match "type" "LINK_DOWN"; + media-type "ethernet"; + action "/etc/rc.devd net.$subsystem stop"; +}; +# +# Like Ethernet devices, but separate because +# they have a different media type. We may want +# to exploit this later. +# +detach 0 { + media-type "802.11"; + action "/etc/rc.devd net.$device-name stop"; +}; +attach 0 { + media-type "802.11"; + action "/etc/rc.devd net.$device-name start"; +}; +notify 0 { + match "system" "IFNET"; + match "type" "LINK_UP"; + media-type "802.11"; + action "/etc/rc.devd net.$subsystem start"; +}; +notify 0 { + match "system" "IFNET"; + match "type" "LINK_DOWN"; + media-type "802.11"; + action "/etc/rc.devd net.$subsystem stop"; +}; + +# An entry like this might be in a different file, but is included here +# as an example of how to override things. Normally 'ed50' would match +# the above attach/detach stuff, but the value of 100 makes it +# hard wired to 1.2.3.4. +attach 100 { + device-name "ed50"; + action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000"; +}; +detach 100 { + device-name "ed50"; +}; + +# When a USB Bluetooth dongle appears activate it +attach 100 { + device-name "ubt[0-9]+"; + action "/etc/rc.d/bluetooth start $device-name"; +}; +detach 100 { + device-name "ubt[0-9]+"; + action "/etc/rc.d/bluetooth stop $device-name"; +}; + +# When a USB keyboard arrives, attach it as the console keyboard. +attach 100 { + device-name "ukbd0"; + action "/etc/rc.d/syscons setkeyboard /dev/ukbd0"; +}; +detach 100 { + device-name "ukbd0"; + action "/etc/rc.d/syscons setkeyboard /dev/kbd0"; +}; + +# The entry below starts moused when a mouse is plugged in. Moused +# stops automatically (actually it bombs :) when the device disappears. +attach 100 { + device-name "ums[0-9]+"; + action "/etc/rc.devd moused.$device-name start"; +}; + +# Firmware download into the ActiveWire board. After the firmware download is +# done the device detaches and reappears as something new and shiny +# automatically. +attach 100 { + match "vendor" "0x0854"; + match "product" "0x0100"; + match "release" "0x0000"; + action "/usr/local/bin/ezdownload -f /usr/local/share/usb/firmware/0854.0100.0_01.hex $device-name"; +}; + +# Firmware download for Entrega Serial DB25 adapter. +attach 100 { + match "vendor" "0x1645"; + match "product" "0x8001"; + match "release" "0x0101"; + action "if ! kldstat -n usio > /dev/null 2>&1 ; then kldload usio; fi /usr/sbin/ezdownload -v -f /usr/share/usb/firmware/1645.8001.0101 /dev/$device-name"; +}; + +# This entry starts the ColdSync tool in daemon mode. Make sure you have an up +# to date /usr/local/etc/palms. We override the 'listen' settings for port and +# type in /usr/local/etc/coldsync.conf. +attach 100 { + device-name "ugen[0-9]+"; + match "vendor" "0x082d"; + match "product" "0x0100"; + match "release" "0x0100"; + action "/usr/local/bin/coldsync -md -p /dev/$device-name -t usb"; +}; + +# +# Rescan scsi device-names on attach, but not detach. However, it is +# disabled by default due to reports of problems. +# +attach 0 { + device-name "$scsi-controller-regex"; +// action "camcontrol rescan all"; +}; + +# Don't even try to second guess what to do about drivers that don't +# match here. Instead, pass it off to syslog. Commented out for the +# moment, as the pnpinfo variable isn't set in devd yet. Individual +# variables within the bus supplied pnpinfo are set. +nomatch 0 { +# action "logger Unknown device: $pnpinfo $location $bus"; +}; + +# Various logging of unknown devices. +nomatch 10 { + match "bus" "uhub[0-9]+"; + action "logger Unknown USB device: vendor $vendor product $product \ + bus $bus"; +}; + +# Some PC-CARDs don't offer numerical manufacturer/product IDs, just +# show the CIS info there. +nomatch 20 { + match "bus" "pccard[0-9]+"; + match "manufacturer" "0xffffffff"; + match "product" "0xffffffff"; + action "logger Unknown PCCARD device: CISproduct $cisproduct \ + CIS-vendor $cisvendor bus $bus"; +}; + +nomatch 10 { + match "bus" "pccard[0-9]+"; + action "logger Unknown PCCARD device: manufacturer $manufacturer \ + product $product CISproduct $cisproduct CIS-vendor \ + $cisvendor bus $bus"; +}; + +nomatch 10 { + match "bus" "cardbus[0-9]+"; + action "logger Unknown Cardbus device: device $device class $class \ + vendor $vendor bus $bus"; +}; + +# Switch power profiles when the AC line state changes. +notify 10 { + match "system" "ACPI"; + match "subsystem" "ACAD"; + action "/etc/rc.d/power_profile $notify"; +}; + +# Notify all users before beginning emergency shutdown when we get +# a _CRT or _HOT thermal event and we're going to power down the system +# very soon. +notify 10 { + match "system" "ACPI"; + match "subsystem" "Thermal"; + match "notify" "0xcc"; + action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'"; +}; + +# Sample ZFS problem reports handling. +notify 10 { + match "system" "ZFS"; + match "type" "zpool"; + action "logger -p kern.err 'ZFS: failed to load zpool $pool'"; +}; + +notify 10 { + match "system" "ZFS"; + match "type" "vdev"; + action "logger -p kern.err 'ZFS: vdev failure, zpool=$pool type=$type'"; +}; + +notify 10 { + match "system" "ZFS"; + match "type" "data"; + action "logger -p kern.warn 'ZFS: zpool I/O failure, zpool=$pool error=$zio_err'"; +}; + +notify 10 { + match "system" "ZFS"; + match "type" "io"; + action "logger -p kern.warn 'ZFS: vdev I/O failure, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size error=$zio_err'"; +}; + +notify 10 { + match "system" "ZFS"; + match "type" "checksum"; + action "logger -p kern.warn 'ZFS: checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'"; +}; + +# User requested suspend, so perform preparation steps and then execute +# the actual suspend process. +notify 10 { + match "system" "ACPI"; + match "subsystem" "Suspend"; + action "/etc/rc.suspend acpi $notify"; +}; +notify 10 { + match "system" "ACPI"; + match "subsystem" "Resume"; + action "/etc/rc.resume acpi $notify"; +}; + +/* EXAMPLES TO END OF FILE + +# The following might be an example of something that a vendor might +# install if you were to add their device. This might reside in +# /usr/local/etc/devd/deqna.conf. A deqna is, in this hypothetical +# example, a pccard ethernet-like device. Students of history may +# know other devices by this name, and will get the in-jokes in this +# entry. +nomatch 10 { + match "bus" "pccard[0-9]+"; + match "manufacturer" "0x1234"; + match "product" "0x2323"; + action "kldload if_deqna"; +}; +attach 10 { + device-name "deqna[0-9]+"; + action "/etc/pccard_ether $device-name start"; +}; +detach 10 { + device-name "deqna[0-9]+"; + action "/etc/pccard_ether $device-name stop"; +}; + +# Examples of notify hooks. A notify is a generic way for a kernel +# subsystem to send event notification to userland. +# +# Here are some examples of ACPI notify handlers. ACPI subsystems that +# generate notifies include the AC adapter, power/sleep buttons, +# control method batteries, lid switch, and thermal zones. +# +# Information returned is not always the same as the ACPI notify +# events. See the ACPI specification for more information about +# notifies. Here is the information returned for each subsystem: +# +# ACAD: AC line state (0 is offline, 1 is online) +# Button: Button pressed (0 for power, 1 for sleep) +# CMBAT: ACPI battery events +# Lid: Lid state (0 is closed, 1 is open) +# Suspend, Resume: Suspend and resume notification +# Thermal: ACPI thermal zone events +# +# This example calls a script when the AC state changes, passing the +# notify value as the first argument. If the state is 0x00, it might +# call some sysctls to implement economy mode. If 0x01, it might set +# the mode to performance. +notify 10 { + match "system" "ACPI"; + match "subsystem" "ACAD"; + action "/etc/acpi_ac $notify"; +}; +*/ diff --git a/etc/rc.conf b/etc/rc.conf deleted file mode 100644 index f0c5b770..00000000 --- a/etc/rc.conf +++ /dev/null @@ -1,91 +0,0 @@ -# Global OpenRC configuration settings - -# Set to "YES" if you want the rc system to try and start services -# in parallel for a slight speed improvement. When running in parallel we -# prefix the service output with it's name as the output will get -# jumbled up. -rc_parallel="NO" - -# Set rc_interactive to "YES" and you'll be able to press the I key during -# boot so you can choose to start specific services. Set to "NO" to disable -# this feature. -rc_interactive="YES" - -# Do we allow any started service in the runlevel to satisfy the depedency -# or do we want all of them regardless of state? For example, if net.eth0 -# and net.eth1 are in the default runlevel then with rc_depend_strict="NO" -# both will be started, but services that depend on 'net' will work if either -# one comes up. With rc_depend_strict="YES" we would require them both to -# come up. -rc_depend_strict="YES" - -# Do we allow services to be hotplugged? If not, set to rc_hotplug="NO" -# NOTE: This does not affect anything hotplug/udev/devd related, just the -# starting/stopping of the init.d service triggered by it. -rc_hotplug="YES" - -# Dynamic /dev managers can trigger coldplug events which cause services to -# start before we are ready for them. If this happens, we can defer these -# services to start in the boot runlevel. Set rc_coldplug="NO" if you don't -# want this. -# NOTE: This also affects module coldplugging in udev-096 and higher -# If you want module coldplugging but not coldplugging of services then you -# can set rc_coldplug="YES" and rc_plug_services="!*" -rc_coldplug="YES" - -# Some people want a finer grain over hotplug/coldplug. rc_plug_services is a -# list of services that are matched in order, either allowing or not. By -# default we allow services through as rc_coldplug/rc_hotplug has to be YES -# anyway. -# Example - rc_plug_services="net.wlan !net.*" -# This allows net.wlan and any service not matching net.* to be plugged. -rc_plug_services="" - -# rc_logger launches a logging daemon to log the entire rc process to -# /var/log/rc.log -rc_logger="NO" - -# By default we filter the environment for our running scripts. To allow other -# variables through, add them here. Use a * to allow all variables through. -# rc_env_allow="VAR1 VAR2" - -############################################################################## -# MISC CONFIGURATION VARIABLES -# There variables are shared between many init scripts - -# Set unicode to YES to turn on unicode support for keyboards and screens. -unicode="NO" - -# Network fstypes. Below is the default. -net_fs_list="afs cifs coda davfs fuse gfs ncpfs nfs nfs4 ocfs2 shfs smbfs" - -############################################################################## -# SERVICE CONFIGURATION VARIABLES -# These variables are documented here, but should be configured in -# /etc/conf.d/foo for service foo and NOT enabled here unless you -# really want them to work on a global basis. - -# Some daemons are started and stopped via start-stop-daemon. -# We can set some things on a per service basis, like the nicelevel. -#export SSD_NICELEVEL="-19" - -# Pass ulimit parameters -#rc_ulimit="-u 30" - -# It's possible to define extra dependencies for services like so -#rc_config="/etc/foo" -#rc_need="openvpn" -#rc_use="net.eth0" -#rc_after="clock" -#rc_before="local" -#rc_provide="!net" - -# You can also enable the above commands here for each service. Below is an -# example for service foo. -#rc_foo_config="/etc/foo" -#rc_foo_need="openvpn" -#rc_foo_after="clock" - -# You can also remove dependencies. -# This is mainly used for saying which servies do NOT provide net. -#rc_net_tap0_provide="!net" diff --git a/etc/rc.conf.Linux b/etc/rc.conf.Linux new file mode 100644 index 00000000..d1c216f3 --- /dev/null +++ b/etc/rc.conf.Linux @@ -0,0 +1,25 @@ + +############################################################################## +# LINUX SPECIFIC OPTIONS + +# This is the number of tty's used in most of the rc-scripts (like +# consolefont, numlock, etc ...) +rc_tty_number=12 + +# Use this variable to control the /dev management behavior. +# devfs - use devfs (requires sys-fs/devfsd) +# mdev - use mdev (requires sys-apps/busybox) +# udev - use udev (requires sys-fs/udev) +# static - let the user manage /dev (YOU need to create ALL device nodes) +# Leave it blank to let rc work it out (udev, mdev, devfs, static) +#rc_devices="" + +# UDEV OPTION: +# Set to "yes" if you want to save /dev to a tarball on shutdown +# and restore it on startup. This is useful if you have a lot of +# custom device nodes that udev does not handle/know about. +rc_device_tarball="NO" + +# Sets the level at which logging of messages is done to the +# console. See dmesg(8) for more info. +dmesg_level="1" diff --git a/etc/rc.conf.in b/etc/rc.conf.in new file mode 100644 index 00000000..f0c5b770 --- /dev/null +++ b/etc/rc.conf.in @@ -0,0 +1,91 @@ +# Global OpenRC configuration settings + +# Set to "YES" if you want the rc system to try and start services +# in parallel for a slight speed improvement. When running in parallel we +# prefix the service output with it's name as the output will get +# jumbled up. +rc_parallel="NO" + +# Set rc_interactive to "YES" and you'll be able to press the I key during +# boot so you can choose to start specific services. Set to "NO" to disable +# this feature. +rc_interactive="YES" + +# Do we allow any started service in the runlevel to satisfy the depedency +# or do we want all of them regardless of state? For example, if net.eth0 +# and net.eth1 are in the default runlevel then with rc_depend_strict="NO" +# both will be started, but services that depend on 'net' will work if either +# one comes up. With rc_depend_strict="YES" we would require them both to +# come up. +rc_depend_strict="YES" + +# Do we allow services to be hotplugged? If not, set to rc_hotplug="NO" +# NOTE: This does not affect anything hotplug/udev/devd related, just the +# starting/stopping of the init.d service triggered by it. +rc_hotplug="YES" + +# Dynamic /dev managers can trigger coldplug events which cause services to +# start before we are ready for them. If this happens, we can defer these +# services to start in the boot runlevel. Set rc_coldplug="NO" if you don't +# want this. +# NOTE: This also affects module coldplugging in udev-096 and higher +# If you want module coldplugging but not coldplugging of services then you +# can set rc_coldplug="YES" and rc_plug_services="!*" +rc_coldplug="YES" + +# Some people want a finer grain over hotplug/coldplug. rc_plug_services is a +# list of services that are matched in order, either allowing or not. By +# default we allow services through as rc_coldplug/rc_hotplug has to be YES +# anyway. +# Example - rc_plug_services="net.wlan !net.*" +# This allows net.wlan and any service not matching net.* to be plugged. +rc_plug_services="" + +# rc_logger launches a logging daemon to log the entire rc process to +# /var/log/rc.log +rc_logger="NO" + +# By default we filter the environment for our running scripts. To allow other +# variables through, add them here. Use a * to allow all variables through. +# rc_env_allow="VAR1 VAR2" + +############################################################################## +# MISC CONFIGURATION VARIABLES +# There variables are shared between many init scripts + +# Set unicode to YES to turn on unicode support for keyboards and screens. +unicode="NO" + +# Network fstypes. Below is the default. +net_fs_list="afs cifs coda davfs fuse gfs ncpfs nfs nfs4 ocfs2 shfs smbfs" + +############################################################################## +# SERVICE CONFIGURATION VARIABLES +# These variables are documented here, but should be configured in +# /etc/conf.d/foo for service foo and NOT enabled here unless you +# really want them to work on a global basis. + +# Some daemons are started and stopped via start-stop-daemon. +# We can set some things on a per service basis, like the nicelevel. +#export SSD_NICELEVEL="-19" + +# Pass ulimit parameters +#rc_ulimit="-u 30" + +# It's possible to define extra dependencies for services like so +#rc_config="/etc/foo" +#rc_need="openvpn" +#rc_use="net.eth0" +#rc_after="clock" +#rc_before="local" +#rc_provide="!net" + +# You can also enable the above commands here for each service. Below is an +# example for service foo. +#rc_foo_config="/etc/foo" +#rc_foo_need="openvpn" +#rc_foo_after="clock" + +# You can also remove dependencies. +# This is mainly used for saying which servies do NOT provide net. +#rc_net_tap0_provide="!net" diff --git a/etc/rc.devd b/etc/rc.devd new file mode 100644 index 00000000..f44d9acb --- /dev/null +++ b/etc/rc.devd @@ -0,0 +1,31 @@ +#!/bin/sh +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +# Inform RC that we are in the background and hotplugged +export IN_BACKGROUND=yes +export IN_HOTPLUG=yes + +getmedia() { + ifconfig "$1" | while read line; do + case "${line}" in + media:" "*) echo "${line}"; return;; + esac + done +} + +# Try and create an init script for network interfaces +if [ ! -e /etc/init.d/"$1" -a ! -e /usr/local/init.d/"$1" ]; then + base=${1%%.*} + if [ "${base}" = "net" ]; then + # We only create links for pyhsical interfaces + [ -n "$(getmedia ${1#*.})" ] || exit 1 + base="net.lo0" + fi + if [ -e /etc/init.d/"${base}" -a "${base}" != "$1" ]; then + ln -s "${base}" /etc/init.d/"$1" + fi +fi + +# Run the init script +exec /etc/init.d/"$1" "$2" diff --git a/etc/rc.in b/etc/rc.in new file mode 100644 index 00000000..aab7cbb8 --- /dev/null +++ b/etc/rc.in @@ -0,0 +1,22 @@ +#!@SHELL@ +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +# If $TERM is not set then assume default of @TERM@ +# This gives us a nice colour boot :) +[ -z "$TERM" -o "$TERM" = "dumb" ] && export TERM="@TERM@" + +# Handle interrupts +trap : SIGINT +trap "echo 'Boot interrupted'; exit 1" SIGQUIT + +# BSD's init works somewhat differently to sysvinit. +# This block should 'translate' from the way init calls it to the way it would +# be called by sysvinit on linux. +RUNLEVEL="1" /sbin/rc sysinit || exit 1 +RUNLEVEL="1" /sbin/rc boot || exit 1 +PREVLEVEL="1" /sbin/rc default + +# We don't actually care if rc default worked or not, we should exit 0 +# to allow logins +exit 0 diff --git a/etc/rc.shutdown.in b/etc/rc.shutdown.in new file mode 100644 index 00000000..e26e8468 --- /dev/null +++ b/etc/rc.shutdown.in @@ -0,0 +1,26 @@ +#!@SHELL@ +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +# Handle interrupts +trap : SIGINT SIGQUIT + +# Try and use stuff in /lib over anywhere else so we can shutdown +# local mounts correctly. +export LD_LIBRARY_PATH="/lib${LD_LIBRARY_PATH:+:}${LDLIBRARY_PATH}" + +# If $TERM is not set then assume default of @TERM@ +# This gives us a nice colour boot :) +[ -z "$TERM" -o "$TERM" = "dumb" ] && export TERM="@TERM@" + +action=${1:-shutdown} + +# BSD's init works somewhat differently to sysvinit. +# This block should 'translate' from the way init calls it to the way it would +# be called by sysvinit on linux. +case "${action}" in + reboot) export RUNLEVEL=6;; + single) export RUNLEVEL=S;; + *) export RUNLEVEL=0;; +esac +exec /sbin/rc "${action}" diff --git a/init.d.BSD/.gitignore b/init.d.BSD/.gitignore deleted file mode 100644 index 0d998294..00000000 --- a/init.d.BSD/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -hostid -moused -newsyslog -pf -rarpd -rc-enabled -rpcbind -savecore -sysctl -syslogd diff --git a/init.d.BSD/Makefile b/init.d.BSD/Makefile deleted file mode 100644 index 8edff64a..00000000 --- a/init.d.BSD/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -DIR= ${INITDIR} -SRCS= hostid.in moused.in newsyslog.in pf.in rarpd.in rc-enabled.in \ - rpcbind.in savecore.in sysctl.in syslogd.in -BIN= ${OBJS} - -MK= ../mk -include ${MK}/scripts.mk diff --git a/init.d.BSD/hostid.in b/init.d.BSD/hostid.in deleted file mode 100644 index a0588848..00000000 --- a/init.d.BSD/hostid.in +++ /dev/null @@ -1,78 +0,0 @@ -#!@PREFIX@/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.in b/init.d.BSD/moused.in deleted file mode 100644 index a0e97cdf..00000000 --- a/init.d.BSD/moused.in +++ /dev/null @@ -1,62 +0,0 @@ -#!@PREFIX@/sbin/runscript -# Copyright 2007-2008 Roy Marples -# 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" -} diff --git a/init.d.BSD/newsyslog.in b/init.d.BSD/newsyslog.in deleted file mode 100644 index 04ca7928..00000000 --- a/init.d.BSD/newsyslog.in +++ /dev/null @@ -1,18 +0,0 @@ -#!@PREFIX@/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 - keyword noprefix -} - -start() -{ - ebegin "Creating and/or trimming log files" - newsyslog -s ${newsyslog_args} - eend $? -} diff --git a/init.d.BSD/pf.in b/init.d.BSD/pf.in deleted file mode 100644 index fa55ea48..00000000 --- a/init.d.BSD/pf.in +++ /dev/null @@ -1,59 +0,0 @@ -#!@PREFIX@/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.in b/init.d.BSD/rarpd.in deleted file mode 100644 index e7510990..00000000 --- a/init.d.BSD/rarpd.in +++ /dev/null @@ -1,28 +0,0 @@ -#!@PREFIX@/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.in b/init.d.BSD/rc-enabled.in deleted file mode 100644 index 9801203b..00000000 --- a/init.d.BSD/rc-enabled.in +++ /dev/null @@ -1,54 +0,0 @@ -#!@PREFIX@/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/* @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 -} diff --git a/init.d.BSD/rpcbind.in b/init.d.BSD/rpcbind.in deleted file mode 100644 index 2d053ebd..00000000 --- a/init.d.BSD/rpcbind.in +++ /dev/null @@ -1,21 +0,0 @@ -#!@PREFIX@/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.in b/init.d.BSD/savecore.in deleted file mode 100644 index e23bde48..00000000 --- a/init.d.BSD/savecore.in +++ /dev/null @@ -1,36 +0,0 @@ -#!@PREFIX@/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/sysctl.in b/init.d.BSD/sysctl.in deleted file mode 100644 index b1d8fb83..00000000 --- a/init.d.BSD/sysctl.in +++ /dev/null @@ -1,26 +0,0 @@ -#!@PREFIX@/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.in b/init.d.BSD/syslogd.in deleted file mode 100644 index b39a7d3c..00000000 --- a/init.d.BSD/syslogd.in +++ /dev/null @@ -1,20 +0,0 @@ -#!@PREFIX@/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 - keyword noprefix -} diff --git a/init.d.FreeBSD/.gitignore b/init.d.FreeBSD/.gitignore deleted file mode 100644 index a4207db3..00000000 --- a/init.d.FreeBSD/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -clock -devd -dumpon -ipfw -mixer -nscd -powerd -syscons diff --git a/init.d.FreeBSD/Makefile b/init.d.FreeBSD/Makefile deleted file mode 100644 index 47cbedc7..00000000 --- a/init.d.FreeBSD/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -DIR= ${INITDIR} -SRCS= clock.in devd.in dumpon.in ipfw.in mixer.in nscd.in powerd.in syscons.in -BIN= ${OBJS} - -MK= ../mk -include ${MK}/scripts.mk diff --git a/init.d.FreeBSD/clock.in b/init.d.FreeBSD/clock.in deleted file mode 100644 index 1c3472a0..00000000 --- a/init.d.FreeBSD/clock.in +++ /dev/null @@ -1,61 +0,0 @@ -#!@PREFIX@/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.in b/init.d.FreeBSD/devd.in deleted file mode 100644 index 039aa961..00000000 --- a/init.d.FreeBSD/devd.in +++ /dev/null @@ -1,22 +0,0 @@ -#!@PREFIX@/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.in b/init.d.FreeBSD/dumpon.in deleted file mode 100644 index f2b65308..00000000 --- a/init.d.FreeBSD/dumpon.in +++ /dev/null @@ -1,25 +0,0 @@ -#!@PREFIX@/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.in b/init.d.FreeBSD/ipfw.in deleted file mode 100644 index f8d9c3e1..00000000 --- a/init.d.FreeBSD/ipfw.in +++ /dev/null @@ -1,149 +0,0 @@ -#!@PREFIX@/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.in b/init.d.FreeBSD/mixer.in deleted file mode 100644 index f496bd18..00000000 --- a/init.d.FreeBSD/mixer.in +++ /dev/null @@ -1,47 +0,0 @@ -#!@PREFIX@/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 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} -} diff --git a/init.d.FreeBSD/nscd.in b/init.d.FreeBSD/nscd.in deleted file mode 100644 index e70ba4a3..00000000 --- a/init.d.FreeBSD/nscd.in +++ /dev/null @@ -1,22 +0,0 @@ -#!@PREFIX@/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.in b/init.d.FreeBSD/powerd.in deleted file mode 100644 index 1c2d8456..00000000 --- a/init.d.FreeBSD/powerd.in +++ /dev/null @@ -1,35 +0,0 @@ -#!@PREFIX@/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 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 -} diff --git a/init.d.FreeBSD/syscons.in b/init.d.FreeBSD/syscons.in deleted file mode 100644 index 94c91a06..00000000 --- a/init.d.FreeBSD/syscons.in +++ /dev/null @@ -1,83 +0,0 @@ -#!@PREFIX@/sbin/runscript -# Copyright 2007-2008 Roy Marples -# 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 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} -} diff --git a/init.d.Linux/consolefont.in b/init.d.Linux/consolefont.in deleted file mode 100644 index a30961e4..00000000 --- a/init.d.Linux/consolefont.in +++ /dev/null @@ -1,78 +0,0 @@ -#!@PREFIX@/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 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} -} diff --git a/init.d.Linux/keymaps.in b/init.d.Linux/keymaps.in deleted file mode 100644 index 2079e049..00000000 --- a/init.d.Linux/keymaps.in +++ /dev/null @@ -1,69 +0,0 @@ -#!@PREFIX@/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 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 -} diff --git a/init.d.Linux/modules.in b/init.d.Linux/modules.in deleted file mode 100644 index 1a0c7458..00000000 --- a/init.d.Linux/modules.in +++ /dev/null @@ -1,59 +0,0 @@ -#!@PREFIX@/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 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 -} diff --git a/init.d.Linux/mtab.in b/init.d.Linux/mtab.in deleted file mode 100644 index a0f14b1e..00000000 --- a/init.d.Linux/mtab.in +++ /dev/null @@ -1,30 +0,0 @@ -#!@PREFIX@/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.in b/init.d.Linux/numlock.in deleted file mode 100644 index 1a71367e..00000000 --- a/init.d.Linux/numlock.in +++ /dev/null @@ -1,42 +0,0 @@ -#!@PREFIX@/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 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" -} diff --git a/init.d.Linux/procfs.in b/init.d.Linux/procfs.in deleted file mode 100644 index a30fd92c..00000000 --- a/init.d.Linux/procfs.in +++ /dev/null @@ -1,89 +0,0 @@ -#!@PREFIX@/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 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 -} diff --git a/init.d.Linux/sysctl.in b/init.d.Linux/sysctl.in deleted file mode 100644 index ad6b2a92..00000000 --- a/init.d.Linux/sysctl.in +++ /dev/null @@ -1,18 +0,0 @@ -#!@PREFIX@/sbin/runscript -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -depend() -{ - use hostname - before bootmisc logger - keyword noopenvz noprefix novserver -} - -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/.gitignore b/init.d.NetBSD/.gitignore deleted file mode 100644 index 70290857..00000000 --- a/init.d.NetBSD/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -swap-blk -ttys -wscons diff --git a/init.d.NetBSD/Makefile b/init.d.NetBSD/Makefile deleted file mode 100644 index 07ab1cf2..00000000 --- a/init.d.NetBSD/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -DIR= ${INITDIR} -SRCS= swap-blk.in ttys.in wscons.in -BIN= ${OBJS} - -MK= ../mk -include ${MK}/scripts.mk diff --git a/init.d.NetBSD/swap-blk.in b/init.d.NetBSD/swap-blk.in deleted file mode 100644 index 4708bfff..00000000 --- a/init.d.NetBSD/swap-blk.in +++ /dev/null @@ -1,23 +0,0 @@ -#!@PREFIX@/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.NetBSD/ttys.in b/init.d.NetBSD/ttys.in deleted file mode 100644 index 8381d042..00000000 --- a/init.d.NetBSD/ttys.in +++ /dev/null @@ -1,23 +0,0 @@ -#!@PREFIX@/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.in b/init.d.NetBSD/wscons.in deleted file mode 100644 index 15e5b56b..00000000 --- a/init.d.NetBSD/wscons.in +++ /dev/null @@ -1,100 +0,0 @@ -#!@PREFIX@/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/Makefile b/init.d/Makefile index 38a3f412..a9f62e25 100644 --- a/init.d/Makefile +++ b/init.d/Makefile @@ -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 diff --git a/init.d/Makefile.FreeBSD b/init.d/Makefile.FreeBSD new file mode 100644 index 00000000..81c7633d --- /dev/null +++ b/init.d/Makefile.FreeBSD @@ -0,0 +1 @@ +SRCS+= adjkerntz.in devd.in dumpon.in ipfw.in mixer.in nscd.in powerd.in syscons.in diff --git a/init.d/Makefile.Linux b/init.d/Makefile.Linux new file mode 100644 index 00000000..f8be1de9 --- /dev/null +++ b/init.d/Makefile.Linux @@ -0,0 +1,2 @@ +SRCS+= hwclock.in consolefont.in keymaps.in modules.in mtab.in numlock.in \ + procfs.in diff --git a/init.d/Makefile.NetBSD b/init.d/Makefile.NetBSD new file mode 100644 index 00000000..90832db5 --- /dev/null +++ b/init.d/Makefile.NetBSD @@ -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 diff --git a/init.d/adjkerntz.in b/init.d/adjkerntz.in new file mode 100644 index 00000000..cf8c1fa8 --- /dev/null +++ b/init.d/adjkerntz.in @@ -0,0 +1,62 @@ +#!@PREFIX@/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() +{ + 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 +} diff --git a/init.d/consolefont.in b/init.d/consolefont.in new file mode 100644 index 00000000..a30961e4 --- /dev/null +++ b/init.d/consolefont.in @@ -0,0 +1,78 @@ +#!@PREFIX@/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 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} +} diff --git a/init.d/devd.in b/init.d/devd.in new file mode 100644 index 00000000..039aa961 --- /dev/null +++ b/init.d/devd.in @@ -0,0 +1,22 @@ +#!@PREFIX@/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/dumpon.in b/init.d/dumpon.in new file mode 100644 index 00000000..f2b65308 --- /dev/null +++ b/init.d/dumpon.in @@ -0,0 +1,25 @@ +#!@PREFIX@/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/hostid.in b/init.d/hostid.in new file mode 100644 index 00000000..a0588848 --- /dev/null +++ b/init.d/hostid.in @@ -0,0 +1,78 @@ +#!@PREFIX@/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/hwclock.in b/init.d/hwclock.in new file mode 100644 index 00000000..9b1a87d5 --- /dev/null +++ b/init.d/hwclock.in @@ -0,0 +1,137 @@ +#!@PREFIX@/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() +{ + 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} +} diff --git a/init.d/ipfw.in b/init.d/ipfw.in new file mode 100644 index 00000000..f8d9c3e1 --- /dev/null +++ b/init.d/ipfw.in @@ -0,0 +1,149 @@ +#!@PREFIX@/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/keymaps.in b/init.d/keymaps.in new file mode 100644 index 00000000..2079e049 --- /dev/null +++ b/init.d/keymaps.in @@ -0,0 +1,69 @@ +#!@PREFIX@/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 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 +} diff --git a/init.d/mixer.in b/init.d/mixer.in new file mode 100644 index 00000000..f496bd18 --- /dev/null +++ b/init.d/mixer.in @@ -0,0 +1,47 @@ +#!@PREFIX@/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 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} +} diff --git a/init.d/modules.in b/init.d/modules.in new file mode 100644 index 00000000..1a0c7458 --- /dev/null +++ b/init.d/modules.in @@ -0,0 +1,59 @@ +#!@PREFIX@/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 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 +} diff --git a/init.d/moused.in b/init.d/moused.in new file mode 100644 index 00000000..a0e97cdf --- /dev/null +++ b/init.d/moused.in @@ -0,0 +1,62 @@ +#!@PREFIX@/sbin/runscript +# Copyright 2007-2008 Roy Marples +# 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" +} diff --git a/init.d/mtab.in b/init.d/mtab.in new file mode 100644 index 00000000..a0f14b1e --- /dev/null +++ b/init.d/mtab.in @@ -0,0 +1,30 @@ +#!@PREFIX@/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/newsyslog.in b/init.d/newsyslog.in new file mode 100644 index 00000000..04ca7928 --- /dev/null +++ b/init.d/newsyslog.in @@ -0,0 +1,18 @@ +#!@PREFIX@/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 + keyword noprefix +} + +start() +{ + ebegin "Creating and/or trimming log files" + newsyslog -s ${newsyslog_args} + eend $? +} diff --git a/init.d/nscd.in b/init.d/nscd.in new file mode 100644 index 00000000..e70ba4a3 --- /dev/null +++ b/init.d/nscd.in @@ -0,0 +1,22 @@ +#!@PREFIX@/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/numlock.in b/init.d/numlock.in new file mode 100644 index 00000000..1a71367e --- /dev/null +++ b/init.d/numlock.in @@ -0,0 +1,42 @@ +#!@PREFIX@/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 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" +} diff --git a/init.d/pf.in b/init.d/pf.in new file mode 100644 index 00000000..fa55ea48 --- /dev/null +++ b/init.d/pf.in @@ -0,0 +1,59 @@ +#!@PREFIX@/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/powerd.in b/init.d/powerd.in new file mode 100644 index 00000000..1c2d8456 --- /dev/null +++ b/init.d/powerd.in @@ -0,0 +1,35 @@ +#!@PREFIX@/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 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 +} diff --git a/init.d/procfs.in b/init.d/procfs.in new file mode 100644 index 00000000..a30fd92c --- /dev/null +++ b/init.d/procfs.in @@ -0,0 +1,89 @@ +#!@PREFIX@/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 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 +} diff --git a/init.d/rarpd.in b/init.d/rarpd.in new file mode 100644 index 00000000..e7510990 --- /dev/null +++ b/init.d/rarpd.in @@ -0,0 +1,28 @@ +#!@PREFIX@/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/rc-enabled.in b/init.d/rc-enabled.in new file mode 100644 index 00000000..9801203b --- /dev/null +++ b/init.d/rc-enabled.in @@ -0,0 +1,54 @@ +#!@PREFIX@/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/* @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 +} diff --git a/init.d/rpcbind.in b/init.d/rpcbind.in new file mode 100644 index 00000000..2d053ebd --- /dev/null +++ b/init.d/rpcbind.in @@ -0,0 +1,21 @@ +#!@PREFIX@/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/savecore.in b/init.d/savecore.in new file mode 100644 index 00000000..e23bde48 --- /dev/null +++ b/init.d/savecore.in @@ -0,0 +1,36 @@ +#!@PREFIX@/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/swap-blk.in b/init.d/swap-blk.in new file mode 100644 index 00000000..4708bfff --- /dev/null +++ b/init.d/swap-blk.in @@ -0,0 +1,23 @@ +#!@PREFIX@/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/syscons.in b/init.d/syscons.in new file mode 100644 index 00000000..94c91a06 --- /dev/null +++ b/init.d/syscons.in @@ -0,0 +1,83 @@ +#!@PREFIX@/sbin/runscript +# Copyright 2007-2008 Roy Marples +# 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. + +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/syslogd.in b/init.d/syslogd.in new file mode 100644 index 00000000..b39a7d3c --- /dev/null +++ b/init.d/syslogd.in @@ -0,0 +1,20 @@ +#!@PREFIX@/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 + keyword noprefix +} diff --git a/init.d/ttys.in b/init.d/ttys.in new file mode 100644 index 00000000..8381d042 --- /dev/null +++ b/init.d/ttys.in @@ -0,0 +1,23 @@ +#!@PREFIX@/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/wscons.in b/init.d/wscons.in new file mode 100644 index 00000000..15e5b56b --- /dev/null +++ b/init.d/wscons.in @@ -0,0 +1,100 @@ +#!@PREFIX@/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/mk/scripts.mk b/mk/scripts.mk index 146b56a5..1bb5662b 100644 --- a/mk/scripts.mk +++ b/mk/scripts.mk @@ -16,29 +16,32 @@ SED_REPLACE= -e 's:@SHELL@:${SH}:g' -e 's:@LIB@:${LIBNAME}:g' -e 's:@SYSCONFDIR # Tweak our shell scripts .SUFFIXES: .sh.in .in .sh.in.sh: - sed ${SED_REPLACE} $< > $@ + sed ${SED_REPLACE} ${SED_EXTRA} $< > $@ .in: - sed ${SED_REPLACE} $< > $@ + sed ${SED_REPLACE} ${SED_EXTRA} $< > $@ all: ${OBJS} realinstall: ${BIN} ${CONF} ${CONF_APPEND} - if test -n "${DIR}"; then ${INSTALL} -d ${DESTDIR}/${PREFIX}${DIR} || exit $$?; fi - if test -n "${BIN}"; then ${INSTALL} -m ${BINMODE} ${BIN} ${DESTDIR}/${PREFIX}${DIR} || exit $$?; fi - if test -n "${INC}"; then ${INSTALL} -m ${INCMODE} ${INC} ${DESTDIR}/${PREFIX}${DIR} || exit $$?; fi - for x in ${CONF}; do \ - if ! test -e ${DESTDIR}/${PREFIX}${DIR}/$$x; then \ + @if test -n "${DIR}"; then \ + ${ECHO} ${INSTALL} -d ${DESTDIR}/${PREFIX}${DIR}; \ + ${INSTALL} -d ${DESTDIR}/${PREFIX}${DIR} || exit $$?; \ + fi + @if test -n "${BIN}"; then \ + ${ECHO} ${INSTALL} -m ${BINMODE} ${BIN} ${DESTDIR}/${PREFIX}${DIR}; \ + ${INSTALL} -m ${BINMODE} ${BIN} ${DESTDIR}/${PREFIX}${DIR} || exit $$?; \ + fi + @if test -n "${INC}"; then \ + ${ECHO} ${INSTALL} -m ${INCMODE} ${INC} ${DESTDIR}/${PREFIX}${DIR}; \ + ${INSTALL} -m ${INCMODE} ${INC} ${DESTDIR}/${PREFIX}${DIR} || exit $$?; \ + fi + @for x in ${CONF}; do \ + if ! test -e ${DESTDIR}/${PREFIX}${DIR}/$$x; then \ + ${ECHO} ${INSTALL} -m ${CONFMODE} $$x ${DESTDIR}/${PREFIX}${DIR}; \ ${INSTALL} -m ${CONFMODE} $$x ${DESTDIR}/${PREFIX}${DIR} || exit $$?; \ fi; \ done - for x in ${CONF_APPEND}; do \ - if test -e ${DESTDIR}/${PREFIX}${DIR}/$$x; then \ - cat $$x >> ${DESTDIR}/${PREFIX}${DIR}/$$x || exit $$?; \ - else \ - ${INSTALL} -m ${CONFMODE} $$x ${DESTDIR}/${PREFIX}${DIR} || exit $$?; \ - fi; \ - done install: all realinstall ${INSTALLAFTER} diff --git a/net.NetBSD/Makefile b/net.NetBSD/Makefile deleted file mode 100644 index ebdb26f2..00000000 --- a/net.NetBSD/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -DIR= ${RC_LIB}/net -INC= ifwatchd.sh - -MK= ../mk -include ${MK}/scripts.mk diff --git a/net.NetBSD/ifwatchd.sh b/net.NetBSD/ifwatchd.sh deleted file mode 100644 index 44c6ea31..00000000 --- a/net.NetBSD/ifwatchd.sh +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -_config_vars="$_config_vars plug_timeout" - -ifwatchd_depend() -{ - program start /usr/sbin/ifwatchd - after macnet rename wireless - before interface - provide plug -} - -ifwatchd_pre_start() -{ - # We don't start ifwatchd if we're being called from the background - yesno ${IN_BACKGROUND} && return 0 - - _exists || return 0 - - # We need a valid MAC address - # It's a basic test to ensure it's not a virtual interface - if ! _get_mac_address >/dev/null 2>&1; then - vewarn "ifwatchd only works on interfaces with a valid MAC address" - return 0 - fi - - ebegin "Starting ifwatchd on ${IFACE}" - - # Mark the us as inactive so ifwatchd can restart us - mark_service_inactive - - # Start ifwatchd - export IN_BACKGROUND=yes - start-stop-daemon --start --exec /usr/sbin/ifwatchd \ - -- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \ - -n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" - unset IN_BACKGROUND - eend "$?" || return 1 - - einfo "Backgrounding ..." - exit 1 -} - -ifwatchd_stop() -{ - yesno ${IN_BACKGROUND} && return 0 - - start-stop-daemon --test --quiet --stop --exec /usr/sbin/ifwatchd \ - -- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \ - -n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" \ - || return 0 - - ebegin "Stopping ifwatchd on" "${IFACE}" - start-stop-daemon --stop --exec /usr/sbin/ifwatchd \ - -- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \ - -n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" \ - && return 0 - eend $? -} diff --git a/net/Makefile b/net/Makefile index 944c3fc3..e2eb4d36 100644 --- a/net/Makefile +++ b/net/Makefile @@ -3,4 +3,6 @@ INC= dhclient.sh dhcpcd.sh macchanger.sh macnet.sh \ ssidnet.sh system.sh wpa_supplicant.sh MK= ../mk +include ${MK}/os.mk +include Makefile.${OS} include ${MK}/scripts.mk diff --git a/net/Makefile.FreeBSD b/net/Makefile.FreeBSD new file mode 100644 index 00000000..e69de29b diff --git a/net/Makefile.Linux b/net/Makefile.Linux new file mode 100644 index 00000000..e69de29b diff --git a/net/Makefile.NetBSD b/net/Makefile.NetBSD new file mode 100644 index 00000000..cda89ef9 --- /dev/null +++ b/net/Makefile.NetBSD @@ -0,0 +1 @@ +INC+= ifwatchd.sh diff --git a/net/ifwatchd.sh b/net/ifwatchd.sh new file mode 100644 index 00000000..44c6ea31 --- /dev/null +++ b/net/ifwatchd.sh @@ -0,0 +1,60 @@ +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +_config_vars="$_config_vars plug_timeout" + +ifwatchd_depend() +{ + program start /usr/sbin/ifwatchd + after macnet rename wireless + before interface + provide plug +} + +ifwatchd_pre_start() +{ + # We don't start ifwatchd if we're being called from the background + yesno ${IN_BACKGROUND} && return 0 + + _exists || return 0 + + # We need a valid MAC address + # It's a basic test to ensure it's not a virtual interface + if ! _get_mac_address >/dev/null 2>&1; then + vewarn "ifwatchd only works on interfaces with a valid MAC address" + return 0 + fi + + ebegin "Starting ifwatchd on ${IFACE}" + + # Mark the us as inactive so ifwatchd can restart us + mark_service_inactive + + # Start ifwatchd + export IN_BACKGROUND=yes + start-stop-daemon --start --exec /usr/sbin/ifwatchd \ + -- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \ + -n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" + unset IN_BACKGROUND + eend "$?" || return 1 + + einfo "Backgrounding ..." + exit 1 +} + +ifwatchd_stop() +{ + yesno ${IN_BACKGROUND} && return 0 + + start-stop-daemon --test --quiet --stop --exec /usr/sbin/ifwatchd \ + -- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \ + -n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" \ + || return 0 + + ebegin "Stopping ifwatchd on" "${IFACE}" + start-stop-daemon --stop --exec /usr/sbin/ifwatchd \ + -- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \ + -n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" \ + && return 0 + eend $? +} diff --git a/runlevels/Makefile b/runlevels/Makefile index 38d93060..9b2a7491 100644 --- a/runlevels/Makefile +++ b/runlevels/Makefile @@ -11,7 +11,6 @@ include ${MK}/sys.mk include ${MK}/os.mk include ${MK}/gitignore.mk include Makefile.${OS} -include Makefile.${SUBOS} all: diff --git a/runlevels/Makefile.FreeBSD b/runlevels/Makefile.FreeBSD index fa8622bc..614e965b 100644 --- a/runlevels/Makefile.FreeBSD +++ b/runlevels/Makefile.FreeBSD @@ -1 +1,5 @@ -BOOT+= clock dumpon syscons +# Generic BSD stuff +BOOT+= hostid net.lo0 newsyslog savecore syslogd + +# FreeBSD specific stuff +BOOT+= adjkerntz dumpon syscons diff --git a/runlevels/Makefile.Linux b/runlevels/Makefile.Linux index 81101e34..1aa23f96 100644 --- a/runlevels/Makefile.Linux +++ b/runlevels/Makefile.Linux @@ -1,2 +1,2 @@ -BOOT+= clock consolefont keymaps modules mtab net.lo procfs +BOOT+= hwclock consolefont keymaps modules mtab net.lo procfs DEFAULT+= hdparm diff --git a/runlevels/Makefile.NetBSD b/runlevels/Makefile.NetBSD index ad61d8fb..e6c2e646 100644 --- a/runlevels/Makefile.NetBSD +++ b/runlevels/Makefile.NetBSD @@ -1 +1,5 @@ -BOOT+= ttys wscons +# Generic BSD stuff +BOOT+= hostid net.lo0 newsyslog savecore syslogd + +# NetBSD specific stuff +BOOT+= ttys wscons diff --git a/sh.BSD/.gitignore b/sh.BSD/.gitignore deleted file mode 100644 index 3dfb118f..00000000 --- a/sh.BSD/.gitignore +++ /dev/null @@ -1 +0,0 @@ -init.sh diff --git a/sh.BSD/Makefile b/sh.BSD/Makefile deleted file mode 100644 index f4544368..00000000 --- a/sh.BSD/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -DIR= ${RC_LIB}/sh -SRCS= init.sh.in -BIN= ${OBJS} - -MK= ../mk -include ${MK}/scripts.mk diff --git a/sh.BSD/init.sh.in b/sh.BSD/init.sh.in deleted file mode 100644 index dbff7368..00000000 --- a/sh.BSD/init.sh.in +++ /dev/null @@ -1,51 +0,0 @@ -#!@SHELL@ -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -# This basically mounts $svcdir as a ramdisk, but preserving its content -# which allows us to run depscan.sh -# FreeBSD has a nice ramdisk - we don't set a size as we should always -# be fairly small and we unmount them after the boot level is done anyway -# NOTE we don't set a size for Linux either -# FreeBSD-7 supports tmpfs now :) -mount_svcdir() -{ - local dotmp=false release=false retval=0 - if [ -e "${RC_SVCDIR}"/deptree ]; then - dotmp=true - if ! mount -t tmpfs none "${RC_LIBDIR}"/tmp 2>/dev/null; then - mdconfig -a -t malloc -s 1m -u 1 - newfs /dev/md1 - mount /dev/md1 "${RC_LIBDIR}"/tmp - release=true - fi - cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \ - "${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null - fi - if ! fstabinfo --mount "${RC_SVCDIR}"; then - if ! mount -t tmpfs -o rw,noexec,nosuid none "${RC_SVCDIR}" 2>/dev/null; then - mdconfig -a -t malloc -s "${rc_svcsize:-1024}"k -u 0 - newfs -b 4096 -i 1024 -n /dev/md0 - mount -o rw,noexec,nosuid /dev/md0 "${RC_SVCDIR}" - fi - fi - retval=$? - if ${dotmp}; then - cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \ - "${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null - umount "${RC_LIBDIR}"/tmp - ${release} && mdconfig -d -u 1 - fi - - return ${retval} -} - -. "${RC_LIBDIR}"/sh/functions.sh -[ -r /etc/rc.conf ] && . /etc/rc.conf - -# Disable devd until we need it -if [ -z "${RC_SYS}" -a "${RC_UNAME}" = "FreeBSD" ]; then - sysctl hw.bus.devctl_disable=1 >/dev/null -fi - -. "${RC_LIBDIR}"/sh/init-common-post.sh diff --git a/sh.Linux/.gitignore b/sh.Linux/.gitignore deleted file mode 100644 index 35d6396d..00000000 --- a/sh.Linux/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -init-early.sh -init.sh diff --git a/sh.Linux/Makefile b/sh.Linux/Makefile deleted file mode 100644 index 829cb7ca..00000000 --- a/sh.Linux/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -DIR= ${RC_LIB}/sh -SRCS= init-early.sh.in init.sh.in -BIN= ${OBJS} - -MK= ../mk -include ${MK}/scripts.mk diff --git a/sh.Linux/init-early.sh.in b/sh.Linux/init-early.sh.in deleted file mode 100644 index d6cb007d..00000000 --- a/sh.Linux/init-early.sh.in +++ /dev/null @@ -1,20 +0,0 @@ -#!@SHELL@ -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -# Try and set a font and as early as we can -if [ -e /etc/runlevels/"${RC_DEFAULTLEVEL}"/consolefont \ - -o -e /etc/runlevels/"${RC_BOOTLEVEL}"/consolefont ]; then - termencoding="(K" - [ -e "${RC_LIBDIR}"/console/unicode ] && termencoding="%G" - CONSOLE="${CONSOLE:-/dev/console}" - printf "\033%s" "${termencoding}" >"${CONSOLE}" 2>/dev/null - if [ -r "${RC_LIBDIR}"/console/font -a -x /bin/setfont ]; then - font="$(cat "${RC_LIBDIR}"/console/font)" - [ -c "${CONSOLE}" ] && cons="-C ${CONSOLE}" - setfont ${cons} "${RC_LIBDIR}"/console/"${font}" 2>/dev/null - fi -fi - -# Ensure we exit 0 so the boot continues -exit 0 diff --git a/sh.Linux/init.sh.in b/sh.Linux/init.sh.in deleted file mode 100644 index 25a3ecb7..00000000 --- a/sh.Linux/init.sh.in +++ /dev/null @@ -1,185 +0,0 @@ -#!@SHELL@ -# Copyright 1999-2007 Gentoo Foundation -# Copyright 2007-2008 Roy Marples -# All rights reserved. Released under the 2-clause BSD license. - -# This basically mounts $RC_SVCDIR as a ramdisk, but preserving its content -# which allows us to store service state and generate dependencies if needed. -# The tricky part is finding something our kernel supports -# tmpfs and ramfs are easy, so force one or the other. -mount_svcdir() -{ - local fs= fsopts="-o rw,noexec,nodev,nosuid" devdir="rc-svcdir" devtmp="none" x= - local svcsize=${rc_svcsize:-1024} - - if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then - fs="tmpfs" - fsopts="${fsopts},mode=0755,size=${svcsize}k" - elif grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then - fs="ramfs" - # ramfs has no special options - elif [ -e /dev/ram0 -a -e /dev/ram1 ] \ - && grep -Eq "[[:space:]]+ext2$" /proc/filesystems; then - devdir="/dev/ram0" - devtmp="/dev/ram1" - fs="ext2" - for x in ${devdir} ${devtmp}; do - dd if=/dev/zero of="${x}" bs=1k count="${svcsize}" - mkfs -t "${fs}" -i 1024 -vm0 "${x}" "${svcsize}" - done - else - echo - eerror "OpenRC requires tmpfs, ramfs or 2 ramdisks + ext2" - eerror "compiled into the kernel" - echo - return 1 - fi - - local dotmp=false - if [ -e "${RC_SVCDIR}"/deptree ]; then - dotmp=true - mount -n -t "${fs}" -o rw "${devtmp}" "${RC_LIBDIR}"/tmp - cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \ - "${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null - fi - - # If we have no entry in fstab for $RC_SVCDIR, provide our own - if ! fstabinfo --mount "${RC_SVCDIR}"; then - mount -n -t "${fs}" ${fsopts} "${devdir}" "${RC_SVCDIR}" - fi - - if ${dotmp}; then - cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \ - "${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null - umount -n "${RC_LIBDIR}"/tmp - fi -} - -. /etc/init.d/functions.sh -. "${RC_LIBDIR}"/sh/rc-functions.sh -[ -r /etc/conf.d/rc ] && . /etc/conf.d/rc -[ -r /etc/rc.conf ] && . /etc/rc.conf - -# Set the console loglevel to 1 for a cleaner boot -# the logger should anyhow dump the ring-0 buffer at start to the -# logs, and that with dmesg can be used to check for problems -if [ -n "${dmesg_level}" -a "${RC_SYS}" != "VSERVER" ]; then - dmesg -n "${dmesg_level}" -fi - -# By default VServer already has /proc mounted, but OpenVZ does not! -# However, some of our users have an old proc image in /proc -# NFC how they managed that, but the end result means we have to test if -# /proc actually works or not. We to this by comparing uptime to one a second -# ago -mountproc=true -if [ -e /proc/uptime ]; then - up="$(cat /proc/uptime)" - sleep 1 - if [ "${up}" = "$(cat /proc/uptime)" ]; then - eerror "You have cruft in /proc that should be deleted" - else - einfo "/proc is already mounted, skipping" - mountproc=false - fi - unset up -fi - -if ${mountproc}; then - procfs="proc" - [ "${RC_UNAME}" = "GNU/kFreeBSD" ] && proc="linprocfs" - ebegin "Mounting /proc" - if ! fstabinfo --mount /proc; then - mount -n -t "${procfs}" -o noexec,nosuid,nodev proc /proc - fi - eend $? -fi -unset mountproc - -# Read off the kernel commandline to see if there's any special settings -# especially check to see if we need to set the CDBOOT environment variable -# Note: /proc MUST be mounted -if [ -r /sbin/livecd-functions.sh ]; then - . /sbin/livecd-functions.sh - livecd_read_commandline -fi - -if [ "${RC_UNAME}" != "GNU/kFreeBSD" \ - -a "${RC_SYS}" != "VSERVER" \ - -a "${RC_SYS}" != "OPENVZ" ] -then - if grep -Eq "[[:space:]]+sysfs$" /proc/filesystems; then - if [ -d /sys ]; then - if ! mountinfo --quiet /sys; then - ebegin "Mounting /sys" - if ! fstabinfo --mount /sys; then - mount -n -t sysfs -o noexec,nosuid,nodev sysfs /sys - fi - eend $? - fi - else - ewarn "No /sys to mount sysfs needed in 2.6 and later kernels!" - fi - fi -fi - -# Try to figure out how the user wants /dev handled -if [ "${rc_devices}" = "static" \ - -o "${RC_SYS}" = "VSERVER" \ - -o "${RC_SYS}" = "OPENVZ" \ - -o "${RC_UNAME}" = "GNU/kFreeBSD" ] -then - ebegin "Using existing device nodes in /dev" - eend 0 -else - case ${rc_devices} in - devfs) managers="devfs udev mdev";; - udev) managers="udev devfs mdev";; - mdev) managers="mdev udev devfs";; - *) managers="udev devfs mdev";; - esac - - for m in ${managers}; do - # Check kernel params - if get_bootparam "no${m}" || ! has_addon ${m}-start; then - continue - fi - # Let's see if we can get this puppy rolling - start_addon ${m} && break - - # Clean up - mountinfo -q /dev && umount -n /dev - done -fi - -# Mount required stuff as user may not have then in /etc/fstab -for x in "devpts /dev/pts 0755 ,gid=5,mode=0620 devpts" "tmpfs /dev/shm 1777 ,nodev shm" -do - set -- ${x} - grep -Eq "[[:space:]]+$1$" /proc/filesystems || continue - mountinfo -q "$2" && continue - - if [ ! -d "$2" ] && \ - [ "${m}" = "devfs" -o "${m}" = "udev" ]; then - mkdir -m "$3" -p "$2" >/dev/null 2>&1 || \ - ewarn "Could not create $2!" - fi - - if [ -d "$2" ]; then - ebegin "Mounting $2" - if ! fstabinfo --mount "$2"; then - mount -n -t "$1" -o noexec,nosuid"$4" "$5" "$2" - fi - eend $? - fi -done - -# If booting off CD, we want to update inittab before setting the runlevel -if [ -f /sbin/livecd-functions.sh -a -n "${CDBOOT}" ]; then - ebegin "Updating inittab" - livecd_fix_inittab - eend $? - telinit q &>/dev/null -fi - -. "${RC_LIBDIR}"/sh/init-common-post.sh diff --git a/sh.NetBSD/.gitignore b/sh.NetBSD/.gitignore deleted file mode 100644 index cb05fa78..00000000 --- a/sh.NetBSD/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -ifwatchd-carrier.sh -ifwatchd-nocarrier.sh diff --git a/sh.NetBSD/Makefile b/sh.NetBSD/Makefile deleted file mode 100644 index c93922bd..00000000 --- a/sh.NetBSD/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -DIR= ${RC_LIB}/sh -SRCS= ifwatchd-carrier.sh.in ifwatchd-nocarrier.sh.in -BIN= ifwatchd-carrier.sh ifwatchd-nocarrier.sh - -MK= ../mk -include ${MK}/scripts.mk diff --git a/sh.NetBSD/ifwatchd-carrier.sh.in b/sh.NetBSD/ifwatchd-carrier.sh.in deleted file mode 100644 index ec9c5abd..00000000 --- a/sh.NetBSD/ifwatchd-carrier.sh.in +++ /dev/null @@ -1,5 +0,0 @@ -#!@SHELL@ -# Wrapper for ifwatchd(8) - -export IN_BACKGROUND=yes -${RC_SERVICE} --quiet start diff --git a/sh.NetBSD/ifwatchd-nocarrier.sh.in b/sh.NetBSD/ifwatchd-nocarrier.sh.in deleted file mode 100644 index 3ba111cb..00000000 --- a/sh.NetBSD/ifwatchd-nocarrier.sh.in +++ /dev/null @@ -1,5 +0,0 @@ -#!@SHELL@ -# Wrapper for ifwatchd(8) - -export IN_BACKGROUND=yes -${RC_SERVICE} --quiet stop diff --git a/sh/Makefile b/sh/Makefile index 2f10ef53..43b796bd 100644 --- a/sh/Makefile +++ b/sh/Makefile @@ -2,14 +2,14 @@ DIR= ${RC_LIB}/sh SRCS= functions.sh.in gendepends.sh.in net.sh.in \ rc-functions.sh.in runscript.sh.in INC= init-common-post.sh rc-mount.sh functions.sh rc-functions.sh -BIN= gendepends.sh net.sh runscript.sh +BIN= gendepends.sh init.sh net.sh runscript.sh INSTALLAFTER= _installafter MK= ../mk -# To get NET_LO +include ${MK}/os.mk +include Makefile.${OS} include ${MK}/scripts.mk -include Makefile.${SUBOS} _installafter: ${INSTALL} -d ${DESTDIR}/${PREFIX}/${INITDIR} diff --git a/sh/Makefile.BSD b/sh/Makefile.BSD deleted file mode 100644 index f1e45618..00000000 --- a/sh/Makefile.BSD +++ /dev/null @@ -1 +0,0 @@ -NET_LO = net.lo0 diff --git a/sh/Makefile.FreeBSD b/sh/Makefile.FreeBSD new file mode 100644 index 00000000..210ee0c3 --- /dev/null +++ b/sh/Makefile.FreeBSD @@ -0,0 +1,8 @@ +SRCS+= init.sh.in + +NET_LO= net.lo0 + +.SUFFIXES: .BSD.sh.in +.BSD.sh.in.sh: + sed ${SED_REPLACE} ${SED_EXTRA} $< > $@ + diff --git a/sh/Makefile.Linux b/sh/Makefile.Linux index 219c92fb..6546d92b 100644 --- a/sh/Makefile.Linux +++ b/sh/Makefile.Linux @@ -1 +1,8 @@ -NET_LO = net.lo +NET_LO= net.lo +SRCS+= init.sh.in init-early.sh.in +BIN+= init-early.sh + +.SUFFIXES: .Linux.sh.in +.Linux.sh.in.sh: + sed ${SED_REPLACE} ${SED_EXTRA} $< > $@ + diff --git a/sh/Makefile.NetBSD b/sh/Makefile.NetBSD new file mode 100644 index 00000000..5b13c88a --- /dev/null +++ b/sh/Makefile.NetBSD @@ -0,0 +1,10 @@ +SRCS+= init.sh.in + +NET_LO= net.lo0 +SRCS+= ifwatchd-carrier.sh.in ifwatchd-nocarrier.sh.in +BIN+= ifwatchd-carrier.sh ifwatchd-nocarrier.sh + +.SUFFIXES: .BSD.sh.in +.BSD.sh.in.sh: + sed ${SED_REPLACE} ${SED_EXTRA} $< > $@ + diff --git a/sh/ifwatchd-carrier.sh.in b/sh/ifwatchd-carrier.sh.in new file mode 100644 index 00000000..ec9c5abd --- /dev/null +++ b/sh/ifwatchd-carrier.sh.in @@ -0,0 +1,5 @@ +#!@SHELL@ +# Wrapper for ifwatchd(8) + +export IN_BACKGROUND=yes +${RC_SERVICE} --quiet start diff --git a/sh/ifwatchd-nocarrier.sh.in b/sh/ifwatchd-nocarrier.sh.in new file mode 100644 index 00000000..3ba111cb --- /dev/null +++ b/sh/ifwatchd-nocarrier.sh.in @@ -0,0 +1,5 @@ +#!@SHELL@ +# Wrapper for ifwatchd(8) + +export IN_BACKGROUND=yes +${RC_SERVICE} --quiet stop diff --git a/sh/init-early.Linux.sh.in b/sh/init-early.Linux.sh.in new file mode 100644 index 00000000..d6cb007d --- /dev/null +++ b/sh/init-early.Linux.sh.in @@ -0,0 +1,20 @@ +#!@SHELL@ +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +# Try and set a font and as early as we can +if [ -e /etc/runlevels/"${RC_DEFAULTLEVEL}"/consolefont \ + -o -e /etc/runlevels/"${RC_BOOTLEVEL}"/consolefont ]; then + termencoding="(K" + [ -e "${RC_LIBDIR}"/console/unicode ] && termencoding="%G" + CONSOLE="${CONSOLE:-/dev/console}" + printf "\033%s" "${termencoding}" >"${CONSOLE}" 2>/dev/null + if [ -r "${RC_LIBDIR}"/console/font -a -x /bin/setfont ]; then + font="$(cat "${RC_LIBDIR}"/console/font)" + [ -c "${CONSOLE}" ] && cons="-C ${CONSOLE}" + setfont ${cons} "${RC_LIBDIR}"/console/"${font}" 2>/dev/null + fi +fi + +# Ensure we exit 0 so the boot continues +exit 0 diff --git a/sh/init.BSD.sh.in b/sh/init.BSD.sh.in new file mode 100644 index 00000000..dbff7368 --- /dev/null +++ b/sh/init.BSD.sh.in @@ -0,0 +1,51 @@ +#!@SHELL@ +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +# This basically mounts $svcdir as a ramdisk, but preserving its content +# which allows us to run depscan.sh +# FreeBSD has a nice ramdisk - we don't set a size as we should always +# be fairly small and we unmount them after the boot level is done anyway +# NOTE we don't set a size for Linux either +# FreeBSD-7 supports tmpfs now :) +mount_svcdir() +{ + local dotmp=false release=false retval=0 + if [ -e "${RC_SVCDIR}"/deptree ]; then + dotmp=true + if ! mount -t tmpfs none "${RC_LIBDIR}"/tmp 2>/dev/null; then + mdconfig -a -t malloc -s 1m -u 1 + newfs /dev/md1 + mount /dev/md1 "${RC_LIBDIR}"/tmp + release=true + fi + cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \ + "${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null + fi + if ! fstabinfo --mount "${RC_SVCDIR}"; then + if ! mount -t tmpfs -o rw,noexec,nosuid none "${RC_SVCDIR}" 2>/dev/null; then + mdconfig -a -t malloc -s "${rc_svcsize:-1024}"k -u 0 + newfs -b 4096 -i 1024 -n /dev/md0 + mount -o rw,noexec,nosuid /dev/md0 "${RC_SVCDIR}" + fi + fi + retval=$? + if ${dotmp}; then + cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \ + "${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null + umount "${RC_LIBDIR}"/tmp + ${release} && mdconfig -d -u 1 + fi + + return ${retval} +} + +. "${RC_LIBDIR}"/sh/functions.sh +[ -r /etc/rc.conf ] && . /etc/rc.conf + +# Disable devd until we need it +if [ -z "${RC_SYS}" -a "${RC_UNAME}" = "FreeBSD" ]; then + sysctl hw.bus.devctl_disable=1 >/dev/null +fi + +. "${RC_LIBDIR}"/sh/init-common-post.sh diff --git a/sh/init.Linux.sh.in b/sh/init.Linux.sh.in new file mode 100644 index 00000000..25a3ecb7 --- /dev/null +++ b/sh/init.Linux.sh.in @@ -0,0 +1,185 @@ +#!@SHELL@ +# Copyright 1999-2007 Gentoo Foundation +# Copyright 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +# This basically mounts $RC_SVCDIR as a ramdisk, but preserving its content +# which allows us to store service state and generate dependencies if needed. +# The tricky part is finding something our kernel supports +# tmpfs and ramfs are easy, so force one or the other. +mount_svcdir() +{ + local fs= fsopts="-o rw,noexec,nodev,nosuid" devdir="rc-svcdir" devtmp="none" x= + local svcsize=${rc_svcsize:-1024} + + if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then + fs="tmpfs" + fsopts="${fsopts},mode=0755,size=${svcsize}k" + elif grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then + fs="ramfs" + # ramfs has no special options + elif [ -e /dev/ram0 -a -e /dev/ram1 ] \ + && grep -Eq "[[:space:]]+ext2$" /proc/filesystems; then + devdir="/dev/ram0" + devtmp="/dev/ram1" + fs="ext2" + for x in ${devdir} ${devtmp}; do + dd if=/dev/zero of="${x}" bs=1k count="${svcsize}" + mkfs -t "${fs}" -i 1024 -vm0 "${x}" "${svcsize}" + done + else + echo + eerror "OpenRC requires tmpfs, ramfs or 2 ramdisks + ext2" + eerror "compiled into the kernel" + echo + return 1 + fi + + local dotmp=false + if [ -e "${RC_SVCDIR}"/deptree ]; then + dotmp=true + mount -n -t "${fs}" -o rw "${devtmp}" "${RC_LIBDIR}"/tmp + cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \ + "${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null + fi + + # If we have no entry in fstab for $RC_SVCDIR, provide our own + if ! fstabinfo --mount "${RC_SVCDIR}"; then + mount -n -t "${fs}" ${fsopts} "${devdir}" "${RC_SVCDIR}" + fi + + if ${dotmp}; then + cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \ + "${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null + umount -n "${RC_LIBDIR}"/tmp + fi +} + +. /etc/init.d/functions.sh +. "${RC_LIBDIR}"/sh/rc-functions.sh +[ -r /etc/conf.d/rc ] && . /etc/conf.d/rc +[ -r /etc/rc.conf ] && . /etc/rc.conf + +# Set the console loglevel to 1 for a cleaner boot +# the logger should anyhow dump the ring-0 buffer at start to the +# logs, and that with dmesg can be used to check for problems +if [ -n "${dmesg_level}" -a "${RC_SYS}" != "VSERVER" ]; then + dmesg -n "${dmesg_level}" +fi + +# By default VServer already has /proc mounted, but OpenVZ does not! +# However, some of our users have an old proc image in /proc +# NFC how they managed that, but the end result means we have to test if +# /proc actually works or not. We to this by comparing uptime to one a second +# ago +mountproc=true +if [ -e /proc/uptime ]; then + up="$(cat /proc/uptime)" + sleep 1 + if [ "${up}" = "$(cat /proc/uptime)" ]; then + eerror "You have cruft in /proc that should be deleted" + else + einfo "/proc is already mounted, skipping" + mountproc=false + fi + unset up +fi + +if ${mountproc}; then + procfs="proc" + [ "${RC_UNAME}" = "GNU/kFreeBSD" ] && proc="linprocfs" + ebegin "Mounting /proc" + if ! fstabinfo --mount /proc; then + mount -n -t "${procfs}" -o noexec,nosuid,nodev proc /proc + fi + eend $? +fi +unset mountproc + +# Read off the kernel commandline to see if there's any special settings +# especially check to see if we need to set the CDBOOT environment variable +# Note: /proc MUST be mounted +if [ -r /sbin/livecd-functions.sh ]; then + . /sbin/livecd-functions.sh + livecd_read_commandline +fi + +if [ "${RC_UNAME}" != "GNU/kFreeBSD" \ + -a "${RC_SYS}" != "VSERVER" \ + -a "${RC_SYS}" != "OPENVZ" ] +then + if grep -Eq "[[:space:]]+sysfs$" /proc/filesystems; then + if [ -d /sys ]; then + if ! mountinfo --quiet /sys; then + ebegin "Mounting /sys" + if ! fstabinfo --mount /sys; then + mount -n -t sysfs -o noexec,nosuid,nodev sysfs /sys + fi + eend $? + fi + else + ewarn "No /sys to mount sysfs needed in 2.6 and later kernels!" + fi + fi +fi + +# Try to figure out how the user wants /dev handled +if [ "${rc_devices}" = "static" \ + -o "${RC_SYS}" = "VSERVER" \ + -o "${RC_SYS}" = "OPENVZ" \ + -o "${RC_UNAME}" = "GNU/kFreeBSD" ] +then + ebegin "Using existing device nodes in /dev" + eend 0 +else + case ${rc_devices} in + devfs) managers="devfs udev mdev";; + udev) managers="udev devfs mdev";; + mdev) managers="mdev udev devfs";; + *) managers="udev devfs mdev";; + esac + + for m in ${managers}; do + # Check kernel params + if get_bootparam "no${m}" || ! has_addon ${m}-start; then + continue + fi + # Let's see if we can get this puppy rolling + start_addon ${m} && break + + # Clean up + mountinfo -q /dev && umount -n /dev + done +fi + +# Mount required stuff as user may not have then in /etc/fstab +for x in "devpts /dev/pts 0755 ,gid=5,mode=0620 devpts" "tmpfs /dev/shm 1777 ,nodev shm" +do + set -- ${x} + grep -Eq "[[:space:]]+$1$" /proc/filesystems || continue + mountinfo -q "$2" && continue + + if [ ! -d "$2" ] && \ + [ "${m}" = "devfs" -o "${m}" = "udev" ]; then + mkdir -m "$3" -p "$2" >/dev/null 2>&1 || \ + ewarn "Could not create $2!" + fi + + if [ -d "$2" ]; then + ebegin "Mounting $2" + if ! fstabinfo --mount "$2"; then + mount -n -t "$1" -o noexec,nosuid"$4" "$5" "$2" + fi + eend $? + fi +done + +# If booting off CD, we want to update inittab before setting the runlevel +if [ -f /sbin/livecd-functions.sh -a -n "${CDBOOT}" ]; then + ebegin "Updating inittab" + livecd_fix_inittab + eend $? + telinit q &>/dev/null +fi + +. "${RC_LIBDIR}"/sh/init-common-post.sh -- cgit v1.2.3