From 9c5433cb225f7a4e56e87623ea2e4011179553a5 Mon Sep 17 00:00:00 2001 From: gordon Date: Thu, 13 Jun 2002 22:14:37 +0000 Subject: [PATCH] Merge in all the changes that Mike Makonnen has been maintaining for a while. This is only the script pieces, the glue for the build comes next. Submitted by: Mike Makonnen Reviewed by: silence on -current and -hackers Prodded by: rwatson --- etc/rc.d/DAEMON | 8 +-- etc/rc.d/LOGIN | 8 +-- etc/rc.d/Makefile | 26 +++++---- etc/rc.d/NETWORK | 10 ---- etc/rc.d/NETWORKING | 12 ++++ etc/rc.d/SERVERS | 6 +- etc/rc.d/abi | 54 ++++++++++++++++++ etc/rc.d/accounting | 36 ++++++++++-- etc/rc.d/addswap | 34 ++++++++++++ etc/rc.d/adjkerntz | 18 ++++++ etc/rc.d/altqd | 22 ++++++++ etc/rc.d/amd | 65 +++++++++++++++++++--- etc/rc.d/apmd | 4 +- etc/rc.d/bgfsck | 19 +++++++ etc/rc.d/bootconf.sh | 27 ++++++--- etc/rc.d/bootparams | 4 +- etc/rc.d/ccd | 4 +- etc/rc.d/cleanvar | 48 ++++++++++++++++ etc/rc.d/cleartmp | 20 ++++++- etc/rc.d/cron | 7 ++- etc/rc.d/devdb | 17 ++++++ etc/rc.d/devfs | 19 +++++++ etc/rc.d/dhclient | 4 +- etc/rc.d/dhcpd | 4 +- etc/rc.d/dhcrelay | 4 +- etc/rc.d/dmesg | 12 ++-- etc/rc.d/dumpon | 32 +++++++++++ etc/rc.d/fsck | 43 +++++++++++++-- etc/rc.d/inetd | 7 ++- etc/rc.d/initrandom | 73 ++++++++++++++++++++++++ etc/rc.d/ip6fw | 58 ++++++++++++++++++++ etc/rc.d/ipfilter | 116 ++++++++++++++++++++++++++++++++------- etc/rc.d/ipfw | 70 +++++++++++++++++++++++ etc/rc.d/ipmon | 28 ++++++++-- etc/rc.d/ipnat | 80 ++++++++++++++++++++++----- etc/rc.d/ipsec | 17 ++++-- etc/rc.d/ipxrouted | 19 +++++++ etc/rc.d/kadmind | 32 +++++++++++ etc/rc.d/kdc | 6 +- etc/rc.d/kerberos | 27 +++++++++ etc/rc.d/keyserv | 22 ++++++++ etc/rc.d/ldconfig | 54 ++++++++++++++++-- etc/rc.d/lkm1 | 3 +- etc/rc.d/lkm2 | 3 +- etc/rc.d/lkm3 | 4 +- etc/rc.d/local | 8 ++- etc/rc.d/localdaemons | 89 ++++++++++++++++++++++++++++++ etc/rc.d/lockd | 29 ++++++++-- etc/rc.d/lomac | 19 +++++++ etc/rc.d/lpd | 16 +++++- etc/rc.d/mopd | 4 +- etc/rc.d/motd | 36 ++++++++++-- etc/rc.d/mountall | 3 +- etc/rc.d/mountcritlocal | 60 ++++++++++++++++---- etc/rc.d/mountcritremote | 82 +++++++++++++++++++++++++-- etc/rc.d/mountd | 45 +++++++++++++-- etc/rc.d/moused | 47 ++++++++++++++++ etc/rc.d/mroute6d | 18 ++++++ etc/rc.d/mrouted | 7 ++- etc/rc.d/msgs | 14 +++++ etc/rc.d/named | 111 ++++++++++++++++++++++++++++++++++++- etc/rc.d/newsyslog | 9 +-- etc/rc.d/nfsclient | 57 +++++++++++++++++++ etc/rc.d/nfsd | 35 ++++++++++-- etc/rc.d/nfslocking | 29 ++++++++-- etc/rc.d/nfsserver | 30 ++++++++++ etc/rc.d/ntpd | 48 ++++++++++++++-- etc/rc.d/ntpdate | 28 +++++++--- etc/rc.d/othermta | 16 ++++++ etc/rc.d/poffd | 3 +- etc/rc.d/postfix | 34 +++++++++--- etc/rc.d/ppp | 48 ++++++++++++++++ etc/rc.d/ppp-user | 48 ++++++++++++++++ etc/rc.d/pppoed | 31 +++++++++++ etc/rc.d/pwcheck | 5 +- etc/rc.d/quota | 23 ++++++-- etc/rc.d/racoon | 6 +- etc/rc.d/raidframe | 22 ++++---- etc/rc.d/random | 93 +++++++++++++++++++++++++++++++ etc/rc.d/rarpd | 7 ++- etc/rc.d/rbootd | 4 +- etc/rc.d/root | 36 ++++++++++-- etc/rc.d/route6d | 26 ++++++++- etc/rc.d/routed | 31 +++++++++-- etc/rc.d/rpcbind | 29 ++++++++-- etc/rc.d/rtadvd | 64 +++++++++++++++++++-- etc/rc.d/rtsold | 4 +- etc/rc.d/rwho | 7 ++- etc/rc.d/savecore | 62 ++++++++++++++++++--- etc/rc.d/screenblank | 4 +- etc/rc.d/securelevel | 49 ++++++++++++----- etc/rc.d/sendmail | 60 +++++++++++++++++--- etc/rc.d/sppp | 36 ++++++++++++ etc/rc.d/sshd | 58 ++++++++++++++------ etc/rc.d/statd | 29 ++++++++-- etc/rc.d/swap1 | 33 ++++++++++- etc/rc.d/swap2 | 4 +- etc/rc.d/sysdb | 6 +- etc/rc.d/syslogd | 55 ++++++++++++++++++- etc/rc.d/timed | 7 ++- etc/rc.d/ttys | 40 ++++++++++---- etc/rc.d/usbd | 18 ++++++ etc/rc.d/vinum | 17 ++++++ etc/rc.d/virecover | 58 +++++++++++++++++--- etc/rc.d/wscons | 39 ++++++++++++- etc/rc.d/xfs | 4 +- etc/rc.d/ypbind | 16 +++++- etc/rc.d/yppasswdd | 21 +++++-- etc/rc.d/ypserv | 18 +++++- etc/rc.d/ypset | 29 ++++++++++ etc/rc.d/ypupdated | 28 ++++++++++ etc/rc.d/ypxfrd | 29 ++++++++++ 112 files changed, 2913 insertions(+), 354 deletions(-) delete mode 100755 etc/rc.d/NETWORK create mode 100644 etc/rc.d/NETWORKING create mode 100644 etc/rc.d/abi create mode 100644 etc/rc.d/addswap create mode 100644 etc/rc.d/adjkerntz create mode 100644 etc/rc.d/altqd create mode 100644 etc/rc.d/bgfsck create mode 100644 etc/rc.d/cleanvar create mode 100644 etc/rc.d/devdb create mode 100644 etc/rc.d/devfs create mode 100644 etc/rc.d/dumpon create mode 100644 etc/rc.d/initrandom create mode 100644 etc/rc.d/ip6fw create mode 100644 etc/rc.d/ipfw create mode 100644 etc/rc.d/ipxrouted create mode 100644 etc/rc.d/kadmind create mode 100644 etc/rc.d/kerberos create mode 100644 etc/rc.d/keyserv create mode 100644 etc/rc.d/localdaemons create mode 100644 etc/rc.d/lomac create mode 100644 etc/rc.d/moused create mode 100644 etc/rc.d/mroute6d create mode 100644 etc/rc.d/msgs create mode 100644 etc/rc.d/nfsclient create mode 100644 etc/rc.d/nfsserver create mode 100644 etc/rc.d/othermta create mode 100644 etc/rc.d/ppp create mode 100644 etc/rc.d/ppp-user create mode 100644 etc/rc.d/pppoed create mode 100644 etc/rc.d/random create mode 100644 etc/rc.d/sppp create mode 100644 etc/rc.d/usbd create mode 100644 etc/rc.d/vinum create mode 100644 etc/rc.d/ypset create mode 100644 etc/rc.d/ypupdated create mode 100644 etc/rc.d/ypxfrd diff --git a/etc/rc.d/DAEMON b/etc/rc.d/DAEMON index 5619e56bff4..0dce9948856 100755 --- a/etc/rc.d/DAEMON +++ b/etc/rc.d/DAEMON @@ -1,12 +1,12 @@ #!/bin/sh # -# $NetBSD: DAEMON,v 1.4 2000/08/21 23:39:07 lukem Exp $ +# $NetBSD: DAEMON,v 1.8 2002/03/22 04:33:57 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: DAEMON -# REQUIRE: accounting aftermountlkm amd cleartmp dmesg ipmon -# REQUIRE: ipnat ipsec ldconfig named network nonlocalswap nfslocking -# REQUIRE: pwcheck quota savecore securelevel sysctl sysdb virecover ypbind +# REQUIRE: NETWORKING SERVERS +# KEYWORD: FreeBSD NetBSD # This is a dummy dependancy, to ensure that general purpose daemons # are run _after_ the above are. diff --git a/etc/rc.d/LOGIN b/etc/rc.d/LOGIN index 39fc88bbaf2..f4501b165f1 100755 --- a/etc/rc.d/LOGIN +++ b/etc/rc.d/LOGIN @@ -1,12 +1,12 @@ #!/bin/sh # -# $NetBSD: LOGIN,v 1.3 2000/07/20 23:36:56 lukem Exp $ +# $NetBSD: LOGIN,v 1.7 2002/03/22 04:33:57 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: LOGIN -# REQUIRE: apmd bootparams dhcpd dhcrelay gated local lpd mopd motd -# REQUIRE: mrouted ntpd rarpd rbootd route6d routed rtadvd rtsold -# REQUIRE: rwho screenblank timed wscons xfs yppasswdd +# REQUIRE: DAEMON +# KEYWORD: FreeBSD NetBSD # This is a dummy dependancy to ensure user services such as xdm, # inetd, cron and kerberos are started after everything else, incase diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index 9c26553b057..13573a020b2 100755 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -1,17 +1,23 @@ # $NetBSD: Makefile,v 1.16 2001/01/14 15:37:22 minoura Exp $ +# $FreeBSD$ .include -FILES= DAEMON LOGIN NETWORK SERVERS accounting amd apmd bootparams \ - bootconf.sh ccd cleartmp cron dhclient dhcpd dhcrelay dmesg \ - fsck gated inetd ipfilter ipmon ipnat ipsec isdnd kdc ldconfig \ - lkm1 lkm2 lkm3 local lpd mopd motd mountall mountcritlocal \ - mountcritremote mountd mrouted named network newsyslog nfsd \ - nfslocking ntpd ntpdate rpcbind poffd postfix ppp pwcheck racoon \ - quota raidframe rarpd rbootd root route6d routed rtadvd rtsold rwho \ - savecore screenblank sendmail securelevel sshd swap1 swap2 sysdb \ - sysctl syslogd timed ttys virecover wscons xdm xfs ypbind \ - yppasswdd ypserv +FILES= DAEMON LOGIN NETWORKING SERVERS abi accounting addswap adjkerntz altqd \ + amd apmd atm1 atm2.sh atm3.sh bgfsck bootconf.sh bootparams ccd \ + cleanvar cleartmp cron devdb devfs dhclient dhcpd dhcrelay diskless \ + dmesg dumpon fsck gated inetd initdiskless initrandom ipfilter ipfw \ + ip6fw ipmon ipnat ipsec ipxrouted isdnd kadmind kdc kerberos keyserv \ + ldconfig lkm1 lkm2 lkm3 local localdaemons lomac lpd mopd motd \ + mountall mountcritlocal mountcritremote mountd moused mroute6d \ + mrouted msgs named network network1 network2 network3 \ + network_ipv6 newsyslog nfsclient nfsd nfslocking \ + othermta nfsserver ntpd ntpdate pccard poffd ppp-user \ + postfix ppp pppoed pwcheck quota racoon raidframe random rarpd \ + rbootd root route6d routed rpcbind rtadvd rtsold \ + rwho savecore screenblank securelevel sendmail serial sppp sshd swap1 \ + swap2 sysdb syscons sysctl syslogd timed ttys usbd vinum virecover \ + wscons xdm xfs ypbind yppasswdd ypserv ypset ypupdated ypxfrd FILESDIR= /etc/rc.d FILESMODE= ${BINMODE} diff --git a/etc/rc.d/NETWORK b/etc/rc.d/NETWORK deleted file mode 100755 index 92040d24bdf..00000000000 --- a/etc/rc.d/NETWORK +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# -# $NetBSD$ -# - -# PROVIDE: NETWORK -# REQUIRE: network dhclient - -# This is a dummy dependancy, for services which require networking -# to be operational before starting. diff --git a/etc/rc.d/NETWORKING b/etc/rc.d/NETWORKING new file mode 100644 index 00000000000..ca23df34578 --- /dev/null +++ b/etc/rc.d/NETWORKING @@ -0,0 +1,12 @@ +#!/bin/sh +# +# $NetBSD: NETWORKING,v 1.2 2002/03/22 04:33:57 thorpej Exp $ +# $FreeBSD$ +# + +# PROVIDE: NETWORKING NETWORK +# REQUIRE: network dhclient altqd network1 network2 network_ipv6 ppp-user +# KEYWORD: FreeBSD NetBSD + +# This is a dummy dependancy, for services which require networking +# to be operational before starting. diff --git a/etc/rc.d/SERVERS b/etc/rc.d/SERVERS index 99a9c17f7fa..e3496cc853f 100755 --- a/etc/rc.d/SERVERS +++ b/etc/rc.d/SERVERS @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: SERVERS,v 1.4 2000/09/21 10:38:04 ad Exp $ +# $NetBSD: SERVERS,v 1.9 2002/03/22 04:33:57 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: SERVERS -# REQUIRE: ipmon kdc newsyslog ppp savecore syslogd ike +# REQUIRE: mountcritremote +# KEYWORD: FreeBSD NetBSD # This is a dummy dependancy, for early-start servers relying on # some basic configuration. diff --git a/etc/rc.d/abi b/etc/rc.d/abi new file mode 100644 index 00000000000..c17b9cbc6d1 --- /dev/null +++ b/etc/rc.d/abi @@ -0,0 +1,54 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: abi +# REQUIRE: LOGIN +# KEYWORD: FreeBSD + +. /etc/rc.subr + +echo -n 'Additional ABI support:' + +name="sysvipc" +rcvar=`set_rcvar` +start_cmd="sysv_start" +stop_cmd=":" + +sysv_start() +{ + echo -n ' sysvipc' + kldload sysvmsg >/dev/null 2>&1 + kldload sysvsem >/dev/null 2>&1 + kldload sysvshm >/dev/null 2>&1 +} +load_rc_config $name +run_rc_command "$1" + +name="linux" +rcvar=`set_rcvar` +start_cmd="linux_start" + +linux_start() +{ + echo -n ' linux' + if ! kldstat -v | grep -E 'linux(aout|elf)' > /dev/null; then + kldload linux > /dev/null 2>&1 + fi + if [ -x /compat/linux/sbin/ldconfig ]; then + /compat/linux/sbin/ldconfig + fi +} +load_rc_config $name +run_rc_command "$1" + +name="svr4" +rcvar=`set_rcvar` +start_precmd="echo -n ' svr4'" +start_cmd="kldload svr4 > /dev/null 2>&1" + +load_rc_config $name +run_rc_command "$1" + +echo '.' diff --git a/etc/rc.d/accounting b/etc/rc.d/accounting index aecb2ad2bfc..af443dc5ae4 100755 --- a/etc/rc.d/accounting +++ b/etc/rc.d/accounting @@ -1,30 +1,54 @@ #!/bin/sh # -# $NetBSD: accounting,v 1.2 2000/05/13 08:45:06 lukem Exp $ +# $NetBSD: accounting,v 1.7 2002/03/22 04:33:57 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: accounting # REQUIRE: mountall +# BEFORE: DAEMON +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="accounting" -rcvar=$name +rcvar=`set_rcvar` +accounting_command="/usr/sbin/accton" +accounting_file="/var/account/acct" start_cmd="accounting_start" stop_cmd="accounting_stop" accounting_start() { - if [ -f /var/account/acct ]; then - echo "Turning on accounting." - /usr/sbin/accton /var/account/acct + case `${CMD_OSTYPE}` in + FreeBSD) + _dir=`dirname "$accounting_file"` + if [ ! -d `dirname "$_dir"` ]; then + if ! mkdir -p "$_dir" ; then + warn "Could not create $_dir." + return 1 + fi + fi + if [ ! -e "$accounting_file" ]; then + touch "$accounting_file" + fi + ;; + *) + ;; + esac + + if [ ! -f ${accounting_file} ]; then + echo "Creating accounting file ${accounting_file}" + ( umask 022 ; > ${accounting_file} ) fi + echo "Turning on accounting." + ${accounting_command} ${accounting_file} } accounting_stop() { echo "Turning off accounting." - /usr/sbin/accton + ${accounting_command} } load_rc_config $name diff --git a/etc/rc.d/addswap b/etc/rc.d/addswap new file mode 100644 index 00000000000..12233d7d212 --- /dev/null +++ b/etc/rc.d/addswap @@ -0,0 +1,34 @@ +#!/bin/sh +# +# Add additional swap files +# +# $FreeBSD$ +# + +# PROVIDE: addswap +# REQUIRE: mountcritlocal +# BEFORE: sysctl +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="addswap" +start_cmd="addswap_start" +stop_cmd=":" + +addswap_start() +{ + case ${swapfile} in + [Nn][Oo] | '') + ;; + *) + if [ -w "${swapfile}" -a -c /dev/mdctl ]; then + echo "Adding ${swapfile} as additional swap" + mdev=`mdconfig -a -t vnode -f ${swapfile}` && swapon /dev/${mdev} + fi + ;; + esac +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/adjkerntz b/etc/rc.d/adjkerntz new file mode 100644 index 00000000000..654c1572c5c --- /dev/null +++ b/etc/rc.d/adjkerntz @@ -0,0 +1,18 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: adjkerntz +# REQUIRE: diskless mountcritlocal random +# BEFORE: network1 +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="adjkerntz" +start_cmd="adjkerntz -i" +stop_cmd=":" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/altqd b/etc/rc.d/altqd new file mode 100644 index 00000000000..c7e626e13ba --- /dev/null +++ b/etc/rc.d/altqd @@ -0,0 +1,22 @@ +#!/bin/sh +# +# $NetBSD: altqd,v 1.2 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD$ +# + +# PROVIDE: altqd +# REQUIRE: network mountcritlocal dhclient +# BEFORE: NETWORKING +# KEYWORD: shutdown + +. /etc/rc.subr + +name="altqd" +rcvar=$name +command="/usr/sbin/${name}" +pidfile="/var/run/${name}.pid" +required_files="/etc/altq.conf" +extra_commands="reload" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/amd b/etc/rc.d/amd index a674a24fd2b..20339c34f23 100755 --- a/etc/rc.d/amd +++ b/etc/rc.d/amd @@ -1,21 +1,68 @@ #!/bin/sh # -# $NetBSD: amd,v 1.6 2000/09/19 13:04:38 lukem Exp $ +# $NetBSD: amd,v 1.10 2002/04/29 12:08:17 lukem Exp $ +# $FreeBSD$ # # PROVIDE: amd -# REQUIRE: rpcbind mountall ypbind +# REQUIRE: rpcbind mountall ypbind nfsclient +# BEFORE: DAEMON +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="amd" -rcvar=$name -command="/usr/sbin/${name}" -load_rc_config $name +rcvar=`set_rcvar` + +case `${CMD_OSTYPE}` in +FreeBSD) + start_cmd="echo 'Starting amd.'; /usr/sbin/${name} &" + start_precmd="amd_precmd" + ;; +NetBSD) + command_args='-p -a '$amd_dir' -F /etc/amd.conf >/var/run/amd.pid' + required_dirs="$amd_dir" + required_files="/etc/amd.conf" + required_vars="rpcbind" + command="/usr/sbin/${name}" + ;; +esac + +amd_precmd() +{ + case `${CMD_OSTYPE}` in + FreeBSD) + if ! checkyesno nfs_client_enable ; then + force_depend nfsclient || return 1 + fi + if [ -z "`check_process rpcbind`" \ + -a ! `checkyesno portmap_enable` ]; then + force_depend rpcbind || return 1 + fi -command_args='-p -a '$amd_dir' -F /etc/amd.conf >/var/run/amd.pid' -required_files="/etc/amd.conf" -required_dirs="$amd_dir" -required_vars="rpcbind" + case ${amd_map_program} in + [Nn][Oo] | '') + ;; + *) + amd_flags="${amd_flags} `eval ${amd_map_program}`" + ;; + esac + case "${amd_flags}" in + '') + if [ ! -r /etc/amd.conf ]; then + warn 'amd will not load without arguments' + return 1 + fi + ;; + *) + amd_flags="-p ${amd_flags} > /var/run/amd.pid 2> /dev/null" \ + ;; + esac + ;; + esac + return 0 +} + +load_rc_config $name run_rc_command "$1" diff --git a/etc/rc.d/apmd b/etc/rc.d/apmd index 01f26d1caff..13f9268bb04 100755 --- a/etc/rc.d/apmd +++ b/etc/rc.d/apmd @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: apmd,v 1.3 2000/05/13 08:45:06 lukem Exp $ +# $NetBSD: apmd,v 1.5 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: apmd # REQUIRE: DAEMON +# BEFORE: LOGIN . /etc/rc.subr diff --git a/etc/rc.d/bgfsck b/etc/rc.d/bgfsck new file mode 100644 index 00000000000..ae081f09413 --- /dev/null +++ b/etc/rc.d/bgfsck @@ -0,0 +1,19 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: bgfsck +# REQUIRE: cron devfs +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="background-fsck" +rcvar="background_fsck" +start_precmd="echo 'Starting background file system checks'" +start_cmd="nice -4 fsck -B -p 2>&1 | logger -p daemon.notice &" +stop_cmd=":" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/bootconf.sh b/etc/rc.d/bootconf.sh index 8f663ca5873..1fdc2013920 100755 --- a/etc/rc.d/bootconf.sh +++ b/etc/rc.d/bootconf.sh @@ -1,6 +1,7 @@ #!/bin/sh # -# $NetBSD: bootconf.sh,v 1.2 2000/08/21 23:34:45 lukem Exp $ +# $NetBSD: bootconf.sh,v 1.5 2002/03/25 03:22:10 wiz Exp $ +# $FreeBSD$ # # PROVIDE: bootconf @@ -20,9 +21,13 @@ bootconf_start() else default=current fi + if [ "$default" = "current" ]; then + def=`ls -ld /etc/etc.current 2>&1` + default="${def##*-> etc.}" + fi + spc="" - for i in /etc/etc.* - do + for i in /etc/etc.*; do name="${i##/etc/etc.}" case $name in current|default|\*) @@ -43,11 +48,11 @@ bootconf_start() _DUMMY=/etc/passwd conf=${_DUMMY} while [ ! -d /etc/etc.$conf/. ]; do - trap "conf=$default; echo; echo Using default of $conf" 14 + trap "conf=$default; echo; echo Using default of $conf" ALRM echo -n "Which configuration [$default] ? " (sleep 30 && kill -ALRM $master) >/dev/null 2>&1 & read conf - trap : 14 + trap : ALRM if [ -z $conf ] ; then conf=$default fi @@ -55,8 +60,16 @@ bootconf_start() conf=${_DUMMY} fi done - rm -f /etc/etc.current - ln -s /etc/etc.$conf /etc/etc.current + + case $conf in + current|default) + ;; + *) + rm -f /etc/etc.current + ln -s /etc/etc.$conf /etc/etc.current + ;; + esac + if [ -f /etc/rc.conf ] ; then . /etc/rc.conf fi diff --git a/etc/rc.d/bootparams b/etc/rc.d/bootparams index 2f27d4f9e5b..3afbd768a50 100755 --- a/etc/rc.d/bootparams +++ b/etc/rc.d/bootparams @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: bootparams,v 1.4 2000/06/02 22:54:11 fvdl Exp $ +# $NetBSD: bootparams,v 1.6 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: bootparams # REQUIRE: rpcbind DAEMON +# BEFORE: LOGIN . /etc/rc.subr diff --git a/etc/rc.d/ccd b/etc/rc.d/ccd index 57c6406e29e..d96788808cb 100755 --- a/etc/rc.d/ccd +++ b/etc/rc.d/ccd @@ -1,9 +1,11 @@ #!/bin/sh # -# $NetBSD: ccd,v 1.2 2000/04/26 05:13:51 thorpej Exp $ +# $NetBSD: ccd,v 1.3 2000/05/13 08:45:06 lukem Exp $ +# $FreeBSD$ # # PROVIDE: disks +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr diff --git a/etc/rc.d/cleanvar b/etc/rc.d/cleanvar new file mode 100644 index 00000000000..5e7331a2bfd --- /dev/null +++ b/etc/rc.d/cleanvar @@ -0,0 +1,48 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: cleanvar +# REQUIRE: adjkerntz mountcritlocal +# BEFORE: network1 +# KEYWORD: FreeBSD + +purgedir() +{ + local dir file + + if [ $# -eq 0 ]; then + purgedir . + else + for dir + do + ( + cd "$dir" && for file in .* * + do + [ ."$file" = .. -o ."$file" = ... ] && continue + if [ -d "$file" -a ! -L "$file" ] + then + purgedir "$file" + else + rm -f -- "$file" + fi + done + ) + done + fi +} + +rm -f /var/run/clean_var /var/spool/lock/clean_var +if [ -d /var/run -a ! -f /var/run/clean_var ]; then + purgedir /var/run + # And an initial utmp file + (cd /var/run && cp /dev/null utmp && chmod 644 utmp;) + >/var/run/clean_var +fi +if [ -d /var/spool/lock -a ! -f /var/spool/lock/clean_var ]; then + purgedir /var/spool/lock + >/var/spool/lock/clean_var +fi +rm -rf /var/spool/uucp/.Temp/* + diff --git a/etc/rc.d/cleartmp b/etc/rc.d/cleartmp index 943e5ca5ee6..27e40ba7975 100755 --- a/etc/rc.d/cleartmp +++ b/etc/rc.d/cleartmp @@ -1,15 +1,18 @@ #!/bin/sh # -# $NetBSD: cleartmp,v 1.2 2000/05/13 08:45:06 lukem Exp $ +# $NetBSD: cleartmp,v 1.4 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: cleartmp # REQUIRE: mountall +# BEFORE: DAEMON +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="cleartmp" -rcvar="clear_tmp" +rcvar=`set_rcvar clear_tmp` start_cmd="cleartmp_start" stop_cmd=":" @@ -24,6 +27,19 @@ cleartmp_start() (cd /tmp && rm -rf [a-km-pr-zA-Z]* && find -x . ! -name . ! -name lost+found ! -name quota.user \ ! -name quota.group -exec rm -rf -- {} \; -type d -prune) + + case `${CMD_OSTYPE}` in + FreeBSD) + # Remove X lock files, since they will prevent you from + # restarting X + # + rm -f /tmp/.X*-lock + rm -fr /tmp/.X11-unix + mkdir -m 1777 /tmp/.X11-unix + ;; + NetBSD) + ;; + esac } load_rc_config $name diff --git a/etc/rc.d/cron b/etc/rc.d/cron index 93634433604..6a1e77c855d 100755 --- a/etc/rc.d/cron +++ b/etc/rc.d/cron @@ -1,16 +1,17 @@ #!/bin/sh # -# $NetBSD: cron,v 1.4 2000/07/17 15:24:48 lukem Exp $ +# $NetBSD: cron,v 1.5 2000/09/19 13:04:38 lukem Exp $ +# $FreeBSD$ # # PROVIDE: cron # REQUIRE: LOGIN -# KEYWORD: shutdown +# KEYWORD: FreeBSD NetBSD shutdown . /etc/rc.subr name="cron" -rcvar=$name +rcvar="`set_rcvar`" command="/usr/sbin/${name}" pidfile="/var/run/${name}.pid" diff --git a/etc/rc.d/devdb b/etc/rc.d/devdb new file mode 100644 index 00000000000..8bd040a427a --- /dev/null +++ b/etc/rc.d/devdb @@ -0,0 +1,17 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: devdb +# REQUIRE: syslogd +# KEYWORD: FreeBSD + +# Build device name databases if we are not using DEVFS +# +if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then + rm -f /var/run/dev.db +else + dev_mkdb +fi + diff --git a/etc/rc.d/devfs b/etc/rc.d/devfs new file mode 100644 index 00000000000..90a80c3ef9f --- /dev/null +++ b/etc/rc.d/devfs @@ -0,0 +1,19 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: devfs +# REQUIRE: LOGIN +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="devfs" + +load_rc_config $name + +# Setup DEVFS, ie permissions, links etc. +# +ln -fs /dev/ttyv0 /dev/vga + diff --git a/etc/rc.d/dhclient b/etc/rc.d/dhclient index 453062e3ee3..cbdc8b0b444 100755 --- a/etc/rc.d/dhclient +++ b/etc/rc.d/dhclient @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: dhclient,v 1.6 2000/07/26 00:11:49 lukem Exp $ +# $NetBSD: dhclient,v 1.8 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: dhclient # REQUIRE: network mountcritlocal +# BEFORE: NETWORKING # # Note that there no syslog logging of dhclient messages at boot because # dhclient needs to start before services that syslog depends upon do. diff --git a/etc/rc.d/dhcpd b/etc/rc.d/dhcpd index 1126769c8e6..55b1f4ade4f 100755 --- a/etc/rc.d/dhcpd +++ b/etc/rc.d/dhcpd @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: dhcpd,v 1.3 2000/05/13 08:45:06 lukem Exp $ +# $NetBSD: dhcpd,v 1.5 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: dhcpd # REQUIRE: DAEMON +# BEFORE: LOGIN . /etc/rc.subr diff --git a/etc/rc.d/dhcrelay b/etc/rc.d/dhcrelay index 4d76dbad88c..d78afa6442a 100755 --- a/etc/rc.d/dhcrelay +++ b/etc/rc.d/dhcrelay @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: dhcrelay,v 1.3 2000/05/13 08:45:06 lukem Exp $ +# $NetBSD: dhcrelay,v 1.5 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: dhcrelay # REQUIRE: DAEMON +# BEFORE: LOGIN . /etc/rc.subr diff --git a/etc/rc.d/dmesg b/etc/rc.d/dmesg index 41ad00f4750..bea74c2b607 100755 --- a/etc/rc.d/dmesg +++ b/etc/rc.d/dmesg @@ -1,22 +1,26 @@ #!/bin/sh # -# $NetBSD: dmesg,v 1.4 2000/07/26 00:11:49 lukem Exp $ +# $NetBSD: dmesg,v 1.8 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: dmesg # REQUIRE: mountcritremote +# BEFORE: DAEMON +# KEYWORD: FreeBSD Daemon . /etc/rc.subr name="dmesg" -rcvar=$name +rcvar=`set_rcvar` +dmesg_file="/var/run/dmesg.boot" start_cmd="do_dmesg" stop_cmd=":" do_dmesg() { - rm -f /var/run/dmesg.boot - dmesg $dmesg_flags > /var/run/dmesg.boot + rm -f ${dmesg_file} + ( umask 022 ; /sbin/dmesg $rc_flags > ${dmesg_file} ) } load_rc_config $name diff --git a/etc/rc.d/dumpon b/etc/rc.d/dumpon new file mode 100644 index 00000000000..c65f63ea57a --- /dev/null +++ b/etc/rc.d/dumpon @@ -0,0 +1,32 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: dumpon +# REQUIRE: initrandom +# BEFORE: disks savecore +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="dumpon" +start_cmd="dumpon_start" +stop_cmd=":" + +dumpon_start() +{ + # Enable dumpdev so that savecore can see it. Enable it + # early so a crash early in the boot process can be caught. + # + case ${dumpdev} in + [Nn][Oo] | '') + ;; + *) + /sbin/dumpon -v ${dumpdev} + ;; + esac +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/fsck b/etc/rc.d/fsck index ddd43024740..a57e15c8b63 100755 --- a/etc/rc.d/fsck +++ b/etc/rc.d/fsck @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD$ +# $NetBSD: fsck,v 1.2 2001/06/18 06:42:35 lukem Exp $ +# $FreeBSD$ # # PROVIDE: fsck # REQUIRE: localswap +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr @@ -25,14 +27,26 @@ stop_boot() fsck_start() { - if [ -e /fastboot ]; then + if [ "$autoboot" = no ]; then echo "Fast boot: skipping disk checks." elif [ "$autoboot" = yes ]; then # During fsck ignore SIGQUIT trap : 3 - echo "Automatic boot in progress: starting file system checks." - fsck -p + echo "Starting file system checks:" + case `${CMD_OSTYPE}` in + FreeBSD) + if checkyesno background_fsck; then + fsck -F -p + else + fsck -p + fi + ;; + NetBSD) + fsck -p + ;; + esac + case $? in 0) ;; @@ -46,9 +60,30 @@ fsck_start() stop_boot ;; 8) + case `${CMD_OSTYPE}` in + FreeBSD) + if checkyesno fsck_y_enable; then + echo "File system preen failed, trying fsck -y." + fsck -y + case $? in + 0) + ;; + *) + echo "Automatic file system check failed; help!" + stop_boot + ;; + esac + else + echo "Automatic file system check failed; help!" + stop_boot + fi + ;; + NetBSD) echo "Automatic file system check failed; help!" stop_boot ;; + esac + ;; 12) echo "Boot interrupted." stop_boot diff --git a/etc/rc.d/inetd b/etc/rc.d/inetd index 8f6249f51e3..08b34385676 100755 --- a/etc/rc.d/inetd +++ b/etc/rc.d/inetd @@ -1,16 +1,17 @@ #!/bin/sh # -# $NetBSD: inetd,v 1.5 2000/07/17 15:24:48 lukem Exp $ +# $NetBSD: inetd,v 1.6 2000/09/19 13:04:38 lukem Exp $ +# $FreeBSD$ # # PROVIDE: inetd # REQUIRE: DAEMON LOGIN -# KEYWORD: shutdown +# KEYWORD: FreeBSD NetBSD shutdown . /etc/rc.subr name="inetd" -rcvar=$name +rcvar=`set_rcvar` command="/usr/sbin/${name}" pidfile="/var/run/${name}.pid" required_files="/etc/${name}.conf" diff --git a/etc/rc.d/initrandom b/etc/rc.d/initrandom new file mode 100644 index 00000000000..318d83f82fd --- /dev/null +++ b/etc/rc.d/initrandom @@ -0,0 +1,73 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: initrandom +# REQUIRE: initdiskless +# BEFORE: disks +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="initrandom" +start_cmd="initrandom_start" +stop_cmd=":" + +feed_dev_random() +{ + if [ -f "${1}" -a -r "${1}" -a -s "${1}" ]; then + cat "${1}" | dd of=/dev/random bs=8k 2>/dev/null + fi +} + +initrandom_start() +{ + echo -n 'Entropy harvesting:' + + if checkyesno harvest_interrupt; then + if [ -w /dev/random ]; then + ${SYSCTL_W} kern.random.sys.harvest.interrupt=1 >/dev/null + echo -n ' interrupts' + fi + fi + + if checkyesno harvest_ethernet; then + if [ -w /dev/random ]; then + ${SYSCTL_W} kern.random.sys.harvest.ethernet=1 >/dev/null + echo -n ' ethernet' + fi + fi + + if checkyesno harvest_p_to_p; then + if [ -w /dev/random ]; then + ${SYSCTL_W} kern.random.sys.harvest.point_to_point=1 >/dev/null + echo -n ' point_to_point' + fi + fi + + echo '.' + + # First pass at reseeding /dev/random. + # + case ${entropy_file} in + [Nn][Oo] | '') + ;; + *) + if [ -w /dev/random ]; then + feed_dev_random "${entropy_file}" + fi + ;; + esac + + # XXX temporary until we can get the entropy + # harvesting rate up + # Entropy below is not great, + # but better than nothing. + ( ps -fauxww; sysctl -a; date; df -ib; dmesg; ps -fauxww; ) \ + | dd of=/dev/random bs=8k 2>/dev/null + cat /bin/ls | dd of=/dev/random bs=8k 2>/dev/null +} + +load_rc_config random +run_rc_command "$1" diff --git a/etc/rc.d/ip6fw b/etc/rc.d/ip6fw new file mode 100644 index 00000000000..4f37e265820 --- /dev/null +++ b/etc/rc.d/ip6fw @@ -0,0 +1,58 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: ip6fw +# REQUIRE: network2 +# BEFORE: network_ipv6 +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="ip6fw" +rcvar=`set_rcvar ipv6_firewall` +start_cmd="ip6fw_start" +start_precmd="ip6fw_prestart" +stop_cmd="${SYSCTL_W} net.inet6.ip6.fw.enable=0" + +ip6fw_prestart() +{ + # Load IPv6 firewall module, if not already loaded + if ! ${SYSCTL} net.inet6.ip6.fw.enable > /dev/null 2>&1; then + kldload ip6fw && { + debug 'Kernel IPv6 firewall module loaded.' + return 0 + } + warn 'IPv6 firewall kernel module failed to load.' + return 1 + fi +} + +ip6fw_start() +{ + # Specify default rules file if none provided + if [ -z "${ipv6_firewall_script}" ]; then + ipv6_firewall_script=/etc/rc.firewall6 + fi + + # Load rules + # + if [ -r "${ipv6_firewall_script}" ]; then + . "${ipv6_firewall_script}" + echo 'IPv6 Firewall rules loaded.' + elif [ "`ip6fw l 65535`" = "65535 deny ipv6 from any to any" ]; then + warn 'IPv6 firewall rules have not been loaded. Default' \ + ' to DENY all access.' + fi + + # Enable firewall logging + # + if checkyesno ipv6_firewall_logging ; then + echo 'IPv6 Firewall logging=YES' + sysctl net.inet6.ip6.fw.verbose=1 >/dev/null + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ipfilter b/etc/rc.d/ipfilter index a2d0c2098b8..2962551c159 100755 --- a/etc/rc.d/ipfilter +++ b/etc/rc.d/ipfilter @@ -1,27 +1,60 @@ #!/bin/sh # -# $NetBSD: ipfilter,v 1.8 2000/10/01 05:58:06 lukem Exp $ +# $NetBSD: ipfilter,v 1.10 2001/02/28 17:03:50 lukem Exp $ +# $FreeBSD$ # # PROVIDE: ipfilter # REQUIRE: root beforenetlkm mountcritlocal tty +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="ipfilter" -rcvar=$name +rcvar=`set_rcvar` +load_rc_config $name + +case `${CMD_OSTYPE}` in +FreeBSD) + stop_precmd="test -f ${ipfilter_rules}" + ;; +NetBSD) + stop_precmd="test -f /etc/ipf.conf -o -f /etc/ipf6.conf" + ;; +esac + start_precmd="ipfilter_prestart" start_cmd="ipfilter_start" -stop_precmd="test -f /etc/ipf.conf -o -f /etc/ipf6.conf" stop_cmd="ipfilter_stop" reload_precmd="$stop_precmd" reload_cmd="ipfilter_reload" +resync_precmd="$stop_precmd" +resync_cmd="ipfilter_resync" status_precmd="$stop_precmd" status_cmd="ipfilter_status" -extra_commands="reload status" +extra_commands="reload resync status" ipfilter_prestart() { +case `${CMD_OSTYPE}` in +FreeBSD) + # load ipfilter kernel module if needed + if ! sysctl net.inet.ipf.fr_pass > /dev/null 2>&1; then + if kldload ipl ; then + echo 'IP-filter module loaded.' + else + warn 'IP-filter module failed to load.' + return 1 + fi + fi + + # check for ipfilter rules + if [ ! -r "${ipfilter_rules}" ]; then + warn 'IP-filter: NO IPF RULES' + return 1 + fi + ;; +NetBSD) if [ ! -f /etc/ipf.conf ] && [ ! -f /etc/ipf6.conf ]; then warn "/etc/ipf*.conf not readable; ipfilter start aborted." # @@ -35,23 +68,42 @@ ipfilter_prestart() fi return 1 fi + ;; +esac return 0 } ipfilter_start() { echo "Enabling ipfilter." - /sbin/ipf -E -Fa - if [ -f /etc/ipf.conf ]; then - /sbin/ipf -f /etc/ipf.conf - fi - if [ -f /etc/ipf6.conf ]; then - /sbin/ipf -6 -f /etc/ipf6.conf - fi + case `${CMD_OSTYPE}` in + FreeBSD) + ${ipfilter_program:-/sbin/ipf} -Fa -f \ + "${ipfilter_rules}" ${ipfilter_flags} + ;; + NetBSD) + /sbin/ipf -E -Fa + if [ -f /etc/ipf.conf ]; then + /sbin/ipf -f /etc/ipf.conf + fi + if [ -f /etc/ipf6.conf ]; then + /sbin/ipf -6 -f /etc/ipf6.conf + fi + ;; + esac } ipfilter_stop() { + case `${CMD_OSTYPE}` in + FreeBSD) + echo "Saving firewall state tables" + ${ipfs_program:-/sbin/ipfs} -W ${ipfs_flags} + ;; + NetBSD) + ;; + esac + # XXX - The following command is not effective for 'lkm's echo "Disabling ipfilter." /sbin/ipf -D } @@ -60,20 +112,42 @@ ipfilter_reload() { echo "Reloading ipfilter rules." - /sbin/ipf -I -Fa - if [ -f /etc/ipf.conf ] && ! /sbin/ipf -I -f /etc/ipf.conf; then - err 1 "reload of ipf.conf failed; not swapping to new ruleset." - fi - if [ -f /etc/ipf6.conf ] && ! /sbin/ipf -I -6 -f /etc/ipf6.conf; then - err 1 "reload of ipf6.conf failed; not swapping to new ruleset." - fi - /sbin/ipf -s + case `${CMD_OSTYPE}` in + FreeBSD) + ${ipfilter_program:-/sbin/ipf} -I -Fa -f \ + "${ipfilter_rules}" ${ipfilter_flags} + ;; + NetBSD) + /sbin/ipf -I -Fa + if [ -f /etc/ipf.conf ] && ! /sbin/ipf -I -f /etc/ipf.conf; then + err 1 "reload of ipf.conf failed; not swapping to" \ + " new ruleset." + fi + if [ -f /etc/ipf6.conf ] && \ + ! /sbin/ipf -I -6 -f /etc/ipf6.conf; then + err 1 "reload of ipf6.conf failed; not swapping to" \ + " new ruleset." + fi + /sbin/ipf -s + ;; + esac + +} + +ipfilter_resync() +{ + case `${CMD_OSTYPE}` in + FreeBSD) + # Don't resync if ipfilter is not loaded + [ sysctl net.inet.ipf.fr_pass > /dev/null 2>&1 ] && return + ;; + esac + ${ipfilter_program:-/sbin/ipf} -y ${ipfilter_flags} } ipfilter_status() { - /sbin/ipf -V + ${ipfilter_program:-/sbin/ipf} -V } -load_rc_config $name run_rc_command "$1" diff --git a/etc/rc.d/ipfw b/etc/rc.d/ipfw new file mode 100644 index 00000000000..92c88e984a5 --- /dev/null +++ b/etc/rc.d/ipfw @@ -0,0 +1,70 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: ipfw +# REQUIRE: ppp-user +# BEFORE: NETWORKING +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="ipfw" +rcvar="firewall_enable" +start_cmd="ipfw_start" +start_precmd="ipfw_precmd" +stop_cmd="${SYSCTL_W} net.inet.ip.fw.enable=0" + +ipfw_precmd() +{ + if ! ${SYSCTL} net.inet.ip.fw.enable > /dev/null 2>&1 ; then + if ! kldload ipfw ; then + warn unable to load firewall module. + return 1 + fi + fi + + return 0 +} + +ipfw_start() +{ + # set the firewall rules script if none was specified + [ -z "${firewall_script}" ] && firewall_script=/etc/rc.firewall + + if [ -r "${firewall_script}" ]; then + . "${firewall_script}" + echo -n 'Firewall rules loaded, starting divert daemons:' + + # Network Address Translation daemon + # + if checkyesno natd_enable ; then + if [ -n "${natd_interface}" ]; then + if echo ${natd_interface} | \ + grep -q -E '^[0-9]+(\.[0-9]+){0,3}$'; then + natd_flags="$natd_flags -a ${natd_interface}" + else + natd_flags="$natd_flags -n ${natd_interface}" + fi + echo -n ' natd' + ${natd_program:-/sbin/natd} ${natd_flags} ${natd_ifarg} + fi + fi + elif [ "`ipfw l 65535`" = "65535 deny ip from any to any" ]; then + echo 'Warning: kernel has firewall functionality, but' \ + ' firewall rules are not enabled.' + echo ' All ip services are disabled.' + fi + echo '.' + + # Firewall logging + # + ! checkyesno firewall_logging && return 0 + + echo 'Firewall logging=YES' + sysctl net.inet.ip.fw.verbose=1 >/dev/null +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ipmon b/etc/rc.d/ipmon index 6f635c5082f..52e84006b95 100755 --- a/etc/rc.d/ipmon +++ b/etc/rc.d/ipmon @@ -1,17 +1,37 @@ #!/bin/sh # -# $NetBSD: ipmon,v 1.2 2000/05/13 08:45:07 lukem Exp $ +# $NetBSD: ipmon,v 2002/04/18 05:02:01 lukem Exp $ +# $FreeBSD$ # # PROVIDE: ipmon # REQUIRE: syslogd +# BEFORE: SERVERS +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="ipmon" -rcvar=$name -command="/usr/sbin/${name}" -command_args="&" +rcvar=`set_rcvar` + +case `${CMD_OSTYPE}` in +FreeBSD) + command="/sbin/ipmon" + start_precmd="ipmon_precmd" + ;; +NetBSD) + command="/usr/sbin/${name}" + command_args="-D" +esac + +ipmon_precmd() +{ + # Make sure ipfilter is loaded before continuing + if ! sysctl net.inet.ipf.fr_pass >/dev/null 2>&1 ; then + return 1 + fi + return 0 +} load_rc_config $name run_rc_command "$1" diff --git a/etc/rc.d/ipnat b/etc/rc.d/ipnat index 1ac21c0d53f..6d4dd3af1fd 100755 --- a/etc/rc.d/ipnat +++ b/etc/rc.d/ipnat @@ -1,32 +1,84 @@ #!/bin/sh # -# $NetBSD: ipnat,v 1.5 2000/08/21 23:33:50 lukem Exp $ +# $NetBSD: ipnat,v 1.6 2000/09/19 13:04:38 lukem Exp $ +# $FreeBSD$ # # PROVIDE: ipnat # REQUIRE: ipfilter mountcritremote +# BEFORE: DAEMON +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="ipnat" -rcvar=$name -config="/etc/ipnat.conf" +rcvar=`set_rcvar` + +case `${CMD_OSTYPE}` in +FreeBSD) + IPNATDIR="/sbin" + start_precmd="ipnat_precmd" + reload_cmd="ipnat_start" + ;; +NetBSD) + IPNATDIR="/usr/sbin" + config="/etc/ipnat.conf" + reload_cmd="/usr/sbin/ipnat -F -C -f ${config}" + start_precmd= + ;; +esac + start_cmd="ipnat_start" -stop_cmd="/usr/sbin/ipnat -F -C" -reload_cmd="/usr/sbin/ipnat -F -C -f ${config}" +stop_cmd="${ipnat_program:-${IPNATDIR}/${name}} -F -C" extra_commands="reload" -ipnat_start() +ipnat_precmd() { - if [ ! -f ${config} ]; then - return 0 + # Make sure ipfilter is loaded before continuing + if ! ${SYSCTL} net.inet.ipf.fr_pass >/dev/null 2>&1 ; then + err 'ipnat requires ipfilter be loaded' + return 1 fi - if ! checkyesno ipfilter || [ ! -f /etc/ipf.conf ]; then - echo "Enabling ipfilter for NAT." - /sbin/ipf -E -Fa - fi - echo -n "Installing NAT rules ... " - /usr/sbin/ipnat -F -f ${config} + return 0 +} + +ipnat_start() +{ + case `${CMD_OSTYPE}` in + FreeBSD) + echo -n 'Installing NAT rules ... ' + if [ -r "${ipnat_rules}" ]; then + ${ipnat_program:-/sbin/ipnat} -CF -f \ + "${ipnat_rules}" ${ipnat_flags} + else + echo -n ' NO IPNAT RULES' + fi + echo '.' + + # restore filter/NAT state tables after loading the rules + if checkyesno ipfs_enable ; then + if [ -r "/var/db/ipf/ipstate.ipf" ]; then + echo -n ' ipfs' + ${ipfs_program:-/sbin/ipfs} -R ${ipfs_flags} + # remove files to avoid reloading old state + # after an ungraceful shutdown + rm -f /var/db/ipf/ipstate.ipf + rm -f /var/db/ipf/ipnat.ipf + fi + fi + ;; + NetBSD) + if [ ! -f ${config} ]; then + return 0 + fi + if ! checkyesno ipfilter || [ ! -f /etc/ipf.conf ]; then + echo "Enabling ipfilter for NAT." + /sbin/ipf -E -Fa + fi + echo -n "Installing NAT rules ... " + /usr/sbin/ipnat -F -f ${config} + ;; + esac } load_rc_config $name diff --git a/etc/rc.d/ipsec b/etc/rc.d/ipsec index 01313f921dd..609b6a604fa 100755 --- a/etc/rc.d/ipsec +++ b/etc/rc.d/ipsec @@ -1,17 +1,22 @@ #!/bin/sh # -# $NetBSD: ipsec,v 1.5 2000/07/21 01:16:07 lukem Exp $ +# $NetBSD: ipsec,v 1.7 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: ipsec # REQUIRE: root beforenetlkm mountcritlocal tty +# BEFORE: DAEMON +# KEYWORD: FreeBSD NetBSD # it does not really require beforenetlkm. . /etc/rc.subr name="ipsec" -rcvar=$name +rcvar=`set_rcvar` +# This will be overiden from rc.conf on FreeBSD. +ipsec_file="/etc/ipsec.conf" start_precmd="ipsec_prestart" start_cmd="ipsec_start" stop_precmd="test -f /etc/ipsec.conf" @@ -21,8 +26,8 @@ extra_commands="reload" ipsec_prestart() { - if [ ! -f /etc/ipsec.conf ]; then - warn "/etc/ipsec.conf not readable; ipsec start aborted." + if [ ! -f "$ipsec_file" ]; then + warn "$ipsec_file not readable; ipsec start aborted." # # If booting directly to multiuser, send SIGTERM to # the parent (/etc/rc) to abort the boot @@ -40,7 +45,7 @@ ipsec_prestart() ipsec_start() { echo "Installing ipsec manual keys/policies." - /sbin/setkey -f /etc/ipsec.conf + /sbin/setkey -f $ipsec_file } ipsec_stop() @@ -60,7 +65,7 @@ ipsec_reload() echo "Reloading ipsec manual keys/policies." /sbin/setkey -F /sbin/setkey -FP - /sbin/setkey -f /etc/ipsec.conf + /sbin/setkey -f "$ipsec_file" } load_rc_config $name diff --git a/etc/rc.d/ipxrouted b/etc/rc.d/ipxrouted new file mode 100644 index 00000000000..28691e373a9 --- /dev/null +++ b/etc/rc.d/ipxrouted @@ -0,0 +1,19 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: ipxrouted +# REQUIRE: SERVERS +# BEFORE: DAEMON +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="ipxrouted" +rcvar=`set_rcvar` +command="/usr/sbin/IPXrouted" +command_args="> /dev/null 2>&1" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/kadmind b/etc/rc.d/kadmind new file mode 100644 index 00000000000..a65a1bb218b --- /dev/null +++ b/etc/rc.d/kadmind @@ -0,0 +1,32 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: kadmin +# REQUIRE: kerberos +# BEFORE: DAEMON +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="kadmindIV" + +# XXX - The rc.conf files must be sourced early so that several +# variables can be set properly. +# +load_rc_config $name + +rcvar=`set_rcvar kadmind4_server` +checkyesno kerberos_stash && stash='-n' || stash= +start_cmd="( sleep 20; ${kadmind4_server} ${stash} > /dev/null 2>&1 & ) &" +required_vars="kerberos4_server_enable" + +run_rc_command "$1" + +name="kadmind5" +rcvar="kadmind5_server_enable" +start_cmd="${kadmind5_server} &" +required_vars="kerberos5_server_enable" + +run_rc_command "$1" diff --git a/etc/rc.d/kdc b/etc/rc.d/kdc index 0d887f31238..43a5005d026 100755 --- a/etc/rc.d/kdc +++ b/etc/rc.d/kdc @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: kdc,v 1.2 2000/09/19 13:04:38 lukem Exp $ +# $NetBSD: kdc,v 1.5 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: kdc -# REQUIRE: NETWORK +# REQUIRE: NETWORKING +# BEFORE: SERVERS . /etc/rc.subr diff --git a/etc/rc.d/kerberos b/etc/rc.d/kerberos new file mode 100644 index 00000000000..5dfec9557b9 --- /dev/null +++ b/etc/rc.d/kerberos @@ -0,0 +1,27 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: kerberos +# REQUIRE: NETWORKING +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="kerberosIV" +rcvar="kerberos4_server_enable" +command="${kerberos4_server}" +checkyesno kerberos_stash && stash='-n' || stash= +command_args="${stash} >> /var/log/kerberos.log &" + +load_rc_config $name +run_rc_command "$1" + +name="kerberos5" +rcvar="kerberos5_server_enable" +command="${kerberos5_server}" +command_args="&" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/keyserv b/etc/rc.d/keyserv new file mode 100644 index 00000000000..2f46908ddf7 --- /dev/null +++ b/etc/rc.d/keyserv @@ -0,0 +1,22 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# Start keyserv if we are running Secure RPC +# + +# PROVIDE: keyserv +# REQUIRE: ypbind +# BEFORE: DAEMON +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="keyserv" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" +required_vars="portmap_enable" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ldconfig b/etc/rc.d/ldconfig index 73cbba538a0..97cd38bbc80 100755 --- a/etc/rc.d/ldconfig +++ b/etc/rc.d/ldconfig @@ -1,23 +1,67 @@ #!/bin/sh # -# $NetBSD: ldconfig,v 1.2 2000/05/13 08:45:07 lukem Exp $ +# $NetBSD: ldconfig,v 1.5 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: ldconfig # REQUIRE: mountall +# BEFORE: DAEMON +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="ldconfig" +ldconfig_command="/sbin/ldconfig" start_cmd="ldconfig_start" stop_cmd=":" ldconfig_start() { - if [ -f /sbin/ldconfig ]; then - echo "Creating a.out runtime link editor directory cache." - ldconfig - fi + case `${CMD_OSTYPE}` in + FreeBSD) + ldconfig=${ldconfig_command} + checkyesno ldconfig_insecure && ldconfig="${ldconfig} -i" + if [ -x "${ldconfig_command}" ]; then + case `/usr/bin/objformat` in + elf) + _LDC=/usr/lib + for i in ${ldconfig_paths}; do + if [ -d "${i}" ]; then + _LDC="${_LDC} ${i}" + fi + done + echo 'ELF ldconfig path:' ${_LDC} + ${ldconfig} -elf ${_LDC} + ;; + esac + + # Legacy aout support for i386 only + case `sysctl -n hw.machine_arch` in + i386) + # Default the a.out ldconfig path. + : ${ldconfig_paths_aout=${ldconfig_paths}} + _LDC=/usr/lib/aout + for i in ${ldconfig_paths_aout}; do + if [ -d "${i}" ]; then + _LDC="${_LDC} ${i}" + fi + done + echo 'a.out ldconfig path:' ${_LDC} + ${ldconfig} -aout ${_LDC} + ;; + esac + fi + ;; + NetBSD) + if [ -f ${ldconfig_command} ]; then + echo "Creating a.out runtime link editor directory cache." + ${ldconfig_command} + fi + ;; + *) + ;; + esac } load_rc_config $name diff --git a/etc/rc.d/lkm1 b/etc/rc.d/lkm1 index 8e71dafbf28..e252909bd7c 100755 --- a/etc/rc.d/lkm1 +++ b/etc/rc.d/lkm1 @@ -1,6 +1,7 @@ #!/bin/sh # -# $NetBSD: lkm1,v 1.5 2000/09/19 13:04:38 lukem Exp $ +# $NetBSD: lkm1,v 1.6 2000/10/09 06:11:38 nisimura Exp $ +# $FreeBSD$ # # PROVIDE: beforenetlkm diff --git a/etc/rc.d/lkm2 b/etc/rc.d/lkm2 index b7b69b97c46..23608df5fc2 100755 --- a/etc/rc.d/lkm2 +++ b/etc/rc.d/lkm2 @@ -1,6 +1,7 @@ #!/bin/sh # -# $NetBSD: lkm2,v 1.3 2000/07/15 02:30:18 lukem Exp $ +# $NetBSD: lkm2,v 1.4 2000/09/19 13:04:38 lukem Exp $ +# $FreeBSD$ # # PROVIDE: beforemountlkm diff --git a/etc/rc.d/lkm3 b/etc/rc.d/lkm3 index a02e0dcb3db..a9d6efdfef4 100755 --- a/etc/rc.d/lkm3 +++ b/etc/rc.d/lkm3 @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: lkm3,v 1.4 2000/07/15 02:30:18 lukem Exp $ +# $NetBSD: lkm3,v 1.6 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: aftermountlkm # REQUIRE: mountall +# BEFORE: DAEMON . /etc/rc.subr diff --git a/etc/rc.d/local b/etc/rc.d/local index 8d6926faed9..42e96bf472c 100755 --- a/etc/rc.d/local +++ b/etc/rc.d/local @@ -1,11 +1,13 @@ #!/bin/sh # -# $NetBSD: local,v 1.4 2000/05/13 08:45:07 lukem Exp $ +# $NetBSD: local,v 1.6 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD$ # -# REQUIRE: DAEMON # PROVIDE: local -# KEYWORD: shutdown +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: FreeBSD NetBSD shutdown . /etc/rc.subr diff --git a/etc/rc.d/localdaemons b/etc/rc.d/localdaemons new file mode 100644 index 00000000000..0ddd4ad252a --- /dev/null +++ b/etc/rc.d/localdaemons @@ -0,0 +1,89 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: localdaemons +# REQUIRE: abi +# KEYWORD: FreeBSD shutdown + +. /etc/rc.subr + +name="localdaemons" +start_cmd="locald_start" +stop_cmd="locald_stop" + +locald_start() +{ + # For each dir in $local_startup, search for init scripts matching *.sh + # + case ${local_startup} in + [Nn][Oo] | '') + ;; + *) + echo -n 'Local package initialization:' + slist="" + if [ -z "${script_name_sep}" ]; then + script_name_sep=" " + fi + for dir in ${local_startup}; do + if [ -d "${dir}" ]; then + for script in ${dir}/*.sh; do + slist="${slist}${script_name_sep}${script}" + done + fi + done + script_save_sep="$IFS" + IFS="${script_name_sep}" + for script in ${slist}; do + if [ -x "${script}" ]; then + (set -T + trap 'exit 1' 2 + ${script} start) + elif [ -f "${script}" -o -L "${script}" ]; then + echo -n " (skipping ${script##*/}, not executable)" + fi + done + IFS="${script_save_sep}" + echo '.' + ;; + esac +} + +locald_stop() +{ + echo -n 'Shutting down daemon processes:' + + # For each dir in $local_startup, search for init scripts matching *.sh + case ${local_startup} in + [Nn][Oo] | '') + ;; + *) + slist="" + if [ -z "${script_name_sep}" ]; then + script_name_sep=" " + fi + for dir in ${local_startup}; do + if [ -d "${dir}" ]; then + for script in ${dir}/*.sh; do + slist="${slist}${script_name_sep}${script}" + done + fi + done + script_save_sep="$IFS" + IFS="${script_name_sep}" + for script in `reverse_list ${slist}`; do + if [ -x "${script}" ]; then + (set -T + trap 'exit 1' 2 + ${script} stop) + fi + done + IFS="${script_save_sep}" + echo '.' + ;; + esac +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/lockd b/etc/rc.d/lockd index bddec826526..aa55bc351d0 100644 --- a/etc/rc.d/lockd +++ b/etc/rc.d/lockd @@ -1,27 +1,46 @@ #!/bin/sh # -# $NetBSD: nfslocking,v 1.3 2000/05/13 08:45:07 lukem Exp $ +# $NetBSD: nfslocking,v 1.6 2002/03/24 15:52:41 lukem Exp $ +# $FreeBSD$ # # PROVIDE: nfslocking -# REQUIRE: nfsd +# REQUIRE: nfsserver nfsclient nfsd +# BEFORE: DAEMON +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr arg=$1 -start_precmd='checkyesno nfs_server || checkyesno nfs_client' +case `${CMD_OSTYPE}` in +FreeBSD) + RCVAR_SERVER="nfs_server_enable" + RCVAR_CLIENT="nfs_client_enable" + RCVAR_STATD="rpc_statd_enable" + RCVAR_LOCKD="rpc_lockd_enable" + ;; +NetBSD) + RCVAR_SERVER="nfs_server" + RCVAR_CLIENT="nfs_client" + RCVAR_STATD="statd" + RCVAR_LOCKD="lockd" + ;; +esac + +start_precmd="checkyesno ${RCVAR_SERVER} || checkyesno ${RCVAR_CLIENT} + [ -n "$rc_force" ]" stop_precmd=$start_precmd status_precmd=$start_precmd name="statd" -rcvar=$name +rcvar=${RCVAR_STATD} command="/usr/sbin/rpc.${name}" load_rc_config $name run_rc_command "$arg" name="lockd" -rcvar=$name +rcvar=${RCVAR_LOCKD} command="/usr/sbin/rpc.${name}" load_rc_config $name run_rc_command "$arg" diff --git a/etc/rc.d/lomac b/etc/rc.d/lomac new file mode 100644 index 00000000000..9919ed081fd --- /dev/null +++ b/etc/rc.d/lomac @@ -0,0 +1,19 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: lomac +# REQUIRE: mountcritremote +# BEFORE: syslogd +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="lomac" +rcvar=`set_rcvar` +start_cmd="kldload lomac >/dev/null 2>&1" +stop_cmd=":" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/lpd b/etc/rc.d/lpd index 83a543a4f1d..83b051ec5f7 100755 --- a/etc/rc.d/lpd +++ b/etc/rc.d/lpd @@ -1,18 +1,28 @@ #!/bin/sh # -# $NetBSD: lpd,v 1.3 2000/05/13 08:45:07 lukem Exp $ +# $NetBSD: lpd,v 1.5 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: lpd # REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="lpd" -rcvar=$name +rcvar=`set_rcvar` command="/usr/sbin/${name}" -pidfile="/var/run/${name}.pid" required_files="/etc/printcap" +case `${CMD_OSTYPE}` in +NetBSD) + pidfile="/var/run/${name}.pid" + ;; +*) + ;; +esac + load_rc_config $name run_rc_command "$1" diff --git a/etc/rc.d/mopd b/etc/rc.d/mopd index 888c4d6f1cb..f6a6710e027 100755 --- a/etc/rc.d/mopd +++ b/etc/rc.d/mopd @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: mopd,v 1.3 2000/05/13 08:45:07 lukem Exp $ +# $NetBSD: mopd,v 1.5 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: mopd # REQUIRE: DAEMON +# BEFORE: LOGIN . /etc/rc.subr diff --git a/etc/rc.d/motd b/etc/rc.d/motd index f0003647f96..f61abc8845f 100755 --- a/etc/rc.d/motd +++ b/etc/rc.d/motd @@ -1,10 +1,13 @@ #!/bin/sh # # $NetBSD: motd,v 1.5 2000/09/19 13:04:38 lukem Exp $ +# $FreeBSD$ # # PROVIDE: motd # REQUIRE: mountcritremote +# BEFORE: LOGIN +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr @@ -13,6 +16,17 @@ rcvar="update_motd" start_cmd="motd_start" stop_cmd=":" +case `${CMD_OSTYPE}` in +FreeBSD) + T=`mktemp /tmp/_motd.XXXXXX` + PERMS="644" + ;; +NetBSD) + T="/etc/_motd" + PERMS="664" + ;; +esac + motd_start() { # Update kernel info in /etc/motd @@ -21,12 +35,24 @@ motd_start() # echo "Updating motd." if [ ! -f /etc/motd ]; then - install -c -o root -g wheel -m 664 /dev/null /etc/motd + install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd fi - T=/etc/_motd - sysctl -n kern.version | while read i; do echo $i; break; done > $T - sed '1{/^NetBSD.*/{d;};};' < /etc/motd >> $T - cmp -s $T /etc/motd || cp $T /etc/motd + + case `${CMD_OSTYPE}` in + FreeBSD) + uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} + awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} + ;; + NetBSD) + sysctl -n kern.version | while read i; do echo $i; break; done > $T + sed '1{/^NetBSD.*/{d;};};' < /etc/motd >> $T + ;; + esac + cmp -s $T /etc/motd || { + echo T=$T + cp $T /etc/motd + chmod ${PERMS} /etc/motd + } rm -f $T } diff --git a/etc/rc.d/mountall b/etc/rc.d/mountall index 2fd80eb6d3a..6ce01f7f23e 100755 --- a/etc/rc.d/mountall +++ b/etc/rc.d/mountall @@ -1,6 +1,7 @@ #!/bin/sh # -# $NetBSD: mountall,v 1.2 2000/04/27 21:00:50 veego Exp $ +# $NetBSD: mountall,v 1.3 2000/05/13 08:45:07 lukem Exp $ +# $FreeBSD$ # # PROVIDE: mountall diff --git a/etc/rc.d/mountcritlocal b/etc/rc.d/mountcritlocal index 38b75f45783..9598f13d70c 100755 --- a/etc/rc.d/mountcritlocal +++ b/etc/rc.d/mountcritlocal @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: mountcritlocal,v 1.3 2000/07/26 00:11:49 lukem Exp $ +# $NetBSD: mountcritlocal,v 1.7 2002/04/29 12:29:53 lukem Exp $ +# $FreeBSD$ # # PROVIDE: mountcritlocal # REQUIRE: root +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr @@ -14,16 +16,52 @@ stop_cmd=":" mountcritlocal_start() { - # mount critical local filesystems - # (as specified in $critical_filesystems_beforenet) - # - mount_critical_filesystems local - - # clean up left-over files. - # this could include the cleanup of lock files and /var/run, etc. - # - rm -f /etc/nologin /var/spool/lock/LCK.* /var/spool/uucp/STST/* - (cd /var/run && rm -rf -- *) + case `${CMD_OSTYPE}` in + FreeBSD) + # Set up the list of network filesystem types for which mounting + # should be delayed until after network initialization. + networkfs_types='nfs:NFS smbfs:SMB portalfs:PORTAL' + case ${extra_netfs_types} in + [Nn][Oo]) + ;; + *) + networkfs_types="${networkfs_types} ${extra_netfs_types}" + ;; + esac + + # Mount everything except nfs filesystems. + mount_excludes='no' + for i in ${networkfs_types}; do + fstype=${i%:*} + mount_excludes="${mount_excludes}${fstype}," + done + mount_excludes=${mount_excludes%,} + mount -a -t ${mount_excludes} + + case $? in + 0) + ;; + *) + echo 'Mounting /etc/fstab filesystems failed,' \ + ' startup aborted' + exit 1 + ;; + esac + ;; + NetBSD) + # Mount critical filesystems that are `local' + # (as specified in $critical_filesystems_local) + # This usually includes /var. + # + mount_critical_filesystems local + + # clean up left-over files. + # this could include the cleanup of lock files and /var/run, etc. + # + rm -f /etc/nologin /var/spool/lock/LCK.* /var/spool/uucp/STST/* + (cd /var/run && rm -rf -- *) + ;; + esac } load_rc_config $name diff --git a/etc/rc.d/mountcritremote b/etc/rc.d/mountcritremote index 6479ea1058b..919fe6d49f0 100755 --- a/etc/rc.d/mountcritremote +++ b/etc/rc.d/mountcritremote @@ -1,19 +1,89 @@ #!/bin/sh # -# $NetBSD: mountcritremote,v 1.2 2000/05/13 08:45:07 lukem Exp $ +# $NetBSD: mountcritremote,v 1.7 2002/04/29 12:29:53 lukem Exp $ +# $FreeBSD$ # # PROVIDE: mountcritremote -# REQUIRE: NETWORK root mountcritlocal +# REQUIRE: NETWORKING root mountcritlocal +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr -# mount critical remote filesystems -# (as specified in $critical_filesystems) -# name="mountcritremote" -start_cmd="mount_critical_filesystems remote" stop_cmd=":" +case `${CMD_OSTYPE}` in + FreeBSD) + start_cmd="mountcritremote_start" + start_precmd="mountcritremote_precmd" + ;; +NetBSD) + start_cmd="mountcritremote_start" + ;; +esac + +# Mount NFS filesystems if present in /etc/fstab +# +# XXX When the vfsload() issues with nfsclient support and related sysctls +# have been resolved, this block can be removed, and the condition that +# skips nfs in the following block (for "other network filesystems") can +# be removed. +# +mountcritremote_precmd() +{ + case "`mount -d -a -t nfs 2> /dev/null`" in + *mount_nfs*) + # Handle absent nfs client support + if ! sysctl vfs.nfs >/dev/null 2>&1 ; then + kldload nfsclient || warn 'nfs mount ' \ + 'requested, but no nfs client in kernel' \ + return 1 + fi + ;; + esac + return 0 +} + +mountcritremote_start() +{ + case `${CMD_OSTYPE}` in + FreeBSD) + # Mount nfs filesystems. + # + echo -n 'Mounting NFS file systems:' + mount -a -t nfs + echo '.' + + # Mount other network filesystems if present in /etc/fstab + for i in ${networkfs_types}; do + fstype=${i%:*} + fsdecr=${i#*:} + + [ "${fstype}" = "nfs" ] && continue + + case "`mount -d -a -t ${fstype}`" in + *mount_${fstype}*) + echo -n "Mounting ${fsdecr} file systems:" + mount -a -t ${fstype} + echo '.' + ;; + esac + done + + # Cleanup /var again just in case it's a network mount + /etc/rc.d/cleanvar start + rm -f /var/run/clean_var /var/spool/lock/clean_var + ;; + NetBSD) + # Mount critical filesystems that may be `remote'. + # (as specified in $critical_filesystems_remote) + # This usually includes /usr. + # + mount_critical_filesystems remote + ;; + esac +} + load_rc_config $name run_rc_command "$1" diff --git a/etc/rc.d/mountd b/etc/rc.d/mountd index d1a64bf643c..7618aebda6e 100755 --- a/etc/rc.d/mountd +++ b/etc/rc.d/mountd @@ -1,24 +1,59 @@ #!/bin/sh # -# $NetBSD: mountd,v 1.6 2000/06/02 22:54:11 fvdl Exp $ +# $NetBSD: mountd,v 1.11 2002/01/31 01:26:06 lukem Exp $ +# $FreeBSD$ # # PROVIDE: mountd -# REQUIRE: NETWORK mountall beforemountlkm rpcbind quota +# REQUIRE: NETWORKING mountall beforemountlkm nfsserver rpcbind quota +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="mountd" -rcvar="nfs_server" -command="/usr/sbin/${name}" required_files="/etc/exports" start_precmd="mountd_precmd" extra_commands="reload" +case `${CMD_OSTYPE}` in +FreeBSD) + rcvar=`set_rcvar nfs_server` + command="/sbin/${name}" + ;; +NetBSD) + rcvar=`set_rcvar` + command="/usr/sbin/${name}" + ;; +esac + mountd_precmd() { + case `${CMD_OSTYPE}` in + FreeBSD) + if ! sysctl vfs.nfsrv >/dev/null 2>&1; then + force_depend nfsserver || return 1 + fi + if [ -z "`check_process rpcbind`" -a ! `checkyesno portmap_enable` ]; then + force_depend rpcbind || return 1 + fi + + # mountd flags will differ depending on rc.conf settings + # + case ${nfs_server_enable} in + [Yy][Ee][Ss]) + if checkyesno weak_mountd_authentication ; then + mountd_flags="${mountd_flags} -n" + fi + ;; + *) + if checkyesno single_mountd_enable ; then + checkyesno weak_mountd_authentication && mountd_flags="-n" + fi + esac + ;; + esac rm -f /var/db/mountdtab - echo -n > /var/db/mountdtab + ( umask 022 ; > /var/db/mountdtab ) return 0 } diff --git a/etc/rc.d/moused b/etc/rc.d/moused new file mode 100644 index 00000000000..bd42e9ffb19 --- /dev/null +++ b/etc/rc.d/moused @@ -0,0 +1,47 @@ +#!/bin/sh +# +# $NetBSD: moused,v 1.1 2001/10/29 23:25:01 augustss Exp $ +# $FreeBSD$ +# + +# PROVIDE: moused +# REQUIRE: DAEMON +# KEYWORD: FreeBSD NetBSD + +. /etc/rc.subr + +name=moused +rcvar=`set_rcvar` + +case `${CMD_OSTYPE}` in +FreeBSD) + start_cmd="moused_start" + ;; +NetBSD) + command="/usr/sbin/${name}" + ;; +esac + +moused_start() +{ + echo -n 'Starting moused:' + /usr/sbin/moused ${moused_flags} -p ${moused_port} -t ${moused_type} + + _mousechar_arg= + case ${mousechar_start} in + [Nn][Oo] | '') + ;; + *) + echo -n ' mousechar_start' + _mousechar_arg="-M ${mousechar_start}" + ;; + esac + + for ttyv in /dev/ttyv* ; do + vidcontrol < ${ttyv} ${_mousechar_arg} -m on + done + echo '.' +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/mroute6d b/etc/rc.d/mroute6d new file mode 100644 index 00000000000..7ae71f06398 --- /dev/null +++ b/etc/rc.d/mroute6d @@ -0,0 +1,18 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: mroute6d +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="mroute6d" +rcvar=`set_rcvar` +command="/usr/local/sbin/pim6dd" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/mrouted b/etc/rc.d/mrouted index 82393841fc0..b1409e1e57d 100755 --- a/etc/rc.d/mrouted +++ b/etc/rc.d/mrouted @@ -1,15 +1,18 @@ #!/bin/sh # -# $NetBSD: mrouted,v 1.4 2000/05/13 08:45:07 lukem Exp $ +# $NetBSD: mrouted,v 1.6 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: mrouted # REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="mrouted" -rcvar=$name +rcvar=`set_rcvar` command="/usr/sbin/${name}" pidfile="/var/run/${name}.pid" required_files="/etc/${name}.conf" diff --git a/etc/rc.d/msgs b/etc/rc.d/msgs new file mode 100644 index 00000000000..64e73cf4ee6 --- /dev/null +++ b/etc/rc.d/msgs @@ -0,0 +1,14 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: msgs +# REQUIRE: LOGIN +# KEYWORD: FreeBSD + +# Make a bounds file for msgs(1) if there isn't one already +# +if [ -d /var/msgs -a ! -f /var/msgs/bounds -a ! -L /var/msgs/bounds ]; then + echo 0 > /var/msgs/bounds +fi diff --git a/etc/rc.d/named b/etc/rc.d/named index b31182234e5..853acf769ee 100755 --- a/etc/rc.d/named +++ b/etc/rc.d/named @@ -1,19 +1,124 @@ #!/bin/sh # -# $NetBSD: named,v 1.5 2000/05/13 08:45:07 lukem Exp $ +# $NetBSD: named,v 1.10 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: named # REQUIRE: SERVERS +# BEFORE: DAEMON +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="named" -rcvar=$name +rcvar=`set_rcvar` command="/usr/sbin/${name}" pidfile="/var/run/${name}.pid" - +start_precmd="named_precmd" +required_dirs="$named_chrootdir" # if it is set, it must exist extra_commands="reload" +case `${CMD_OSTYPE}` in +FreeBSD) + nuser=bind + ngroup=bind + ;; +NetBSD) + nuser=named + ngroup=named + ;; +esac + +# If running in a chroot cage, ensure that the appropriate files +# exist inside the cage, as well as helper symlinks into the cage +# from outside. +# +# As this is called after the is_running and required_dir checks +# are made in run_rc_command(), we can safely assume ${named_chrootdir} +# exists and named isn't running at this point (unless forcestart +# is used). +# +chroot_autoupdate() +{ + # If the named-xfer in the system is newer than the one in the + # chroot directory or if it (in the chrootdir) doesn't exist + # copy it over + # + if [ ! -x "${named_chrootdir}/usr/libexec/named-xfer" -o \ + "${named_chrootdir}/usr/libexec/named-xfer" -ot \ + /usr/libexec/named-xfer ]; then + rm -f "${named_chrootdir}/usr/libexec/named-xfer" + cp -p /usr/libexec/named-xfer "${named_chrootdir}/usr/libexec" + fi + + # Copy /dev/null over, if neccessary. Preserve everything (perms, + # ownership, mod times). + # + if [ ! -c "${named_chrootdir}/dev/null" ]; then + rm -f "${named_chrootdir}/dev/null" + ( cd /dev ; /bin/pax -rw -pe null "${named_chrootdir}/dev" ) + fi + + # Copy local timezone information if it's not up-to-date. + # + if [ -f /etc/localtime ]; then + cmp -s /etc/localtime "${named_chrootdir}/etc/localtime" || \ + cp -p /etc/localtime "${named_chrootdir}/etc/localtime" + fi +} + +# Make symlinks to the correct pid and ndc socket files +# +make_symlinks() +{ + ln -fs "${named_chrootdir}/var/run/named.pid" /var/run/named.pid + ln -fs "${named_chrootdir}/var/run/ndc" /var/run/ndc + +} + +named_precmd() +{ + case `${CMD_OSTYPE}` in + FreeBSD) + ! checkyesno named_rcng && return 0 + # Is the user using a sandbox? + if [ -z "$named_chrootdir" ]; then + rc_flags="-u $nuser -g $ngroup rc_flags" + return 0 + fi + + # Do the following checks only if the user wants them done + checkyesno named_chroot_autoupdate && chroot_autoupdate + ;; + NetBSD) + chroot_autoupdate + ;; + esac + + case `${CMD_OSTYPE}` in + FreeBSD) + # Make the symlinks only if the user wants them done. + checkyesno named_symlink_enable && make_symlinks + ;; + NetBSD) + make_symlinks + ;; + esac + + # Change run_rc_commands()'s internal copy of $named_flags + # + case `${CMD_OSTYPE}` in + FreeBSD) + ! checkyesno named_rcng && return + ;; + esac + rc_flags="-u $nuser -g $ngroup -t ${named_chrootdir} $rc_flags" +} + load_rc_config $name +# The following variable requires that rc.conf be loaded first +# +required_dirs="$named_chrootdir" # if it is set, it must exist + run_rc_command "$1" diff --git a/etc/rc.d/newsyslog b/etc/rc.d/newsyslog index a842e4036b2..5a3927e125a 100755 --- a/etc/rc.d/newsyslog +++ b/etc/rc.d/newsyslog @@ -1,24 +1,25 @@ #!/bin/sh # -# $NetBSD$ +# $NetBSD: newsyslog,v 1.5 2002/03/24 15:51:26 lukem Exp $ +# $FreeBSD$ # # PROVIDE: newsyslog # REQUIRE: mountcritremote sysdb -# BEFORE: syslogd +# BEFORE: syslogd SERVERS . /etc/rc.subr name="newsyslog" +rcvar=$name required_files="/etc/newsyslog.conf" -start_precmd="checkyesno newsyslog" start_cmd="newsyslog_start" stop_cmd=":" newsyslog_start() { echo -n "Trimming log files:" - /usr/bin/newsyslog -s $newsyslog_flags + /usr/bin/newsyslog -s $rc_flags echo " done." } diff --git a/etc/rc.d/nfsclient b/etc/rc.d/nfsclient new file mode 100644 index 00000000000..9327748dee0 --- /dev/null +++ b/etc/rc.d/nfsclient @@ -0,0 +1,57 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: nfsclient +# REQUIRE: NETWORKING mountcritremote rpcbind +# KEYWORD: FreeBSD shutdown + +. /etc/rc.subr + +name="nfsclient" +rcvar="nfs_client_enable" +start_cmd="nfsclient_start" +start_precmd="nfsclient_precmd" +stop_cmd="unmount_all" + +# Load nfs module if it was not compiled into the kernel +nfsclient_precmd() +{ + if ! sysctl vfs.nfs >/dev/null 2>&1; then + if ! kldload nfsclient ; then + warn 'Could not load nfs client module' + return 1 + fi + fi + return 0 +} + +nfsclient_start() +{ + # + # Set some nfs client related sysctls + # + + if [ -n "${nfs_access_cache}" ]; then + echo -n " NFS access cache time=${nfs_access_cache}" + sysctl vfs.nfs.access_cache_timeout=${nfs_access_cache} >/dev/null + fi + if [ -n "${nfs_bufpackets}" ]; then + sysctl vfs.nfs.bufpackets=${nfs_bufpackets} > /dev/null + fi + + unmount_all +} + +unmount_all() +{ + # If /var/db/mounttab exists, some nfs-server has not been + # successfully notified about a previous client shutdown. + # If there is no /var/db/mounttab, we do nothing. + if [ -f /var/db/mounttab ]; then + rpc.umntall -k + fi +} +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/nfsd b/etc/rc.d/nfsd index a0d3aa19f9a..df967206efb 100755 --- a/etc/rc.d/nfsd +++ b/etc/rc.d/nfsd @@ -1,17 +1,44 @@ #!/bin/sh # -# $NetBSD: nfsd,v 1.2 2000/05/13 08:45:07 lukem Exp $ +# $NetBSD: nfsd,v 1.4 2001/06/16 06:13:10 lukem Exp $ +# $FreeBSD$ # # PROVIDE: nfsd # REQUIRE: mountd +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="nfsd" -rcvar="nfs_server" -command="/usr/sbin/${name}" -required_vars="rpcbind" +rcvar=`set_rcvar nfs_server` + +case `${CMD_OSTYPE}` in +FreeBSD) + command="/sbin/nfsd" + command_args="${nfs_server_flags}" + required_vars="portmap_enable" + start_precmd="nfsd_precmd" + ;; +NetBSD) + command="/usr/sbin/${name}" + required_vars="mountd rpcbind" + start_precmd= + ;; +esac + +nfsd_precmd() +{ + if ! sysctl vfs.nfsrv >/dev/null 2>&1; then + force_depend nfsserver || return 1 + fi + + if checkyesno nfs_reserved_port_only ; then + echo -n ' NFS on reserved port only=YES' + sysctl vfs.nfsrv.nfs_privport=1 > /dev/null + fi + return 0 +} load_rc_config $name run_rc_command "$1" diff --git a/etc/rc.d/nfslocking b/etc/rc.d/nfslocking index bddec826526..aa55bc351d0 100755 --- a/etc/rc.d/nfslocking +++ b/etc/rc.d/nfslocking @@ -1,27 +1,46 @@ #!/bin/sh # -# $NetBSD: nfslocking,v 1.3 2000/05/13 08:45:07 lukem Exp $ +# $NetBSD: nfslocking,v 1.6 2002/03/24 15:52:41 lukem Exp $ +# $FreeBSD$ # # PROVIDE: nfslocking -# REQUIRE: nfsd +# REQUIRE: nfsserver nfsclient nfsd +# BEFORE: DAEMON +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr arg=$1 -start_precmd='checkyesno nfs_server || checkyesno nfs_client' +case `${CMD_OSTYPE}` in +FreeBSD) + RCVAR_SERVER="nfs_server_enable" + RCVAR_CLIENT="nfs_client_enable" + RCVAR_STATD="rpc_statd_enable" + RCVAR_LOCKD="rpc_lockd_enable" + ;; +NetBSD) + RCVAR_SERVER="nfs_server" + RCVAR_CLIENT="nfs_client" + RCVAR_STATD="statd" + RCVAR_LOCKD="lockd" + ;; +esac + +start_precmd="checkyesno ${RCVAR_SERVER} || checkyesno ${RCVAR_CLIENT} + [ -n "$rc_force" ]" stop_precmd=$start_precmd status_precmd=$start_precmd name="statd" -rcvar=$name +rcvar=${RCVAR_STATD} command="/usr/sbin/rpc.${name}" load_rc_config $name run_rc_command "$arg" name="lockd" -rcvar=$name +rcvar=${RCVAR_LOCKD} command="/usr/sbin/rpc.${name}" load_rc_config $name run_rc_command "$arg" diff --git a/etc/rc.d/nfsserver b/etc/rc.d/nfsserver new file mode 100644 index 00000000000..f62029e9cca --- /dev/null +++ b/etc/rc.d/nfsserver @@ -0,0 +1,30 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: nfsserver +# REQUIRE: NETWORKING mountcritremote +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="nfsserver" +rcvar="nfs_server_enable" +start_cmd="nfsserver_start" +stop_cmd=":" + +# Load nfs modules if they were not compiled into the kernel +nfsserver_start() +{ + if ! sysctl vfs.nfsrv >/dev/null 2>&1; then + if ! kldload nfsserver ; then + warn 'Could not load NFS server module' + return 1 + fi + fi + return 0 +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ntpd b/etc/rc.d/ntpd index b09c4d1971b..81671a1d2a6 100755 --- a/etc/rc.d/ntpd +++ b/etc/rc.d/ntpd @@ -1,18 +1,56 @@ #!/bin/sh # -# $NetBSD: ntpd,v 1.2 2000/05/13 08:45:07 lukem Exp $ +# $NetBSD: ntpd,v 1.6 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: ntpd # REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr -name="ntpd" -rcvar=$name -command="/usr/sbin/${name}" -pidfile="/var/run/${name}.pid" +case `${CMD_OSTYPE}` in +FreeBSD) + name="xntpd" + ;; +NetBSD) + name="ntpd" + start_precmd="ntpd_precmd" + ;; +esac + +rcvar=`set_rcvar` +command="/usr/sbin/ntpd" +pidfile="/var/run/ntpd.pid" required_files="/etc/ntp.conf" +ntpd_precmd() +{ + if [ -z "$ntpd_chrootdir" ]; then + return 0; + fi + + # If running in a chroot cage, ensure that the appropriate files + # exist inside the cage, as well as helper symlinks into the cage + # from outside. + # + # As this is called after the is_running and required_dir checks + # are made in run_rc_command(), we can safely assume ${ntpd_chrootdir} + # exists and ntpd isn't running at this point (unless forcestart + # is used). + # + if [ ! -c "${ntpd_chrootdir}/dev/clockctl" ]; then + rm -f "${ntpd_chrootdir}/dev/clockctl" + ( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" ) + fi + ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift + + # Change run_rc_commands()'s internal copy of $ntpd_flags + # + rc_flags="-u ntpd:ntpd -i ${ntpd_chrootdir} $rc_flags" +} + load_rc_config $name run_rc_command "$1" diff --git a/etc/rc.d/ntpdate b/etc/rc.d/ntpdate index d0a8a18adab..37b1d07b2ce 100755 --- a/etc/rc.d/ntpdate +++ b/etc/rc.d/ntpdate @@ -1,29 +1,41 @@ #!/bin/sh # -# $NetBSD: ntpdate,v 1.5 2000/08/21 14:48:39 abs Exp $ +# $NetBSD: ntpdate,v 1.8 2002/03/22 04:16:39 lukem Exp $ +# $FreeBSD$ # # PROVIDE: ntpdate -# REQUIRE: NETWORK syslogd +# REQUIRE: NETWORKING syslogd +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="ntpdate" -rcvar=$name -start_cmd="ntpdate_start" -stop_cmd=":" +rcvar=`set_rcvar` + +case `${CMD_OSTYPE}` in +FreeBSD) + command="/usr/sbin/${name}" + command_args=">/dev/null 2>&1" + pidfile="/var/run/${name}.pid" + ;; +NetBSD) + start_cmd="ntpdate_start" + stop_cmd=":" + ;; +esac ntpdate_start() { if [ -z "$ntpdate_hosts" ]; then ntpdate_hosts=`awk ' - /^server[ \t]*127.127/ {next} - /^(server|peer)/ {print $2} + /^server[ \t]*127.127/ {next} + /^(server|peer)/ {print $2} ' /dev/null + fi +} + +random_start() +{ + # Reseed /dev/random with previously stored entropy. + case ${entropy_dir} in + [Nn][Oo]) + ;; + *) + entropy_dir=${entropy_dir:-/var/db/entropy} + if [ -d "${entropy_dir}" ]; then + if [ -w /dev/random ]; then + for seedfile in ${entropy_dir}/*; do + feed_dev_random "${seedfile}" + done + fi + fi + ;; + esac + + case ${entropy_file} in + [Nn][Oo] | '') + ;; + *) + if [ -w /dev/random ]; then + feed_dev_random "${entropy_file}" + fi + ;; + esac +} + +random_stop() +{ + # Write some entropy so when the machine reebots /dev/random + # can be reseeded + # + case ${entropy_file} in + [Nn][Oo] | '') + ;; + *) + echo -n 'Writing entropy file:' + rm -f ${entropy_file} + oumask=`umask` + umask 077 + if touch ${entropy_file} ; then + entropy_file_confirmed="${entropy_file}" + else + # Try this as a reasonable alternative for read-only + # roots, diskless workstations, etc. + rm -f /var/db/entropy + if touch /var/db/entropy ; then + entropy_file_confirmed=/var/db/entropy + fi + fi + case ${entropy_file_confirmed} in + '') + err 1 '${entropy_file_confirmed}:' \ + ' entropy file write failed.' + ;; + *) + dd if=/dev/random of=${entropy_file_confirmed} \ + bs=4096 count=1 2> /dev/null + echo '.' + ;; + esac + umask ${oumask} + ;; + esac +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/rarpd b/etc/rc.d/rarpd index b0e4212d446..63e0bfc8669 100755 --- a/etc/rc.d/rarpd +++ b/etc/rc.d/rarpd @@ -1,15 +1,18 @@ #!/bin/sh # -# $NetBSD: rarpd,v 1.3 2000/05/13 08:45:09 lukem Exp $ +# $NetBSD: rarpd,v 1.5 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: rarpd # REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="rarpd" -rcvar=$name +rcvar=`set_rcvar` command="/usr/sbin/${name}" pidfile="/var/run/${name}.pid" required_files="/etc/ethers" diff --git a/etc/rc.d/rbootd b/etc/rc.d/rbootd index ba64fdf8bf6..423c5c04b32 100755 --- a/etc/rc.d/rbootd +++ b/etc/rc.d/rbootd @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: rbootd,v 1.4 2000/05/13 08:45:09 lukem Exp $ +# $NetBSD: rbootd,v 1.6 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: rbootd # REQUIRE: DAEMON +# BEFORE: LOGIN . /etc/rc.subr diff --git a/etc/rc.d/root b/etc/rc.d/root index 8a7e3b0c7d9..d1c07832c52 100755 --- a/etc/rc.d/root +++ b/etc/rc.d/root @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: root,v 1.1.1.1 2000/03/10 11:53:24 lukem Exp $ +# $NetBSD: root,v 1.2 2000/05/13 08:45:09 lukem Exp $ +# $FreeBSD$ # # PROVIDE: root # REQUIRE: fsck +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr @@ -14,9 +16,35 @@ stop_cmd=":" root_start() { - umount -a >/dev/null 2>&1 - mount / - rm -f /fastboot + case `${CMD_OSTYPE}` in + FreeBSD) + # root normally must be read/write, but if this is a BOOTP NFS + # diskless boot it does not have to be. + # + case ${root_rw_mount} in + [Nn][Oo] | '') + ;; + *) + if ! mount -u -o rw / ; then + echo 'Mounting root filesystem rw failed, startup aborted' + exit 1 + fi + ;; + esac + + umount -a >/dev/null 2>&1 + mount / + + # If we booted a special kernel remove the record + # so we will boot the default kernel next time. + [ -e /boot/nextkernel ] && rm -f /boot/nextkernel + ;; + NetBSD) + umount -a >/dev/null 2>&1 + mount / + rm -f /fastboot + ;; + esac } load_rc_config $name diff --git a/etc/rc.d/route6d b/etc/rc.d/route6d index 0edfcb3df9c..4d94efe8074 100755 --- a/etc/rc.d/route6d +++ b/etc/rc.d/route6d @@ -1,16 +1,36 @@ #!/bin/sh # -# $NetBSD: route6d,v 1.3 2000/05/13 08:45:09 lukem Exp $ +# $NetBSD: route6d,v 1.5 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: route6d # REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="route6d" -rcvar=$name -command="/usr/sbin/${name}" +# XXX - Executable may be in a different location. The $name variable +# is different from the variable in rc.conf(5) so the +# subroutines in rc.subr won't catch it. In this case, it +# is also needed by the eval statement in the FreeBSD conditional. +# load_rc_config $name + +case `${CMD_OSTYPE}` in +FreeBSD) + rcvar="ipv6_router_enable" + command="${ipv6_router:-/usr/sbin/${name}}" + required_vars="ipv6_gateway_enable" + eval ${name}_flags=\"${ipv6_router_flags}\" + ;; +NetBSD) + rcvar=$name + command="/usr/sbin/${name}" + ;; +esac + run_rc_command "$1" diff --git a/etc/rc.d/routed b/etc/rc.d/routed index c9ae5239378..0d58ee85c36 100755 --- a/etc/rc.d/routed +++ b/etc/rc.d/routed @@ -1,17 +1,37 @@ #!/bin/sh # -# $NetBSD: routed,v 1.4 2000/05/13 08:45:09 lukem Exp $ +# $NetBSD: routed,v 1.7 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: routed -# REQUIRE: DAEMON gated +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="routed" -rcvar=$name -command="/sbin/${name}" -start_precmd="routed_precmd" + +# XXX - Executable may be in a different location. The $name variable +# is different from the variable in rc.conf(5) so the +# subroutines in rc.subr won't catch it. +# +load_rc_config $name + +case `${CMD_OSTYPE}` in +FreeBSD) + rcvar="router_enable" + command="${router:-/sbin/${name}}" + eval ${name}_flags=${router_flags} + start_precmd= + ;; +NetBSD) + rcvar=${name} + command="/sbin/${name}" + start_precmd="routed_precmd" + ;; +esac routed_precmd() { @@ -21,5 +41,4 @@ routed_precmd() fi } -load_rc_config $name run_rc_command "$1" diff --git a/etc/rc.d/rpcbind b/etc/rc.d/rpcbind index 1715975fa14..9f6e544844d 100755 --- a/etc/rc.d/rpcbind +++ b/etc/rc.d/rpcbind @@ -1,17 +1,36 @@ #!/bin/sh # -# $NetBSD: rpcbind,v 1.4 2000/07/26 00:11:49 lukem Exp $ +# $NetBSD: rpcbind,v 1.6 2002/01/31 01:26:06 lukem Exp $ +# $FreeBSD$ # # PROVIDE: rpcbind -# REQUIRE: NETWORK ntpdate syslogd named ppp +# REQUIRE: NETWORKING ntpdate syslogd named ppp +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="rpcbind" -rcvar=$name -command="/usr/sbin/${name}" -pidfile="/var/run/${name}.pid" +# XXX - Executable may be in a different location. The $name variable +# is different from the variable in rc.conf(5) so the +# subroutines in rc.subr won't catch it. +# load_rc_config $name +command="${portmap_program:-/usr/sbin/${name}}" + +case `${CMD_OSTYPE}` in +FreeBSD) + pidfile= + rcvar="portmap_enable" + command="${portmap_program:-/usr/sbin/${name}}" + eval ${name}_flags=\"${portmap_flags}\" + ;; +NetBSD) + rcvar=$name + command="/usr/sbin/${name}" + pidfile="/var/run/${name}.pid" + ;; +esac + run_rc_command "$1" diff --git a/etc/rc.d/rtadvd b/etc/rc.d/rtadvd index 73470358e05..8317e33ca89 100755 --- a/etc/rc.d/rtadvd +++ b/etc/rc.d/rtadvd @@ -1,25 +1,81 @@ #!/bin/sh # -# $NetBSD: rtadvd,v 1.3 2000/05/13 08:45:09 lukem Exp $ +# $NetBSD: rtadvd,v 1.5 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: rtadvd # REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="rtadvd" -rcvar=$name +rcvar=`set_rcvar` command="/usr/sbin/${name}" start_precmd="rtadvd_precmd" +case `${CMD_OSTYPE}` in +FreeBSD) + IS_GATEWAY="checkyesno ipv6_gateway_enable" + ;; +NetBSD) + IS_GATEWAY="eval [ \"$ip6mode\" = \"router\" ]" + ;; +esac + rtadvd_precmd() { - if [ "$ip6mode" != "router" ]; then + if ! ${IS_GATEWAY} ; then warn \ - "${name} cannot be used on IPv6 host, only on an IPv6 router." + "${name} cannot be used on IPv6 host, only on an IPv6 router." return 1 fi + + # This should be enabled with a great care. + # You may want to fine-tune /etc/rtadvd.conf. + # + # And if you wish your rtadvd to receive and process + # router renumbering messages, specify your Router Renumbering + # security policy by -R option. + # + # See `man 3 ipsec_set_policy` for IPsec policy specification + # details. + # (CAUTION: This enables your routers prefix renumbering + # from another machine, so if you enable this, do it with + # enough care.) + # + case `${CMD_OSTYPE}` in + FreeBSD) + # If specific interfaces haven't been specified, + # get a list of interfaces and enable it on them + # + case ${rtadvd_interfaces} in + '') + for i in `ifconfig -l` ; do + case $i in + lo0|gif[0-9]*|stf[0-9]*|faith[0-9]*|lp[0-9]*|sl[0-9]*|tun[0-9]*) + continue + ;; + *) + rtadvd_interfaces="${rtadvd_interfaces} ${i}" + ;; + esac + done + ;; + esac + command_args="${rtadvd_interfaces}" + + # Enable Router Renumbering, unicast case + # (use correct src/dst addr) + # rtadvd -R "in ipsec ah/transport/fec0:0:0:1::1-fec0:0:0:10::1/require" ${ipv6_network_interfaces} + # Enable Router Renumbering, multicast case + # (use correct src addr) + # rtadvd -R "in ipsec ah/transport/ff05::2-fec0:0:0:10::1/require" ${ipv6_network_interfaces} + ;; + esac + return 0 } load_rc_config $name diff --git a/etc/rc.d/rtsold b/etc/rc.d/rtsold index 840ab2abb8e..8645816efb3 100755 --- a/etc/rc.d/rtsold +++ b/etc/rc.d/rtsold @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: rtsold,v 1.3 2000/05/13 08:45:09 lukem Exp $ +# $NetBSD: rtsold,v 1.5 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: rtsold # REQUIRE: DAEMON +# BEFORE: LOGIN . /etc/rc.subr diff --git a/etc/rc.d/rwho b/etc/rc.d/rwho index e62817165f2..4a01ac1482a 100755 --- a/etc/rc.d/rwho +++ b/etc/rc.d/rwho @@ -1,15 +1,18 @@ #!/bin/sh # -# $NetBSD: rwho,v 1.3 2000/05/13 08:45:09 lukem Exp $ +# $NetBSD: rwho,v 1.5 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: rwho # REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="rwhod" -rcvar=$name +rcvar="`set_rcvar`" command="/usr/sbin/${name}" load_rc_config $name diff --git a/etc/rc.d/savecore b/etc/rc.d/savecore index 5b6e1150b24..21a6a4b21c8 100755 --- a/etc/rc.d/savecore +++ b/etc/rc.d/savecore @@ -1,29 +1,73 @@ #!/bin/sh # -# $NetBSD: savecore,v 1.2 2000/05/13 08:45:09 lukem Exp $ +# $NetBSD: savecore,v 1.5 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: savecore # REQUIRE: syslogd +# BEFORE: SERVERS +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="savecore" -rcvar=$name start_cmd="savecore_start" +start_precmd="savecore_prestart" stop_cmd=":" -savecore_start() +case `${CMD_OSTYPE}` in +NetBSD) + rcvar=$name + ;; +esac + +savecore_prestart() { - # /var/crash should be a directory or a symbolic link + # ${DUMPDIR} should be a directory or a symbolic link # to the crash directory if core dumps are to be saved. # - if [ -d /var/crash/. ]; then + DUMPDIR="${dumpdir:-/var/crash}" + + case `${CMD_OSTYPE}` in + FreeBSD) + # Quit if we have no dump device + case ${dumpdev} in + [Nn][Oo] | '') + debug 'No dump device. Quitting.' + return 1 + ;; + esac + + # If there is no crash directory set it now + case ${dumpdir} in + '') + dumpdir='/var/crash' + ;; + [Nn][Oo]) + dumpdir='NO' + ;; + esac + + if [ ! -e "${dumpdev}" -o ! -d "${dumpdir}" ]; then + warn "Wrong dump device or directory. Savecore not run." + return 1 + fi + ;; + NetBSD) + if [ ! -d "${dumpdir}" ]; then + warn "No /var/crash directory; savecore not run." + return 1 + fi + ;; + esac + return 0 +} + +savecore_start() +{ echo "Checking for core dump..." - savecore $savecore_flags /var/crash - else - warn "No /var/crash directory; savecore not run." - fi + savecore ${savecore_flags} ${DUMPDIR} } load_rc_config $name diff --git a/etc/rc.d/screenblank b/etc/rc.d/screenblank index 6ac8f5ed9b7..de2af4f562c 100755 --- a/etc/rc.d/screenblank +++ b/etc/rc.d/screenblank @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: screenblank,v 1.3 2000/05/13 08:45:09 lukem Exp $ +# $NetBSD: screenblank,v 1.5 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: screenblank # REQUIRE: DAEMON +# BEFORE: LOGIN . /etc/rc.subr diff --git a/etc/rc.d/securelevel b/etc/rc.d/securelevel index c3f3121ef47..dce65e59968 100755 --- a/etc/rc.d/securelevel +++ b/etc/rc.d/securelevel @@ -1,10 +1,13 @@ #!/bin/sh # -# $NetBSD: securelevel,v 1.1 2000/08/21 23:31:24 lukem Exp $ +# $NetBSD: securelevel,v 1.4 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: securelevel # REQUIRE: aftermountlkm ipnat mountd +# BEFORE: DAEMON +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr @@ -14,19 +17,39 @@ stop_cmd=":" securelevel_start() { - # if $securelevel is set, change it here, else if it is 0, - # change it to 1 here, before we start daemons or login services. - # - if [ -n "$securelevel" ]; then - echo -n "Setting securelevel: " - sysctl kern.securelevel=$securelevel - else - securelevel=`sysctl -n kern.securelevel` - if [ x"$securelevel" = x0 ]; then - echo -n "Setting securelevel: " - sysctl kern.securelevel=1 + case `${CMD_OSTYPE}` in + FreeBSD) + case ${kern_securelevel_enable} in + [Yy][Ee][Ss]) + if [ ${kern_securelevel} -ge 0 ]; then + echo 'Raising kernel security level: ' + ${SYSCTL_W} kern.securelevel=${kern_securelevel} + fi + ;; + esac + ;; + NetBSD) + # if $securelevel is set higher, change it here, else if + # it is 0, change it to 1 here, before we start daemons + # or login services. + # + osecurelevel=`sysctl -n kern.securelevel` + if [ -n "$securelevel" -a "$securelevel" != "$osecurelevel" ]; then + if [ "$securelevel" -lt "$osecurelevel" ]; then + echo "Can't lower securelevel." + exit 1 + else + echo -n "Setting securelevel: " + ${SYSCTL_W} kern.securelevel=$securelevel + fi + else + if [ "$osecurelevel" = 0 ]; then + echo -n "Setting securelevel: " + ${SYSCTL_W} kern.securelevel=1 + fi fi - fi + ;; + esac } load_rc_config $name diff --git a/etc/rc.d/sendmail b/etc/rc.d/sendmail index 61a0b6f4db2..efa096345b4 100755 --- a/etc/rc.d/sendmail +++ b/etc/rc.d/sendmail @@ -1,19 +1,22 @@ #!/bin/sh # -# $NetBSD: sendmail,v 1.12 2000/10/09 06:11:38 nisimura Exp $ +# $NetBSD: sendmail,v 1.14 2002/02/12 01:26:36 lukem Exp $ +# $FreeBSD$ # # PROVIDE: mail # REQUIRE: LOGIN +# KEYWORD: FreeBSD NetBSD +# we make mail start late, so that things like .forward's are not +# processed until the system is fully operational -# we could do this, but make mail start late, so that things like -# .forward's are not processed until the system is fully operational -## REQUIRE: DAEMON - +# XXX - Get together with sendmail mantainer to figure out how to +# better handle SENDMAIL_ENABLE and 3rd party MTAs. +# . /etc/rc.subr name="sendmail" -rcvar=$name +rcvar=`set_rcvar` command="/usr/sbin/${name}" pidfile="/var/run/${name}.pid" required_files="/etc/mail/${name}.cf" @@ -24,7 +27,7 @@ sendmail_precmd() # Die if there's pre-8.10 custom configuration file. This check is # mandatory for smooth upgrade. See NetBSD PR 10100 for details. # - if checkyesno sendmail && [ -f "/etc/${name}.cf" ]; then + if checkyesno ${rcvar} && [ -f "/etc/${name}.cf" ]; then if ! cmp -s "/etc/mail/${name}.cf" "/etc/${name}.cf"; then warn \ "${name} was not started; you have multiple copies of sendmail.cf." @@ -47,8 +50,8 @@ sendmail_precmd() # check couple of common db files, too for f in genericstable virtusertable domaintable mailertable; do - if [ -r "/etc/mail/$f" ] && [ "/etc/mail/$f" -nt "/etc/mail/$f.db" ]; - then + if [ -r "/etc/mail/$f" -a \ + "/etc/mail/$f" -nt "/etc/mail/$f.db" ]; then echo \ "${name}: /etc/mail/$f newer than /etc/mail/$f.db, regenerating" /usr/sbin/makemap hash /etc/mail/$f < /etc/mail/$f @@ -58,3 +61,42 @@ sendmail_precmd() load_rc_config $name run_rc_command "$1" + +case `${CMD_OSTYPE}` in +FreeBSD) + case $SENDMAIL_ENABLE in + NONE) + exit + ;; + esac + pid_file= + required_files= + start_precmd= + + name="sendmail_outbound" + rcvar=`set_rcvar` + start_cmd="/usr/sbin/sendmail $sendmail_outbound_flags" + #command="/usr/sbin/sendmail" + + load_rc_config $name + run_rc_command "$1" + + name="sendmail_submit" + rcvar=`set_rcvar` + start_cmd="/usr/sbin/sendmail $sendmail_submit_flags" + #command="/usr/sbin/sendmail" + + load_rc_config $name + run_rc_command "$1" + + name="sendmail_clientmqueue" + rcvar="sendmail_msp_queue_enable" + start_cmd="/usr/sbin/sendmail $sendmail_msp_queue_flags" + #command="/usr/sbin/sendmail" + #command_args="${sendmail_msp_queue_flags}" + required_files="/etc/mail/submit.cf" + + load_rc_config $name + run_rc_command "$1" + ;; +esac diff --git a/etc/rc.d/sppp b/etc/rc.d/sppp new file mode 100644 index 00000000000..0080fc7fec1 --- /dev/null +++ b/etc/rc.d/sppp @@ -0,0 +1,36 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: sppp +# REQUIRE: root +# BEFORE: network1 +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="sppp" +start_cmd="sppp_start" +stop_cmd=":" + +sppp_start() +{ + # Special options for sppp(4) interfaces go here. These need + # to go _before_ the general ifconfig since in the case + # of hardwired (no link1 flag) but required authentication, you + # cannot pass auth parameters down to the already running interface. + # + for ifn in ${sppp_interfaces}; do + eval spppcontrol_args=\$spppconfig_${ifn} + if [ -n "${spppcontrol_args}" ]; then + # The auth secrets might contain spaces; in order + # to retain the quotation, we need to eval them + # here. + eval spppcontrol ${ifn} ${spppcontrol_args} + fi + done +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/sshd b/etc/rc.d/sshd index e31a0282f86..416ab7fd586 100755 --- a/etc/rc.d/sshd +++ b/etc/rc.d/sshd @@ -1,48 +1,70 @@ #!/bin/sh # -# $NetBSD: sshd,v 1.7 2000/08/10 22:49:43 lukem Exp $ +# $NetBSD: sshd,v 1.18 2002/04/29 08:23:34 lukem Exp $ +# $FreeBSD$ # # PROVIDE: sshd # REQUIRE: LOGIN +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="sshd" -rcvar=$name +rcvar=`set_rcvar` command="/usr/sbin/${name}" +keygen_cmd="sshd_keygen" +start_precmd="sshd_precmd" pidfile="/var/run/${name}.pid" -required_files="/etc/${name}.conf" +required_files="/etc/ssh/sshd_config" extra_commands="keygen reload" sshd_keygen() { - if [ -f /etc/ssh_host_key ]; then - echo "You already have an RSA host key in /etc/ssh_host_key" - echo "Skipping RSA Key Generation" + ( + umask 022 + + # Can't do anything if ssh is not installed + [ -x /usr/bin/ssh-keygen ] || { + warn "/usr/bin/ssh-keygen does not exist." + return 1 + } + + if [ -f /etc/ssh/ssh_host_key ]; then + echo "You already have an RSA host key" \ + "in /etc/ssh/ssh_host_key" + echo "Skipping protocol version 1 RSA Key Generation" + else + /usr/bin/ssh-keygen -t rsa1 -b 1024 \ + -f /etc/ssh/ssh_host_key -N '' + fi + + if [ -f /etc/ssh/ssh_host_dsa_key ]; then + echo "You already have a DSA host key" \ + "in /etc/ssh/ssh_host_dsa_key" + echo "Skipping protocol version 2 DSA Key Generation" else - umask 022 - /usr/bin/ssh-keygen -b 1024 -f /etc/ssh_host_key -N '' + /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' fi - if [ -f /etc/ssh_host_dsa_key ]; then - echo "You already have a DSA host key in /etc/ssh_host_dsa_key" - echo "Skipping DSA Key Generation" + if [ -f /etc/ssh/ssh_host_rsa_key ]; then + echo "You already have a RSA host key" \ + "in /etc/ssh/ssh_host_rsa_key" + echo "Skipping protocol version 2 RSA Key Generation" else - umask 022 - /usr/bin/ssh-keygen -d -f /etc/ssh_host_dsa_key -N '' + /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' fi + ) } sshd_precmd() { - if [ ! -f /etc/ssh_host_key -o ! -f /etc/ssh_host_dsa_key ]; then - /etc/rc.d/sshd keygen + if [ ! -f /etc/ssh/ssh_host_key -o \ + ! -f /etc/ssh/ssh_host_dsa_key -o \ + ! -f /etc/ssh/ssh_host_rsa_key ]; then + run_rc_command keygen fi } -keygen_cmd=sshd_keygen -start_precmd=sshd_precmd - load_rc_config $name run_rc_command "$1" diff --git a/etc/rc.d/statd b/etc/rc.d/statd index bddec826526..aa55bc351d0 100644 --- a/etc/rc.d/statd +++ b/etc/rc.d/statd @@ -1,27 +1,46 @@ #!/bin/sh # -# $NetBSD: nfslocking,v 1.3 2000/05/13 08:45:07 lukem Exp $ +# $NetBSD: nfslocking,v 1.6 2002/03/24 15:52:41 lukem Exp $ +# $FreeBSD$ # # PROVIDE: nfslocking -# REQUIRE: nfsd +# REQUIRE: nfsserver nfsclient nfsd +# BEFORE: DAEMON +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr arg=$1 -start_precmd='checkyesno nfs_server || checkyesno nfs_client' +case `${CMD_OSTYPE}` in +FreeBSD) + RCVAR_SERVER="nfs_server_enable" + RCVAR_CLIENT="nfs_client_enable" + RCVAR_STATD="rpc_statd_enable" + RCVAR_LOCKD="rpc_lockd_enable" + ;; +NetBSD) + RCVAR_SERVER="nfs_server" + RCVAR_CLIENT="nfs_client" + RCVAR_STATD="statd" + RCVAR_LOCKD="lockd" + ;; +esac + +start_precmd="checkyesno ${RCVAR_SERVER} || checkyesno ${RCVAR_CLIENT} + [ -n "$rc_force" ]" stop_precmd=$start_precmd status_precmd=$start_precmd name="statd" -rcvar=$name +rcvar=${RCVAR_STATD} command="/usr/sbin/rpc.${name}" load_rc_config $name run_rc_command "$arg" name="lockd" -rcvar=$name +rcvar=${RCVAR_LOCKD} command="/usr/sbin/rpc.${name}" load_rc_config $name run_rc_command "$arg" diff --git a/etc/rc.d/swap1 b/etc/rc.d/swap1 index 0582498af94..92811074a9d 100755 --- a/etc/rc.d/swap1 +++ b/etc/rc.d/swap1 @@ -1,23 +1,50 @@ #!/bin/sh # -# $NetBSD: swap1,v 1.4 2000/05/13 08:45:09 lukem Exp $ +# $NetBSD: swap1,v 1.8 2002/03/24 15:52:41 lukem Exp $ +# $FreeBSD$ # # PROVIDE: localswap # REQUIRE: disks +# KEYWORD: FreeBSD NetBSD shutdown . /etc/rc.subr name="swap1" +case `${CMD_OSTYPE}` in +FreeBSD) + start_cmd='swapon -a' + stop_cmd=':' + ;; +NetBSD) + # Add all block-type swap devices; these might be necessary + # during disk checks. + # + start_cmd="swap1_start" + stop_cmd="swap1_stop" + ;; +esac + # Add all block-type swap devices; these might be necessary # during disk checks. # -start_cmd='swapctl -A -t blk' +swap1_start() +{ + if ! checkyesno no_swap; then + swapctl -A -t blk + fi +} # Remove all block-type swap devices # -stop_cmd="swapctl -U -t blk" +swap1_stop() +{ + if checkyesno swapoff || [ -n "$rc_force" ]; then + echo "Removing block-type swap devices" + swapctl -U -t blk + fi +} load_rc_config swap run_rc_command "$1" diff --git a/etc/rc.d/swap2 b/etc/rc.d/swap2 index 288e620abbb..5f3bd6f31f4 100755 --- a/etc/rc.d/swap2 +++ b/etc/rc.d/swap2 @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: swap2,v 1.4 2000/07/17 12:27:04 lukem Exp $ +# $NetBSD: swap2,v 1.6 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: nonlocalswap # REQUIRE: mountcritremote +# BEFORE: DAEMON . /etc/rc.subr diff --git a/etc/rc.d/sysdb b/etc/rc.d/sysdb index 29b0d3b1a5c..7d072357eba 100755 --- a/etc/rc.d/sysdb +++ b/etc/rc.d/sysdb @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: sysdb,v 1.6 2000/10/09 05:02:14 nisimura Exp $ +# $NetBSD: sysdb,v 1.9 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: sysdb # REQUIRE: mountcritremote +# BEFORE: DAEMON . /etc/rc.subr @@ -20,7 +22,7 @@ sysdb_start() # echo "Building databases..." booted_kernel=`sysctl -n machdep.booted_kernel 2>/dev/null` - kvm_mkdb ${booted_kernel:-/netbsd} + kvm_mkdb "${booted_kernel:-/netbsd}" dev_mkdb # Re-create /var/run/utmp, which is deleted by mountcritlocal diff --git a/etc/rc.d/syslogd b/etc/rc.d/syslogd index 2c8caeabad8..07399b8a2fb 100755 --- a/etc/rc.d/syslogd +++ b/etc/rc.d/syslogd @@ -1,21 +1,38 @@ #!/bin/sh # -# $NetBSD: syslogd,v 1.6 2000/07/29 21:50:20 veego Exp $ +# $NetBSD: syslogd,v 1.12 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: syslogd # REQUIRE: mountcritremote sysdb wscons +# BEFORE: SERVERS +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="syslogd" -rcvar=$name +rcvar=`set_rcvar` command="/usr/sbin/${name}" -pidfile="/var/run/${name}.pid" required_files="/etc/syslog.conf" start_precmd="syslogd_precmd" extra_commands="reload" +_sockfile="/var/run/syslogd.sockets" + +case `${CMD_OSTYPE}` in +FreeBSD) + pidfile="/var/run/syslog.pid" + evalargs="rc_flags=\"\`set_socketlist\` \$rc_flags\"" + altlog_proglist="named" + ;; +NetBSD) + pidfile="/var/run/${name}.pid" + evalargs="rc_flags=\"-P \$_sockfile \$rc_flags\"" + altlog_proglist="named ntpd" + ;; +esac + syslogd_precmd() { # Transitional symlink for old binaries @@ -24,8 +41,40 @@ syslogd_precmd() ln -sf /var/run/log /dev/log fi rm -f /var/run/log + + # Create default list of syslog sockets to watch + # + ( umask 022 ; > $_sockfile ) + + # If running named(8) or ntpd(8) chrooted, added appropriate + # syslog socket to list of sockets to watch. + # + for _l in $altlog_proglist; do + eval _ldir=\$${_l}_chrootdir + if checkyesno `set_rcvar $_l` && [ -n "$_ldir" ]; then + echo "${_ldir}/var/run/log" >> $_sockfile + fi + done + + # If other sockets have been provided, change run_rc_command()'s + # internal copy of $syslogd_flags to force use of specific + # syslogd sockets. + # + if [ -s $_sockfile ]; then + echo "/var/run/log" >> $_sockfile + eval $evalargs + fi + return 0 } +set_socketlist() +{ + _socketargs= + for _s in `cat $_sockfile | tr '\n' ' '` ; do + _socketargs="-l $_s $_socketargs" + done + echo $_socketargs +} load_rc_config $name run_rc_command "$1" diff --git a/etc/rc.d/timed b/etc/rc.d/timed index 097a53c0a1e..1c26e4a1c4a 100755 --- a/etc/rc.d/timed +++ b/etc/rc.d/timed @@ -1,15 +1,18 @@ #!/bin/sh # -# $NetBSD: timed,v 1.3 2000/05/13 08:45:09 lukem Exp $ +# $NetBSD: timed,v 1.5 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: timed # REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="timed" -rcvar=$name +rcvar=`set_rcvar` command="/usr/sbin/${name}" load_rc_config $name diff --git a/etc/rc.d/ttys b/etc/rc.d/ttys index 6e128544568..d9073f83a47 100755 --- a/etc/rc.d/ttys +++ b/etc/rc.d/ttys @@ -1,10 +1,12 @@ #!/bin/sh # # $NetBSD: ttys,v 1.1.1.1 2000/03/10 11:53:24 lukem Exp $ +# $FreeBSD$ # # PROVIDE: tty # REQUIRE: root +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr @@ -14,18 +16,34 @@ stop_cmd=":" ttyflags_start() { - # set flags on ttys. - # (do early, in case they use tty for SLIP in network) - # - echo "Setting tty flags." - ttyflags -a + case `${CMD_OSTYPE}` in + FreeBSD) - # setup ptys - # - # XXX: there may be more ptys than this; maybe use - # sysctl to find out how many? - # - chmod 666 /dev/tty[pqrs]* + # Whack the pty perms back into shape. + # XXX: there may be more ptys than this; maybe use + # sysctl to find out how many? + # + if ls /dev/tty[pqrsPQRS]* > /dev/null 2>&1; then + chflags 0 /dev/tty[pqrsPQRS]* + chmod 666 /dev/tty[pqrsPQRS]* + chown root:wheel /dev/tty[pqrsPQRS]* + fi + ;; + NetBSD) + # set flags on ttys. + # (do early, in case they use tty for SLIP in network) + # + echo "Setting tty flags." + ttyflags -a + + # setup ptys + # + # XXX: there may be more ptys than this; maybe use + # sysctl to find out how many? + # + chmod 666 /dev/tty[pqrs]* + ;; + esac } load_rc_config $name diff --git a/etc/rc.d/usbd b/etc/rc.d/usbd new file mode 100644 index 00000000000..bed1a6dd495 --- /dev/null +++ b/etc/rc.d/usbd @@ -0,0 +1,18 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: usbd +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="usbd" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/vinum b/etc/rc.d/vinum new file mode 100644 index 00000000000..706e7f010c2 --- /dev/null +++ b/etc/rc.d/vinum @@ -0,0 +1,17 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: disks +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="vinum" +rcvar="start_vinum" +start_cmd="vinum start" +stop_cmd=":" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/virecover b/etc/rc.d/virecover index aad6295a808..9ecdbf6e9c4 100755 --- a/etc/rc.d/virecover +++ b/etc/rc.d/virecover @@ -1,27 +1,71 @@ #!/bin/sh # -# $NetBSD: virecover,v 1.3 2000/07/26 00:11:49 lukem Exp $ +# $NetBSD: virecover,v 1.6 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: virecover # REQUIRE: mountcritremote +# BEFORE: DAEMON +# KEYWORD: FreeBSD NetBSD # # XXX: should require `mail'! . /etc/rc.subr name="virecover" -start_cmd="virecover_start" stop_cmd=":" +case `${CMD_OSTYPE}` in +FreeBSD) + start_cmd="virecover_start" + ;; +NetBSD) + command="/usr/libexec/${name}" + ;; +esac + virecover_start() { - recover=`find /var/tmp/vi.recover -name 'recover.*' -type f -print` - if [ -n "$recover" ]; then - echo "Preserving editor files." - for i in $recover; do - sendmail -t < $i + find /var/tmp/vi.recover ! -type f -a ! -type d -delete + vibackup=`echo /var/tmp/vi.recover/vi.*` + if [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then + echo -n 'Recovering vi editor sessions:' + for i in /var/tmp/vi.recover/vi.*; do + # Only test files that are readable. + if [ ! -r "${i}" ]; then + continue + fi + + # Unmodified nvi editor backup files either have the + # execute bit set or are zero length. Delete them. + if [ -x "${i}" -o ! -s "${i}" ]; then + rm -f "${i}" + fi done + + # It is possible to get incomplete recovery files, if the editor + # crashes at the right time. + virecovery=`echo /var/tmp/vi.recover/recover.*` + if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then + for i in /var/tmp/vi.recover/recover.*; do + # Only test files that are readable. + if [ ! -r "${i}" ]; then + continue + fi + + # Delete any recovery files that are zero length, + # corrupted, or that have no corresponding backup file. + # Else send mail to the user. + recfile=`awk '/^X-vi-recover-path:/{print $2}' < "${i}"` + if [ -n "${recfile}" -a -s "${recfile}" ]; then + sendmail -t < "${i}" + else + rm -f "${i}" + fi + done + fi + echo '.' fi } diff --git a/etc/rc.d/wscons b/etc/rc.d/wscons index ecbc48aba6b..9bb6e111943 100755 --- a/etc/rc.d/wscons +++ b/etc/rc.d/wscons @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: wscons,v 1.5 2000/08/21 23:02:25 lukem Exp $ +# $NetBSD: wscons,v 1.9 2002/04/26 00:06:54 lukem Exp $ +# $FreeBSD$ # # PROVIDE: wscons # REQUIRE: mountcritremote +# BEFORE: LOGIN . /etc/rc.subr @@ -17,8 +19,9 @@ wscons_start() { wscfg=/usr/sbin/wsconscfg wsfld=/usr/sbin/wsfontload + wsctl=/sbin/wsconsctl config=/etc/wscons.conf - usage="usage: wsconfig [-n] [-f configfile] [-font fontpgm] [-screen screenpgm]" + usage="Usage: wsconfig [-n] [-f configfile] [-font fontpgm] [-screen screenpgm]" DOIT= while [ $# -gt 0 ]; do @@ -55,6 +58,7 @@ wscons_start() \#*|"") continue ;; + font) name=$arg1 width=$arg2 @@ -87,6 +91,7 @@ wscons_start() cmd="$cmd -N $name $file" eval $DOIT $cmd ;; + screen) idx=$arg1 scr=$arg2 @@ -110,6 +115,7 @@ wscons_start() cmd="$cmd $idx" eval $DOIT $cmd ;; + keyboard) kbd=$arg1 cmd=$wscfg @@ -123,10 +129,39 @@ wscons_start() esac eval $DOIT $cmd ;; + + encoding) + map=$arg1 + cmd="$wsctl -w \"encoding=$map\"" + eval $DOIT $cmd + ;; + + mapfile) + mapfile=$arg1 + ( while read entry; do + case "$entry" in + \#*|"") + continue + ;; + *) + cmd="$wsctl -w \"map+=$entry\"" + cmd="$cmd >/dev/null" + eval $DOIT $cmd + ;; + esac + done ) < $mapfile + ;; + mux) cmd="$wscfg -m $arg1" eval $DOIT $cmd ;; + + setvar) + cmd="$wsctl -w $arg1" + eval $DOIT $cmd + ;; + esac done ) < $config } diff --git a/etc/rc.d/xfs b/etc/rc.d/xfs index f1b4daddb89..a0692fa66d7 100755 --- a/etc/rc.d/xfs +++ b/etc/rc.d/xfs @@ -1,10 +1,12 @@ #!/bin/sh # -# $NetBSD: xfs,v 1.4 2000/09/19 13:04:39 lukem Exp $ +# $NetBSD: xfs,v 1.6 2002/03/22 04:34:01 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: xfs # REQUIRE: mountall cleartmp +# BEFORE: LOGIN . /etc/rc.subr diff --git a/etc/rc.d/ypbind b/etc/rc.d/ypbind index 754908744f6..dfd87ec4782 100755 --- a/etc/rc.d/ypbind +++ b/etc/rc.d/ypbind @@ -1,18 +1,30 @@ #!/bin/sh # -# $NetBSD: ypbind,v 1.3 2000/05/13 08:45:10 lukem Exp $ +# $NetBSD: ypbind,v 1.5 2002/03/22 04:34:01 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: ypbind # REQUIRE: ypserv +# BEFORE: DAEMON +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="ypbind" -rcvar=$name command="/usr/sbin/${name}" start_precmd="ypbind_precmd" +case `${CMD_OSTYPE}` in +FreeBSD) + rcvar="nis_client_enable" + command_args="${nis_client_flags}" + ;; +NetBSD) + rcvar=$name + ;; +esac + ypbind_precmd() { _domain=`domainname` diff --git a/etc/rc.d/yppasswdd b/etc/rc.d/yppasswdd index 4b3ab7045db..3cb98076b04 100755 --- a/etc/rc.d/yppasswdd +++ b/etc/rc.d/yppasswdd @@ -1,19 +1,32 @@ #!/bin/sh # -# $NetBSD: yppasswdd,v 1.4 2000/06/02 22:54:13 fvdl Exp $ +# $NetBSD: yppasswdd,v 1.6 2002/03/22 04:34:01 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: yppasswdd # REQUIRE: ypserv ypbind +# BEFORE: LOGIN +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="yppasswdd" -rcvar=$name -command="/usr/sbin/rpc.${name}" -required_vars="rpcbind ypserv" +command="/usr/sbin/rpc.{name}" start_precmd="yppasswdd_precmd" +case `${CMD_OSTYPE}` in +FreeBSD) + rcvar="nis_yppasswdd_enable" + required_vars="portmap_enable nis_server_enable" + command_args="${nis_yppasswdd_flags}" + ;; +NetBSD) + rcvar=$name + required_vars="rpcbind ypserv" + ;; +esac + yppasswdd_precmd() { _domain=`domainname` diff --git a/etc/rc.d/ypserv b/etc/rc.d/ypserv index 69fdd200e0f..99c8d9da6d7 100755 --- a/etc/rc.d/ypserv +++ b/etc/rc.d/ypserv @@ -1,19 +1,31 @@ #!/bin/sh # -# $NetBSD: ypserv,v 1.4 2000/06/02 22:54:13 fvdl Exp $ +# $NetBSD: ypserv,v 1.5 2000/09/19 13:04:39 lukem Exp $ +# $FreeBSD$ # # PROVIDE: ypserv # REQUIRE: rpcbind +# KEYWORD: FreeBSD NetBSD . /etc/rc.subr name="ypserv" -rcvar=$name command="/usr/sbin/${name}" -required_vars="rpcbind" start_precmd="ypserv_precmd" +case `${CMD_OSTYPE}` in +FreeBSD) + rcvar="nis_server_enable" + required_vars="portmap_enable" + command_args="${nis_server_flags}" + ;; +NetBSD) + rcvar=${name} + required_vars="rpcbind" + ;; +esac + ypserv_precmd() { _domain=`domainname` diff --git a/etc/rc.d/ypset b/etc/rc.d/ypset new file mode 100644 index 00000000000..175a63492bf --- /dev/null +++ b/etc/rc.d/ypset @@ -0,0 +1,29 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: ypset +# REQUIRE: ypbind +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="ypset" +rcvar="nis_ypset_enable" +command="/usr/sbin/${name}" +command_args="${nis_ypset_flags}" +required_vars="portmap_enable nis_client_enable" +start_precmd="ypset_precmd" + +ypset_precmd() +{ + _domain=`domainname` + if [ -z "$_domain" ]; then + warn "domainname(1) is not set." + return 1 + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ypupdated b/etc/rc.d/ypupdated new file mode 100644 index 00000000000..1b3e2b19723 --- /dev/null +++ b/etc/rc.d/ypupdated @@ -0,0 +1,28 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: ypupdated +# REQUIRE: rpcbind ypserv +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="ypupdated" +rcvar="rpc_ypupdated_enable" +command="/usr/sbin/rpc.${name}" +required_vars="portmap_enable nis_server_enable" +start_precmd="rpc_ypupdated_precmd" + +rpc_ypupdated_precmd() +{ + _domain=`domainname` + if [ -z "$_domain" ]; then + warn "domainname(1) is not set." + return 1 + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ypxfrd b/etc/rc.d/ypxfrd new file mode 100644 index 00000000000..9b325322abf --- /dev/null +++ b/etc/rc.d/ypxfrd @@ -0,0 +1,29 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: ypxfrd +# REQUIRE: rpcbind +# KEYWORD: FreeBSD + +. /etc/rc.subr + +name="ypxfrd" +rcvar="nis_ypxfrd_enable" +command="/usr/sbin/rpc.${name}" +command_args="${nis_ypxfrd_flags}" +required_vars="portmap_enable nis_server_enable" +start_precmd="ypxfrd_precmd" + +ypxfrd_precmd() +{ + _domain=`domainname` + if [ -z "$_domain" ]; then + warn "domainname(1) is not set." + return 1 + fi +} + +load_rc_config $name +run_rc_command "$1" -- 2.45.2