From: Matthew Dillon Date: Thu, 24 Jul 2003 06:35:39 +0000 (+0000) Subject: Bring RCNG in from 5.x and adjust config files and scripts accordingly. X-Git-Tag: v2.0.1~13261 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/9c600e7dc7d49484402b035e0603d6447f88d960 Bring RCNG in from 5.x and adjust config files and scripts accordingly. Bring in the 5.x mergemaster. Bring in the 5.x rcorder. Adjust Makefile's and mtree to deal with /etc/rc.d Submitted-by: ROBERT GARRETT Additional-work-by: dillon --- diff --git a/etc/Makefile b/etc/Makefile index df0e53ccd7..3c51947b10 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -1,6 +1,6 @@ # from: @(#)Makefile 5.11 (Berkeley) 5/21/91 # $FreeBSD: src/etc/Makefile,v 1.219.2.38 2003/03/04 09:49:00 ru Exp $ -# $DragonFly: src/etc/Makefile,v 1.3 2003/06/17 05:14:56 dillon Exp $ +# $DragonFly: src/etc/Makefile,v 1.4 2003/07/24 06:35:32 dillon Exp $ .if !defined(NO_SENDMAIL) SUBDIR= sendmail @@ -13,21 +13,16 @@ BIN1= amd.map apmd.conf auth.conf \ inetd.conf login.access login.conf \ motd modems networks newsyslog.conf \ pam.conf phones printcap profile protocols \ - rc rc.atm rc.diskless1 rc.diskless2 rc.firewall rc.firewall6 \ - rc.network rc.network6 rc.pccard rc.sendmail rc.serial rc.shutdown \ - rc.syscons rc.sysctl remote rpc services \ + rc rc.firewall rc.firewall6 \ + rc.sendmail rc.shutdown \ + remote rpc services \ shells sysctl.conf syslog.conf usbd.conf \ etc.${MACHINE_ARCH}/disktab \ - etc.${MACHINE_ARCH}/rc.${MACHINE_ARCH} \ etc.${MACHINE_ARCH}/ttys \ ${.CURDIR}/../gnu/usr.bin/man/manpath/manpath.config \ ${.CURDIR}/../usr.bin/mail/misc/mail.rc \ ${.CURDIR}/../usr.bin/locate/locate/locate.rc -.if !defined(NO_I4B) -BIN1+= rc.isdn -.endif - .if exists(${.CURDIR}/../crypto) && !defined(NO_OPENSSL) .if !defined(NO_OPENSSH) SSH= ${.CURDIR}/../crypto/openssh/ssh_config \ @@ -38,7 +33,7 @@ SSL= ${.CURDIR}/../crypto/openssl/apps/openssl.cnf .endif # -rwxr-xr-x root:wheel, for the new cron root:wheel -BIN2= netstart pccard_ether rc.suspend rc.resume +BIN2= pccard_ether rc.suspend rc.resume DEFAULTS= rc.conf make.conf pccard.conf periodic.conf @@ -78,6 +73,7 @@ distribution: cd ${.CURDIR}/defaults; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \ ${DEFAULTS} ${DESTDIR}/etc/defaults cd ${.CURDIR}/periodic; ${MAKE} install + cd ${.CURDIR}/rc.d; ${MAKE} install cd ${.CURDIR}/../gnu/usr.bin/send-pr; ${MAKE} etc-gnats-freefall cd ${.CURDIR}/../share/termcap; ${MAKE} etc-termcap cd ${.CURDIR}/../usr.sbin/rmt; ${MAKE} etc-rmt diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index 41692018b8..273a707c93 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -13,17 +13,24 @@ # # All arguments must be in double or single quotes. # -# $FreeBSD: src/etc/defaults/rc.conf,v 1.53.2.62 2003/02/12 03:56:46 gshapiro Exp $ -# $DragonFly: src/etc/defaults/rc.conf,v 1.2 2003/06/17 04:24:47 dillon Exp $ +# $FreeBSD: src/etc/defaults/rc.conf,v 1.180 2003/06/26 09:50:50 smkelly Exp $ +# $DragonFly: src/etc/defaults/rc.conf,v 1.3 2003/07/24 06:35:35 dillon Exp $ ############################################################## ### Important initial Boot-time options #################### ############################################################## +rc_debug="NO" # Set to YES to enable debugging output from rc.d +rc_info="YES" # Enables display of informational messages at boot. +rcshutdown_timeout="30" # Seconds to wait before terminating rc.shutdown swapfile="NO" # Set to name of swapfile if aux swapfile desired. apm_enable="NO" # Set to YES to enable APM BIOS functions (or NO). apmd_enable="NO" # Run apmd to handle APM event from userland. apmd_flags="" # Flags to apmd (if enabled). +devd_enable="NO" # Run devd, to trigger programs on device tree changes. +kldxref_enable="NO" # Build linker.hints files with kldxref(8). +kldxref_clobber="NO" # Overwrite old linker.hints at boot. +kldxref_module_path="" # Override kern.module_path. A ';'-delimited list. pccard_enable="NO" # Set to YES if you want to configure PCCARD devices. pccard_mem="DEFAULT" # If pccard_enable=YES, this is card memory address. pccard_beep="2" # pccard beep type. @@ -31,10 +38,14 @@ pccard_ifconfig="NO" # Specialized pccard ethernet configuration (or NO). pccardd_flags="-z" # Additional flags for pccardd. pccard_conf="/etc/defaults/pccard.conf" # pccardd(8) config file pccard_ether_delay="5" # Delay before trying to start dhclient in pccard_ether +removable_interfaces="" # Removable network interfaces for /etc/pccard_ether. local_startup="/usr/local/etc/rc.d /usr/X11R6/etc/rc.d" # startup script dirs. script_name_sep=" " # Change if your startup scripts' names contain spaces rc_conf_files="/etc/rc.conf /etc/rc.conf.local" fsck_y_enable="NO" # Set to YES to do fsck -y if the initial preen fails. +netfs_types="nfs:NFS smbfs:SMB portalfs:PORTAL nwfs:NWFS" # Net filesystems. +extra_netfs_types="NO" # List of network extra filesystem types for delayed + # mount at startup (or NO). ############################################################## ### Network configuration sub-section ###################### @@ -43,8 +54,8 @@ fsck_y_enable="NO" # Set to YES to do fsck -y if the initial preen fails. ### Basic network and firewall/security options: ### hostname="" # Set this! nisdomainname="NO" # Set to NIS domain if using NIS (or NO). -dhcp_program="/sbin/dhclient" # Path to dhcp client program. -dhcp_flags="" # Additional flags to pass to dhcp client. +dhclient_program="/sbin/dhclient" # Path to dhcp client program. +dhclient_flags="" # Additional flags to pass to dhcp client. firewall_enable="NO" # Set to YES to enable firewall functionality firewall_script="/etc/rc.firewall" # Which script to run to set up the firewall firewall_type="UNKNOWN" # Firewall type (see /etc/rc.firewall) @@ -115,34 +126,42 @@ syslogd_enable="YES" # Run syslog daemon (or NO). syslogd_program="/usr/sbin/syslogd" # path to syslogd, if you want a different one. syslogd_flags="-s" # Flags to syslogd (if enabled). #syslogd_flags="-ss" # Syslogd flags to not bind an inet socket -inetd_enable="YES" # Run the network daemon dispatcher (YES/NO). +inetd_enable="NO" # Run the network daemon dispatcher (YES/NO). inetd_program="/usr/sbin/inetd" # path to inetd, if you want a different one. inetd_flags="-wW" # Optional flags to inetd # # named. It may be possible to run named in a sandbox, man security for # details. # +named_rcng="NO" # XXX Temporary. Enable to use new rc + # functionality in support of named. See + # variables below. named_enable="NO" # Run named, the DNS server (or NO). named_program="/usr/sbin/named" # path to named, if you want a different one. -#named_flags="-u bind -g bind" # Flags for named +named_flags="-u bind -g bind" # Flags for named +named_pidfile="/var/run/named/pid" # Pid file +named_chrootdir="" # Chroot directory (or "" not to auto-chroot it) +named_chroot_autoupdate="YES" # Automatically install/update chrooted + # components of named. See /etc/rc.d/named. +named_symlink_enable="YES" # Symlink ${named_pidfile} and /var/run/ndc + # to their chrooted counterparts. # # kerberos. Do not run the admin daemons on slave servers # -kerberos_server_enable="NO" # Run a kerberos master server (or NO). -kadmind_server_enable="NO" # Run kadmind (or NO) kerberos5_server_enable="NO" # Run a kerberos 5 master server (or NO). kerberos5_server="/usr/libexec/kdc" # path to kerberos 5 KDC kadmind5_server_enable="NO" # Run kadmind (or NO) -kadmind5_server="/usr/libexec/k5admind" # path to kerberos 5 admin daemon -kerberos_stash="NO" # Is the kerberos master key stashed? +kadmind5_server="/usr/libexec/kadmind" # path to kerberos 5 admin daemon +kpasswdd_server_enable="NO" # Run kpasswdd (or NO) +kpasswdd_server="/usr/libexec/kpasswdd" # path to kerberos 5 passwd daemon rwhod_enable="NO" # Run the rwho daemon (or NO). rwhod_flags="" # Flags for rwhod rarpd_enable="NO" # Run rarpd (or NO). rarpd_flags="" # Flags to rarpd. -xtend_enable="NO" # Run the X-10 power controller daemon. -xtend_flags="" # Flags to xtend (if enabled). +bootparamd_enable="NO" # Run bootparamd (or NO). +bootparamd_flags="" # Flags to bootparamd pppoed_enable="NO" # Run the PPP over Ethernet daemon. pppoed_provider="*" # Provider and ppp(8) config file entry. pppoed_flags="-P /var/run/pppoed.pid" # Flags to pppoed (if enabled). @@ -151,25 +170,26 @@ sshd_enable="NO" # Enable sshd sshd_program="/usr/sbin/sshd" # path to sshd, if you want a different one. sshd_flags="" # Additional flags for sshd. -### Network daemon (NFS): All need portmap_enable="YES" ### +### Network daemon (NFS): All need rpcbind_enable="YES" ### amd_enable="NO" # Run amd service with $amd_flags (or NO). amd_flags="-a /.amd_mnt -l syslog /host /etc/amd.map /net /etc/amd.map" amd_map_program="NO" # Can be set to "ypcat -k amd.master" nfs_client_enable="NO" # This host is an NFS client (or NO). -nfs_client_flags="-n 4" # Flags to nfsiod (if enabled). +nfs_client_flags="-n 4" # Flags to nfsiod (if enabled). nfs_access_cache="2" # Client cache timeout in seconds nfs_server_enable="NO" # This host is an NFS server (or NO). nfs_server_flags="-u -t -n 4" # Flags to nfsd (if enabled). -single_mountd_enable="NO" # Run mountd only (or NO). +mountd_enable="NO" # Run mountd (or NO). mountd_flags="-r" # Flags to mountd (if NFS server enabled). weak_mountd_authentication="NO" # Allow non-root mount requests to be served. nfs_reserved_port_only="NO" # Provide NFS only on secure port (or NO). nfs_bufpackets="" # bufspace (in packets) for client -rpc_lockd_enable="NO" # Run NFS rpc.lockd (*broken!*) if nfs_server. -rpc_statd_enable="YES" # Run NFS rpc.statd if nfs_server (or NO). -portmap_enable="NO" # Run the portmapper service (YES/NO). -portmap_program="/usr/sbin/portmap" # path to portmap, if you want a different one. -portmap_flags="" # Flags to portmap (if enabled). +rpc_lockd_enable="NO" # Run NFS rpc.lockd needed for client/server. +rpc_statd_enable="NO" # Run NFS rpc.statd needed for client/server. +rpcbind_enable="NO" # Run the portmapper service (YES/NO). +# this is rpcbind in 5.x +rpcbind_program="/usr/sbin/portmap" # path to rpcbind, if you want a different one. +rpcbind_flags="" # Flags to rpcbind (if enabled). rpc_ypupdated_enable="NO" # Run if NIS master and SecureRPC (or NO). keyserv_enable="NO" # Run the SecureRPC keyserver (or NO). keyserv_flags="" # Flags to keyserv (if enabled). @@ -180,11 +200,11 @@ timed_flags="" # Flags to timed (if enabled). ntpdate_enable="NO" # Run ntpdate to sync time on boot (or NO). ntpdate_program="/usr/sbin/ntpdate" # path to ntpdate, if you want a different one. ntpdate_flags="-b" # Flags to ntpdate (if enabled). -xntpd_enable="NO" # Run ntpd Network Time Protocol (or NO). -xntpd_program="/usr/sbin/ntpd" # path to ntpd, if you want a different one. -xntpd_flags="-p /var/run/ntpd.pid" # Flags to ntpd (if enabled). +ntpd_enable="NO" # Run ntpd Network Time Protocol (or NO). +ntpd_program="/usr/sbin/ntpd" # path to ntpd, if you want a different one. +ntpd_flags="-p /var/run/ntpd.pid" # Flags to ntpd (if enabled). -# Network Information Services (NIS) options: All need portmap_enable="YES" ### +# Network Information Services (NIS) options: All need rpcbind_enable="YES" ### nis_client_enable="NO" # We're an NIS client (or NO). nis_client_flags="" # Flags to ypbind (if enabled). nis_ypset_enable="NO" # Run ypset at boot time (or NO). @@ -285,7 +305,7 @@ stf_interface_ipv6_slaid="0000" # IPv6 Site Level Aggregator for stf0 ipv6_faith_prefix="NO" # Set faith prefix to enable a FAITH # IPv6-to-IPv4 TCP translator. You also need # faithd(8) setup. -ipv6_ipv4mapping="YES" # Set to "NO" to disable IPv4 mapped IPv6 addr +ipv6_ipv4mapping="NO" # Set to "YES" to enable IPv4 mapped IPv6 addr # communication. (like ::ffff:a.b.c.d) ipv6_firewall_enable="NO" # Set to YES to enable IPv6 firewall # functionality @@ -304,7 +324,7 @@ ipv6_ipfilter_rules="/etc/ipf6.rules" # rules definition file for ipfilter, keymap="NO" # keymap in /usr/share/syscons/keymaps/* (or NO). keyrate="NO" # keyboard rate to: slow, normal, fast (or NO). -keybell="NO" # bell to duration.pitch or normal or visual (or NO). +keybell="NO" # See kbdcontrol(1) for options. Use "off" to disable. keychange="NO" # function keys default values (or NO). cursor="NO" # cursor type {normal|blink|destructive} (or NO). scrnmap="NO" # screen map in /usr/share/syscons/scrnmaps/* (or NO). @@ -312,18 +332,36 @@ font8x16="NO" # font 8x16 from /usr/share/syscons/fonts/* (or NO). font8x14="NO" # font 8x14 from /usr/share/syscons/fonts/* (or NO). font8x8="NO" # font 8x8 from /usr/share/syscons/fonts/* (or NO). blanktime="300" # blank time (in seconds) or "NO" to turn it off. -saver="NO" # screen saver: Uses /modules/${saver}_saver.ko +saver="NO" # screen saver: Uses /boot/kernel/${saver}_saver.ko moused_enable="NO" # Run the mouse daemon. moused_type="auto" # See man page for rc.conf(5) for available settings. moused_port="/dev/psm0" # Set to your mouse port. moused_flags="" # Any additional flags to moused. -mousechar_start="NO" # if 0xd0-0xd3 default range is occuped in your +mousechar_start="NO" # if 0xd0-0xd3 default range is occupied in your # language code table, specify alternative range # start like mousechar_start=3, see vidcontrol(1) allscreens_flags="" # Set this vidcontrol mode for all virtual screens allscreens_kbdflags="" # Set this kbdcontrol mode for all virtual screens +############################################################## +### pcvt console driver options ############################ +############################################################## + +pcvt_verbose="NO" # set to YES to enable verbose configuration messages +pcvt_keymap="NO" # keyboard map in /usr/share/misc/keycap.pcvt (or NO). +pcvt_keydel="NO" # key repeat delay, 0-3 (250,500,750,1000 msec) (or NO). +pcvt_keyrate="NO" # keyboard repetition rate 31-0 (2-30 char/sec) (or NO). +pcvt_keyrepeat="NO" # keyboard repeat ON or OFF (or NO). +pcvt_force24="NO" # force a 24 line display (when 25 possible) (or NO). +pcvt_hpext="NO" # use HP extensions (function keys labels) (or NO). +pcvt_lines="NO" # lines (25, 28, 40, 50 or NO). +pcvt_blanktime="NO" # blank time (in seconds) (or NO). +pcvt_cursorh="NO" # cursor top scanline (topmost line is 0) (or NO). +pcvt_cursorl="NO" # cursor low scanline (bottom line is 16) (or NO). +pcvt_monohigh="NO" # set intensity to high on monochrome monitors (or NO). + + ############################################################## ### Mail Transfer Agent (MTA) options ###################### ############################################################## @@ -331,8 +369,7 @@ allscreens_kbdflags="" # Set this kbdcontrol mode for all virtual screens mta_start_script="/etc/rc.sendmail" # Script to start your chosen MTA, called by /etc/rc. # Settings for /etc/rc.sendmail: -sendmail_enable="YES" # Run the sendmail inbound daemon (YES/NO/NONE). - # If NONE, don't start any sendmail processes. +sendmail_enable="NO" # Run the sendmail inbound daemon (YES/NO). sendmail_flags="-L sm-mta -bd -q30m" # Flags to sendmail (as a server) sendmail_submit_enable="YES" # Start a localhost-only MTA for mail submission sendmail_submit_flags="-L sm-mta -bd -q30m -ODaemonPortOptions=Addr=localhost" @@ -364,10 +401,10 @@ check_quotas="YES" # Check quotas on startup (or NO). accounting_enable="NO" # Turn on process accounting (or NO). ibcs2_enable="NO" # Ibcs2 (SCO) emulation loaded at startup (or NO). ibcs2_loaders="coff" # List of additional Ibcs2 loaders (or NO). +sysvipc_enable="NO" # Load System V IPC primitives at startup (or NO). linux_enable="NO" # Linux binary compatibility loaded at startup (or NO). svr4_enable="NO" # SysVR4 emulation loaded at startup (or NO). osf1_enable="NO" # Alpha OSF/1 emulation loaded at startup (or NO). -rand_irqs="NO" # Stir the entropy pool (like "5 11" or NO). clear_tmp_enable="NO" # Clear /tmp at startup. ldconfig_insecure="NO" # Set to YES to disable ldconfig security checks ldconfig_paths="/usr/lib/compat /usr/X11R6/lib /usr/local/lib" @@ -376,9 +413,25 @@ ldconfig_paths_aout="/usr/lib/compat/aout /usr/X11R6/lib/aout /usr/local/lib/aou # a.out shared library search paths kern_securelevel_enable="NO" # kernel security level (see init(8)), kern_securelevel="-1" # range: -1..3 ; `-1' is the most insecure +lomac_enable="NO" # start lomac(4) security module at boot update_motd="YES" # update version info in /etc/motd (or NO) start_vinum="NO" # set to YES to start vinum unaligned_print="YES" # print unaligned access warnings on the alpha (or NO). +entropy_file="/entropy" # Set to NO to disable caching entropy through reboots. + # /var/db/entropy is preferred if / is not available. +entropy_dir="/var/db/entropy" # Set to NO to disable caching entropy via cron. +entropy_save_sz="2048" # Size of the entropy cache files. +entropy_save_num="8" # Number of entropy cache files to save. +harvest_interrupt="YES" # Entropy device harvests interrupt randomness +harvest_ethernet="YES" # Entropy device harvests ethernet randomness +harvest_p_to_p="YES" # Entropy device harvests point-to-point randomness +dmesg_enable="YES" # Save dmesg(8) to /var/run/dmesg.boot +jail_enable="NO" # Set to NO to disable starting of any jails +jail_list="" # Space separated list of names of jails +jail_set_hostname_allow="YES" # Allow root user in a jail to change its hostname +jail_socket_unixiproute_only="YES" # Route only TCP/IP within a jail +jail_sysvipc_allow="NO" # Allow SystemV IPC use from within a jail +watchdogd_enable="NO" # Start the software watchdog daemon ############################################################## ### Define source_rc_confs, the mechanism used by /etc/rc.* ## diff --git a/etc/etc.alpha/rc.alpha b/etc/etc.alpha/rc.alpha deleted file mode 100644 index fc1ff6bc3b..0000000000 --- a/etc/etc.alpha/rc.alpha +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -# -# $FreeBSD: src/etc/etc.alpha/rc.alpha,v 1.7.2.5 2001/12/19 17:52:18 ru Exp $ -# $DragonFly: src/etc/etc.alpha/Attic/rc.alpha,v 1.2 2003/06/17 04:24:47 dillon Exp $ -# Do alpha specific processing -# - -echo -n 'Initial rc.alpha initialization:' - -# Start the Alpha OSF/1 binary compatibility if requested. -# -case ${osf1_enable} in -[Yy][Ee][Ss]) - echo -n ' OSF/1' - if ! kldstat -v | grep osf1_ecoff > /dev/null; then - kldload osf1 > /dev/null 2>&1 - fi - ;; -esac - -# knob for wether or not we should print out unaligned access warnings -# -case ${unaligned_print} in -[Nn][Oo]) - sysctl machdep.unaligned_print=0 - ;; -esac - -echo '.' diff --git a/etc/etc.i386/rc.i386 b/etc/etc.i386/rc.i386 deleted file mode 100644 index ad3a148ce5..0000000000 --- a/etc/etc.i386/rc.i386 +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh - -# -# $FreeBSD: src/etc/etc.i386/rc.i386,v 1.51.2.5 2001/02/27 20:03:30 jhb Exp $ -# $DragonFly: src/etc/etc.i386/Attic/rc.i386,v 1.2 2003/06/17 04:24:47 dillon Exp $ -# Do i386 specific processing -# - -echo -n 'Initial rc.i386 initialization:' - -case ${apm_enable} in -[Yy][Ee][Ss]) - echo -n ' apm' - apm -e enable > /dev/null 2>&1 - APM_DONE=yes - ;; -esac - -case ${apmd_enable} in -[Yy][Ee][Ss]) - case ${APM_DONE} in - '') - echo -n ' apm' - apm -e enable > /dev/null 2>&1 - ;; - esac - - echo -n ' apmd'; apmd ${apmd_flags} - ;; -esac - -# Start the SCO binary emulation if requested. -# -case ${ibcs2_enable} in -[Yy][Ee][Ss]) - echo -n ' ibcs2' - kldload ibcs2 > /dev/null 2>&1 - case ${ibcs2_loaders} in - [Nn][Oo]) - ;; - *) - for i in ${ibcs2_loaders}; do - kldload ibcs2_$i > /dev/null 2>&1 - done - ;; - esac - ;; -esac - -case ${xtend_enable} in -[Yy][Ee][Ss]) - echo -n ' xtend'; /usr/libexec/xtend - ;; -esac - -echo '.' - -# interrupts for /dev/random device -# -case ${rand_irqs} in -[Nn][Oo] | '') - ;; -*) - echo -n 'entropy IRQs:' - for irq in ${rand_irqs}; do - echo -n " ${irq}" && rndcontrol -q -s ${irq} - done - echo '.' - ;; -esac diff --git a/etc/mtree/BSD.root.dist b/etc/mtree/BSD.root.dist index 5b383b697e..2133d482b6 100644 --- a/etc/mtree/BSD.root.dist +++ b/etc/mtree/BSD.root.dist @@ -1,5 +1,5 @@ # $FreeBSD: src/etc/mtree/BSD.root.dist,v 1.45.2.4 2002/06/10 15:33:27 obrien Exp $ -# $DragonFly: src/etc/mtree/BSD.root.dist,v 1.2 2003/06/17 04:24:48 dillon Exp $ +# $DragonFly: src/etc/mtree/BSD.root.dist,v 1.3 2003/07/24 06:35:36 dillon Exp $ # # Please see the file src/etc/mtree/README before making changes to this file. # @@ -49,6 +49,8 @@ .. ppp .. + rc.d + .. skel .. ssh diff --git a/etc/netstart b/etc/netstart deleted file mode 100644 index 3d435979b7..0000000000 --- a/etc/netstart +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 1993 The FreeBSD Project -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# $FreeBSD: src/etc/netstart,v 1.54.2.5 2001/08/01 19:45:36 obrien Exp $ -# $DragonFly: src/etc/Attic/netstart,v 1.2 2003/06/17 04:24:45 dillon Exp $ -# From: @(#)netstart 5.9 (Berkeley) 3/30/91 -# - -# This file is NOT called by any of the other scripts - it has been -# obsoleted by /etc/rc.network and is provided here only for user -# convenience (if you're sitting in single user mode and wish to start -# the network by hand, this script will do it for you). -# - -# If there is a global system configuration file, suck it in. -if [ -f /etc/defaults/rc.conf ]; then - . /etc/defaults/rc.conf - source_rc_confs -elif [ -f /etc/rc.conf ]; then - . /etc/rc.conf -fi - -# Start pccard if necessary -if [ -r /etc/rc.pccard ]; then - . /etc/rc.pccard -fi - -if [ -r /etc/rc.network ]; then - . /etc/rc.network -else - echo 'Sorry, I cannot find /etc/rc.network - aborting' - exit 1 -fi - -echo 'Doing stage one network startup:' -network_pass1 - -case ${ipv6_enable} in -[Yy][Ee][Ss]) - if [ -r /etc/rc.network6 ]; then - . /etc/rc.network6 - else - echo 'Sorry, I cannot find /etc/rc.network6 - aborting' - exit 1 - fi - - echo 'Doing stage one network6 startup:' - network6_pass1 - ;; -esac - -exit 0 diff --git a/etc/network.subr b/etc/network.subr new file mode 100644 index 0000000000..452da13fac --- /dev/null +++ b/etc/network.subr @@ -0,0 +1,608 @@ +# +# Copyright (c) 2003 The FreeBSD Project. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD: src/etc/network.subr,v 1.151 2003/06/24 03:55:21 kuriyama Exp $ +# $DragonFly: src/etc/network.subr,v 1.1 2003/07/24 06:35:32 dillon Exp $ +# + +# +# Subroutines commonly used from network startup scripts. +# Requires that rc.conf be loaded first. +# + +# ifconfig_up if +# Evaluate ifconfig(8) arguments for interface $if and +# run ifconfig(8) with those arguments. It returns 0 if +# arguments were found and executed or 1 if the interface +# had no arguments. +# +ifconfig_up() +{ + eval ifconfig_args=\$ifconfig_$1 + if [ -n "${ifconfig_args}" ]; then + ifconfig $1 ${ifconfig_args} + return 0 + fi + return 1 +} + +# ifconfig_down if +# Remove all inet entries from the $if interface. It returns +# 0 if inet entries were found and removed. It returns 1 if +# no entries were found or they could not be removed. +# +ifconfig_down() +{ + [ -z "$1" ] && return 1 + _ifs="^" + _ret=1 + + inetList="`ifconfig $1 | grep 'inet ' | tr "\n" "$_ifs"`" + + oldifs="$IFS" + IFS="$_ifs" + for _inet in $inetList ; do + # get rid of extraneous line + [ -z "$_inet" ] && break + + _inet=`expr "$_inet" : '.*\(inet \([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*'` + + IFS="$oldifs" + ifconfig $1 ${_inet} delete + IFS="$_ifs" + _ret=0 + done + IFS="$oldifs" + + return $_ret +} + +# ifalias_up if +# Configure aliases for network interface $if. +# It returns 0 if at least one alias was configured or +# 1 if there were none. +# +ifalias_up() +{ + _ret=1 + alias=0 + while : ; do + eval ifconfig_args=\$ifconfig_$1_alias${alias} + if [ -n "${ifconfig_args}" ]; then + ifconfig $1 ${ifconfig_args} alias + alias=$((${alias} + 1)) + _ret=0 + else + break + fi + done + return $_ret +} + +#ifalias_down if +# Remove aliases for network interface $if. +# It returns 0 if at least one alias was removed or +# 1 if there were none. +# +ifalias_down() +{ + _ret=1 + alias=0 + while : ; do + eval ifconfig_args=\$ifconfig_$1_alias${alias} + if [ -n "${ifconfig_args}" ]; then + ifconfig $1 ${ifconfig_args} -alias + alias=$((${alias} + 1)) + _ret=0 + else + break + fi + done + return $_ret +} + +# ifscript_up if +# Evaluate a startup script for the $if interface. +# It returns 0 if a script was found and processed or +# 1 if no script was found. +# +ifscript_up() +{ + if [ -r /etc/start_if.$1 ]; then + . /etc/start_if.$1 + return 0 + fi + return 1 +} + +# ifscript_down if +# Evaluate a shutdown script for the $if interface. +# It returns 0 if a script was found and processed or +# 1 if no script was found. +# +ifscript_down() +{ + if [ -r /etc/stop_if.$1 ]; then + . /etc/stop_if.$1 + return 0 + fi + return 1 +} + +# Create cloneable interfaces. +# +clone_up() +{ + _prefix= + _list= + for ifn in ${cloned_interfaces}; do + ifconfig ${ifn} create + if [ $? -eq 0 ]; then + _list="${_list}${_prefix}${ifn}" + [ -z "$_prefix" ] && _prefix=' ' + fi + done + debug "Cloned: ${_list}" +} + +# Destroy cloned interfaces. Destroyed interfaces are echoed +# to standard output. +# +clone_down() +{ + _prefix= + _list= + for ifn in ${cloned_interfaces}; do + ifconfig ${ifn} destroy + if [ $? -eq 0 ]; then + _list="${_list}${_prefix}${ifn}" + [ -z "$_prefix" ] && _prefix=' ' + fi + done + debug "Destroyed clones: ${_list}" +} + +gif_up() { + case ${gif_interfaces} in + [Nn][Oo] | '') + ;; + *) + for i in ${gif_interfaces}; do + eval peers=\$gifconfig_$i + case ${peers} in + '') + continue + ;; + *) + ifconfig $i create >/dev/null 2>&1 + ifconfig $i tunnel ${peers} + ifconfig $i up + ;; + esac + done + ;; + esac +} + +# +# ipx_up ifn +# Configure any IPX addresses for interface $ifn. Returns 0 if IPX +# arguments were found and configured; returns 1 otherwise. +# +ipx_up() +{ + ifn="$1" + eval ifconfig_args=\$ifconfig_${ifn}_ipx + if [ -n "${ifconfig_args}" ]; then + ifconfig ${ifn} ${ifconfig_args} + return 0 + fi + return 1 +} + +# ipx_down ifn +# Remove IPX addresses for interface $ifn. Returns 0 if IPX +# addresses were found and unconfigured. It returns 1, otherwise. +# +ipx_down() +{ + [ -z "$1" ] && return 1 + _ifs="^" + _ret=1 + + ipxList="`ifconfig $1 | grep 'ipx ' | tr "\n" "$_ifs"`" + + oldifs="$IFS" + IFS="$_ifs" + for _ipx in $ipxList ; do + # get rid of extraneous line + [ -z "$_ipx" ] && break + + _ipx=`expr "$_ipx" : '.*\(ipx [0-9a-h]\{1,8\}H*\.[0-9a-h]\{1,12\}\).*'` + + IFS="$oldifs" + ifconfig $1 ${_ipx} delete + IFS="$_ifs" + _ret=0 + done + IFS="$oldifs" + + return $_ret +} + +# +# list_net_interfaces type +# List all network interfaces. The type of interface returned +# can be controlled by the type argument. The type +# argument can be any of the following: +# nodhcp - all interfaces, excluding DHCP configured interfaces +# dhcp - list only DHCP configured interfaces +# If no argument is specified all network interfaces are output. +# Note that the list always includes cloned interfaces. +# +list_net_interfaces() +{ + type=$1 + + # Get a list of ALL the interfaces + # + case ${network_interfaces} in + [Aa][Uu][Tt][Oo]) + _tmplist="`ifconfig -l`" + ;; + *) + _tmplist="${network_interfaces}" + ;; + esac + _tmplist="${_tmplist} ${cloned_interfaces}" + + if [ -z "$type" ]; then + echo $_tmplist + return 0 + fi + + # Separate out dhcp and non-dhcp intefraces + # + _aprefix= + _brefix= + for _if in ${_tmplist} ; do + eval _ifarg="\$ifconfig_${_if}" + case "$_ifarg" in + [Dd][Hh][Cc][Pp]) + _dhcplist="${_dhcplist}${_aprefix}${_if}" + [ -z "$_aprefix" ] && _aprefix=' ' + ;; + ''|*) + _nodhcplist="${_nodhcplist}${_bprefix}${_if}" + [ -z "$_bprefix" ] && _bprefix=' ' + ;; + esac + done + + case "$type" in + nodhcp) + echo $_nodhcplist + ;; + dhcp) + echo $_dhcplist + ;; + esac + return 0 +} + +hexdigit() +{ + if [ $1 -lt 10 ]; then + echo $1 + else + case $1 in + 10) echo a ;; + 11) echo b ;; + 12) echo c ;; + 13) echo d ;; + 14) echo e ;; + 15) echo f ;; + esac + fi +} + +hexprint() +{ + val=$1 + str='' + + dig=`hexdigit $((${val} & 15))` + str=${dig}${str} + val=$((${val} >> 4)) + while [ ${val} -gt 0 ]; do + dig=`hexdigit $((${val} & 15))` + str=${dig}${str} + val=$((${val} >> 4)) + done + + echo ${str} +} + +# Setup the interfaces for IPv6 +network6_interface_setup() +{ + interfaces=$* + rtsol_interfaces='' + case ${ipv6_gateway_enable} in + [Yy][Ee][Ss]) + rtsol_available=no + ;; + *) + rtsol_available=yes + ;; + esac + for i in $interfaces; do + rtsol_interface=yes + eval prefix=\$ipv6_prefix_$i + if [ -n "${prefix}" ]; then + rtsol_available=no + rtsol_interface=no + laddr=`network6_getladdr $i` + hostid=`expr "${laddr}" : 'fe80::\(.*\)%\(.*\)'` + for j in ${prefix}; do + address=$j\:${hostid} + ifconfig $i inet6 ${address} prefixlen 64 alias + + case ${ipv6_gateway_enable} in + [Yy][Ee][Ss]) + # subnet-router anycast address + # (rfc2373) + ifconfig $i inet6 $j:: prefixlen 64 \ + alias anycast + ;; + esac + done + fi + eval ipv6_ifconfig=\$ipv6_ifconfig_$i + if [ -n "${ipv6_ifconfig}" ]; then + rtsol_available=no + rtsol_interface=no + ifconfig $i inet6 ${ipv6_ifconfig} alias + fi + + if [ ${rtsol_available} = yes -a ${rtsol_interface} = yes ] + then + case ${i} in + lo0|gif[0-9]*|stf[0-9]*|faith[0-9]*|lp[0-9]*|sl[0-9]*|tun[0-9]*) + ;; + *) + rtsol_interfaces="${rtsol_interfaces} ${i}" + ;; + esac + else + ifconfig $i inet6 + fi + done + + if [ ${rtsol_available} = yes -a -n "${rtsol_interfaces}" ]; then + # Act as endhost - automatically configured. + # You can configure only single interface, as + # specification assumes that autoconfigured host has + # single interface only. + sysctl net.inet6.ip6.accept_rtadv=1 + set ${rtsol_interfaces} + ifconfig $1 up + rtsol $1 + fi + + for i in $interfaces; do + alias=0 + while : ; do + eval ipv6_ifconfig=\$ipv6_ifconfig_${i}_alias${alias} + if [ -z "${ipv6_ifconfig}" ]; then + break; + fi + ifconfig $i inet6 ${ipv6_ifconfig} alias + alias=$((${alias} + 1)) + done + done +} + +# Setup IPv6 to IPv4 mapping +network6_stf_setup() +{ + case ${stf_interface_ipv4addr} in + [Nn][Oo] | '') + ;; + *) + # assign IPv6 addr and interface route for 6to4 interface + stf_prefixlen=$((16+${stf_interface_ipv4plen:-0})) + OIFS="$IFS" + IFS=".$IFS" + set ${stf_interface_ipv4addr} + IFS="$OIFS" + hexfrag1=`hexprint $(($1*256 + $2))` + hexfrag2=`hexprint $(($3*256 + $4))` + ipv4_in_hexformat="${hexfrag1}:${hexfrag2}" + case ${stf_interface_ipv6_ifid} in + [Aa][Uu][Tt][Oo] | '') + for i in ${ipv6_network_interfaces}; do + laddr=`network6_getladdr ${i}` + case ${laddr} in + '') + ;; + *) + break + ;; + esac + done + stf_interface_ipv6_ifid=`expr "${laddr}" : \ + 'fe80::\(.*\)%\(.*\)'` + case ${stf_interface_ipv6_ifid} in + '') + stf_interface_ipv6_ifid=0:0:0:1 + ;; + esac + ;; + esac + ifconfig stf0 create >/dev/null 2>&1 + ifconfig stf0 inet6 2002:${ipv4_in_hexformat}:${stf_interface_ipv6_slaid:-0}:${stf_interface_ipv6_ifid} \ + prefixlen ${stf_prefixlen} + # disallow packets to malicious 6to4 prefix + route add -inet6 2002:e000:: -prefixlen 20 ::1 -reject + route add -inet6 2002:7f00:: -prefixlen 24 ::1 -reject + route add -inet6 2002:0000:: -prefixlen 24 ::1 -reject + route add -inet6 2002:ff00:: -prefixlen 24 ::1 -reject + ;; + esac +} + +# Setup static routes +network6_static_routes_setup() +{ + # Set up any static routes. + case ${ipv6_defaultrouter} in + [Nn][Oo] | '') + ;; + *) + ipv6_static_routes="default ${ipv6_static_routes}" + ipv6_route_default="default ${ipv6_defaultrouter}" + ;; + esac + case ${ipv6_static_routes} in + [Nn][Oo] | '') + ;; + *) + for i in ${ipv6_static_routes}; do + eval ipv6_route_args=\$ipv6_route_${i} + route add -inet6 ${ipv6_route_args} + done + ;; + esac +} + +# Setup faith +network6_faith_setup() +{ + case ${ipv6_faith_prefix} in + [Nn][Oo] | '') + ;; + *) + sysctl net.inet6.ip6.keepfaith=1 + ifconfig faith0 create >/dev/null 2>&1 + ifconfig faith0 up + for prefix in ${ipv6_faith_prefix}; do + prefixlen=`expr "${prefix}" : ".*/\(.*\)"` + case ${prefixlen} in + '') + prefixlen=96 + ;; + *) + prefix=`expr "${prefix}" : \ + "\(.*\)/${prefixlen}"` + ;; + esac + route add -inet6 ${prefix} -prefixlen ${prefixlen} ::1 + route change -inet6 ${prefix} -prefixlen ${prefixlen} \ + -ifp faith0 + done + ;; + esac +} + +# Install the "default interface" to kernel, which will be used +# as the default route when there's no router. +network6_default_interface_setup() +{ + # Choose IPv6 default interface if it is not clearly specified. + case ${ipv6_default_interface} in + '') + for i in ${ipv6_network_interfaces}; do + case $i in + lo0|faith[0-9]*) + continue + ;; + esac + laddr=`network6_getladdr $i exclude_tentative` + case ${laddr} in + '') + ;; + *) + ipv6_default_interface=$i + break + ;; + esac + done + ;; + esac + + # Disallow unicast packets without outgoing scope identifiers, + # or route such packets to a "default" interface, if it is specified. + route add -inet6 fe80:: -prefixlen 10 ::1 -reject + case ${ipv6_default_interface} in + [Nn][Oo] | '') + route add -inet6 ff02:: -prefixlen 16 ::1 -reject + ;; + *) + laddr=`network6_getladdr ${ipv6_default_interface}` + route add -inet6 ff02:: ${laddr} -prefixlen 16 -interface \ + -cloning + + # Disable installing the default interface with the + # case net.inet6.ip6.forwarding=0 and + # net.inet6.ip6.accept_rtadv=0, due to avoid conflict + # between the default router list and the manual + # configured default route. + case ${ipv6_gateway_enable} in + [Yy][Ee][Ss]) + ;; + *) + if [ `sysctl -n net.inet6.ip6.accept_rtadv` -eq 1 ] + then + ndp -I ${ipv6_default_interface} + fi + ;; + esac + ;; + esac +} + +network6_getladdr() +{ + ifconfig $1 2>/dev/null | while read proto addr rest; do + case ${proto} in + inet6) + case ${addr} in + fe80::*) + if [ -z "$2" ]; then + echo ${addr} + return + fi + case ${rest} in + *tentative*) + continue + ;; + *) + echo ${addr} + return + esac + esac + esac + done +} diff --git a/etc/pccard_ether b/etc/pccard_ether index a2ffa2cb33..582b518d71 100644 --- a/etc/pccard_ether +++ b/etc/pccard_ether @@ -1,7 +1,7 @@ #!/bin/sh - # # $FreeBSD: src/etc/pccard_ether,v 1.15.2.10 2001/09/14 17:28:11 imp Exp $ -# $DragonFly: src/etc/pccard_ether,v 1.2 2003/06/17 04:24:45 dillon Exp $ +# $DragonFly: src/etc/pccard_ether,v 1.3 2003/07/24 06:35:32 dillon Exp $ # # pccard_ether interfacename [start|stop] [ifconfig option] # @@ -22,14 +22,23 @@ stop_dhcp() { start_dhcp() { stop_dhcp - if [ -x "${dhcp_program}" ]; then - if [ `basename ${dhcp_program}` = "dhclient" ]; then + case ${pccard_ether_delay} in + [Nn][Oo]) + ;; + [0-9]) + sleep ${pccard_ether_delay} + ;; + esac + [ -n "$dhcp_program" ] && dhclient_program="$dhcp_program" + [ -n "$dhcp_flags" ] && dhclient_flags="$dhcp_flags" + if [ -x "${dhclient_program}" ]; then + if [ `basename ${dhclient_program}` = "dhclient" ]; then pidfile="/var/run/dhclient.${interface}.pid" - dhcp_flags="${dhcp_flags} -pf ${pidfile}" + dhclient_flags="${dhcp_flags} -pf ${pidfile}" fi - ${dhcp_program} ${dhcp_flags} ${interface} + ${dhclient_program} ${dhcp_flags} ${interface} else - echo "${dhcp_program}: DHCP client software not available" + echo "${dhclient_program}: DHCP client software not available" fi } @@ -47,19 +56,9 @@ shift startstop=$1 shift -case ${pccard_ether_delay} in -[Nn][Oo]) - ;; -[0-9]) - sleep ${pccard_ether_delay} - ;; -*) # Default until it has had a chance to make it to /etc/defaults/rc.conf - sleep 5 - ;; -esac - case ${pccard_ifconfig} in [Nn][Oo] | '') + expr "${removable_interfaces}" : ".*${interface}" > /dev/null || exit 0 ;; *) # Backward compatible @@ -69,6 +68,11 @@ esac case ${startstop} in [Ss][Tt][Aa][Rr][Tt] | '') + if ifconfig ${interface} | grep -s UP, > /dev/null 2>&1; then + # Interface is already up, so ignore it. + exit 0 + fi + if [ -r /etc/start_if.${interface} ]; then . /etc/start_if.${interface} fi @@ -133,8 +137,8 @@ case ${startstop} in # IPv6 setup case ${ipv6_enable} in [Yy][Ee][Ss]) - if [ -r /etc/rc.network6 ]; then - . /etc/rc.network6 + if [ -r /etc/network.subr ]; then + . /etc/network.subr network6_interface_setup ${interface} fi ;; @@ -155,7 +159,7 @@ case ${startstop} in stop_dhcp ;; *) - # Delelte static route if specified + # Delete static route if specified eval ifx_routes=\$static_routes_${interface} if [ -n "${ifx_routes}" ]; then for i in ${ifx_routes}; do @@ -179,8 +183,18 @@ case ${startstop} in ;; esac - # Remove the network interface and clean the ARP table + # Remove the network interface and cleaning the ARP table ifconfig ${interface} delete arp -d -a + + # Clean the routing table + case ${removable_route_flush} in + [Nn][Oo]) + ;; + *) + # flush beforehand, just in case.... + route -n flush -inet + ;; + esac ;; esac diff --git a/etc/rc b/etc/rc index 9197dd6969..3338b1208b 100644 --- a/etc/rc +++ b/etc/rc @@ -25,8 +25,8 @@ # SUCH DAMAGE. # # @(#)rc 5.27 (Berkeley) 6/5/91 -# $FreeBSD: src/etc/rc,v 1.212.2.51 2002/10/17 17:25:07 schweikh Exp $ -# $DragonFly: src/etc/rc,v 1.2 2003/06/17 04:24:45 dillon Exp $ +# $FreeBSD: src/etc/rc,v 1.329 2003/05/02 05:27:33 dougb Exp $ +# $DragonFly: src/etc/rc,v 1.3 2003/07/24 06:35:32 dillon Exp $ # # System startup script run by init on autoboot @@ -47,703 +47,32 @@ stty status '^T' trap : 2 trap : 3 # shouldn't be needed -bootmode=$1 - HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin export HOME PATH -# BOOTP diskless boot. We have to run the rc file early in order to -# retarget various config files. -# See /usr/share/examples/diskless/clone_root for details on how -# to setup diskless on the client and the server. -# -if [ -r /etc/rc.diskless1 ]; then - dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` - if [ ${dlv:=0} != 0 ]; then - . /etc/rc.diskless1 - fi -fi +. /etc/rc.subr -# If there is a global system configuration file, suck it in. +# Note: the system configuration files are loaded as part of +# the RCNG system (rc.d/rccond). Do not load them here as it may +# interfere with diskless booting. # -if [ -r /etc/defaults/rc.conf ]; then - . /etc/defaults/rc.conf - source_rc_confs -elif [ -r /etc/rc.conf ]; then - . /etc/rc.conf -fi - -chkdepend() { - svc=$1 - svc_var=$2 - dep=$3 - dep_var=$4 - - eval svc_val=\${$svc_var} - eval dep_val=\${$dep_var} - - case ${svc_val} in - [Yy][Ee][Ss]) - case ${dep_val} in - [Yy][Ee][Ss]) - ;; - *) - eval ${dep_var}="YES" - echo "DEPENDENCY NOTE: ${dep} will be enabled" \ - "to support ${svc}" - ;; - esac - ;; - esac -} - -chkdepend amd amd_enable portmap portmap_enable -chkdepend amd amd_enable NFS nfs_client_enable -chkdepend NFS nfs_server_enable portmap portmap_enable -chkdepend NIS nis_server_enable portmap portmap_enable -chkdepend NIS nis_client_enable portmap portmap_enable - -# Enable dumpdev early so that a crash during the boot process can be caught. -# -case ${dumpdev} in -[Nn][Oo] | '') - dumpdev='NO' - ;; -*) - /sbin/dumpon -v ${dumpdev} - ;; -esac - -# Configure ccd devices. -# -if [ -r /etc/ccd.conf ]; then - ccdconfig -C -fi - -case ${start_vinum} in -[Yy][Ee][Ss]) - vinum start - ;; -esac - -swapon -a - -# Last chance to do things before potentially waiting for -# operator to do fsck related tasks -if [ -r /etc/rc.early ]; then - . /etc/rc.early -fi - -case ${bootmode} in -autoboot) - echo 'Automatic boot in progress...' - fsck -p - case $? in - 0) - ;; - 2) - exit 1 - ;; - 4) - reboot - echo 'Reboot failed... help!' - exit 1 - ;; - 8) - case ${fsck_y_enable} in - [Yy][Ee][Ss]) - echo 'File system preen failed, trying fsck -y . . .' - fsck -y - case $? in - 0) - ;; - *) - echo 'Automatic file system check failed . . . help!' - exit 1 - ;; - esac - ;; - *) - echo 'Automatic file system check failed . . . help!' - exit 1 - ;; - esac - ;; - 12) - echo 'Reboot interrupted' - exit 1 - ;; - 130) - # interrupt before catcher installed - exit 1 - ;; - *) - echo 'Unknown error in reboot' - exit 1 - ;; - esac - ;; -*) - echo 'Skipping disk checks ...' - ;; -esac - -set -T -trap "echo 'Reboot interrupted'; exit 1" 3 - -# 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 - -# If using diskless, run custom disk mounting function here -# -if [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then - sh ${diskless_mount} +if [ "$1" = autoboot ]; then + autoboot=yes + _boot="faststart" + rc_fast=yes # run_rc_command(): do fast booting else -# otherwise mount everything except nfs filesystems. - mount -a -t nonfs -fi - -case $? in -0) - ;; -*) - echo 'Mounting /etc/fstab filesystems failed, startup aborted' - exit 1 - ;; -esac - -adjkerntz -i - -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 -} - -clean_var() { - if [ -d /var/run -a ! -f /var/run/clean_var ]; then - purgedir /var/run - # Keep a copy of the boot messages around - dmesg >/var/run/dmesg.boot - # 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/* -} - -# network_pass1() *may* end up writing stuff to /var - we don't want to -# remove it immediately afterwards - *nor* do we want to fail to clean -# an NFS-mounted /var. -rm -f /var/run/clean_var /var/spool/lock/clean_var -clean_var - -# Add additional swapfile, if configured. -# -case ${swapfile} in -[Nn][Oo] | '') - ;; -*) - if [ -w "${swapfile}" -a -c /dev/vn0b ]; then - echo "Adding ${swapfile} as additional swap" - vnconfig -e /dev/vn0b ${swapfile} swap - fi - ;; -esac - -# Early pass to set the variables we can -# -if [ -r /etc/rc.sysctl ]; then - sh /etc/rc.sysctl first -fi - -# Configure serial devices -# -if [ -r /etc/rc.serial ]; then - . /etc/rc.serial -fi - -# Start up PC-card configuration -# -if [ -r /etc/rc.pccard ]; then - . /etc/rc.pccard -fi - -# Start up the initial network configuration. -# -if [ -r /etc/rc.network ]; then - . /etc/rc.network # We only need to do this once. - network_pass1 -fi - -case ${ipv6_enable} in -[Yy][Ee][Ss]) - if [ -r /etc/rc.network6 ]; then - . /etc/rc.network6 # We only need to do this once also. - network6_pass1 - fi - ;; -esac - -# Mount NFS filesystems if present in /etc/fstab -# -case "`mount -d -a -t nfs 2> /dev/null`" in -*mount_nfs*) - echo -n 'Mounting NFS file systems:' - mount -a -t nfs - echo '.' - ;; -esac - -# If we booted a special kernel remove the record so we will boot -# the default kernel next time -# -rm -f /boot/nextboot.conf - -# Whack the pty perms back into shape. -# -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 - -# Clean up left-over files -# -clean_var # If it hasn't already been done -rm /var/run/clean_var /var/spool/lock/clean_var - -# Clearing /tmp at boot-time seems to have a long tradition. It doesn't -# help in any way for long-living systems, and it might accidentally -# clobber files you would rather like to have preserved after a crash -# (if not using mfs /tmp anyway). -# -# See also the example of another cleanup policy in /etc/periodic/daily. -# -case ${clear_tmp_enable} in -[Yy][Ee][Ss]) - echo -n 'Clearing /tmp:' - # prune quickly with one rm, then use find to clean up /tmp/[lq]* - # (not needed with mfs /tmp, but doesn't hurt there...) - (cd /tmp && rm -rf [a-km-pr-zA-Z]* && - find -d . ! -name . ! -name lost+found ! -name quota.user \ - ! -name quota.group -exec rm -rf -- {} \;) - echo '.' - ;; -esac - -# Remove X lock files, since they will prevent you from restarting X11 -# after a system crash. -# -rm -f /tmp/.X*-lock -rm -fr /tmp/.X11-unix -mkdir -m 1777 /tmp/.X11-unix - -# Snapshot any kernel -c changes back to disk here . -# This has changed with ELF and /kernel.config. - -echo -n 'Additional daemons:' - -# Start system logging and name service. Named needs to start before syslogd -# if you don't have a /etc/resolv.conf. -# -case ${syslogd_enable} in -[Yy][Ee][Ss]) - # Transitional symlink (for the next couple of years :) until all - # binaries have had a chance to move towards /var/run/log. - if [ ! -L /dev/log ]; then - # might complain for r/o root f/s - ln -sf /var/run/log /dev/log - fi - - rm -f /var/run/log - echo -n ' syslogd'; - ${syslogd_program:-/usr/sbin/syslogd} ${syslogd_flags} - ;; -esac - -echo '.' - -# Build devices database -# -dev_mkdb - -# $dumpdir should be a directory or a symbolic link -# to the crash directory if core dumps are to be saved. -# -if [ "${dumpdev}" != 'NO' ]; then - case ${dumpdir} in - '') - dumpdir='/var/crash' - ;; - [Nn][Oo]) - dumpdir='NO' - ;; - esac - - if [ "${dumpdir}" != 'NO' ]; then - echo -n 'Checking for core dump: ' - /sbin/savecore ${savecore_flags} "${dumpdir}" - fi -fi - -if [ -n "${network_pass1_done}" ]; then - network_pass2 + autoboot=no + _boot="start" fi -# Enable/Check the quotas (must be after ypbind if using NIS) -# -case ${enable_quotas} in -[Yy][Ee][Ss]) - case ${check_quotas} in - [Yy][Ee][Ss]) - echo -n 'Checking quotas:' - quotacheck -a - echo ' done.' - ;; - esac +os=`eval ${CMD_OSTYPE}` +files=`rcorder -k ${os} -s nostart /etc/rc.d/* 2>/dev/null` - echo -n 'Enabling quotas:' - quotaon -a - echo ' done.' - ;; -esac - -if [ -n "${network_pass2_done}" ]; then - network_pass3 -fi - -# Check the password temp/lock file -# -if [ -e /etc/ptmp ]; then - logger -s -p auth.err \ - "password file may be incorrect -- /etc/ptmp exists" -fi - -case ${accounting_enable} in -[Yy][Ee][Ss]) - if [ -d /var/account ]; then - echo 'Turning on accounting:' - if [ ! -e /var/account/acct ]; then - touch /var/account/acct - fi - accton /var/account/acct - fi - ;; -esac - -# Make shared lib searching a little faster. Leave /usr/lib first if you -# add your own entries or you may come to grief. -# -ldconfig="/sbin/ldconfig" -case ${ldconfig_insecure} in -[Yy][Ee][Ss]) - ldconfig="${ldconfig} -i" - ;; -esac -if [ -x /sbin/ldconfig ]; 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 - -# Now start up miscellaneous daemons that don't belong anywhere else -# -echo -n 'Starting standard daemons:' -case ${inetd_enable} in -[Nn][Oo]) - ;; -*) - echo -n ' inetd'; ${inetd_program:-/usr/sbin/inetd} ${inetd_flags} - ;; -esac - -case ${cron_enable} in -[Nn][Oo]) - ;; -*) - echo -n ' cron'; ${cron_program:-/usr/sbin/cron} ${cron_flags} - ;; -esac - -case ${lpd_enable} in -[Yy][Ee][Ss]) - echo -n ' printer'; ${lpd_program:-/usr/sbin/lpd} ${lpd_flags} - ;; -esac - -case ${sshd_enable} in -[Yy][Ee][Ss]) - if [ -x ${sshd_program:-/usr/sbin/sshd} ]; then - echo -n ' sshd'; - ${sshd_program:-/usr/sbin/sshd} ${sshd_flags} - fi - ;; -esac - -case ${usbd_enable} in -[Yy][Ee][Ss]) - echo -n ' usbd'; /usr/sbin/usbd ${usbd_flags} - ;; -esac - -case ${mta_start_script} in -/*) - if [ -r ${mta_start_script} ]; then - sh ${mta_start_script} - fi - ;; -esac - -echo '.' - -# Recover vi editor files. -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 - -# 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 - -case ${update_motd} in -[Nn][Oo] | '') - ;; -*) - if T=`mktemp /tmp/_motd.XXXXXX`; then - 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} - cmp -s ${T} /etc/motd || { - cp ${T} /etc/motd - chmod 644 /etc/motd - } - rm -f ${T} - fi - ;; -esac - -# Configure implementation specific stuff -# -arch=`uname -p` -if [ -r /etc/rc.${arch} ]; then - . /etc/rc.${arch} -fi - -# Configure the system console -# -if [ -r /etc/rc.syscons ]; then - . /etc/rc.syscons -fi - -echo -n 'Additional ABI support:' - -# Start the Linux binary compatibility if requested. -# -case ${linux_enable} in -[Yy][Ee][Ss]) - 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 - ;; -esac - -# Start the SysVR4 binary emulation if requested. -# -case ${svr4_enable} in -[Yy][Ee][Ss]) - echo -n ' svr4'; - kldload streams > /dev/null 2>&1 - kldload svr4 > /dev/null 2>&1 - ;; -esac - -echo '.' - -# Do traditional (but rather obsolete) rc.local file if it exists. If you -# use this file and want to make it programmatic, source /etc/defaults/rc.conf -# in /etc/rc.local and add your custom variables to /etc/rc.conf, as -# shown below. Please do not put local extensions into /etc/rc itself. -# Use /etc/rc.local -# -# ---- rc.local ---- -# if [ -r /etc/defaults/rc.conf ]; then -# . /etc/defaults/rc.conf -# source_rc_confs -# elif [ -r /etc/rc.conf ]; then -# . /etc/rc.conf -# fi -# -# ... additional startup conditionals ... -# ---- rc.local ---- -# -if [ -r /etc/rc.local ]; then - echo -n 'Starting local daemons:' - sh /etc/rc.local - echo '.' -fi - -# For each valid 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 - -if [ -n "${network_pass3_done}" ]; then - network_pass4 -fi - -# Late pass to set variables we missed the first time -# -if [ -r /etc/rc.sysctl ]; then - sh /etc/rc.sysctl last -fi - -# Raise kernel security level. This should be done only after `fsck' has -# repaired local file systems if you want the securelevel to be greater than 1. -# -case ${kern_securelevel_enable} in -[Yy][Ee][Ss]) - if [ "${kern_securelevel}" -ge 0 ]; then - echo 'Raising kernel security level: ' - sysctl kern.securelevel=${kern_securelevel} - fi - ;; -esac +for _rc_elem in ${files}; do + run_rc_script ${_rc_elem} ${_boot} +done echo '' - date - exit 0 - diff --git a/etc/rc.d/DAEMON b/etc/rc.d/DAEMON new file mode 100644 index 0000000000..96349cc7bb --- /dev/null +++ b/etc/rc.d/DAEMON @@ -0,0 +1,13 @@ +#!/bin/sh +# +# $NetBSD: DAEMON,v 1.8 2002/03/22 04:33:57 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/DAEMON,v 1.3 2002/10/12 13:49:20 schweikh Exp $ +# $DragonFly: src/etc/rc.d/DAEMON,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: DAEMON +# REQUIRE: NETWORKING SERVERS +# KEYWORD: DragonFly FreeBSD NetBSD + +# This is a dummy dependency, to ensure that general purpose daemons +# are run _after_ the above are. diff --git a/etc/rc.d/LOGIN b/etc/rc.d/LOGIN new file mode 100644 index 0000000000..857a93d28d --- /dev/null +++ b/etc/rc.d/LOGIN @@ -0,0 +1,16 @@ +#!/bin/sh +# +# $NetBSD: LOGIN,v 1.7 2002/03/22 04:33:57 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/LOGIN,v 1.3 2002/10/12 13:49:20 schweikh Exp $ +# $DragonFly: src/etc/rc.d/LOGIN,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: LOGIN +# REQUIRE: DAEMON +# KEYWORD: DragonFly FreeBSD NetBSD + +# This is a dummy dependency to ensure user services such as xdm, +# inetd, cron and kerberos are started after everything else, in case +# the administrator has increased the system security level and +# wants to delay user logins until the system is (almost) fully +# operational. diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile new file mode 100644 index 0000000000..08fad07dc6 --- /dev/null +++ b/etc/rc.d/Makefile @@ -0,0 +1,30 @@ +# $NetBSD: Makefile,v 1.16 2001/01/14 15:37:22 minoura Exp $ +# $FreeBSD: src/etc/rc.d/Makefile,v 1.20 2003/06/29 05:15:57 mtm Exp $ +# $DragonFly: src/etc/rc.d/Makefile,v 1.1 2003/07/24 06:35:37 dillon Exp $ + +.include + +# note: bgfsk, devd, devfs, and lomac left out (from 5.0) +# +FILES= DAEMON LOGIN NETWORKING SERVERS abi accounting addswap adjkerntz amd \ + apm apmd archdep atm1 atm2.sh atm3.sh bootparams ccd cleanvar \ + cleartmp cron dhclient diskless dmesg dumpon fsck \ + hostname inetd initdiskless initrandom ip6fw ipfilter ipfs ipfw ipmon \ + ipnat ipsec ipxrouted isdnd jail \ + kadmind kerberos keyserv kldxref kpasswdd \ + ldconfig local localdaemons lpd \ + motd mountcritlocal mountcritremote \ + mountd moused mroute6d mrouted msgs \ + named netif netoptions network1 network2 network3 \ + network_ipv6 nfsclient nfsd nfslocking nfsserver nisdomain ntpd \ + ntpdate othermta pccard pcvt ppp-user pppoed pwcheck quota random \ + rarpd rcconf.sh root route6d routed routing rpcbind rtadvd rwho \ + savecore securelevel sendmail serial sppp sshd swap1 syscons sysctl \ + syslogd timed ttys usbd vinum virecover watchdogd ypbind \ + yppasswdd ypserv ypset ypupdated ypxfrd +FILESDIR= /etc/rc.d +FILESMODE= ${BINMODE} + +NOPROG= noprog + +.include diff --git a/etc/rc.d/NETWORKING b/etc/rc.d/NETWORKING new file mode 100644 index 0000000000..147cee9609 --- /dev/null +++ b/etc/rc.d/NETWORKING @@ -0,0 +1,14 @@ +#!/bin/sh +# +# $NetBSD: NETWORKING,v 1.2 2002/03/22 04:33:57 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/NETWORKING,v 1.6 2003/06/29 05:15:57 mtm Exp $ +# $DragonFly: src/etc/rc.d/NETWORKING,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: NETWORKING NETWORK +# REQUIRE: network dhclient altqd netif routing network_ipv6 isdnd ppp-user +# REQUIRE: routed mrouted route6d mroute6d +# KEYWORD: DragonFly FreeBSD NetBSD + +# This is a dummy dependency, for services which require networking +# to be operational before starting. diff --git a/etc/rc.d/SERVERS b/etc/rc.d/SERVERS new file mode 100644 index 0000000000..e7f4c0843e --- /dev/null +++ b/etc/rc.d/SERVERS @@ -0,0 +1,13 @@ +#!/bin/sh +# +# $NetBSD: SERVERS,v 1.9 2002/03/22 04:33:57 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/SERVERS,v 1.3 2002/10/12 13:49:21 schweikh Exp $ +# $DragonFly: src/etc/rc.d/SERVERS,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: SERVERS +# REQUIRE: mountcritremote +# KEYWORD: DragonFly FreeBSD NetBSD + +# This is a dummy dependency, 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 0000000000..ab79e63260 --- /dev/null +++ b/etc/rc.d/abi @@ -0,0 +1,56 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/abi,v 1.2 2003/05/05 15:38:41 mtm Exp $ +# $DragonFly: src/etc/rc.d/abi,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: abi +# REQUIRE: LOGIN +# BEFORE: securelevel +# KEYWORD: DragonFly 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 new file mode 100644 index 0000000000..1e1fff8a7f --- /dev/null +++ b/etc/rc.d/accounting @@ -0,0 +1,70 @@ +#!/bin/sh +# +# $NetBSD: accounting,v 1.7 2002/03/22 04:33:57 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/accounting,v 1.4 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/accounting,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: accounting +# REQUIRE: mountall +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="accounting" +rcvar=`set_rcvar` +accounting_command="/usr/sbin/accton" +accounting_file="/var/account/acct" +start_cmd="accounting_start" +stop_cmd="accounting_stop" + +accounting_start() +{ + case ${OSTYPE} in + DragonFly) + _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 + ;; + 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." + ${accounting_command} +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/addswap b/etc/rc.d/addswap new file mode 100644 index 0000000000..8ccccdc3ec --- /dev/null +++ b/etc/rc.d/addswap @@ -0,0 +1,35 @@ +#!/bin/sh +# +# Add additional swap files +# +# $FreeBSD: src/etc/rc.d/addswap,v 1.2 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/addswap,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: addswap +# REQUIRE: mountcritlocal +# BEFORE: sysctl +# KEYWORD: DragonFly 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 0000000000..3ce9534dfe --- /dev/null +++ b/etc/rc.d/adjkerntz @@ -0,0 +1,19 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/adjkerntz,v 1.2 2003/04/18 17:55:05 mtm Exp $ +# $DragonFly: src/etc/rc.d/adjkerntz,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: adjkerntz +# REQUIRE: diskless mountcritlocal random +# BEFORE: netif +# KEYWORD: DragonFly 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 0000000000..b89d07649e --- /dev/null +++ b/etc/rc.d/altqd @@ -0,0 +1,23 @@ +#!/bin/sh +# +# $NetBSD: altqd,v 1.2 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/altqd,v 1.1 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/altqd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# 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 new file mode 100644 index 0000000000..70602e5400 --- /dev/null +++ b/etc/rc.d/amd @@ -0,0 +1,101 @@ +#!/bin/sh +# +# $NetBSD: amd,v 1.10 2002/04/29 12:08:17 lukem Exp $ +# $FreeBSD: src/etc/rc.d/amd,v 1.9 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/amd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: amd +# REQUIRE: rpcbind mountall ypbind nfsclient +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="amd" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" + +case ${OSTYPE} in +DragonFly) + start_precmd="amd_precmd" + command_args="&" + ;; +FreeBSD) + start_precmd="amd_precmd" + command_args="&" + ;; +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" + ;; +esac + +amd_precmd() +{ + case ${OSTYPE} in + DragonFly) + if ! checkyesno nfs_client_enable; then + force_depend nfsclient || return 1 + fi + + if ! checkyesno rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + then + force_depend rpcbind || return 1 + fi + + case ${amd_map_program} in + [Nn][Oo] | '') + ;; + *) + rc_flags="${rc_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 + ;; + esac + ;; + + FreeBSD) + if ! checkyesno nfs_client_enable; then + force_depend nfsclient || return 1 + fi + + if ! checkyesno rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + then + force_depend rpcbind || return 1 + fi + + case ${amd_map_program} in + [Nn][Oo] | '') + ;; + *) + rc_flags="${rc_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 + ;; + esac + ;; + esac + return 0 +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/apm b/etc/rc.d/apm new file mode 100644 index 0000000000..83eaea2062 --- /dev/null +++ b/etc/rc.d/apm @@ -0,0 +1,47 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/apm,v 1.4 2003/06/09 17:44:30 mtm Exp $ +# $DragonFly: src/etc/rc.d/apm,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: apm +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="apm" +rcvar=`set_rcvar` +start_precmd="apm_precmd" +command="/usr/sbin/${name}" +start_cmd="${command} -e enable" +stop_cmd="${command} -e disable" +status_cmd="apm_status" + +apm_precmd() +{ + case `${SYSCTL_N} hw.machine_arch` in + i386) + return 0 + ;; + esac + return 1 +} + +apm_status() +{ + case `${command} -s` in + 1) + echo "APM is enabled." + return 0 + ;; + 0) + echo "APM is disabled" + ;; + esac + return 1 +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/apmd b/etc/rc.d/apmd new file mode 100644 index 0000000000..c63a57592a --- /dev/null +++ b/etc/rc.d/apmd @@ -0,0 +1,53 @@ +#!/bin/sh +# +# $NetBSD: apmd,v 1.5 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/apmd,v 1.8 2003/06/09 17:44:30 mtm Exp $ +# $DragonFly: src/etc/rc.d/apmd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: apmd +# REQUIRE: DAEMON apm +# BEFORE: LOGIN +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="apmd" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" + +case ${OSTYPE} in +DragonFly) + start_precmd="apmd_prestart" + ;; +FreeBSD) + start_precmd="apmd_prestart" + ;; +esac + +apmd_prestart() +{ + case `${SYSCTL_N} hw.machine_arch` in + i386) + # Enable apm if it is not already enabled + if ! checkyesno apm_enable && \ + ! /etc/rc.d/apm forcestatus 1>/dev/null 2>&1 + then + force_depend apm || return 1 + fi + + # Warn user about acpi apm compatibility support which + # does not work with apmd. + if [ ! -e /dev/apmctl ]; then + warn "/dev/apmctl not found; kernel is missing apm(4)" + fi + ;; + *) + return 1 + ;; + esac + return 0 +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/archdep b/etc/rc.d/archdep new file mode 100644 index 0000000000..d40a5970b3 --- /dev/null +++ b/etc/rc.d/archdep @@ -0,0 +1,71 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/archdep,v 1.5 2003/05/06 00:09:51 obrien Exp $ +# $DragonFly: src/etc/rc.d/Attic/archdep,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: archdep +# REQUIRE: LOGIN +# BEFORE: abi +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name=archdep +load_rc_config $name + +# should we print out unaligned access warnings? +# +unaligned_warnings() +{ + if ! checkyesno unaligned_print; then + sysctl machdep.unaligned_print=0 + fi +} + +# Alpha OSF/1 binary emulation +# +osf1_compat() +{ + if checkyesno osf1_enable; then + echo -n ' OSF/1' + if ! kldstat -v | grep osf1_ecoff > /dev/null; then + kldload osf1 > /dev/null 2>&1 + fi + fi +} + +# SCO binary emulation +# +ibcs2_compat() +{ + if checkyesno ibcs2_enable; then + echo -n ' ibcs2' + kldload ibcs2 > /dev/null 2>&1 + case ${ibcs2_loaders} in + [Nn][Oo]) + ;; + *) + for i in ${ibcs2_loaders}; do + kldload ibcs2_$i > /dev/null 2>&1 + done + ;; + esac + fi +} + +_arch=`${SYSCTL_N} hw.machine` +echo -n "Initial $_arch initialization:" +case $_arch in +i386) + ibcs2_compat + ;; +alpha) + osf1_compat + unaligned_warnings + ;; +ia64) + unaligned_warnings + ;; +esac +echo '.' diff --git a/etc/rc.atm b/etc/rc.d/atm1 similarity index 65% rename from etc/rc.atm rename to etc/rc.d/atm1 index e95b6848c7..ed4bcb76e0 100644 --- a/etc/rc.atm +++ b/etc/rc.d/atm1 @@ -24,17 +24,29 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD: src/etc/rc.atm,v 1.6.2.3 2001/11/19 10:42:28 sheldonh Exp $ -# $DragonFly: src/etc/Attic/rc.atm,v 1.2 2003/06/17 04:24:45 dillon Exp $ +# $FreeBSD: src/etc/rc.d/atm1,v 1.12 2003/04/18 17:55:05 mtm Exp $ +# $DragonFly: src/etc/rc.d/atm1,v 1.1 2003/07/24 06:35:37 dillon Exp $ # -# +# PROVIDE: atm1 +# REQUIRE: root +# BEFORE: netif +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="atm" +rcvar="atm_enable" +start_cmd="atm_start" +stop_cmd=":" + # ATM networking startup script # # Initial interface configuration. # N.B. /usr is not mounted. # -atm_pass1() { +atm_start() +{ # Locate all probed ATM adapters atmdev=`atm sh stat int | while read dev junk; do case ${dev} in @@ -44,6 +56,9 @@ atm_pass1() { hfa[0-9] | hfa[0-9][0-9]) echo "${dev} " ;; + idt[0-9] | idt[0-9][0-9]) + echo "${dev} " + ;; *) continue ;; @@ -127,92 +142,7 @@ atm_pass1() { esac echo '.' - atm_pass1_done=YES } -# -# Finish up configuration. -# N.B. /usr is not mounted. -# -atm_pass2() { - echo -n 'Configuring ATM network interfaces:' - - atm_scspd=0 - atm_atmarpd="" - - # Configure network interfaces - for phy in ${atm_phy}; do - eval netif_args=\$atm_netif_${phy} - set -- ${netif_args} - netname=$1 - netcnt=$2 - netindx=0 - while [ ${netindx} -lt ${netcnt} ]; do - net="${netname}${netindx}" - netindx=$((${netindx} + 1)) - echo -n " ${net}" - - # Configure atmarp server - eval atmarp_args=\$atm_arpserver_${net} - if [ -n "${atmarp_args}" ]; then - atm set arpserver ${net} ${atmarp_args} || - continue - fi - eval scsparp_args=\$atm_scsparp_${net} - - case ${scsparp_args} in - [Yy][Ee][Ss]) - case ${atmarp_args} in - local) - ;; - *) - echo ' local arpserver required for SCSP' - continue - ;; - esac - - atm_atmarpd="${atm_atmarpd} ${net}" - atm_scspd=1 - esac - done - done - echo '.' - - # Define any PVCs. - if [ -n "${atm_pvcs}" ]; then - for i in ${atm_pvcs}; do - eval pvc_args=\$atm_pvc_${i} - atm add pvc ${pvc_args} - done - fi - - # Define any permanent ARP entries. - if [ -n "${atm_arps}" ]; then - for i in ${atm_arps}; do - eval arp_args=\$atm_arp_${i} - atm add arp ${arp_args} - done - fi - atm_pass2_done=YES -} - -# -# Start any necessary daemons. -# -atm_pass3() { - # Start SCSP daemon (if needed) - case ${atm_scspd} in - 1) - echo -n ' scspd' - scspd - ;; - esac - - # Start ATMARP daemon (if needed) - if [ -n "${atm_atmarpd}" ]; then - echo -n ' atmarpd' - atmarpd ${atm_atmarpd} - fi - - atm_pass3_done=YES -} +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/atm2.sh b/etc/rc.d/atm2.sh new file mode 100644 index 0000000000..8d2cb1c92d --- /dev/null +++ b/etc/rc.d/atm2.sh @@ -0,0 +1,105 @@ +#!/bin/sh +# +# Copyright (c) 2000 The FreeBSD Project +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD: src/etc/rc.d/atm2.sh,v 1.13 2003/06/29 05:15:57 mtm Exp $ +# $DragonFly: src/etc/rc.d/atm2.sh,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: atm2 +# REQUIRE: atm1 netif +# BEFORE: routing +# KEYWORD: DragonFly FreeBSD + +# +# Additional ATM interface configuration +# + +. /etc/rc.subr + +atm2_start() +{ + # Configure network interfaces + for phy in ${atm_phy}; do + eval netif_args=\$atm_netif_${phy} + set -- ${netif_args} + netname=$1 + netcnt=$2 + netindx=0 + while [ ${netindx} -lt ${netcnt} ]; do + net="${netname}${netindx}" + netindx=$((${netindx} + 1)) + echo -n " ${net}" + + # Configure atmarp server + eval atmarp_args=\$atm_arpserver_${net} + if [ -n "${atmarp_args}" ]; then + atm set arpserver ${net} ${atmarp_args} || + continue + fi + eval scsparp_args=\$atm_scsparp_${net} + + case ${scsparp_args} in + [Yy][Ee][Ss]) + case ${atmarp_args} in + local) + ;; + *) + echo ' local arpserver required for SCSP' + continue + ;; + esac + + atm_atmarpd="${atm_atmarpd} ${net}" + atm_scspd=1 + ;; + esac + done + done + echo '.' + + # Define any permanent ARP entries. + if [ -n "${atm_arps}" ]; then + for i in ${atm_arps}; do + eval arp_args=\$atm_arp_${i} + atm add arp ${arp_args} + done + fi + + # XXX - required by atm3.sh. I don't like having one script depend + # on variables in another script (especially in a dynamic + # ordered system like this), but it's necessary for the moment. + # + export atm_atmarpd + export atm_scspd +} + +load_rc_config "XXX" + +case ${atm_enable} in +[Yy][Ee][Ss]) + atm2_start + ;; +esac diff --git a/etc/rc.pccard b/etc/rc.d/atm3.sh similarity index 64% rename from etc/rc.pccard rename to etc/rc.d/atm3.sh index 974a25f1d6..ac45881d78 100644 --- a/etc/rc.pccard +++ b/etc/rc.d/atm3.sh @@ -1,6 +1,6 @@ -#!/bin/sh - +#!/bin/sh # -# Copyright (c) 1996 The FreeBSD Project +# Copyright (c) 2000 The FreeBSD Project # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -24,34 +24,46 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD: src/etc/rc.pccard,v 1.20.2.5 2001/03/06 02:22:00 obrien Exp $ -# $DragonFly: src/etc/Attic/rc.pccard,v 1.2 2003/06/17 04:24:45 dillon Exp $ +# $FreeBSD: src/etc/rc.d/atm3.sh,v 1.10 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/atm3.sh,v 1.1 2003/07/24 06:35:37 dillon Exp $ # -# PC-card startup script +# Start ATM daemons +# XXX - This script uses global variables set by scripts atm1 and atm2. +# Ideally this shouldn't be the case. +# -case ${pccard_enable} in -[Yy][Ee][Ss]) - echo -n 'Setup PC-CARD:' +# PROVIDE: atm3 +# REQUIRE: atm2 +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD - case ${pccard_mem} in - [Dd][Ee][Ff][Aa][Uu][Ll][Tt]) - pccardc pccardmem 0xd0000 1>/dev/null && echo -n ' memory' - ;; - *) - pccardc pccardmem ${pccard_mem} 1>/dev/null && echo -n ' memory' +. /etc/rc.subr + +atm3_start() +{ + echo -n 'Starting ATM daemons:' + + # Start SCSP daemon (if needed) + case ${atm_scspd} in + 1) + echo -n ' scspd' + scspd ;; esac - if [ -n "${pccard_beep}" ] ; then - pccardc beep ${pccard_beep} && echo -n ' beep' + # Start ATMARP daemon (if needed) + if [ -n "${atm_atmarpd}" ]; then + echo -n ' atmarpd' + atmarpd ${atm_atmarpd} fi + echo '.' +} - if [ -n "${pccard_conf}" ]; then - pccardd_flags="${pccardd_flags} -f ${pccard_conf}" - fi +load_rc_config "XXX" - pccardd ${pccardd_flags} && echo -n ' pccardd' - echo '.' +case ${atm_enable} in +[Yy][Ee][Ss]) + atm3_start ;; esac diff --git a/etc/rc.d/bootconf.sh b/etc/rc.d/bootconf.sh new file mode 100644 index 0000000000..592e4a7347 --- /dev/null +++ b/etc/rc.d/bootconf.sh @@ -0,0 +1,83 @@ +#!/bin/sh +# +# $NetBSD: bootconf.sh,v 1.5 2002/03/25 03:22:10 wiz Exp $ +# $FreeBSD: src/etc/rc.d/bootconf.sh,v 1.4 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/Attic/bootconf.sh,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: bootconf +# REQUIRE: mountcritlocal + +bootconf_start() +{ + # Refer to newbtconf(8) for more information + # + + if [ ! -e /etc/etc.current ]; then + return 0 + fi + if [ -L /etc/etc.default ]; then + def=`ls -ld /etc/etc.default 2>&1` + default="${def##*-> etc.}" + 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 + name="${i##/etc/etc.}" + case $name in + current|default|\*) + continue + ;; + *) + if [ "$name" = "$default" ]; then + echo -n "${spc}[${name}]" + else + echo -n "${spc}${name}" + fi + spc=" " + ;; + esac + done + echo + master=$$ + _DUMMY=/etc/passwd + conf=${_DUMMY} + while [ ! -d /etc/etc.$conf/. ]; do + 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 : ALRM + if [ -z $conf ]; then + conf=$default + fi + if [ ! -d /etc/etc.$conf/. ]; then + conf=${_DUMMY} + fi + done + + 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 +} + +case "$1" in +*start) + bootconf_start + ;; +esac diff --git a/etc/rc.d/bootparams b/etc/rc.d/bootparams new file mode 100644 index 0000000000..0c8f9f65dd --- /dev/null +++ b/etc/rc.d/bootparams @@ -0,0 +1,32 @@ +#!/bin/sh +# +# $NetBSD: bootparams,v 1.6 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/bootparams,v 1.4 2002/09/06 16:18:05 gordon Exp $ +# $DragonFly: src/etc/rc.d/bootparams,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: bootparams +# REQUIRE: rpcbind DAEMON +# BEFORE: LOGIN +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="bootparamd" +rcvar=`set_rcvar` +required_files="/etc/bootparams" + +case ${OSTYPE} in +DragonFly) + command="/usr/sbin/${name}" + ;; +FreeBSD) + command="/usr/sbin/${name}" + ;; +NetBSD) + command="/usr/sbin/rpc.${name}" + ;; +esac + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ccd b/etc/rc.d/ccd new file mode 100644 index 0000000000..2b2b0a6e3c --- /dev/null +++ b/etc/rc.d/ccd @@ -0,0 +1,26 @@ +#!/bin/sh +# +# $NetBSD: ccd,v 1.3 2000/05/13 08:45:06 lukem Exp $ +# $FreeBSD: src/etc/rc.d/ccd,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/ccd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: disks +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="ccd" +start_cmd="ccd_start" +stop_cmd=":" + +ccd_start() +{ + if [ -f /etc/ccd.conf ]; then + echo "Configuring CCD devices." + ccdconfig -C + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/cleanvar b/etc/rc.d/cleanvar new file mode 100644 index 0000000000..ca3b7af3a6 --- /dev/null +++ b/etc/rc.d/cleanvar @@ -0,0 +1,52 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/cleanvar,v 1.5 2003/07/14 13:02:36 mtm Exp $ +# $DragonFly: src/etc/rc.d/cleanvar,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: cleanvar +# REQUIRE: mountcritlocal +# KEYWORD: DragonFly 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 +} + +# These files must be removed only the first time this script is run +# on boot. +# +[ "$1" != "reload" ] && 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 new file mode 100644 index 0000000000..23a71d0374 --- /dev/null +++ b/etc/rc.d/cleartmp @@ -0,0 +1,56 @@ +#!/bin/sh +# +# $NetBSD: cleartmp,v 1.4 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/cleartmp,v 1.4 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/cleartmp,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: cleartmp +# REQUIRE: mountall +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="cleartmp" +rcvar=`set_rcvar clear_tmp` +start_cmd="cleartmp_start" +stop_cmd=":" + +cleartmp_start() +{ + echo "Clearing /tmp." + # + # Prune quickly with one rm, then use find to clean up + # /tmp/[lq]* (this is not needed with mfs /tmp, but + # doesn't hurt anything). + # + (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 ${OSTYPE} in + DragonFly) + # 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 + ;; + + 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 +run_rc_command "$1" diff --git a/etc/rc.d/cron b/etc/rc.d/cron new file mode 100644 index 0000000000..61eed3ddc6 --- /dev/null +++ b/etc/rc.d/cron @@ -0,0 +1,21 @@ +#!/bin/sh +# +# $NetBSD: cron,v 1.5 2000/09/19 13:04:38 lukem Exp $ +# $FreeBSD: src/etc/rc.d/cron,v 1.3 2003/05/05 15:38:41 mtm Exp $ +# $DragonFly: src/etc/rc.d/cron,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: cron +# REQUIRE: LOGIN +# BEFORE: securelevel +# KEYWORD: DragonFly FreeBSD NetBSD shutdown + +. /etc/rc.subr + +name="cron" +rcvar="`set_rcvar`" +command="/usr/sbin/${name}" +pidfile="/var/run/${name}.pid" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/dhclient b/etc/rc.d/dhclient new file mode 100644 index 0000000000..030773c474 --- /dev/null +++ b/etc/rc.d/dhclient @@ -0,0 +1,124 @@ +#!/bin/sh +# +# $NetBSD: dhclient,v 1.8 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/dhclient,v 1.6 2003/06/29 05:34:41 mtm Exp $ +# $DragonFly: src/etc/rc.d/dhclient,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: dhclient +# REQUIRE: network netif mountcritlocal +# BEFORE: NETWORKING +# KEYWORD: DragonFly FreeBSD NetBSD +# +# Note that there no syslog logging of dhclient messages at boot because +# dhclient needs to start before services that syslog depends upon do. +# + +. /etc/rc.subr +. /etc/network.subr + +name="dhclient" +pidfile="/var/run/${name}.pid" +case "${OSTYPE}" in +DragonFly) + rcvar= + start_precmd="dhclient_prestart" + start_postcmd="dhclient_poststart" + stop_cmd="dhclient_stop" + stop_precmd="dhclient_prestop" + stop_postcmd="dhclient_poststop" + ;; + +FreeBSD) + rcvar= + start_precmd="dhclient_prestart" + start_postcmd="dhclient_poststart" + stop_cmd="dhclient_stop" + stop_precmd="dhclient_prestop" + stop_postcmd="dhclient_poststop" + ;; +NetBSD) + rcvar=$name + command="/sbin/${name}" + ;; +esac + +dhclient_common() +{ + dhcp_list="`list_net_interfaces dhcp`" + if [ -z "$dhcp_list" ]; then + return 1 + fi + + # Determine the scope of the command + # + _cooked_list="$dhcp_list" + if [ -n "$_cmdifn" ]; then + eval _cooked_list=\"`expr "$dhcp_list" : ".*\($_cmdifn\).*"`\" + if [ -z "$_cooked_list" ]; then + err "No such network interface: $_cmdifn" + return 1 + fi + fi +} + +dhclient_prestart() +{ + dhclient_common || return 1 + + for ifn in ${_cooked_list}; do + ifscript_up ${ifn} + done + + rc_flags="${rc_flags} ${_cooked_list}" + return 0 +} + +dhclient_poststart() +{ + for ifn in ${_cooked_list}; do + ifalias_up ${ifn} + ipx_up ${ifn} + ifconfig ${ifn} + done +} + +dhclient_stop() +{ + echo -n "Releasing DHCP leases:" + for ifn in $_cooked_list ; do + ${command} -r $ifn + if [ $? -eq 0 ]; then + echo -n " $ifn" + else + _fail="$_fail $ifn" + fi + done + echo '.' + debug "The following leases failed to release: $_fail" +} + +dhclient_prestop() +{ + dhclient_common || return 1 + + for ifn in ${_cooked_list}; do + ipx_down ${ifn} + ifalias_down ${ifn} + done +} + +dhclient_poststop() +{ + for ifn in ${_cooked_list}; do + ifscript_down ${ifn} + done +} + +if [ -n "$2" ]; then + _cmdifn="$2" +fi + +load_rc_config $name + +run_rc_command "$1" diff --git a/etc/rc.d/dhcpd b/etc/rc.d/dhcpd new file mode 100644 index 0000000000..774be69903 --- /dev/null +++ b/etc/rc.d/dhcpd @@ -0,0 +1,21 @@ +#!/bin/sh +# +# $NetBSD: dhcpd,v 1.5 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/dhcpd,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/dhcpd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: dhcpd +# REQUIRE: DAEMON +# BEFORE: LOGIN + +. /etc/rc.subr + +name="dhcpd" +rcvar=$name +command="/usr/sbin/${name}" +pidfile="/var/run/${name}.pid" +required_files="/etc/${name}.conf /var/db/${name}.leases" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/dhcrelay b/etc/rc.d/dhcrelay new file mode 100644 index 0000000000..56b045c6b7 --- /dev/null +++ b/etc/rc.d/dhcrelay @@ -0,0 +1,20 @@ +#!/bin/sh +# +# $NetBSD: dhcrelay,v 1.5 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/dhcrelay,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/dhcrelay,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: dhcrelay +# REQUIRE: DAEMON +# BEFORE: LOGIN + +. /etc/rc.subr + +name="dhcrelay" +rcvar=$name +command="/usr/sbin/${name}" +pidfile="/var/run/${name}.pid" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.diskless2 b/etc/rc.d/diskless similarity index 68% rename from etc/rc.diskless2 rename to etc/rc.d/diskless index e6d30a5453..df087e0a20 100644 --- a/etc/rc.diskless2 +++ b/etc/rc.d/diskless @@ -1,3 +1,5 @@ +#!/bin/sh +# # Copyright (c) 1999 Matt Dillon # All rights reserved. # @@ -22,13 +24,19 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD: src/etc/rc.diskless2,v 1.5.2.14 2002/12/23 17:39:06 dillon Exp $ -# $DragonFly: src/etc/Attic/rc.diskless2,v 1.2 2003/06/17 04:24:45 dillon Exp $ +# $FreeBSD: src/etc/rc.d/diskless,v 1.25 2003/02/15 16:34:14 jhay Exp $ +# $DragonFly: src/etc/rc.d/diskless,v 1.1 2003/07/24 06:35:37 dillon Exp $ # -# -# rc.diskless2 -# +# PROVIDE: diskless +# REQUIRE: initdiskless rcconf mountcritlocal +# BEFORE: addswap random +# KEYWORD: DragonFly FreeBSD + +dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` +[ ${dlv:=0} -eq 0 ] && exit 0 + +name="diskless2" # Provide a function for normalizing the mounting of memory # filesystems. This should allow the rest of the code here to remain @@ -40,12 +48,15 @@ mount_md() { if [ -n "$3" ]; then bpi="-i $3" fi - /sbin/mount_mfs -s $1 -T qp120at -b 8192 -f 1024 $bpi dummy $2 + /sbin/mdmfs $bpi -s $1 -M md $2 } # If there is a global system configuration file, suck it in. # -if [ -r /etc/defaults/rc.conf ]; then +if [ -r /etc/rc.subr ]; then + . /etc/rc.subr + load_rc_config $name +elif [ -r /etc/defaults/rc.conf ]; then . /etc/defaults/rc.conf source_rc_confs elif [ -r /etc/rc.conf ]; then @@ -59,25 +70,24 @@ fi # exists before doing the mount -a. # if (/bin/mkdir /var/.diskless 2> /dev/null); then - rmdir /var/.diskless + rmdir /var/.diskless else - echo "+++ mfs_mount of /var" - mount_md ${varsize:=65536} /var + echo "+++ mount_md of /var" + mount_md ${varsize:=32m} /var fi if [ ! -d /var/db ]; then mkdir /var/db fi -# Now we need the rest of our mounts, particularly /usr. +# Now we need the rest of our mounts, particularly /usr # -mount -a +mount -a # chown and chgrp are in /usr # Populate /var # echo "+++ populate /var using /etc/mtree/BSD.var.dist" /usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var > /dev/null - case ${sendmail_enable} in [Nn][Oo][Nn][Ee]) ;; @@ -100,7 +110,6 @@ echo "+++ create lastlog" # /usr/bin/newaliases -# # XXX make sure to create one dir for each printer as requested by lpd # # If we do not have a writable /tmp, create a memory @@ -120,19 +129,38 @@ else fi fi -# If /dev has already been created in rc.diskless1 it will be writable -# and we do nothing. If /dev is not writable then we have to dup it as -# a memory filesystem. -# -# note: /conf/dev.cpio.gz is no longer valid. Use /conf/base/dev.cpio.gz -# instead and it will be handled in rc.diskless1 - -if (/bin/mkdir /dev/.diskless 2> /dev/null); then +if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then + # we have DEVFS, no worries... + true +elif (/bin/mkdir /dev/.diskless 2> /dev/null); then + # if /dev is writable assume it has already been populated + # via rc.diskless1 + # rmdir /dev/.diskless else - (cd /; find -x dev | cpio --create -H newc | gzip) > /tmp/dev.cpio.gz + (cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp mount_md 4096 /dev 512 - (cd /; gzip -dc /tmp/dev.cpio.gz | cpio --extract -H newc -d ) - rm -f /tmp/dev.cpio.gz + (cd /; cpio -i -H newc -d < /tmp/dev.tmp) + rm -f /tmp/dev.tmp +fi + +# generate our hostname +# +if [ -z "`hostname -s`" ]; then + hostname=`/bin/kenv dhcp.host-name` + hostname $hostname + echo "Hostname is $hostname" +fi + +# if the info is available via dhcp/kenv +# build the resolv.conf +# +if [ ! -e /etc/resolv.conf ]; then + echo domain `/bin/kenv dhcp.domain-name` > /etc/resolv.conf + + set `/bin/kenv dhcp.domain-name-servers` + for ns in `IFS=','; echo $*`; do + echo nameserver $ns >> /etc/resolv.conf; + done fi diff --git a/etc/rc.d/dmesg b/etc/rc.d/dmesg new file mode 100644 index 0000000000..78f485301b --- /dev/null +++ b/etc/rc.d/dmesg @@ -0,0 +1,28 @@ +#!/bin/sh +# +# $NetBSD: dmesg,v 1.8 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/dmesg,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/dmesg,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: dmesg +# REQUIRE: mountcritremote +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD Daemon + +. /etc/rc.subr + +name="dmesg" +rcvar=`set_rcvar` +dmesg_file="/var/run/dmesg.boot" +start_cmd="do_dmesg" +stop_cmd=":" + +do_dmesg() +{ + rm -f ${dmesg_file} + ( umask 022 ; /sbin/dmesg $rc_flags > ${dmesg_file} ) +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/downinterfaces b/etc/rc.d/downinterfaces new file mode 100644 index 0000000000..e0fae511b1 --- /dev/null +++ b/etc/rc.d/downinterfaces @@ -0,0 +1,28 @@ +#!/bin/sh +# +# $NetBSD: downinterfaces,v 1.2 2001/09/04 20:40:40 martin Exp $ +# $DragonFly: src/etc/rc.d/Attic/downinterfaces,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: downinterfaces +# KEYWORD: shutdown + +if [ "x$1" != "xstop" ]; then exit 0; fi + +. /etc/rc.conf + +tmp=`ifconfig -lu` +iflist="" +for int in $tmp; do + case $int in + pppoe*) iflist="$iflist $int" + ;; + esac +done +iflist="$iflist $force_down_interfaces" +if [ "$iflist" = "" ] || [ "$iflist" = " " ]; then exit 0; fi + +echo "Shutting down interfaces:$iflist" +for int in $iflist; do + ifconfig $int down +done diff --git a/etc/rc.d/dumpon b/etc/rc.d/dumpon new file mode 100644 index 0000000000..7c65a36a14 --- /dev/null +++ b/etc/rc.d/dumpon @@ -0,0 +1,33 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/dumpon,v 1.1 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/dumpon,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: dumpon +# REQUIRE: initrandom +# BEFORE: disks savecore +# KEYWORD: DragonFly 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/early.sh b/etc/rc.d/early.sh new file mode 100644 index 0000000000..e342442d5d --- /dev/null +++ b/etc/rc.d/early.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/early.sh,v 1.1 2003/04/24 08:27:29 mtm Exp $ +# $DragonFly: src/etc/rc.d/Attic/early.sh,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: early +# REQUIRE: disks localswap +# BEFORE: fsck +# KEYWORD: DragonFly FreeBSD + +# +# Support for legacy /etc/rc.early script +# +if [ -r /etc/rc.early ]; then + . /etc/rc.early +fi diff --git a/etc/rc.d/fsck b/etc/rc.d/fsck new file mode 100644 index 0000000000..4346dd571b --- /dev/null +++ b/etc/rc.d/fsck @@ -0,0 +1,121 @@ +#!/bin/sh +# +# $NetBSD: fsck,v 1.2 2001/06/18 06:42:35 lukem Exp $ +# $FreeBSD: src/etc/rc.d/fsck,v 1.4 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/fsck,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: fsck +# REQUIRE: localswap +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="fsck" +start_cmd="fsck_start" +stop_cmd=":" + +stop_boot() +{ + # Terminate the process (which may include the parent /etc/rc) + # if booting directly to multiuser mode. + # + if [ "$autoboot" = yes ]; then + kill -TERM $$ + fi + exit 1 +} + +fsck_start() +{ + if [ "$autoboot" = no ]; then + echo "Fast boot: skipping disk checks." + elif [ "$autoboot" = yes ]; then + # During fsck ignore SIGQUIT + trap : 3 + + echo "Starting file system checks:" + case ${OSTYPE} in + DragonFly) + fsck -p + ;; + FreeBSD) + fsck -p + ;; + NetBSD) + fsck -p + ;; + esac + + case $? in + 0) + ;; + 2) + stop_boot + ;; + 4) + echo "Rebooting..." + reboot + echo "Reboot failed; help!" + stop_boot + ;; + 8) + case ${OSTYPE} in + DragonFly) + 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 + ;; + + 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 + ;; + 130) + stop_boot + ;; + *) + echo "Unknown error; help!" + stop_boot + ;; + esac + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/gated b/etc/rc.d/gated new file mode 100644 index 0000000000..e0b974c110 --- /dev/null +++ b/etc/rc.d/gated @@ -0,0 +1,19 @@ +#!/bin/sh +# +# $NetBSD: gated,v 1.3 2000/05/13 08:45:06 lukem Exp $ +# $DragonFly: src/etc/rc.d/Attic/gated,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: gated +# REQUIRE: DAEMON + +. /etc/rc.subr + +name="gated" +rcvar=$name +command="/usr/sbin/${name}" +pidfile="/var/run/${name}.pid" +required_files="/etc/${name}.conf" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.sysctl b/etc/rc.d/hostname similarity index 57% copy from etc/rc.sysctl copy to etc/rc.d/hostname index 546658c358..ae7b10fd30 100644 --- a/etc/rc.sysctl +++ b/etc/rc.d/hostname @@ -1,7 +1,6 @@ #!/bin/sh # -# Copyright (c) 1999 Warner Losh -# All rights reserved. +# Copyright (c) 2003 The FreeBSD Project. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -12,10 +11,10 @@ # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) @@ -24,39 +23,30 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD: src/etc/rc.sysctl,v 1.4.4.6 2002/04/15 00:44:13 dougb Exp $ -# $DragonFly: src/etc/Attic/rc.sysctl,v 1.2 2003/06/17 04:24:45 dillon Exp $ +# $FreeBSD: src/etc/rc.d/hostname,v 1.2 2003/04/24 08:20:47 mtm Exp $ +# $DragonFly: src/etc/rc.d/hostname,v 1.1 2003/07/24 06:35:37 dillon Exp $ # -# -# Read in /etc/sysctl.conf and set things accordingly -# +# PROVIDE: hostname +# REQUIRE: mountcritlocal tty +# BEFORE: netif +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="hostname" +start_cmd="hostname_start" +stop_cmd=":" -if [ -f /etc/sysctl.conf ]; then - while read var comments - do - case ${var} in - \#*|'') - ;; - *) - mib=${var%=*} - val=${var#*=} +hostname_start() +{ + # Set the host name if it is not already set + # + if [ -z "`hostname -s`" ]; then + hostname ${hostname} + echo "Setting hostname: `hostname`." + fi +} - if current_value=`sysctl -n ${mib} 2>/dev/null`; then - case ${current_value} in - ${val}) ;; - *) - sysctl ${var} - ;; - esac - else - case ${1} in - last) - echo "Warning: sysctl ${mib} does not exist" - ;; - esac - fi - ;; - esac - done < /etc/sysctl.conf -fi +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ifwatchd b/etc/rc.d/ifwatchd new file mode 100644 index 0000000000..a52e6e988a --- /dev/null +++ b/etc/rc.d/ifwatchd @@ -0,0 +1,17 @@ +#!/bin/sh +# +# $DragonFly: src/etc/rc.d/Attic/ifwatchd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ifwatchd +# REQUIRE: mountcritremote network + +. /etc/rc.subr + +name="ifwatchd" +rcvar=$name +command="/usr/sbin/${name}" + +load_rc_config $name +run_rc_command "$1" + diff --git a/etc/rc.d/inetd b/etc/rc.d/inetd new file mode 100644 index 0000000000..6ca2ed9866 --- /dev/null +++ b/etc/rc.d/inetd @@ -0,0 +1,22 @@ +#!/bin/sh +# +# $NetBSD: inetd,v 1.6 2000/09/19 13:04:38 lukem Exp $ +# $FreeBSD: src/etc/rc.d/inetd,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/inetd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: inetd +# REQUIRE: DAEMON LOGIN +# KEYWORD: DragonFly FreeBSD NetBSD shutdown + +. /etc/rc.subr + +name="inetd" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" +pidfile="/var/run/${name}.pid" +required_files="/etc/${name}.conf" +extra_commands="reload" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.diskless1 b/etc/rc.d/initdiskless similarity index 73% rename from etc/rc.diskless1 rename to etc/rc.d/initdiskless index 61e507117f..99f22e8750 100644 --- a/etc/rc.diskless1 +++ b/etc/rc.d/initdiskless @@ -1,11 +1,36 @@ -# Copyright (c) 1999-2002 Matt Dillion. Terms and conditions based on -# the FreeBSD copyright as found at the base of the source distribution. -# -# $FreeBSD: src/etc/rc.diskless1,v 1.5.2.11 2003/04/14 18:12:05 jhay Exp $ -# $DragonFly: src/etc/Attic/rc.diskless1,v 1.2 2003/06/17 04:24:45 dillon Exp $ -# -# /etc/rc.diskless1 - general BOOTP startup -# +#!/bin/sh +# +# Copyright (c) 1999 Matt Dillion +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD: src/etc/rc.d/initdiskless,v 1.24 2003/06/30 21:47:06 brooks Exp $ +# $DragonFly: src/etc/rc.d/initdiskless,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# +# PROVIDE: initdiskless +# KEYWORD: DragonFly FreeBSD + + # On entry to this script the entire system consists of a read-only root # mounted via NFS. We use the contents of /conf to create and populate # memory filesystems. The kernel has run BOOTP and configured an interface @@ -55,6 +80,9 @@ # NOTE! rc.diskless2 will create /var, /tmp, and /dev. Those filesystems # should not be specified in /conf. At least not yet. +dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` +[ ${dlv:=0} -eq 0 ] && exit 0 + # chkerr: # # Routine to check for error @@ -77,7 +105,7 @@ chkerr() { # Create a generic memory disk # mount_md() { - /sbin/mount_mfs -s $1 -T qp120at -b 8192 -f 1024 dummy $2 + /sbin/mdmfs -i 4096 -s $1 -M md $2 } # Create the memory filesystem if it has not already been created @@ -85,7 +113,7 @@ mount_md() { create_md() { if [ "x`eval echo \\$md_created_$1`" = "x" ]; then if [ "x`eval echo \\$md_size_$1`" = "x" ]; then - md_size=8192 + md_size=4096 else md_size=`eval echo \\$md_size_$1` fi @@ -122,6 +150,17 @@ for i in ${iflist} ; do done echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa} Broadcast ${bootp_ipbca}" +# Figure out our NFS root path +# +set `mount -t nfs` +while [ $# -ge 1 ] ; do + if [ "$2" = "on" -a "$3" = "/" ]; then + nfsroot="$1" + break + fi + shift +done + # Resolve templates in /conf/base, /conf/default, /conf/${bootp_ipbca}, # and /conf/${bootp_ipa}. For each subdirectory found within these # directories: @@ -137,6 +176,10 @@ echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa} Broadcast ${bootp_ipbca}" # might contain 'myserver:/etc'. NFS remounts allow you to avoid # having to dup your system directories in /conf. Your server must # be sure to export those filesystems -alldirs, however. +# If the diskless_remount file contains a string beginning with a +# '/' it is assumed that the local nfsroot should be prepended to +# it before attemping to the remount. This allows the root to be +# relocated without needing to change the remount files. # for i in base default ${bootp_ipbca} ${bootp_ipa} ; do for j in /conf/$i/* ; do @@ -151,6 +194,9 @@ for i in base default ${bootp_ipbca} ${bootp_ipa} ; do # if [ -d $j -a -f $j/diskless_remount ]; then nfspt=`/bin/cat $j/diskless_remount` + if [ `expr "$nfspt" : '\(.\)'` = "/" ]; then + nfspt="${nfsroot}${nfspt}" + fi mount_nfs $nfspt $j chkerr $? "mount_nfs $nfspt $j" fi @@ -194,12 +240,3 @@ for i in base default ${bootp_ipbca} ${bootp_ipa} ; do done done -# Tell /etc/rc to run the specified script after -# it does its mounts but before it does anything -# else. -# -# This script is responsible for setting up the -# diskless mount environment. - -diskless_mount="/etc/rc.diskless2" - diff --git a/etc/rc.d/initrandom b/etc/rc.d/initrandom new file mode 100644 index 0000000000..4e1f85442a --- /dev/null +++ b/etc/rc.d/initrandom @@ -0,0 +1,74 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/initrandom,v 1.1 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/initrandom,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: initrandom +# REQUIRE: initdiskless +# BEFORE: disks +# KEYWORD: DragonFly 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 0000000000..b5807003ff --- /dev/null +++ b/etc/rc.d/ip6fw @@ -0,0 +1,59 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/ip6fw,v 1.3 2003/06/29 05:15:57 mtm Exp $ +# $DragonFly: src/etc/rc.d/ip6fw,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ip6fw +# REQUIRE: routing +# BEFORE: network_ipv6 +# KEYWORD: DragonFly 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 new file mode 100644 index 0000000000..d3b8d86134 --- /dev/null +++ b/etc/rc.d/ipfilter @@ -0,0 +1,227 @@ +#!/bin/sh +# +# $NetBSD: ipfilter,v 1.10 2001/02/28 17:03:50 lukem Exp $ +# $FreeBSD: src/etc/rc.d/ipfilter,v 1.10 2003/04/30 02:54:17 mtm Exp $ +# $DragonFly: src/etc/rc.d/ipfilter,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ipfilter +# REQUIRE: root beforenetlkm mountcritlocal tty ipmon +# BEFORE: netif +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="ipfilter" +rcvar=`set_rcvar` +load_rc_config $name + +case ${OSTYPE} in +DragonFly) + stop_precmd="test -f ${ipfilter_rules} -o -f ${ipv6_ipfilter_rules}" + ;; + +FreeBSD) + stop_precmd="test -f ${ipfilter_rules} -o -f ${ipv6_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_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 resync status" + +ipfilter_prestart() +{ +case ${OSTYPE} in +DragonFly) + # load ipfilter kernel module if needed + if ! sysctl net.inet.ipf.fr_pass > /dev/null 2>&1; then + if kldload ipl; then + info 'IP-filter module loaded.' + else + err 1 'IP-filter module failed to load.' + fi + fi + # check for ipfilter rules + if [ ! -r "${ipfilter_rules}" ] && [ ! -r "${ipv6_ipfilter_rules}" ] + then + warn 'IP-filter: NO IPF RULES' + return 1 + fi + ;; + +FreeBSD) + # load ipfilter kernel module if needed + if ! sysctl net.inet.ipf.fr_pass > /dev/null 2>&1; then + if kldload ipl; then + info 'IP-filter module loaded.' + else + err 1 'IP-filter module failed to load.' + fi + fi + + # check for ipfilter rules + if [ ! -r "${ipfilter_rules}" ] && [ ! -r "${ipv6_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." + # + # If booting directly to multiuser, send SIGTERM to + # the parent (/etc/rc) to abort the boot + # + if [ "$autoboot" = yes ]; then + echo "ERROR: ABORTING BOOT (sending SIGTERM to parent)!" + kill -TERM $$ + exit 1 + fi + return 1 + fi + ;; +esac + return 0 +} + +ipfilter_start() +{ + echo "Enabling ipfilter." + case ${OSTYPE} in + DragonFly) + ${ipfilter_program:-/sbin/ipf} -EFa + if [ -r "${ipfilter_rules}" ]; then + ${ipfilter_program:-/sbin/ipf} \ + -f "${ipfilter_rules}" ${ipfilter_flags} + fi + ${ipfilter_program:-/sbin/ipf} -6 -EFa + if [ -r "${ipv6_ipfilter_rules}" ]; then + ${ipfilter_program:-/sbin/ipf} -6 \ + -f "${ipv6_ipfilter_rules}" ${ipfilter_flags} + fi + ;; + + FreeBSD) + ${ipfilter_program:-/sbin/ipf} -EFa + if [ -r "${ipfilter_rules}" ]; then + ${ipfilter_program:-/sbin/ipf} \ + -f "${ipfilter_rules}" ${ipfilter_flags} + fi + ${ipfilter_program:-/sbin/ipf} -6 -EFa + if [ -r "${ipv6_ipfilter_rules}" ]; then + ${ipfilter_program:-/sbin/ipf} -6 \ + -f "${ipv6_ipfilter_rules}" ${ipfilter_flags} + fi + ;; + 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 ${OSTYPE} in + DragonFly) + echo "Saving firewall state tables" + ${ipfs_program:-/sbin/ipfs} -W ${ipfs_flags} + ;; + 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 +} + +ipfilter_reload() +{ + echo "Reloading ipfilter rules." + + case ${OSTYPE} in + DragonFly) + ${ipfilter_program:-/sbin/ipf} -I -Fa + if [ -r "${ipfilter_rules}" ]; then + ${ipfilter_program:-/sbin/ipf} -I \ + -f "${ipfilter_rules}" ${ipfilter_flags} + fi + ${ipfilter_program:-/sbin/ipf} -I -6 -Fa + if [ -r "${ipv6_ipfilter_rules}" ]; then + ${ipfilter_program:-/sbin/ipf} -I -6 \ + -f "${ipv6_ipfilter_rules}" ${ipfilter_flags} + fi + ${ipfilter_program:-/sbin/ipf} -s + ;; + FreeBSD) + ${ipfilter_program:-/sbin/ipf} -I -Fa + if [ -r "${ipfilter_rules}" ]; then + ${ipfilter_program:-/sbin/ipf} -I \ + -f "${ipfilter_rules}" ${ipfilter_flags} + fi + ${ipfilter_program:-/sbin/ipf} -I -6 -Fa + if [ -r "${ipv6_ipfilter_rules}" ]; then + ${ipfilter_program:-/sbin/ipf} -I -6 \ + -f "${ipv6_ipfilter_rules}" ${ipfilter_flags} + fi + ${ipfilter_program:-/sbin/ipf} -s + ;; + 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 ${OSTYPE} in + DragonFly) + # Don't resync if ipfilter is not loaded + [ sysctl net.inet.ipf.fr_pass > /dev/null 2>&1 ] && return + ;; + 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() +{ + ${ipfilter_program:-/sbin/ipf} -V +} + +run_rc_command "$1" diff --git a/etc/rc.d/ipfs b/etc/rc.d/ipfs new file mode 100644 index 0000000000..46286b3740 --- /dev/null +++ b/etc/rc.d/ipfs @@ -0,0 +1,64 @@ +#!/bin/sh +# +# $NetBSD: ipfs,v 1.3 2002/02/11 13:55:42 lukem Exp $ +# $FreeBSD: src/etc/rc.d/ipfs,v 1.2 2003/04/24 08:20:47 mtm Exp $ +# $DragonFly: src/etc/rc.d/ipfs,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ipfs +# REQUIRE: ipnat +# BEFORE: netif +# KEYWORD: DragonFly FreeBSD NetBSD shutdown + +. /etc/rc.subr + +name="ipfs" +rcvar=`set_rcvar` +start_cmd="ipfs_start" +stop_cmd="ipfs_stop" +case ${OSTYPE} in +DragonFly) + start_precmd="ipfs_prestart" + ;; +FreeBSD) + start_precmd="ipfs_prestart" + ;; +NetBSD) + ipfs_program="/usr/sbin/ipfs" + ;; +esac + +ipfs_prestart() +{ + # Do not continue if either ipnat or ipfilter is not enabled or + # if the ipfilter module is not loaded. + # + if ! checkyesno ipfilter_enable -o ! checkyesno ipnat_enable ; then + err 1 "${name} requires either ipfilter or ipnat enabled" + fi + if ! sysctl net.inet.ipf.fr_pass >/dev/null 2>&1; then + err 1 "ipfilter module is not loaded" + fi + return 0 +} + +ipfs_start() +{ + if [ -r /var/db/ipf/ipstate.ipf -a -r /var/db/ipf/ipnat.ipf ]; then + ${ipfs_program} -R ${rc_flags} + rm -f /var/db/ipf/ipstate.ipf /var/db/ipf/ipnat.ipf + fi +} + +ipfs_stop() +{ + if [ ! -d /var/db/ipf ]; then + mkdir /var/db/ipf + chmod 700 /var/db/ipf + chown root:wheel /var/db/ipf + fi + ${ipfs_program} -W ${rc_flags} +} + +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 0000000000..2050084212 --- /dev/null +++ b/etc/rc.d/ipfw @@ -0,0 +1,82 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/ipfw,v 1.4 2003/03/30 15:52:18 mtm Exp $ +# $DragonFly: src/etc/rc.d/ipfw,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ipfw +# REQUIRE: ppp-user +# BEFORE: NETWORKING +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="ipfw" +rcvar="firewall_enable" +start_cmd="ipfw_start" +start_precmd="ipfw_precmd" +stop_cmd="ipfw_stop" + +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 + fi + echo -n ' natd' + ${natd_program:-/sbin/natd} ${natd_flags} ${natd_ifarg} + 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 + # + if checkyesno firewall_logging; then + echo 'Firewall logging enabled' + sysctl net.inet.ip.fw.verbose=1 >/dev/null + fi + + # Enable the firewall + # + ${SYSCTL_W} net.inet.ip.fw.enable=1 +} + +ipfw_stop() +{ + # Disable the firewall + # + ${SYSCTL_W} net.inet.ip.fw.enable=0 +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ipmon b/etc/rc.d/ipmon new file mode 100644 index 0000000000..628705f528 --- /dev/null +++ b/etc/rc.d/ipmon @@ -0,0 +1,47 @@ +#!/bin/sh +# +# $NetBSD: ipmon,v 2002/04/18 05:02:01 lukem Exp $ +# $FreeBSD: src/etc/rc.d/ipmon,v 1.6 2003/07/14 13:02:36 mtm Exp $ +# $DragonFly: src/etc/rc.d/ipmon,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ipmon +# REQUIRE: mountcritlocal hostname sysctl cleanvar +# BEFORE: SERVERS +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="ipmon" +rcvar=`set_rcvar` + +case ${OSTYPE} in +DragonFly) + command="/sbin/ipmon" + start_precmd="ipmon_precmd" + ;; +FreeBSD) + command="/sbin/ipmon" + start_precmd="ipmon_precmd" + ;; +NetBSD) + command="/usr/sbin/${name}" + command_args="-D" +esac + +ipmon_precmd() +{ + # Continue only if ipfilter or ipnat is enabled and the + # ipfilter module is loaded. + # + if ! checkyesno ipfilter_enable -o ! checkyesno ipnat_enable ; then + err 1 "${name} requires either ipfilter or ipnat enabled" + fi + if ! sysctl net.inet.ipf.fr_pass >/dev/null 2>&1; then + err 1 "ipfilter module is not loaded" + fi + return 0 +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ipnat b/etc/rc.d/ipnat new file mode 100644 index 0000000000..7cd2f12e25 --- /dev/null +++ b/etc/rc.d/ipnat @@ -0,0 +1,66 @@ +#!/bin/sh +# +# $NetBSD: ipnat,v 1.6 2000/09/19 13:04:38 lukem Exp $ +# $FreeBSD: src/etc/rc.d/ipnat,v 1.8 2003/04/30 02:54:17 mtm Exp $ +# $DragonFly: src/etc/rc.d/ipnat,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ipnat +# REQUIRE: ipfilter +# BEFORE: DAEMON netif +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="ipnat" +rcvar=`set_rcvar` +load_rc_config $name + +case ${OSTYPE} in +NetBSD) + ipnat_flags= + ipnat_rules="/etc/ipnat.conf" + ipnat_program="/usr/sbin/ipnat" + ;; +esac + +start_precmd="ipnat_precmd" +start_cmd="ipnat_start" +stop_cmd="${ipnat_program} -F -C" +reload_cmd="${ipnat_program} -F -C -f ${ipnat_rules}" +extra_commands="reload" + +ipnat_precmd() +{ + case ${OSTYPE} in + NetBSD) + if ! checkyesno ipfilter || [ ! -f /etc/ipf.conf ]; then + echo "Enabling ipfilter for NAT." + /sbin/ipf -E -Fa + fi + return 0 + ;; + esac + + # Make sure ipfilter is loaded before continuing + if ! ${SYSCTL} net.inet.ipf.fr_pass >/dev/null 2>&1; then + if kldload ipl; then + info 'IP-filter module loaded.' + else + err 1 'IP-filter module failed to load.' + fi + fi + return 0 +} + +ipnat_start() +{ + if [ ! -f ${ipnat_rules} ]; then + warn 'NO IPNAT RULES' + return 0 + fi + echo -n "Installing NAT rules." + ${ipnat_program} -CF -f ${ipnat_rules} ${ipnat_flags} +} + +run_rc_command "$1" diff --git a/etc/rc.d/ipsec b/etc/rc.d/ipsec new file mode 100644 index 0000000000..bf2983e04f --- /dev/null +++ b/etc/rc.d/ipsec @@ -0,0 +1,87 @@ +#!/bin/sh +# +# $NetBSD: ipsec,v 1.7 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/ipsec,v 1.5 2003/02/16 20:46:08 mtm Exp $ +# $DragonFly: src/etc/rc.d/ipsec,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ipsec +# REQUIRE: root beforenetlkm mountcritlocal tty +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD NetBSD + +# it does not really require beforenetlkm. + +. /etc/rc.subr + +name="ipsec" +rcvar=`set_rcvar` +start_precmd="ipsec_prestart" +start_cmd="ipsec_start" +stop_precmd="test -f /etc/ipsec.conf" +stop_cmd="ipsec_stop" +reload_cmd="ipsec_reload" +extra_commands="reload" + +case ${OSTYPE} in +DragonFly) + ipsec_program="/usr/sbin/setkey" + # ipsec_file is set by rc.conf + ;; + +FreeBSD) + ipsec_program="/usr/sbin/setkey" + # ipsec_file is set by rc.conf + ;; +NetBSD) + ipsec_program="/sbin/setkey" + ipsec_file="/etc/ipsec.conf" + ;; +esac + +ipsec_prestart() +{ + 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 + # + if [ "$autoboot" = yes ]; then + echo "ERROR: ABORTING BOOT (sending SIGTERM to parent)!" + kill -TERM $$ + exit 1 + fi + return 1 + fi + return 0 +} + +ipsec_start() +{ + echo "Installing ipsec manual keys/policies." + ${ipsec_program} -f $ipsec_file +} + +ipsec_stop() +{ + echo "Clearing ipsec manual keys/policies." + + # still not 100% sure if we would like to do this. + # it is very questionable to do this during shutdown session, since + # it can hang any of remaining IPv4/v6 session. + # + ${ipsec_program} -F + ${ipsec_program} -FP +} + +ipsec_reload() +{ + echo "Reloading ipsec manual keys/policies." + ${ipsec_program} -F + ${ipsec_program} -FP + ${ipsec_program} -f "$ipsec_file" +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ipxrouted b/etc/rc.d/ipxrouted new file mode 100644 index 0000000000..c4330c472b --- /dev/null +++ b/etc/rc.d/ipxrouted @@ -0,0 +1,20 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/ipxrouted,v 1.1 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/ipxrouted,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ipxrouted +# REQUIRE: SERVERS +# BEFORE: DAEMON +# KEYWORD: DragonFly 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/isdnd b/etc/rc.d/isdnd new file mode 100644 index 0000000000..d49c28f29f --- /dev/null +++ b/etc/rc.d/isdnd @@ -0,0 +1,79 @@ +#!/bin/sh +# +# $NetBSD: isdnd,v 1.9 2002/04/10 23:37:13 martin Exp $ +# $FreeBSD: src/etc/rc.d/isdnd,v 1.15 2003/07/15 12:39:37 mtm Exp $ +# $DragonFly: src/etc/rc.d/isdnd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# +# Mostly based on original script (/etc/rc.isdn) written by Hellmuth Michaelis +# + +# PROVIDE: isdnd +# REQUIRE: netif mountcritlocal +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="isdnd" +rcvar=`set_rcvar isdn` +pidfile="/var/run/${name}.pid" + +case ${OSTYPE} in +DragonFly) + start_cmd="isdnd_start" + ;; +FreeBSD) + start_cmd="isdnd_start" + ;; +NetBSD) + command="/usr/sbin/${name}" + required_files="/etc/isdn/${name}.rc" + ;; +esac + +isdnd_start() +{ + echo -n 'ISDN subsystem setup:' + + # Check for pcvt driver (VT100/VT220 emulator) + # + if [ -x /usr/sbin/ispcvt ]; then + if /usr/sbin/ispcvt; then + # No vidcontrol if we are using pcvt + # + isdn_screenflags=NO + fi + fi + + # Start isdnd + # + echo -n ' isdnd' + case ${isdn_fsdev} in + [Nn][Oo] | '') + /usr/sbin/isdnd ${isdn_flags} + ;; + *) + # Change vidmode of ${isdn_fsdev} + # + case ${isdn_screenflags} in + [Nn][Oo]) + ;; + *) + /usr/sbin/vidcontrol < ${isdn_fsdev} > ${isdn_fsdev} 2>&1 ${isdn_screenflags} + ;; + esac + + /usr/sbin/isdnd ${isdn_flags} -f -r ${isdn_fsdev} -t ${isdn_ttype} + ;; + esac + + # Start isdntrace + # + if checkyesno isdn_trace; then + echo -n ' isdntrace' + nohup /usr/sbin/isdntrace ${isdn_traceflags} >/dev/null 2>&1 & + fi + echo '.' +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/jail b/etc/rc.d/jail new file mode 100644 index 0000000000..71b751679b --- /dev/null +++ b/etc/rc.d/jail @@ -0,0 +1,70 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/jail,v 1.4 2003/05/05 15:38:41 mtm Exp $ +# $DragonFly: src/etc/rc.d/jail,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: jail +# REQUIRE: LOGIN +# BEFORE: securelevel +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="jail" +rcvar=`set_rcvar` +start_cmd="jail_start" +stop_cmd="jail_stop" + +jail_start() +{ + echo -n 'Configuring jails:' + echo -n ' set_hostname_allowed=' + if checkyesno jail_set_hostname_allow ; then + echo -n 'YES' + ${SYSCTL_W} 1>/dev/null security.jail.set_hostname_allowed=1 + else + echo -n 'NO' + ${SYSCTL_W} 1>/dev/null security.jail.set_hostname_allowed=0 + fi + + echo -n ' unixiproute_only=' + if checkyesno jail_socket_unixiproute_only ; then + echo -n 'YES' + ${SYSCTL_W} 1>/dev/null security.jail.socket_unixiproute_only=1 + else + echo -n 'NO' + ${SYSCTL_W} 1>/dev/null security.jail.socket_unixiproute_only=0 + fi + + echo -n ' sysvipc_allow=' + if checkyesno jail_sysvipc_allow ; then + echo -n 'YES' + ${SYSCTL_W} 1>/dev/null security.jail.sysvipc_allowed=1 + else + echo -n 'NO' + ${SYSCTL_W} 1>/dev/null security.jail.sysvipc_allowed=0 + fi + echo '.' + + echo 'Starting Jails.' + for _jail in ${jail_list} + do + eval jail_rootdir=\"\$jail_${_jail}_rootdir\" + eval jail_hostname=\"\$jail_${_jail}_hostname\" + eval jail_ip=\"\$jail_${_jail}_ip\" + eval jail_exec=\"\$jail_${_jail}_exec\" + [ -z ${jail_exec} ] && jail_exec="/bin/sh /etc/rc" + + jail ${jail_rootdir} ${jail_hostname} ${jail_ip} ${jail_exec} + done +} + +jail_stop() +{ + kill -TERM $(ps aux | awk '$8 ~ /.*J/ {print $2};') +} + + +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 0000000000..b601a51663 --- /dev/null +++ b/etc/rc.d/kadmind @@ -0,0 +1,22 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/kadmind,v 1.3 2003/03/08 09:50:10 markm Exp $ +# $DragonFly: src/etc/rc.d/kadmind,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: kadmin +# REQUIRE: kerberos +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="kadmind5" +load_rc_config $name +rcvar="kadmind5_server_enable" +unset start_cmd +command="${kadmind5_server}" +command_args="&" +required_vars="kerberos5_server_enable" + +run_rc_command "$1" diff --git a/etc/rc.d/kdc b/etc/rc.d/kdc new file mode 100644 index 0000000000..0e25083bad --- /dev/null +++ b/etc/rc.d/kdc @@ -0,0 +1,21 @@ +#!/bin/sh +# +# $NetBSD: kdc,v 1.5 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/kdc,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/kdc,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: kdc +# REQUIRE: NETWORKING +# BEFORE: SERVERS + +. /etc/rc.subr + +name="kdc" +rcvar=$name +command="/usr/sbin/${name}" +pidfile="/var/run/${name}.pid" +required_files="/etc/krb5.conf" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/kerberos b/etc/rc.d/kerberos new file mode 100644 index 0000000000..5217217ae0 --- /dev/null +++ b/etc/rc.d/kerberos @@ -0,0 +1,19 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/kerberos,v 1.3 2003/03/08 09:50:10 markm Exp $ +# $DragonFly: src/etc/rc.d/kerberos,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: kerberos +# REQUIRE: NETWORKING +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="kerberos5" +load_rc_config $name +rcvar="kerberos5_server_enable" +command="${kerberos5_server}" +command_args="&" + +run_rc_command "$1" diff --git a/etc/rc.d/keyserv b/etc/rc.d/keyserv new file mode 100644 index 0000000000..16f758597e --- /dev/null +++ b/etc/rc.d/keyserv @@ -0,0 +1,34 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/keyserv,v 1.2 2002/08/14 05:44:32 gordon Exp $ +# $DragonFly: src/etc/rc.d/keyserv,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# Start keyserv if we are running Secure RPC +# + +# PROVIDE: keyserv +# REQUIRE: ypbind +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="keyserv" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" +start_precmd="keyserv_prestart" + +keyserv_prestart() +{ + if ! checkyesno rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + then + force_depend rpcbind || return 1 + fi + + return 0 +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/kldxref b/etc/rc.d/kldxref new file mode 100644 index 0000000000..087cb9b87e --- /dev/null +++ b/etc/rc.d/kldxref @@ -0,0 +1,36 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/kldxref,v 1.2 2003/04/18 17:55:05 mtm Exp $ +# $DragonFly: src/etc/rc.d/Attic/kldxref,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: kldxref +# REQUIRE: root mountcritlocal +# BEFORE: netif +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +rcvar="kldxref_enable" +name="kldxref" +stop_cmd=":" +start_cmd="kldxref_start" + +kldxref_start () { + if [ -n "$kldxref_module_path" ]; then + MODULE_PATHS="$kldxref_module_path" + else + MODULE_PATHS=`sysctl -n kern.module_path` + fi + IFS=';' + for MODULE_DIR in $MODULE_PATHS; do + if [ ! -f "$MODULE_DIR/linker.hints" ] || + checkyesno kldxref_clobber; then + echo "Building $MODULE_DIR/linker.hints" + kldxref "$MODULE_DIR" + fi + done +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/kpasswdd b/etc/rc.d/kpasswdd new file mode 100644 index 0000000000..479504672f --- /dev/null +++ b/etc/rc.d/kpasswdd @@ -0,0 +1,22 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/kpasswdd,v 1.2 2003/05/06 02:28:03 mtm Exp $ +# $DragonFly: src/etc/rc.d/kpasswdd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: kpasswdd +# REQUIRE: kadmin +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="kpasswdd" +load_rc_config $name +rcvar="kpasswdd_server_enable" +unset start_cmd +command="${kpasswdd_server}" +command_args="&" +required_vars="kadmind5_server_enable" + +run_rc_command "$1" diff --git a/etc/rc.d/ldconfig b/etc/rc.d/ldconfig new file mode 100644 index 0000000000..d559c02c80 --- /dev/null +++ b/etc/rc.d/ldconfig @@ -0,0 +1,97 @@ +#!/bin/sh +# +# $NetBSD: ldconfig,v 1.5 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/ldconfig,v 1.7 2003/06/30 15:02:05 trhodes Exp $ +# $DragonFly: src/etc/rc.d/ldconfig,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ldconfig +# REQUIRE: mountall mountcritremote +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="ldconfig" +ldconfig_command="/sbin/ldconfig" +start_cmd="ldconfig_start" +stop_cmd=":" + +ldconfig_start() +{ + case ${OSTYPE} in + DragonFly) + _ins= + ldconfig=${ldconfig_command} + checkyesno ldconfig_insecure && _ins="-i" + if [ -x "${ldconfig_command}" ]; then + _LDC=/usr/lib + for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do + if [ -r "${i}" ]; then + _LDC="${_LDC} ${i}" + fi + done + echo 'ELF ldconfig path:' ${_LDC} + ${ldconfig} -elf ${_ins} ${_LDC} + # 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} /etc/ld.so.conf; do + if [ -r "${i}" ]; then + _LDC="${_LDC} ${i}" + fi + done + echo 'a.out ldconfig path:' ${_LDC} + ${ldconfig} -aout ${_ins} ${_LDC} + ;; + esac + fi + ;; + + FreeBSD) + _ins= + ldconfig=${ldconfig_command} + checkyesno ldconfig_insecure && _ins="-i" + if [ -x "${ldconfig_command}" ]; then + _LDC=/usr/lib + for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do + if [ -r "${i}" ]; then + _LDC="${_LDC} ${i}" + fi + done + echo 'ELF ldconfig path:' ${_LDC} + ${ldconfig} -elf ${_ins} ${_LDC} + + # 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} /etc/ld.so.conf; do + if [ -r "${i}" ]; then + _LDC="${_LDC} ${i}" + fi + done + echo 'a.out ldconfig path:' ${_LDC} + ${ldconfig} -aout ${_ins} ${_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 +run_rc_command "$1" diff --git a/etc/rc.d/lkm1 b/etc/rc.d/lkm1 new file mode 100644 index 0000000000..07ece30b4b --- /dev/null +++ b/etc/rc.d/lkm1 @@ -0,0 +1,41 @@ +#!/bin/sh +# +# $NetBSD: lkm1,v 1.6 2000/10/09 06:11:38 nisimura Exp $ +# $FreeBSD: src/etc/rc.d/lkm1,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/lkm1,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: beforenetlkm +# REQUIRE: root bootconf + +. /etc/rc.subr + +name="lkm1" +rcvar="lkm" +start_cmd="lkm1_start" +stop_cmd="lkm1_stop" + +lkm1_start() +{ +# load kernel modules specified in /etc/lkm.conf if the /usr +# filesystem is already present with "/" or can be mounted now +# + if [ -f /etc/rc.lkm ]; then + mount /usr >/dev/null 2>&1 + if [ -x /usr/bin/ld ]; then + lkmstage=BEFORENET + set start ; . /etc/rc.lkm + fi + fi +} + +lkm1_stop() +{ + if [ -f /etc/rc.lkm ] && [ -x /usr/bin/ld ]; then + lkmstage=BEFORENET + set stop ; . /etc/rc.lkm + fi +} + +load_rc_config lkm +run_rc_command "$1" diff --git a/etc/rc.d/lkm2 b/etc/rc.d/lkm2 new file mode 100644 index 0000000000..b2c3b43fc6 --- /dev/null +++ b/etc/rc.d/lkm2 @@ -0,0 +1,39 @@ +#!/bin/sh +# +# $NetBSD: lkm2,v 1.4 2000/09/19 13:04:38 lukem Exp $ +# $FreeBSD: src/etc/rc.d/lkm2,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/lkm2,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: beforemountlkm +# REQUIRE: syslogd + +. /etc/rc.subr + +name="lkm2" +rcvar="lkm" +start_cmd="lkm2_start" +stop_cmd="lkm2_stop" + +# load kernel modules specified in /etc/lkm.conf +# +lkm2_start() +{ + if [ -r /etc/rc.lkm ]; then + lkmstage=BEFOREMOUNT + set start ; . /etc/rc.lkm + else + warn "/etc/rc.lkm not found; LKMs not loaded." + fi +} + +lkm2_stop() +{ + if [ -r /etc/rc.lkm ]; then + lkmstage=BEFOREMOUNT + set stop ; . /etc/rc.lkm + fi +} + +load_rc_config lkm +run_rc_command "$1" diff --git a/etc/rc.d/lkm3 b/etc/rc.d/lkm3 new file mode 100644 index 0000000000..394520eca1 --- /dev/null +++ b/etc/rc.d/lkm3 @@ -0,0 +1,30 @@ +#!/bin/sh +# +# $NetBSD: lkm3,v 1.6 2002/03/22 04:33:58 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/lkm3,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/lkm3,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: aftermountlkm +# REQUIRE: mountall +# BEFORE: DAEMON + +. /etc/rc.subr + +name="lkm3" +rcvar="lkm" +start_cmd="do_lkm3 start" +stop_cmd="do_lkm3 stop" + +do_lkm3() +{ + # (un)load kernel modules specified in /etc/lkm.conf + # + if [ -f /etc/rc.lkm ]; then + lkmstage=AFTERMOUNT + set $1 ; . /etc/rc.lkm + fi +} + +load_rc_config lkm +run_rc_command "$1" diff --git a/etc/rc.d/local b/etc/rc.d/local new file mode 100644 index 0000000000..ebaeb71e1a --- /dev/null +++ b/etc/rc.d/local @@ -0,0 +1,38 @@ +#!/bin/sh +# +# $NetBSD: local,v 1.6 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/local,v 1.4 2002/10/17 23:46:32 sobomax Exp $ +# $DragonFly: src/etc/rc.d/local,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: local +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: DragonFly FreeBSD NetBSD shutdown + +. /etc/rc.subr + +name="local" +start_cmd="local_start" +stop_cmd="local_stop" + +local_start() +{ + echo -n 'Starting local daemons:' + if [ -f /etc/rc.local ]; then + . /etc/rc.local + fi + echo '.' +} + +local_stop() +{ + echo -n 'Shutting down local daemons:' + if [ -f /etc/rc.shutdown.local ]; then + . /etc/rc.shutdown.local + fi + echo '.' +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/localdaemons b/etc/rc.d/localdaemons new file mode 100644 index 0000000000..d9c2c573dc --- /dev/null +++ b/etc/rc.d/localdaemons @@ -0,0 +1,91 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/localdaemons,v 1.2 2003/05/05 15:38:41 mtm Exp $ +# $DragonFly: src/etc/rc.d/localdaemons,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: localdaemons +# REQUIRE: abi +# BEFORE: securelevel +# KEYWORD: DragonFly 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/lpd b/etc/rc.d/lpd new file mode 100644 index 0000000000..a31a0e944a --- /dev/null +++ b/etc/rc.d/lpd @@ -0,0 +1,29 @@ +#!/bin/sh +# +# $NetBSD: lpd,v 1.5 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/lpd,v 1.3 2002/09/06 16:18:05 gordon Exp $ +# $DragonFly: src/etc/rc.d/lpd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: lpd +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="lpd" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" +required_files="/etc/printcap" + +case ${OSTYPE} in +NetBSD) + pidfile="/var/run/${name}.pid" + ;; +*) + ;; +esac + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/mixerctl b/etc/rc.d/mixerctl new file mode 100644 index 0000000000..571bd49996 --- /dev/null +++ b/etc/rc.d/mixerctl @@ -0,0 +1,27 @@ +#!/bin/sh +# +# $NetBSD: mixerctl,v 1.2 2002/06/02 19:04:10 jmcneill Exp $ +# $DragonFly: src/etc/rc.d/Attic/mixerctl,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: mixerctl +# REQUIRE: mountcritremote + +. /etc/rc.subr + +name="mixerctl" +start_cmd="mixerctl_start" +stop_cmd=":" + +mixerctl_start() +{ + if [ -r /etc/mixerctl.conf ]; then + echo "Setting mixerctl variables..." + while read setting; do + mixerctl -n -w $setting + done < /etc/mixerctl.conf + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/mopd b/etc/rc.d/mopd new file mode 100644 index 0000000000..c1f478980f --- /dev/null +++ b/etc/rc.d/mopd @@ -0,0 +1,19 @@ +#!/bin/sh +# +# $NetBSD: mopd,v 1.5 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/mopd,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/mopd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: mopd +# REQUIRE: DAEMON +# BEFORE: LOGIN + +. /etc/rc.subr + +name="mopd" +rcvar=$name +command="/usr/sbin/${name}" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/motd b/etc/rc.d/motd new file mode 100644 index 0000000000..405a26639f --- /dev/null +++ b/etc/rc.d/motd @@ -0,0 +1,69 @@ +#!/bin/sh +# +# $NetBSD: motd,v 1.5 2000/09/19 13:04:38 lukem Exp $ +# $FreeBSD: src/etc/rc.d/motd,v 1.6 2003/06/30 22:06:26 mtm Exp $ +# $DragonFly: src/etc/rc.d/motd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: motd +# REQUIRE: mountcritremote +# BEFORE: LOGIN +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="motd" +rcvar="update_motd" +start_cmd="motd_start" +stop_cmd=":" + +case ${OSTYPE} in +DragonFly) + PERMS="644" + ;; + +FreeBSD) + PERMS="644" + ;; +NetBSD) + PERMS="664" + ;; +esac + +motd_start() +{ + # Update kernel info in /etc/motd + # Must be done *before* interactive logins are possible + # to prevent possible race conditions. + # + echo "Updating motd." + if [ ! -f /etc/motd ]; then + install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd + fi + + case ${OSTYPE} in + DragonFly) + T=`mktemp -t motd` + 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} + ;; + FreeBSD) + T=`mktemp -t motd` + 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) + T='/etc/_motd' + 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 || { + cp $T /etc/motd + chmod ${PERMS} /etc/motd + } + rm -f $T +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/mountall b/etc/rc.d/mountall new file mode 100644 index 0000000000..90aca5faa4 --- /dev/null +++ b/etc/rc.d/mountall @@ -0,0 +1,18 @@ +#!/bin/sh +# +# $NetBSD: mountall,v 1.3 2000/05/13 08:45:07 lukem Exp $ +# $FreeBSD: src/etc/rc.d/mountall,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/mountall,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: mountall +# REQUIRE: beforemountlkm + +. /etc/rc.subr + +name="mountall" +start_cmd="echo 'Mounting all filesystems...'; mount -a" +stop_cmd="echo 'Unmounting all filesystems...'; umount -a" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/mountcritlocal b/etc/rc.d/mountcritlocal new file mode 100644 index 0000000000..716fa4bc17 --- /dev/null +++ b/etc/rc.d/mountcritlocal @@ -0,0 +1,99 @@ +#!/bin/sh +# +# $NetBSD: mountcritlocal,v 1.7 2002/04/29 12:29:53 lukem Exp $ +# $FreeBSD: src/etc/rc.d/mountcritlocal,v 1.5 2003/06/01 01:43:37 gordon Exp $ +# $DragonFly: src/etc/rc.d/mountcritlocal,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: mountcritlocal +# REQUIRE: root +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="mountcritlocal" +start_cmd="mountcritlocal_start" +stop_cmd=":" + +mountcritlocal_start() +{ + case ${OSTYPE} in + DragonFly) + + # Set up the list of network filesystem types for which mounting + # should be delayed until after network initialization. + case ${extra_netfs_types} in + [Nn][Oo]) + ;; + *) + netfs_types="${netfs_types} ${extra_netfs_types}" + ;; + esac + + # Mount everything except nfs filesystems. + mount_excludes='no' + for i in ${netfs_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 + ;; + + FreeBSD) + # Set up the list of network filesystem types for which mounting + # should be delayed until after network initialization. + case ${extra_netfs_types} in + [Nn][Oo]) + ;; + *) + netfs_types="${netfs_types} ${extra_netfs_types}" + ;; + esac + + # Mount everything except nfs filesystems. + mount_excludes='no' + for i in ${netfs_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 +run_rc_command "$1" diff --git a/etc/rc.d/mountcritremote b/etc/rc.d/mountcritremote new file mode 100644 index 0000000000..936fc7ae7c --- /dev/null +++ b/etc/rc.d/mountcritremote @@ -0,0 +1,135 @@ +#!/bin/sh +# +# $NetBSD: mountcritremote,v 1.7 2002/04/29 12:29:53 lukem Exp $ +# $FreeBSD: src/etc/rc.d/mountcritremote,v 1.6 2003/06/01 01:43:37 gordon Exp $ +# $DragonFly: src/etc/rc.d/mountcritremote,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: mountcritremote +# REQUIRE: NETWORKING root mountcritlocal +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="mountcritremote" +stop_cmd=":" + +case ${OSTYPE} in + DragonFly) + start_cmd="mountcritremote_start" + start_precmd="mountcritremote_precmd" + ;; + 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 ${OSTYPE} in + DragonFly) + # Mount nfs filesystems. + # + echo -n 'Mounting NFS file systems:' + mount -a -t nfs + echo '.' + # Mount other network filesystems if present in /etc/fstab. + case ${extra_netfs_types} in + [Nn][Oo]) + ;; + *) + netfs_types="${netfs_types} ${extra_netfs_types}" + ;; + esac + for i in ${netfs_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 reload + rm -f /var/run/clean_var /var/spool/lock/clean_var + ;; + + + FreeBSD) + # Mount nfs filesystems. + # + echo -n 'Mounting NFS file systems:' + mount -a -t nfs + echo '.' + + # Mount other network filesystems if present in /etc/fstab. + case ${extra_netfs_types} in + [Nn][Oo]) + ;; + *) + netfs_types="${netfs_types} ${extra_netfs_types}" + ;; + esac + + for i in ${netfs_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 reload + 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 new file mode 100644 index 0000000000..8d7c217422 --- /dev/null +++ b/etc/rc.d/mountd @@ -0,0 +1,73 @@ +#!/bin/sh +# +# $NetBSD: mountd,v 1.11 2002/01/31 01:26:06 lukem Exp $ +# $FreeBSD: src/etc/rc.d/mountd,v 1.9 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/mountd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: mountd +# REQUIRE: NETWORKING mountall beforemountlkm nfsserver rpcbind quota +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="mountd" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" +required_files="/etc/exports" +start_precmd="mountd_precmd" +extra_commands="reload" + +mountd_precmd() +{ + case ${OSTYPE} in + DragonFly) + if ! checkyesno rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + 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 mountd_enable; then + checkyesno weak_mountd_authentication && mountd_flags="-n" + fi + esac + ;; + + FreeBSD) + if ! checkyesno rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + 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 mountd_enable; then + checkyesno weak_mountd_authentication && mountd_flags="-n" + fi + esac + ;; + esac + rm -f /var/db/mountdtab + ( umask 022 ; > /var/db/mountdtab ) + return 0 +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/moused b/etc/rc.d/moused new file mode 100644 index 0000000000..ae6c8b1221 --- /dev/null +++ b/etc/rc.d/moused @@ -0,0 +1,49 @@ +#!/bin/sh +# +# $NetBSD: moused,v 1.1 2001/10/29 23:25:01 augustss Exp $ +# $FreeBSD: src/etc/rc.d/moused,v 1.3 2002/09/27 16:54:21 gordon Exp $ +# $DragonFly: src/etc/rc.d/moused,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: moused +# REQUIRE: DAEMON +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name=moused +rcvar=`set_rcvar` +command="/usr/sbin/${name}" + +case ${OSTYPE} in +DragonFly) + start_cmd="moused_start" + ;; +FreeBSD) + start_cmd="moused_start" + ;; +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 0000000000..50b6cd9e57 --- /dev/null +++ b/etc/rc.d/mroute6d @@ -0,0 +1,18 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/mroute6d,v 1.2 2003/01/25 23:14:08 mtm Exp $ +# $DragonFly: src/etc/rc.d/mroute6d,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: mroute6d +# REQUIRE: network_ipv6 +# KEYWORD: DragonFly 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 new file mode 100644 index 0000000000..c85b709a29 --- /dev/null +++ b/etc/rc.d/mrouted @@ -0,0 +1,22 @@ +#!/bin/sh +# +# $NetBSD: mrouted,v 1.6 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/mrouted,v 1.5 2003/06/29 05:15:57 mtm Exp $ +# $DragonFly: src/etc/rc.d/mrouted,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: mrouted +# REQUIRE: netif routing +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="mrouted" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" +pidfile="/var/run/${name}.pid" +required_files="/etc/${name}.conf" +extra_commands="reload" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/msgs b/etc/rc.d/msgs new file mode 100644 index 0000000000..39b8e3c09f --- /dev/null +++ b/etc/rc.d/msgs @@ -0,0 +1,15 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/msgs,v 1.1 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/msgs,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: msgs +# REQUIRE: LOGIN +# KEYWORD: DragonFly 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 new file mode 100644 index 0000000000..bb2d18adf8 --- /dev/null +++ b/etc/rc.d/named @@ -0,0 +1,146 @@ +#!/bin/sh +# +# $NetBSD: named,v 1.10 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/named,v 1.6 2003/01/12 04:53:54 mtm Exp $ +# $DragonFly: src/etc/rc.d/named,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: named +# REQUIRE: SERVERS +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="named" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" +start_precmd="named_precmd" +required_dirs="$named_chrootdir" # if it is set, it must exist +extra_commands="reload" + +case ${OSTYPE} in +DragonFly) + nuser=bind + ngroup=bind + ;; +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}${named_pidfile}" ${named_pidfile} + ln -fs "${named_chrootdir}/var/run/ndc" /var/run/ndc + +} + +named_precmd() +{ + case ${OSTYPE} in + DragonFly) + ! 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 + ;; + 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 ${OSTYPE} in + DragonFly) + # Make the symlinks only if the user wants them done. + checkyesno named_symlink_enable && make_symlinks + ;; + 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 ${OSTYPE} in + DragonFly) + ! checkyesno named_rcng && return + ;; + 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 +pidfile="${named_pidfile:-/var/run/${name}/pid}" + +run_rc_command "$1" diff --git a/etc/rc.d/ndbootd b/etc/rc.d/ndbootd new file mode 100644 index 0000000000..ee7b0e3a5a --- /dev/null +++ b/etc/rc.d/ndbootd @@ -0,0 +1,18 @@ +#!/bin/sh +# +# $DragonFly: src/etc/rc.d/Attic/ndbootd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ndbootd +# REQUIRE: DAEMON + +. /etc/rc.subr + +name="ndbootd" +rcvar=$name +command="/usr/sbin/${name}" +pidfile="/var/run/${name}.pid" +required_files="/etc/ethers" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/netif b/etc/rc.d/netif new file mode 100644 index 0000000000..65b20b0779 --- /dev/null +++ b/etc/rc.d/netif @@ -0,0 +1,167 @@ +#!/bin/sh +# +# Copyright (c) 2003 The FreeBSD Project. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE PROJECT ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# $FreeBSD: src/etc/rc.d/netif,v 1.2 2003/06/29 05:34:41 mtm Exp $ +# $DragonFly: src/etc/rc.d/netif,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: netif +# REQUIRE: atm1 ipfilter mountcritlocal pccard serial sppp sysctl tty +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr +. /etc/network.subr + +name="network" +start_cmd="network_start" +stop_cmd="network_stop" +cloneup_cmd="clone_up" +clonedown_cmd="clone_down" +extra_commands="cloneup clonedown" +_cmdifn= + +network_start() +{ + if [ -z "$_cmdifn" ]; then + # + # We're operating as a general network start routine. + # + + # Create cloned interfaces + clone_up + + # Create IPv6<-->IPv4 tunnels + gif_up + fi + + # Configure the interface(s). + network_common ifn_start verbose + + # Resync ipfilter + /etc/rc.d/ipfilter resync +} + +network_stop() +{ + echo -n "Stopping network:" + + # Deconfigure the interface(s) + network_common ifn_stop + echo '.' +} + +# network_common routine verbose +# Common configuration subroutine for network interfaces. This +# routine takes all the preparatory steps needed for configuriing +# an interface and then calls $routine. If $verbose is specified, +# it will call ifconfig(8) to show, in long format, the configured +# interfaces. If $verbose is not given, it will simply output the +# configured interface(s). +network_common() +{ + _func= + _verbose= + + if [ -z "$1" ]; then + err "network_common(): No function name specified." + else + _func="$1" + fi + [ -n "$2" ] && _verbose=yes + + # Get a list of network interfaces. Do not include dhcp interfaces. + _ifn_list="`list_net_interfaces nodhcp`" + + # Set the scope of the command (all interfaces or just one). + # + _cooked_list="$_ifn_list" + if [ -n "$_cmdifn" ]; then + eval _cooked_list=\"`expr "$_ifn_list" : ".*\($_cmdifn\).*"`\" + if [ -z "$_cooked_list" ]; then + err "No such network interface: $_cmdifn" + return 1 + fi + fi + + for ifn in ${_cooked_list}; do + if ${_func} ${ifn} ; then + eval showstat_$ifn=1 + else + _fail="$_fail $ifn" + fi + done + + # Display interfaces configured by this script + # + for ifn in ${_cooked_list}; do + eval showstat=\$showstat_${ifn} + if [ ! -z ${showstat} ]; then + if [ -n "$_verbose" ]; then + ifconfig ${ifn} + else + echo -n " ${ifn}" + fi + fi + done + debug "The following interfaces were not configured: $_fail" +} + +ifn_start() +{ + local ifn cfg + ifn="$1" + cfg=1 + + [ -z "$ifn" ] && return 1 + + ifscript_up ${ifn} && cfg=0 + ifconfig_up ${ifn} && cfg=0 + ifalias_up ${ifn} && cfg=0 + ipx_up ${ifn} && cfg=0 + + return $cfg +} + +ifn_stop() +{ + local ifn cfg + ifn="$1" + cfg=1 + + [ -z "$ifn" ] && return 1 + + ipx_down ${ifn} && cfg=0 + ifalias_down ${ifn} && cfg=0 + ifconfig_down ${ifn} && cfg=0 + ifscript_down ${ifn} && cfg=0 + + return $cfg +} + +if [ -n "$2" ]; then + _cmdifn="$2" +fi + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/netoptions b/etc/rc.d/netoptions new file mode 100644 index 0000000000..bfccf6ccd7 --- /dev/null +++ b/etc/rc.d/netoptions @@ -0,0 +1,37 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/netoptions,v 1.138 2003/06/29 05:09:48 mtm Exp $ +# $DragonFly: src/etc/rc.d/netoptions,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: netoptions +# REQUIRE: localdaemons +# BEFORE: securelevel +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +load_rc_config 'XXX' + +echo -n 'Additional TCP options:' +case ${log_in_vain} in +[Nn][Oo] | '') + log_in_vain=0 + ;; +[Yy][Ee][Ss]) + log_in_vain=1 + ;; +[0-9]*) + ;; +*) + echo " invalid log_in_vain setting: ${log_in_vain}" + log_in_vain=0 + ;; +esac + +[ "${log_in_vain}" -ne 0 ] && ( + echo -n " log_in_vain=${log_in_vain}" + sysctl net.inet.tcp.log_in_vain="${log_in_vain}" >/dev/null + sysctl net.inet.udp.log_in_vain="${log_in_vain}" >/dev/null +) +echo '.' diff --git a/etc/rc.d/network b/etc/rc.d/network new file mode 100644 index 0000000000..9a30f24818 --- /dev/null +++ b/etc/rc.d/network @@ -0,0 +1,388 @@ +#!/bin/sh +# +# $NetBSD: network,v 1.29 2001/01/11 17:56:16 itojun Exp $ +# $FreeBSD: src/etc/rc.d/network,v 1.3 2002/08/12 10:04:32 schweikh Exp $ +# $DragonFly: src/etc/rc.d/Attic/network,v 1.1 2003/07/24 06:35:37 dillon Exp $ + +# PROVIDE: network +# REQUIRE: ipfilter ipsec mountcritlocal root tty sysctl + +. /etc/rc.subr + +name="network" +start_cmd="network_start" +stop_cmd="network_stop" + +network_start() +{ + # set hostname, turn on network + # + echo "Starting network." + + # If $hostname is set, use it for my Internet name, + # otherwise use /etc/myname + # + if [ -z "$hostname" ] && [ -f /etc/myname ]; then + hostname=`cat /etc/myname` + fi + if [ -n "$hostname" ]; then + echo "Hostname: $hostname" + hostname $hostname + else + # Don't warn about it if we're going to run + # DHCP later, as we will probably get the + # hostname at that time. + # + if ! checkyesno dhclient && [ -z "`hostname`" ]; then + warn "\$hostname not set." + fi + fi + + # Check $domainname first, then /etc/defaultdomain, + # for NIS/YP domain name + # + if [ -z "$domainname" ] && [ -f /etc/defaultdomain ]; then + domainname=`cat /etc/defaultdomain` + fi + if [ -n "$domainname" ]; then + echo "NIS domainname: $domainname" + domainname $domainname + fi + + # Flush all routes just to make sure it is clean + if checkyesno flushroutes; then + route -n flush + fi + + # Set the address for the first loopback interface, so that the + # auto-route from a newly configured interface's address to lo0 + # works correctly. + # + # NOTE: obscure networking problems may occur if lo0 isn't configured... + # + ifconfig lo0 inet 127.0.0.1 + + # According to RFC1122, 127.0.0.0/8 should not leave the node. + # + route add -inet 127.0.0.0 -netmask 0xff000000 127.0.0.1 -reject + + # IPv6 routing setups, and host/router mode selection. + # + if ifconfig lo0 inet6 >/dev/null 2>&1; then + # We have IPv6 support in kernel. + + # disallow link-local unicast dest without outgoing scope + # identifiers. + # + route add -inet6 fe80:: -prefixlen 10 ::1 -reject + + # disallow site-local unicast dest without outgoing scope + # identifiers. + # If you configure site-locals without scope id (it is + # permissible config for routers that are not on scope + # boundary), you may want to comment the following one out. + # + if ! checkyesno ip6sitelocal; then + route add -inet6 fec0:: -prefixlen 10 ::1 -reject + fi + + # disallow "internal" addresses to appear on the wire. + # + route add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject + + # disallow packets to malicious IPv4 compatible prefix + # + route add -inet6 ::224.0.0.0 -prefixlen 100 ::1 -reject + route add -inet6 ::127.0.0.0 -prefixlen 104 ::1 -reject + route add -inet6 ::0.0.0.0 -prefixlen 104 ::1 -reject + route add -inet6 ::255.0.0.0 -prefixlen 104 ::1 -reject + + # disallow packets to malicious 6to4 prefix + # + route add -inet6 2002:e000:: -prefixlen 20 ::1 -reject + route add -inet6 2002:7f00:: -prefixlen 24 ::1 -reject + route add -inet6 2002:0000:: -prefixlen 24 ::1 -reject + route add -inet6 2002:ff00:: -prefixlen 24 ::1 -reject + + # Completely disallow packets to IPv4 compatible prefix. + # This may conflict with RFC1933 under following circumstances: + # (1) An IPv6-only KAME node tries to originate packets to IPv4 + # compatible destination. The KAME node has no IPv4 + # compatible support. Under RFC1933, it should transmit + # native IPv6 packets toward IPv4 compatible destination, + # hoping it would reach a router that forwards the packet + # toward auto-tunnel interface. + # (2) An IPv6-only node originates a packet to IPv4 compatible + # destination. A KAME node is acting as an IPv6 router, and + # asked to forward it. + # Due to rare use of IPv4 compatible address, and security + # issues with it, we disable it by default. + # + route add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject + + sysctl net.inet6.ip6.forwarding=0 >/dev/null + sysctl net.inet6.ip6.accept_rtadv=0 >/dev/null + + # backward compatibility + # + if [ -z "$ip6mode" ] && [ -n "$ip6forwarding" ]; then + warn 'Please migrate to newer rc.conf' \ + '(use ip6mode, not ip6forwarding)' + if checkyesno ip6forwarding; then + ip6mode=router + elif checkyesno rtsol; then + ip6mode=autohost + else + ip6mode=host + fi + fi + + case $ip6mode in + router) + echo 'IPv6 mode: router' + sysctl net.inet6.ip6.forwarding=1 >/dev/null + ;; + + autohost) + echo 'IPv6 mode: autoconfigured host' + sysctl net.inet6.ip6.accept_rtadv=1 >/dev/null + ;; + + host) + echo 'IPv6 mode: host' + ;; + + *) echo 'WARNING: invalid value in ip6mode' + ;; + + esac + fi + + # Configure all of the network interfaces listed in $net_interfaces; + # if $auto_ifconfig is YES, grab all interfaces from ifconfig. + # In the following, "xxN" stands in for interface names, like "le0". + # For any interfaces that has an $ifconfig_xxN variable associated, + # we do "ifconfig xxN $ifconfig_xxN". + # If there is no such variable, we take the contents of the file + # /etc/ifconfig.xxN, and run "ifconfig xxN" repeatedly, using each + # line of the file as the arguments for a separate "ifconfig" + # invocation. + # + # In order to configure an interface reasonably, you at the very least + # need to specify "[addr_family] [hostname]" (e.g "inet my.domain.org"), + # and probably a netmask (as in "netmask 0xffffffe0"). You will + # frequently need to specify a media type, as in "media UTP", for + # interface cards with multiple media connections that do not + # autoconfigure. See the ifconfig manual page for details. + # + # Note that /etc/ifconfig.xxN takes multiple lines. The following + # configuration is possible: + # inet 10.1.1.1 netmask 0xffffff00 + # inet 10.1.1.2 netmask 0xffffff00 alias + # inet6 fec0::1 prefixlen 64 alias + # + # You can put shell script fragment into /etc/ifconfig.xxN by + # starting a line with "!". Refer to ifconfig.if(5) for details. + # + if [ "$net_interfaces" != NO ]; then + if checkyesno auto_ifconfig; then + tmp=`ifconfig -l` + for cloner in `ifconfig -C 2>/dev/null`; do + for int in /etc/ifconfig.${cloner}[0-9]*; do + [ ! -f $int ] && break + tmp="$tmp ${int##*.}" + done + done + else + tmp="$net_interfaces" + fi + echo -n 'Configuring network interfaces:' + for int in $tmp; do + eval args=\$ifconfig_$int + if [ -n "$args" ]; then + echo -n " $int" + ifconfig $int $args + elif [ -f /etc/ifconfig.$int ]; then + echo -n " $int" + while read args; do + [ -z "$args" ] && continue + case "$args" in + "#"*) + ;; + "!"*) + eval ${args#*!} + ;; + *) + ifconfig $int $args + ;; + esac + done < /etc/ifconfig.$int + else + if ! checkyesno auto_ifconfig; then + echo + warn \ + "/etc/ifconfig.$int missing and ifconfig_$int not set;" + warn "interface $int not configured." + fi + continue + fi + configured_interfaces="$configured_interfaces $int" + done + echo "." + fi + + # Check $defaultroute, then /etc/mygate, for the name of my gateway + # host. That name must be in /etc/hosts. + # + if [ -z "$defaultroute" ] && [ -f /etc/mygate ]; then + defaultroute=`cat /etc/mygate` + fi + if [ -n "$defaultroute" ]; then + route add default $defaultroute + fi + + # Check if each configured interface xxN has an $ifaliases_xxN variable + # associated, then configure additional IP addresses for that interface. + # The variable contains a list of "address netmask" pairs, with + # "netmask" set to "-" if the interface default netmask is to be used. + # + # Note that $ifaliases_xxN works only with certain configurations and + # considered not recommended. Use /etc/ifconfig.xxN if possible. + # + # + if [ -n "$configured_interfaces" ]; then + echo "Adding interface aliases:" + done_aliases_message=yes + fi + for int in $configured_interfaces; do + eval args=\$ifaliases_$int + if [ -n "$args" ]; then + set -- $args + while [ $# -ge 2 ]; do + addr=$1 ; net=$2 ; shift 2 + if [ "$net" = "-" ]; then + # for compatibility only, obsolete + ifconfig $int inet alias $addr + else + ifconfig $int inet alias $addr \ + netmask $net + fi + # Use loopback, not the wire + route add $addr 127.0.0.1 + done + fi + done + + # /etc/ifaliases, if it exists, contains the names of additional IP + # addresses for each interface. It is formatted as a series of lines + # that contain + # address interface netmask + # + # Note that /etc/ifaliases works only with certain cases only and its + # use is not recommended. Use /etc/ifconfig.xxN instead. + # + # + if [ -f /etc/ifaliases ]; then + if [ "$done_aliases_message" != yes ]; then + echo "Adding interface aliases:" + fi + while read addr int net; do + if [ -z "$net" ]; then + # for compatibility only, obsolete + ifconfig $int inet alias $addr + else + ifconfig $int inet alias $addr netmask $net + fi + # use loopback, not the wire + route add $addr 127.0.0.1 + done < /etc/ifaliases + fi + + # IPv6 interface autoconfiguration. + # + if ifconfig lo0 inet6 >/dev/null 2>&1; then + # wait till DAD is completed. always invoke it in case + # if are configured manually by ifconfig + # + dadcount=`sysctl -n net.inet6.ip6.dad_count 2>/dev/null` + sleep $dadcount + sleep 1 + + if checkyesno rtsol; then + if [ "$ip6mode" = "autohost" ]; then + echo 'Sending router solicitation...' + rtsol $rtsol_flags + else + echo + warn \ + "ip6mode must be set to 'autohost' to use rtsol." + fi + + # wait till DAD is completed, for global addresses + # configured by router advert message. + # + sleep $dadcount + sleep 1 + fi + fi + + # XXX this must die + if [ -s /etc/netstart.local ]; then + sh /etc/netstart.local start + fi +} + +network_stop() +{ + echo "Stopping network." + + # XXX this must die + if [ -s /etc/netstart.local ]; then + sh /etc/netstart.local stop + fi + + echo "Deleting aliases." + if [ -f /etc/ifaliases ]; then + while read addr int net; do + ifconfig $int inet delete $addr + done < /etc/ifaliases + fi + + for int in `ifconfig -lu`; do + eval args=\$ifaliases_$int + if [ -n "$args" ]; then + set -- $args + while [ $# -ge 2 ]; do + addr=$1 ; net=$2 ; shift 2 + ifconfig $int inet delete $addr + done + fi + done + + # down interfaces + # + echo -n 'Downing network interfaces:' + if [ "$net_interfaces" != NO ]; then + if checkyesno auto_ifconfig; then + tmp=`ifconfig -l` + else + tmp="$net_interfaces" + fi + for int in $tmp; do + eval args=\$ifconfig_$int + if [ -n "$args" ] || [ -f /etc/ifconfig.$int ]; then + echo -n " $int" + ifconfig $int down + fi + done + echo "." + fi + + # flush routes + # + route -n flush + +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/network1 b/etc/rc.d/network1 new file mode 100644 index 0000000000..5a16de2d9a --- /dev/null +++ b/etc/rc.d/network1 @@ -0,0 +1,227 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/network1,v 1.147 2003/06/06 13:00:43 mtm Exp $ +# $DragonFly: src/etc/rc.d/Attic/network1,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: network1 +# REQUIRE: atm1 ipfilter mountcritlocal pccard serial sppp sysctl tty +# KEYWORD: DragonFly FreeBSD nostart + +. /etc/rc.subr + +name="network1" +start_cmd="network_start" +stop_cmd="network_stop" + +convert_host_conf() +{ + host_conf=$1; shift; + nsswitch_conf=$1; shift; + awk ' \ + /^[:blank:]*#/ { next } \ + /(hosts|local|file)/ { nsswitch[c] = "files"; c++; next } \ + /(dns|bind)/ { nsswitch[c] = "dns"; c++; next } \ + /nis/ { nsswitch[c] = "nis"; c++; next } \ + { printf "Warning: unrecognized line [%s]", $0 > "/dev/stderr" } \ + END { \ + printf "hosts: "; \ + for (i in nsswitch) printf "%s ", nsswitch[i]; \ + printf "\n"; \ + }' < $host_conf > $nsswitch_conf +} + +generate_host_conf() +{ + nsswitch_conf=$1; shift; + host_conf=$1; shift; + + awk ' + BEGIN { + xlat["files"] = "hosts"; + xlat["dns"] = "bind"; + xlat["nis"] = "nis"; + cont = 0; + } + sub(/^[\t ]*hosts:/, "") || cont { + if (!cont) + srcs = "" + sub(/#.*/, "") + gsub(/[][]/, " & ") + cont = sub(/\\$/, "") + srcs = srcs " " $0 + } + END { + print "# Auto-generated from nsswitch.conf, do not edit" + ns = split(srcs, s) + for (n = 1; n <= ns; ++n) { + if (s[n] in xlat) + print xlat[s[n]] + } + } + ' <$nsswitch_conf >$host_conf +} + +network_gif_setup() { + case ${gif_interfaces} in + [Nn][Oo] | '') + ;; + *) + for i in ${gif_interfaces}; do + eval peers=\$gifconfig_$i + case ${peers} in + '') + continue + ;; + *) + ifconfig $i create >/dev/null 2>&1 + ifconfig $i tunnel ${peers} + ifconfig $i up + ;; + esac + done + ;; + esac +} + +network_start() +{ + # set hostname, turn on network + # + echo -n "Doing initial network setup:" + + # Generate host.conf for compatibility + # + if [ -f "/etc/nsswitch.conf" ]; then + echo -n ' host.conf' + generate_host_conf /etc/nsswitch.conf /etc/host.conf + fi + + # Convert host.conf to nsswitch.conf if necessary + # + if [ -f "/etc/host.conf" -a ! -f "/etc/nsswitch.conf" ]; then + echo '' + echo 'Warning: /etc/host.conf is no longer used' + echo ' /etc/nsswitch.conf will be created for you' + convert_host_conf /etc/host.conf /etc/nsswitch.conf + fi + + # Set the host name if it is not already set + # + if [ -z "`hostname -s`" ]; then + hostname ${hostname} + echo -n ' hostname' + fi + + # Set the domainname if we're using NIS + # + case ${nisdomainname} in + [Nn][Oo]|'') + ;; + *) + domainname ${nisdomainname} + echo -n ' domain' + ;; + esac + + echo '.' + + # Attempt to create cloned interfaces. + for ifn in ${cloned_interfaces}; do + ifconfig ${ifn} create + done + + # gifconfig + network_gif_setup + + # Set up all the network interfaces, calling startup scripts if needed + # + case ${network_interfaces} in + [Aa][Uu][Tt][Oo]) + network_interfaces="`ifconfig -l`" + ;; + *) + network_interfaces="${network_interfaces} ${cloned_interfaces}" + ;; + esac + + dhcp_interfaces="" + for ifn in ${network_interfaces}; do + if [ -r /etc/start_if.${ifn} ]; then + . /etc/start_if.${ifn} + eval showstat_$ifn=1 + fi + + # Do the primary ifconfig if specified + # + eval ifconfig_args=\$ifconfig_${ifn} + + case ${ifconfig_args} in + '') + ;; + [Dd][Hh][Cc][Pp]) + # DHCP inits are done all in one go below + dhcp_interfaces="$dhcp_interfaces $ifn" + eval showstat_$ifn=1 + ;; + *) + ifconfig ${ifn} ${ifconfig_args} + eval showstat_$ifn=1 + ;; + esac + done + + if [ ! -z "${dhcp_interfaces}" ]; then + ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces} + fi + + for ifn in ${network_interfaces}; do + # Check to see if aliases need to be added + # + alias=0 + while : ; do + eval ifconfig_args=\$ifconfig_${ifn}_alias${alias} + if [ -n "${ifconfig_args}" ]; then + ifconfig ${ifn} ${ifconfig_args} alias + eval showstat_$ifn=1 + alias=$((${alias} + 1)) + else + break; + fi + done + + # Do ipx address if specified + # + eval ifconfig_args=\$ifconfig_${ifn}_ipx + if [ -n "${ifconfig_args}" ]; then + ifconfig ${ifn} ${ifconfig_args} + eval showstat_$ifn=1 + fi + done + + # Display ifconfiged interfaces + for ifn in ${network_interfaces}; do + eval showstat=\$showstat_${ifn} + if [ ! -z ${showstat} ]; then + ifconfig ${ifn} + fi + done + + # Resync ipfilter + /etc/rc.d/ipfilter resync +} + +network_stop() +{ + echo -n "Stopping network:" + + # flush routes + # + echo -n " flush routes" + route -n flush + + echo '.' +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/network2 b/etc/rc.d/network2 new file mode 100644 index 0000000000..be46ad34aa --- /dev/null +++ b/etc/rc.d/network2 @@ -0,0 +1,141 @@ +#!/bin/sh +# +# Configure routing and miscellaneous network tunables +# +# $FreeBSD: src/etc/rc.d/network2,v 1.137 2003/06/29 05:15:57 mtm Exp $ +# $DragonFly: src/etc/rc.d/Attic/network2,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: network2 +# REQUIRE: netif ppp-user +# KEYWORD: DragonFly FreeBSD nostart + +. /etc/rc.subr + +name="network2" +start_cmd="network2_start" +stop_cmd=":" + +network2_start() +{ + case ${defaultrouter} in + [Nn][Oo] | '') + ;; + *) + static_routes="default ${static_routes}" + route_default="default ${defaultrouter}" + ;; + esac + + # Setup static routes. This should be done before router discovery. + # + if [ -n "${static_routes}" ]; then + for i in ${static_routes}; do + eval route_args=\$route_${i} + route add ${route_args} + done + fi + + echo -n 'Additional routing options:' + case ${tcp_extensions} in + [Yy][Ee][Ss] | '') + ;; + *) + echo -n ' tcp extensions=NO' + sysctl net.inet.tcp.rfc1323=0 >/dev/null + ;; + esac + + case ${icmp_bmcastecho} in + [Yy][Ee][Ss]) + echo -n ' broadcast ping responses=YES' + sysctl net.inet.icmp.bmcastecho=1 >/dev/null + ;; + esac + + case ${icmp_drop_redirect} in + [Yy][Ee][Ss]) + echo -n ' ignore ICMP redirect=YES' + sysctl net.inet.icmp.drop_redirect=1 >/dev/null + ;; + esac + + case ${icmp_log_redirect} in + [Yy][Ee][Ss]) + echo -n ' log ICMP redirect=YES' + sysctl net.inet.icmp.log_redirect=1 >/dev/null + ;; + esac + + case ${gateway_enable} in + [Yy][Ee][Ss]) + echo -n ' IP gateway=YES' + sysctl net.inet.ip.forwarding=1 >/dev/null + ;; + esac + + case ${forward_sourceroute} in + [Yy][Ee][Ss]) + echo -n ' do source routing=YES' + sysctl net.inet.ip.sourceroute=1 >/dev/null + ;; + esac + + case ${accept_sourceroute} in + [Yy][Ee][Ss]) + echo -n ' accept source routing=YES' + sysctl net.inet.ip.accept_sourceroute=1 >/dev/null + ;; + esac + + case ${tcp_keepalive} in + [Nn][Oo]) + echo -n ' TCP keepalive=NO' + sysctl net.inet.tcp.always_keepalive=0 >/dev/null + ;; + esac + + case ${tcp_drop_synfin} in + [Yy][Ee][Ss]) + echo -n ' drop SYN+FIN packets=YES' + sysctl net.inet.tcp.drop_synfin=1 >/dev/null + ;; + esac + + case ${ipxgateway_enable} in + [Yy][Ee][Ss]) + echo -n ' IPX gateway=YES' + sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null + ;; + esac + + case ${arpproxy_all} in + [Yy][Ee][Ss]) + echo -n ' ARP proxyall=YES' + sysctl net.link.ether.inet.proxyall=1 >/dev/null + ;; + esac + + case ${ip_portrange_first} in + [Nn][Oo] | '') + ;; + *) + echo -n " ip_portrange_first=$ip_portrange_first" + sysctl net.inet.ip.portrange.first=$ip_portrange_first >/dev/null + ;; + esac + + case ${ip_portrange_last} in + [Nn][Oo] | '') + ;; + *) + echo -n " ip_portrange_last=$ip_portrange_last" + sysctl net.inet.ip.portrange.last=$ip_portrange_last >/dev/null + ;; + esac + + echo '.' +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/network3 b/etc/rc.d/network3 new file mode 100644 index 0000000000..7c372e0f54 --- /dev/null +++ b/etc/rc.d/network3 @@ -0,0 +1,37 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/network3,v 1.138 2003/06/29 05:15:57 mtm Exp $ +# $DragonFly: src/etc/rc.d/Attic/network3,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: network3 +# REQUIRE: localdaemons +# BEFORE: securelevel +# KEYWORD: DragonFly FreeBSD nostart + +. /etc/rc.subr + +load_rc_config 'XXX' + +echo -n 'Additional TCP options:' +case ${log_in_vain} in +[Nn][Oo] | '') + log_in_vain=0 + ;; +[Yy][Ee][Ss]) + log_in_vain=1 + ;; +[0-9]*) + ;; +*) + echo " invalid log_in_vain setting: ${log_in_vain}" + log_in_vain=0 + ;; +esac + +[ "${log_in_vain}" -ne 0 ] && ( + echo -n " log_in_vain=${log_in_vain}" + sysctl net.inet.tcp.log_in_vain="${log_in_vain}" >/dev/null + sysctl net.inet.udp.log_in_vain="${log_in_vain}" >/dev/null +) +echo '.' diff --git a/etc/rc.d/network_ipv6 b/etc/rc.d/network_ipv6 new file mode 100644 index 0000000000..51101c5bc8 --- /dev/null +++ b/etc/rc.d/network_ipv6 @@ -0,0 +1,127 @@ +#!/bin/sh +# +# Copyright (c) 2000 The KAME Project +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD: src/etc/rc.d/network_ipv6,v 1.35 2003/06/29 05:15:57 mtm Exp $ +# From: src/etc/rc.network6,v 1.29 2002/04/06 15:15:43 +# $DragonFly: src/etc/rc.d/network_ipv6,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: network_ipv6 +# REQUIRE: routing +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr +. /etc/network.subr + +name="network_ipv6" +rcvar=`set_rcvar ipv6` +start_cmd="network_ipv6_start" + +network_ipv6_start() +{ + # disallow "internal" addresses to appear on the wire + route add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject + route add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject + + case ${ipv6_network_interfaces} in + [Aa][Uu][Tt][Oo]) + # Get a list of network interfaces + ipv6_network_interfaces="`ifconfig -l`" + ;; + [Nn][Oo][Nn][Ee]) + ipv6_network_interfaces='' + ;; + esac + + if checkyesno ipv6_gateway_enable; then + # act as a router + ${SYSCTL_W} net.inet6.ip6.forwarding=1 + ${SYSCTL_W} net.inet6.ip6.accept_rtadv=0 + + # wait for DAD + for i in $ipv6_network_interfaces; do + ifconfig $i up + done + sleep `${SYSCTL_N} net.inet6.ip6.dad_count` + sleep 1 + else + # act as endhost - start with manual configuration + # Setup of net.inet6.ip6.accept_rtadv is done later by + # network6_interface_setup. + ${SYSCTL_W} net.inet6.ip6.forwarding=0 + fi + + if [ -n "${ipv6_network_interfaces}" ]; then + # Setup the interfaces + network6_interface_setup $ipv6_network_interfaces + + # wait for DAD's completion (for global addrs) + sleep `${SYSCTL_N} net.inet6.ip6.dad_count` + sleep 1 + fi + + # Filter out interfaces on which IPv6 initialization failed. + if checkyesno ipv6_gateway_enable; then + ipv6_working_interfaces="" + for i in ${ipv6_network_interfaces}; do + laddr=`network6_getladdr $i exclude_tentative` + case ${laddr} in + '') + ;; + *) + ipv6_working_interfaces="$i \ + ${ipv6_working_interfaces}" + ;; + esac + done + ipv6_network_interfaces=${ipv6_working_interfaces} + fi + + # Setup IPv6 to IPv4 mapping + network6_stf_setup + + # Install the "default interface" to kernel, which will be used + # as the default route when there's no router. + network6_default_interface_setup + + # Setup static routes + network6_static_routes_setup + + # Setup faith + network6_faith_setup + + # Support for IPv4 address tacked onto an IPv6 address + if checkyesno ipv6_ipv4mapping; then + echo 'IPv4 mapped IPv6 address support=YES' + ${SYSCTL_W} net.inet6.ip6.v6only=0 >/dev/null + else + echo 'IPv4 mapped IPv6 address support=NO' + ${SYSCTL_W} net.inet6.ip6.v6only=1 >/dev/null + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/newsyslog b/etc/rc.d/newsyslog new file mode 100644 index 0000000000..8d071f053f --- /dev/null +++ b/etc/rc.d/newsyslog @@ -0,0 +1,28 @@ +#!/bin/sh +# +# $NetBSD: newsyslog,v 1.5 2002/03/24 15:51:26 lukem Exp $ +# $FreeBSD: src/etc/rc.d/newsyslog,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/newsyslog,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: newsyslog +# REQUIRE: mountcritremote sysdb +# BEFORE: syslogd SERVERS + +. /etc/rc.subr + +name="newsyslog" +rcvar=$name +required_files="/etc/newsyslog.conf" +start_cmd="newsyslog_start" +stop_cmd=":" + +newsyslog_start() +{ + echo -n "Trimming log files:" + /usr/bin/newsyslog -s $rc_flags + echo " done." +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/nfsclient b/etc/rc.d/nfsclient new file mode 100644 index 0000000000..96f024e0be --- /dev/null +++ b/etc/rc.d/nfsclient @@ -0,0 +1,62 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/nfsclient,v 1.3 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/nfsclient,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: nfsclient +# REQUIRE: NETWORKING mountcritremote rpcbind +# KEYWORD: DragonFly 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() +{ + # + # Run nfsiod and set some nfs client related sysctls + # + if [ -n "${nfs_client_flags}" ]; then + echo -n ' nfsiod' + nfsiod ${nfs_client_flags} + fi + + if [ -n "${nfs_access_cache}" ]; then + echo "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 new file mode 100644 index 0000000000..ed0c535491 --- /dev/null +++ b/etc/rc.d/nfsd @@ -0,0 +1,62 @@ +#!/bin/sh +# +# $NetBSD: nfsd,v 1.4 2001/06/16 06:13:10 lukem Exp $ +# $FreeBSD: src/etc/rc.d/nfsd,v 1.9 2003/01/24 00:37:52 mtm Exp $ +# $DragonFly: src/etc/rc.d/nfsd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: nfsd +# REQUIRE: mountd +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="nfsd" +rcvar=`set_rcvar nfs_server` +command="/usr/sbin/${name}" + +load_rc_config $name +case ${OSTYPE} in +DragonFly) + command_args="${nfs_server_flags}" + start_precmd="nfsd_precmd" + sig_stop="USR1" + ;; + +FreeBSD) + command_args="${nfs_server_flags}" + start_precmd="nfsd_precmd" + sig_stop="USR1" + ;; +NetBSD) + 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 rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + then + force_depend rpcbind || return 1 + fi + + if ! checkyesno mountd_enable && \ + ! /etc/rc.d/mountd forcestatus 1>/dev/null 2>&1 + then + force_depend mountd || return 1 + fi + + if checkyesno nfs_reserved_port_only; then + echo 'NFS on reserved port only=YES' + sysctl vfs.nfsrv.nfs_privport=1 > /dev/null + fi + return 0 +} + +run_rc_command "$1" diff --git a/etc/rc.d/nfslocking b/etc/rc.d/nfslocking new file mode 100644 index 0000000000..7b3d1ded4c --- /dev/null +++ b/etc/rc.d/nfslocking @@ -0,0 +1,53 @@ +#!/bin/sh +# +# $NetBSD: nfslocking,v 1.6 2002/03/24 15:52:41 lukem Exp $ +# $FreeBSD: src/etc/rc.d/nfslocking,v 1.4 2003/01/20 18:57:16 mtm Exp $ +# $DragonFly: src/etc/rc.d/nfslocking,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: nfslocking +# REQUIRE: nfsserver nfsclient nfsd +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +arg=$1 + +case ${OSTYPE} in +DragonFly) + RCVAR_SERVER="nfs_server_enable" + RCVAR_CLIENT="nfs_client_enable" + RCVAR_STATD="rpc_statd_enable" + RCVAR_LOCKD="rpc_lockd_enable" + ;; +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=${RCVAR_STATD} +command="/usr/sbin/rpc.${name}" +load_rc_config $name +run_rc_command "$arg" + +name="lockd" +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 0000000000..5389cdfce1 --- /dev/null +++ b/etc/rc.d/nfsserver @@ -0,0 +1,31 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/nfsserver,v 1.2 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/nfsserver,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: nfsserver +# REQUIRE: NETWORKING mountcritremote +# KEYWORD: DragonFly 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/nisdomain b/etc/rc.d/nisdomain new file mode 100644 index 0000000000..34850c7870 --- /dev/null +++ b/etc/rc.d/nisdomain @@ -0,0 +1,120 @@ +#!/bin/sh +# +# Copyright (c) 1993 - 2003 The FreeBSD Project. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD: src/etc/rc.d/nisdomain,v 1.1 2003/04/18 17:51:54 mtm Exp $ +# $DragonFly: src/etc/rc.d/nisdomain,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: nisdomain +# REQUIRE: SERVERS rpcbind +# BEFORE: ypbind ypserv ypxfrd +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="nisdomain" +start_cmd="nisdomain_start" +stop_cmd=":" + +convert_host_conf() +{ + host_conf=$1; shift; + nsswitch_conf=$1; shift; + awk ' \ + /^[:blank:]*#/ { next } \ + /(hosts|local|file)/ { nsswitch[c] = "files"; c++; next } \ + /(dns|bind)/ { nsswitch[c] = "dns"; c++; next } \ + /nis/ { nsswitch[c] = "nis"; c++; next } \ + { printf "Warning: unrecognized line [%s]", $0 > "/dev/stderr" } \ + END { \ + printf "hosts: "; \ + for (i in nsswitch) printf "%s ", nsswitch[i]; \ + printf "\n"; \ + }' < $host_conf > $nsswitch_conf +} + +generate_host_conf() +{ + nsswitch_conf=$1; shift; + host_conf=$1; shift; + + awk ' +BEGIN { + xlat["files"] = "hosts"; + xlat["dns"] = "bind"; + xlat["nis"] = "nis"; + cont = 0; +} +sub(/^[\t ]*hosts:/, "") || cont { + if (!cont) + srcs = "" + sub(/#.*/, "") + gsub(/[][]/, " & ") + cont = sub(/\\$/, "") + srcs = srcs " " $0 +} +END { + print "# Auto-generated from nsswitch.conf, do not edit" + ns = split(srcs, s) + for (n = 1; n <= ns; ++n) { + if (s[n] in xlat) + print xlat[s[n]] + } +} +' <$nsswitch_conf >$host_conf +} + +nisdomain_start() +{ + # Generate host.conf for compatibility + # + if [ -f "/etc/nsswitch.conf" ]; then + echo 'Generating host.conf.' + generate_host_conf /etc/nsswitch.conf /etc/host.conf + fi + + # Convert host.conf to nsswitch.conf if necessary + # + if [ -f "/etc/host.conf" -a ! -f "/etc/nsswitch.conf" ]; then + echo '' + echo 'Warning: /etc/host.conf is no longer used' + echo ' /etc/nsswitch.conf will be created for you' + convert_host_conf /etc/host.conf /etc/nsswitch.conf + fi + + # Set the domainname if we're using NIS + # + case ${nisdomainname} in + [Nn][Oo]|'') + ;; + *) + domainname ${nisdomainname} + echo "Setting NIS domain: `/bin/domainname`." + ;; + esac +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ntpd b/etc/rc.d/ntpd new file mode 100644 index 0000000000..883e59dc30 --- /dev/null +++ b/etc/rc.d/ntpd @@ -0,0 +1,54 @@ +#!/bin/sh +# +# $NetBSD: ntpd,v 1.6 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/ntpd,v 1.5 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/Attic/ntpd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ntpd +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name=ntpd +rcvar=`set_rcvar` +command="/usr/sbin/${name}" +pidfile="/var/run/${name}.pid" +required_files="/etc/ntp.conf" + +case ${OSTYPE} in +NetBSD) + start_precmd="ntpd_precmd" + ;; +esac + +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 new file mode 100644 index 0000000000..4ee3a62ff4 --- /dev/null +++ b/etc/rc.d/ntpdate @@ -0,0 +1,49 @@ +#!/bin/sh +# +# $NetBSD: ntpdate,v 1.8 2002/03/22 04:16:39 lukem Exp $ +# $FreeBSD: src/etc/rc.d/ntpdate,v 1.4 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/Attic/ntpdate,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ntpdate +# REQUIRE: NETWORKING syslogd +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="ntpdate" +rcvar=`set_rcvar` + +case ${OSTYPE} in +DragonFly) + command="/usr/sbin/${name}" + command_args=">/dev/null 2>&1" + pidfile="/var/run/${name}.pid" + ;; +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} + ' /dev/null && echo -n ' memory' ;; *) - mib=${var%=*} - val=${var#*=} - - if current_value=`sysctl -n ${mib} 2>/dev/null`; then - case ${current_value} in - ${val}) ;; - *) - sysctl ${var} - ;; - esac - else - case ${1} in - last) - echo "Warning: sysctl ${mib} does not exist" - ;; - esac - fi + pccardc pccardmem ${pccard_mem} 1>/dev/null && echo -n ' memory' ;; esac - done < /etc/sysctl.conf -fi + + if [ -n "${pccard_beep}" ]; then + pccardc beep ${pccard_beep} && echo -n ' beep' + fi + + if [ -n "${pccard_conf}" ]; then + pccardd_flags="${pccardd_flags} -f ${pccard_conf}" + fi + + pccardd ${pccardd_flags} && echo -n ' pccardd' + echo '.' + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/pcvt b/etc/rc.d/pcvt new file mode 100644 index 0000000000..e3fa4d8f6d --- /dev/null +++ b/etc/rc.d/pcvt @@ -0,0 +1,234 @@ +#!/bin/sh - +# +# Copyright (c) 2002 The FreeBSD Project +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD: src/etc/rc.d/pcvt,v 1.3 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/Attic/pcvt,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: pcvt +# REQUIRE: LOGIN +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="pcvt" +start_precmd="pcvt_precmd" +start_cmd="pcvt_start" + +pcvt_precmd() +{ + if [ -x /usr/sbin/ispcvt ]; then + /usr/sbin/ispcvt -d /dev/ttyv0 && return 0 + fi + return 1 +} + +pcvt_echo() +{ + if checkyesno pcvt_verbose; then + echo $1 "$2" + fi +} + +pcvt_start() +{ + # path for pcvt's EGA/VGA download fonts + FONTP=/usr/share/misc/pcvtfonts + + if checkyesno pcvt_verbose; then + echo "Configuring pcvt console driver:" + else + echo "-n" "Configuring pcvt" + fi + + # video adapter type + + adapter=`/usr/sbin/scon -d /dev/ttyv0 -a` + + pcvt_echo "-n" " video adapter type is $adapter, " + + # monitor type (mono/color) + + monitor=`/usr/sbin/scon -d /dev/ttyv0 -m` + + pcvt_echo "" "monitor type is $monitor" + + # load fonts into VGA + + if [ $adapter = VGA ]; then + pcvt_echo "-n" " loading fonts: 8x16:0," + loadfont -d /dev/ttyv0 -c0 -f $FONTP/vt220l.816 + + pcvt_echo "-n" "1 " + loadfont -d /dev/ttyv0 -c1 -f $FONTP/vt220h.816 + + pcvt_echo "-n" " 8x14:0," + loadfont -d /dev/ttyv0 -c2 -f $FONTP/vt220l.814 + + pcvt_echo "-n" "1 " + loadfont -d /dev/ttyv0 -c3 -f $FONTP/vt220h.814 + + pcvt_echo "-n" " 8x10:0," + loadfont -d /dev/ttyv0 -c4 -f $FONTP/vt220l.810 + + pcvt_echo "-n" "1 " + loadfont -d /dev/ttyv0 -c5 -f $FONTP/vt220h.810 + + pcvt_echo "-n" " 8x8:0," + loadfont -d /dev/ttyv0 -c6 -f $FONTP/vt220l.808 + + pcvt_echo "" "1 " + loadfont -d /dev/ttyv0 -c7 -f $FONTP/vt220h.808 + + # setting screen sizes + + case ${pcvt_lines} in + 28) + size=-s28 + pcvt_echo "" " switching to 28 lines" + ;; + 40) + size=-s40 + pcvt_echo "" " switching to 40 lines" + ;; + 50) + size=-s50 + pcvt_echo "" " switching to 50 lines" + ;; + *) + size=-s25 + pcvt_echo "" " switching to 25 lines" + ;; + esac + fi + + # use HP extensions to VT220 or plain VT220 ? + + if checkyesno pcvt_hpext; then + emulation=-H + pcvt_echo "" " setting emulation to VT220 with HP extensions" + else + emulation=-V + pcvt_echo "" " setting emulation to VT220" + fi + + # for all screens do + + for device in /dev/ttyv* + do + # set emulation + + /usr/sbin/scon -d$device $size $emulation >/dev/null 2>&1 + if [ $? != 0 ]; then + break 1 + fi + + # set cursor shape + + case ${pcvt_cursorh} in + [Nn][Oo] | '') + ;; + *) + case ${pcvt_cursorl} in + [Nn][Oo] | '') + ;; + *) + /usr/sbin/cursor -d$device -s$pcvt_cursorh -e$pcvt_cursorl + ;; + esac + ;; + esac + + # on monochrome monitor, set color palette to use a higher intensity + + if checkyesno pcvt_monohigh && \ + [ $monitor = MONO -a $adapter = VGA ] + then + /usr/sbin/scon -d$device -p8,60,60,60 + fi + done + + # switch to screen 0 + + pcvt_echo "" " switching to screen 0" + + /usr/sbin/scon -d /dev/ttyv0 + + # screensaver timeout + + case ${pcvt_blanktime} in + [Nn][Oo] | '') + ;; + *) + pcvt_echo "" " setting screensaver timeout to $pcvt_blanktime seconds" + /usr/sbin/scon -d /dev/ttyv0 -t$pcvt_blanktime + ;; + esac + + # national keyboard layout + + case ${pcvt_keymap} in + [Nn][Oo] | '') + ;; + *) + pcvt_echo "" " switching national keyboard layout to $pcvt_keymap" + /usr/sbin/kcon -m $pcvt_keymap + ;; + esac + + # keyboard repeat delay value + + case ${pcvt_keydel} in + [Nn][Oo] | '') + ;; + *) + pcvt_echo "" " setting keyboard delay to $pcvt_keydel" + /usr/sbin/kcon -d$pcvt_keydel + ;; + esac + + # keyboard repeat rate value + + case ${pcvt_keyrate} in + [Nn][Oo] | '') + ;; + *) + pcvt_echo "" " setting keyboard repeat rate to $pcvt_keyrate" + /usr/sbin/kcon -r$pcvt_keyrate + ;; + esac + + # done + + if checkyesno pcvt_verbose; then + echo "Finished configuring pcvt console driver." + else + echo "." + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/poffd b/etc/rc.d/poffd new file mode 100644 index 0000000000..31fcca3997 --- /dev/null +++ b/etc/rc.d/poffd @@ -0,0 +1,19 @@ +#!/bin/sh +# +# $NetBSD: poffd,v 1.1 2001/01/14 15:37:22 minoura Exp $ +# $FreeBSD: src/etc/rc.d/poffd,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/poffd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: poffd +# REQUIRE: DAEMON + +. /etc/rc.subr + +name="poffd" +rcvar=$name +command="/usr/sbin/${name}" +start_precmd="test -c /dev/pow0" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/postfix b/etc/rc.d/postfix new file mode 100644 index 0000000000..96f0c8d0c1 --- /dev/null +++ b/etc/rc.d/postfix @@ -0,0 +1,43 @@ +#!/bin/sh +# +# $NetBSD: postfix,v 1.6 2002/02/12 02:19:27 lukem Exp $ +# $FreeBSD: src/etc/rc.d/postfix,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/postfix,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: mail +# REQUIRE: LOGIN +# we make mail start late, so that things like .forward's are not +# processed until the system is fully operational + +. /etc/rc.subr + +name="postfix" +rcvar=$name +required_files="/etc/${name}/main.cf" +start_precmd="postfix_precmd" +start_cmd="${name} start" +stop_cmd="${name} stop" +reload_cmd="${name} reload" +extra_commands="reload" +spooletcdir="/var/spool/${name}/etc" +required_dirs=$spooletcdir + +postfix_precmd() +{ + # As this is called after the is_running and required_dir checks + # are made in run_rc_command(), we can safely assume ${spooletcdir} + # exists and postfix isn't running at this point (unless forcestart + # is used). + # + + for f in localtime resolv.conf services; do + if [ -f /etc/$f ]; then + cmp -s /etc/$f ${spooletcdir}/$f || \ + cp -p /etc/$f ${spooletcdir}/$f + fi + done +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ppp b/etc/rc.d/ppp new file mode 100644 index 0000000000..ca6e181612 --- /dev/null +++ b/etc/rc.d/ppp @@ -0,0 +1,69 @@ +#!/bin/sh +# +# $NetBSD: ppp,v 1.6 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/ppp,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/ppp,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ppp +# REQUIRE: mountcritremote syslogd +# BEFORE: SERVERS +# +# Note that this means that syslogd will not be listening on +# any PPP addresses. This is considered a feature. +# + +. /etc/rc.subr + +name="ppp" +start_cmd="ppp_start" +stop_cmd="ppp_stop" +sig_stop="-INT" +sig_hup="-HUP" +hup_cmd="ppp_hup" +extra_commands="hup" + +ppp_start() +{ + # /etc/ppp/peers and $ppp_peers contain boot configuration + # information for pppd. each value in $ppp_peers that has a + # file in /etc/ppp/peers of the same name, will be run as + # `pppd call '. + # + if [ -n "$ppp_peers" ]; then + set -- $ppp_peers + echo -n "Starting pppd:" + while [ $# -ge 1 ]; do + peer=$1 + shift + if [ -f /etc/ppp/peers/$peer ]; then + pppd call $peer + echo -n " $peer" + fi + done + echo "." + fi +} + +ppp_hup() +{ + pids="`check_process pppd`" + if [ -n "$pids" ]; then + for pid in $pids; do + kill $sig_hup $pid + done + fi +} + +ppp_stop() +{ + pids="`check_process pppd`" + if [ -n "$pids" ]; then + for pid in $pids; do + kill $sig_stop $pid + done + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ppp-user b/etc/rc.d/ppp-user new file mode 100644 index 0000000000..3de41c0d73 --- /dev/null +++ b/etc/rc.d/ppp-user @@ -0,0 +1,49 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/ppp-user,v 1.4 2003/04/18 17:55:05 mtm Exp $ +# $DragonFly: src/etc/rc.d/ppp-user,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ppp-user +# REQUIRE: netif isdnd +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="ppp" +rcvar="ppp_enable" +start_cmd="ppp_start" +stop_cmd=":" + +ppp_start() +{ + # Establish ppp mode. + # + if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \ + -a "${ppp_mode}" != "dedicated" \ + -a "${ppp_mode}" != "background" ]; then + ppp_mode="auto" + fi + + ppp_command="/usr/sbin/ppp -quiet -${ppp_mode}" + + # Switch on NAT mode? + # + case ${ppp_nat} in + [Yy][Ee][Ss]) + ppp_command="${ppp_command} -nat" + ;; + esac + + ppp_command="${ppp_command} ${ppp_profile}" + + echo "Starting ppp as \"${ppp_user}\"" + su -m ${ppp_user} -c "exec ${ppp_command}" + + # Re-Sync ipfilter so it picks up any new network interfaces + # + /etc/rc.d/ipfilter resync +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/pppoed b/etc/rc.d/pppoed new file mode 100644 index 0000000000..0051a451df --- /dev/null +++ b/etc/rc.d/pppoed @@ -0,0 +1,32 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/pppoed,v 1.1 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/pppoed,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: pppoed +# REQUIRE: NETWORKING +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="pppoed" +rcvar="`set_rcvar`" +start_cmd="pppoed_start" +# XXX stop_cmd will not be straightforward +stop_cmd=":" + +pppoed_start() +{ + if [ -n "${pppoed_provider}" ]; then + pppoed_flags="${pppoed_flags} -p ${pppoed_provider}" + fi + echo 'Starting pppoed' + _opts=$-; set -f + /usr/libexec/pppoed ${pppoed_flags} ${pppoed_interface} + set +f; set -${_opts} +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/pwcheck b/etc/rc.d/pwcheck new file mode 100644 index 0000000000..794458694a --- /dev/null +++ b/etc/rc.d/pwcheck @@ -0,0 +1,30 @@ +#!/bin/sh +# +# $NetBSD: pwcheck,v 1.4 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/pwcheck,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/pwcheck,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: pwcheck +# REQUIRE: mountcritremote syslogd +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="pwcheck" +start_cmd="pwcheck_start" +stop_cmd=":" + +pwcheck_start() +{ + # check the password temp/lock file + # + if [ -f /etc/ptmp ]; then + logger -s -p auth.err \ + "password file may be incorrect -- /etc/ptmp exists" + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/quota b/etc/rc.d/quota new file mode 100644 index 0000000000..0c6de5f21b --- /dev/null +++ b/etc/rc.d/quota @@ -0,0 +1,36 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/quota,v 1.3 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/quota,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# Enable/Check the quotas (must be after ypbind if using NIS) +# + +# PROVIDE: quota +# REQUIRE: mountcritremote +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="quota" +rcvar="enable_quotas" +start_cmd="quota_start" +stop_cmd="/usr/sbin/quotaoff -a" + +quota_start() +{ + if checkyesno check_quotas; then + echo -n 'Checking quotas:' + quotacheck -a + echo ' done.' + fi + + echo -n 'Enabling quotas:' + quotaon -a + echo ' done.' +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/racoon b/etc/rc.d/racoon new file mode 100644 index 0000000000..441024f28c --- /dev/null +++ b/etc/rc.d/racoon @@ -0,0 +1,21 @@ +#!/bin/sh +# +# $NetBSD: racoon,v 1.3 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/racoon,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/racoon,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ike +# REQUIRE: isdnd kdc ppp +# BEFORE: SERVERS + +. /etc/rc.subr + +name="racoon" +rcvar=$name +command="/usr/sbin/${name}" +pidfile="/var/run/${name}.pid" +required_files="/etc/racoon/racoon.conf" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/random b/etc/rc.d/random new file mode 100644 index 0000000000..dd045e474e --- /dev/null +++ b/etc/rc.d/random @@ -0,0 +1,94 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/random,v 1.3 2003/04/18 17:55:05 mtm Exp $ +# $DragonFly: src/etc/rc.d/random,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: random +# REQUIRE: diskless mountcritlocal initrandom +# BEFORE: netif +# KEYWORD: DragonFly FreeBSD shutdown + +. /etc/rc.subr + +name="random" +start_cmd="random_start" +stop_cmd="random_stop" + +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 +} + +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 new file mode 100644 index 0000000000..ea52b9aa36 --- /dev/null +++ b/etc/rc.d/rarpd @@ -0,0 +1,22 @@ +#!/bin/sh +# +# $NetBSD: rarpd,v 1.5 2002/03/22 04:33:59 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/rarpd,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/rarpd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: rarpd +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="rarpd" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" +pidfile="/var/run/${name}.pid" +required_files="/etc/ethers" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/rbootd b/etc/rc.d/rbootd new file mode 100644 index 0000000000..814f870765 --- /dev/null +++ b/etc/rc.d/rbootd @@ -0,0 +1,22 @@ +#!/bin/sh +# +# $NetBSD: rbootd,v 1.6 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/rbootd,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/rbootd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: rbootd +# REQUIRE: DAEMON +# BEFORE: LOGIN + +. /etc/rc.subr + +name="rbootd" +rcvar=$name +command="/usr/sbin/${name}" +pidfile="/var/run/${name}.pid" +required_files="/etc/${name}.conf" +extra_commands="reload" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/rcconf.sh b/etc/rc.d/rcconf.sh new file mode 100644 index 0000000000..5cec3889a9 --- /dev/null +++ b/etc/rc.d/rcconf.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/rcconf.sh,v 1.2 2003/01/25 20:02:35 mtm Exp $ +# $DragonFly: src/etc/rc.d/rcconf.sh,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: rcconf +# REQUIRE: initdiskless +# BEFORE: disks initrandom +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +echo "Loading configuration files." +load_rc_config 'XXX' diff --git a/etc/rc.d/root b/etc/rc.d/root new file mode 100644 index 0000000000..509230ce4a --- /dev/null +++ b/etc/rc.d/root @@ -0,0 +1,77 @@ +#!/bin/sh +# +# $NetBSD: root,v 1.2 2000/05/13 08:45:09 lukem Exp $ +# $FreeBSD: src/etc/rc.d/root,v 1.5 2002/10/31 02:06:05 gordon Exp $ +# $DragonFly: src/etc/rc.d/root,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: root +# REQUIRE: fsck +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="root" +start_cmd="root_start" +stop_cmd=":" + +root_start() +{ + case ${OSTYPE} in + DragonFly) + # 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. + if [ -e /boot/nextkernel ]; then + rm -f /boot/nextkernel + fi + ;; + + 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. + if [ -e /boot/nextkernel ]; then + rm -f /boot/nextkernel + fi + ;; + NetBSD) + umount -a >/dev/null 2>&1 + mount / + rm -f /fastboot + ;; + esac +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/route6d b/etc/rc.d/route6d new file mode 100644 index 0000000000..87315fcfa9 --- /dev/null +++ b/etc/rc.d/route6d @@ -0,0 +1,41 @@ +#!/bin/sh +# +# $NetBSD: route6d,v 1.5 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/route6d,v 1.5 2003/01/25 23:14:08 mtm Exp $ +# $DragonFly: src/etc/rc.d/route6d,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: route6d +# REQUIRE: network_ipv6 +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="route6d" + +# 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 ${OSTYPE} in +DragonFly) + rcvar="ipv6_router_enable" + command="${ipv6_router:-/usr/sbin/${name}}" + eval ${name}_flags=\"${ipv6_router_flags}\" + ;; + +FreeBSD) + rcvar="ipv6_router_enable" + command="${ipv6_router:-/usr/sbin/${name}}" + 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 new file mode 100644 index 0000000000..d45028724b --- /dev/null +++ b/etc/rc.d/routed @@ -0,0 +1,52 @@ +#!/bin/sh +# +# $NetBSD: routed,v 1.7 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/routed,v 1.6 2003/06/29 05:15:57 mtm Exp $ +# $DragonFly: src/etc/rc.d/routed,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: routed +# REQUIRE: netif routing +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="routed" + +# 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 ${OSTYPE} in +DragonFly) + rcvar="router_enable" + command="${router:-/sbin/${name}}" + eval ${name}_flags=${router_flags} + start_precmd= + ;; + + +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() +{ + if checkyesno gated && checkyesno routed; then + warn "gated and routed both requested to be run: only running gated." + return 1 + fi +} + +run_rc_command "$1" diff --git a/etc/rc.d/routing b/etc/rc.d/routing new file mode 100644 index 0000000000..eafa240548 --- /dev/null +++ b/etc/rc.d/routing @@ -0,0 +1,158 @@ +#!/bin/sh +# +# Configure routing and miscellaneous network tunables +# +# $FreeBSD: src/etc/rc.d/routing,v 1.138 2003/06/29 17:59:09 mtm Exp $ +# $DragonFly: src/etc/rc.d/routing,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: routing +# REQUIRE: netif ppp-user +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="routing" +start_cmd="routing_start" +stop_cmd="routing_stop" +extra_commands="options static" +static_cmd="static_start" +options_cmd="options_start" + +routing_start() +{ + static_start + options_start +} + +routing_stop() +{ + route -n flush +} + +static_start() +{ + case ${defaultrouter} in + [Nn][Oo] | '') + ;; + *) + static_routes="default ${static_routes}" + route_default="default ${defaultrouter}" + ;; + esac + + # Setup static routes. This should be done before router discovery. + # + if [ -n "${static_routes}" ]; then + for i in ${static_routes}; do + eval route_args=\$route_${i} + route add ${route_args} + done + fi +} + +options_start() +{ + echo -n 'Additional routing options:' + case ${tcp_extensions} in + [Yy][Ee][Ss] | '') + ;; + *) + echo -n ' tcp extensions=NO' + sysctl net.inet.tcp.rfc1323=0 >/dev/null + ;; + esac + + case ${icmp_bmcastecho} in + [Yy][Ee][Ss]) + echo -n ' broadcast ping responses=YES' + sysctl net.inet.icmp.bmcastecho=1 >/dev/null + ;; + esac + + case ${icmp_drop_redirect} in + [Yy][Ee][Ss]) + echo -n ' ignore ICMP redirect=YES' + sysctl net.inet.icmp.drop_redirect=1 >/dev/null + ;; + esac + + case ${icmp_log_redirect} in + [Yy][Ee][Ss]) + echo -n ' log ICMP redirect=YES' + sysctl net.inet.icmp.log_redirect=1 >/dev/null + ;; + esac + + case ${gateway_enable} in + [Yy][Ee][Ss]) + echo -n ' IP gateway=YES' + sysctl net.inet.ip.forwarding=1 >/dev/null + ;; + esac + + case ${forward_sourceroute} in + [Yy][Ee][Ss]) + echo -n ' do source routing=YES' + sysctl net.inet.ip.sourceroute=1 >/dev/null + ;; + esac + + case ${accept_sourceroute} in + [Yy][Ee][Ss]) + echo -n ' accept source routing=YES' + sysctl net.inet.ip.accept_sourceroute=1 >/dev/null + ;; + esac + + case ${tcp_keepalive} in + [Nn][Oo]) + echo -n ' TCP keepalive=NO' + sysctl net.inet.tcp.always_keepalive=0 >/dev/null + ;; + esac + + case ${tcp_drop_synfin} in + [Yy][Ee][Ss]) + echo -n ' drop SYN+FIN packets=YES' + sysctl net.inet.tcp.drop_synfin=1 >/dev/null + ;; + esac + + case ${ipxgateway_enable} in + [Yy][Ee][Ss]) + echo -n ' IPX gateway=YES' + sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null + ;; + esac + + case ${arpproxy_all} in + [Yy][Ee][Ss]) + echo -n ' ARP proxyall=YES' + sysctl net.link.ether.inet.proxyall=1 >/dev/null + ;; + esac + + case ${ip_portrange_first} in + [Nn][Oo] | '') + ;; + *) + echo -n " ip_portrange_first=$ip_portrange_first" + sysctl net.inet.ip.portrange.first=$ip_portrange_first >/dev/null + ;; + esac + + case ${ip_portrange_last} in + [Nn][Oo] | '') + ;; + *) + echo -n " ip_portrange_last=$ip_portrange_last" + sysctl net.inet.ip.portrange.last=$ip_portrange_last >/dev/null + ;; + esac + + echo '.' +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/rpcbind b/etc/rc.d/rpcbind new file mode 100644 index 0000000000..df117b52c5 --- /dev/null +++ b/etc/rc.d/rpcbind @@ -0,0 +1,25 @@ +#!/bin/sh +# +# $NetBSD: rpcbind,v 1.6 2002/01/31 01:26:06 lukem Exp $ +# $FreeBSD: src/etc/rc.d/rpcbind,v 1.6 2002/09/06 16:18:05 gordon Exp $ +# $DragonFly: src/etc/rc.d/rpcbind,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: rpcbind +# REQUIRE: NETWORKING ntpdate syslogd named ppp +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="rpcbind" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" + +case ${OSTYPE} in +NetBSD) + pidfile="/var/run/${name}.pid" + ;; +esac + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/rtadvd b/etc/rc.d/rtadvd new file mode 100644 index 0000000000..4ab160ed7b --- /dev/null +++ b/etc/rc.d/rtadvd @@ -0,0 +1,108 @@ +#!/bin/sh +# +# $NetBSD: rtadvd,v 1.5 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/rtadvd,v 1.5 2003/01/24 00:37:52 mtm Exp $ +# $DragonFly: src/etc/rc.d/rtadvd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: rtadvd +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="rtadvd" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" +start_precmd="rtadvd_precmd" + +rtadvd_precmd() +{ + case ${OSTYPE} in + DragonFly) + IS_GATEWAY="checkyesno ipv6_gateway_enable" + ;; + FreeBSD) + IS_GATEWAY="checkyesno ipv6_gateway_enable" + ;; + NetBSD) + IS_GATEWAY="eval [ \"$ip6mode\" = \"router\" ]" + ;; + esac + if ! ${IS_GATEWAY}; then + warn \ + "${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 ${OSTYPE} in + DragonFly) + # 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_interf + ;; + 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 +run_rc_command "$1" diff --git a/etc/rc.d/rtsold b/etc/rc.d/rtsold new file mode 100644 index 0000000000..81ce99f3eb --- /dev/null +++ b/etc/rc.d/rtsold @@ -0,0 +1,28 @@ +#!/bin/sh +# +# $NetBSD: rtsold,v 1.5 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/rtsold,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/rtsold,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: rtsold +# REQUIRE: DAEMON +# BEFORE: LOGIN + +. /etc/rc.subr + +name="rtsold" +rcvar=$name +command="/usr/sbin/${name}" +start_precmd="rtsold_precmd" + +rtsold_precmd() +{ + if [ "$ip6mode" != "autohost" ]; then + warn "\$ip6mode must be set to 'autohost' to use ${name}." + return 1 + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/rwho b/etc/rc.d/rwho new file mode 100644 index 0000000000..12a3533408 --- /dev/null +++ b/etc/rc.d/rwho @@ -0,0 +1,20 @@ +#!/bin/sh +# +# $NetBSD: rwho,v 1.5 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/rwho,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/rwho,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: rwho +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="rwhod" +rcvar="`set_rcvar`" +command="/usr/sbin/${name}" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/savecore b/etc/rc.d/savecore new file mode 100644 index 0000000000..1cff400910 --- /dev/null +++ b/etc/rc.d/savecore @@ -0,0 +1,98 @@ +#!/bin/sh +# +# $NetBSD: savecore,v 1.5 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/savecore,v 1.3 2002/09/06 16:18:05 gordon Exp $ +# $DragonFly: src/etc/rc.d/savecore,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: savecore +# REQUIRE: syslogd +# BEFORE: SERVERS +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="savecore" +start_cmd="savecore_start" +start_precmd="savecore_prestart" +stop_cmd=":" + +case ${OSTYPE} in +NetBSD) + rcvar=$name + ;; +esac + +savecore_prestart() +{ + # ${DUMPDIR} should be a directory or a symbolic link + # to the crash directory if core dumps are to be saved. + # + DUMPDIR="${dumpdir:-/var/crash}" + + case ${OSTYPE} in + DragonFly) + # Quit if we have no dumb 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 + ;; + + 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} ${DUMPDIR} +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/screenblank b/etc/rc.d/screenblank new file mode 100644 index 0000000000..76f6d55d93 --- /dev/null +++ b/etc/rc.d/screenblank @@ -0,0 +1,20 @@ +#!/bin/sh +# +# $NetBSD: screenblank,v 1.5 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/screenblank,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/screenblank,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: screenblank +# REQUIRE: DAEMON +# BEFORE: LOGIN + +. /etc/rc.subr + +name="screenblank" +rcvar=$name +command="/usr/sbin/${name}" +pidfile="/var/run/${name}.pid" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/securelevel b/etc/rc.d/securelevel new file mode 100644 index 0000000000..021c57dbcb --- /dev/null +++ b/etc/rc.d/securelevel @@ -0,0 +1,70 @@ +#!/bin/sh +# +# $NetBSD: securelevel,v 1.4 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/securelevel,v 1.6 2003/05/05 15:38:41 mtm Exp $ +# $DragonFly: src/etc/rc.d/securelevel,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: securelevel +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="securelevel" +start_cmd="securelevel_start" +stop_cmd=":" + +securelevel_start() +{ + # Last chance to set sysctl variables that failed the first time. + # + /etc/rc.d/sysctl lastload + + case ${OSTYPE} in + DragonFly) + 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 + ;; + + 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 + ;; + esac +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/sendmail b/etc/rc.d/sendmail new file mode 100644 index 0000000000..9359f255f4 --- /dev/null +++ b/etc/rc.d/sendmail @@ -0,0 +1,147 @@ +#!/bin/sh +# +# $NetBSD: sendmail,v 1.14 2002/02/12 01:26:36 lukem Exp $ +# $FreeBSD: src/etc/rc.d/sendmail,v 1.7 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/sendmail,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: mail +# REQUIRE: LOGIN +# KEYWORD: DragonFly FreeBSD NetBSD +# we make mail start late, so that things like .forward's are not +# processed until the system is fully operational + +# 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=`set_rcvar` +required_files="/etc/mail/${name}.cf" + +case ${OSTYPE} in +DragonFly) + command=${sendmail_program:-/usr/sbin/sendmail} + pidfile=${sendmail_pidfile:-/var/run/sendmail.pid} + load_rc_config $name + case ${sendmail_enable} in + [Nn][Oo][Nn][Ee]) + sendmail_enable="NO" + sendmail_submit_enable="NO" + sendmail_outbound_enable="NO" + sendmail_msp_queue_enable="NO" + ;; + esac + ;; + +FreeBSD) + command=${sendmail_program:-/usr/sbin/sendmail} + pidfile=${sendmail_pidfile:-/var/run/sendmail.pid} + + load_rc_config $name + + case ${sendmail_enable} in + [Nn][Oo][Nn][Ee]) + sendmail_enable="NO" + sendmail_submit_enable="NO" + sendmail_outbound_enable="NO" + sendmail_msp_queue_enable="NO" + ;; + esac + ;; +NetBSD) + command="/usr/sbin/${name}" + pidfile="/var/run/${name}.pid" + start_precmd="sendmail_precmd" + + load_rc_config $name + ;; +esac + +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 ${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." + return 1 + fi + fi + + # check modifications on /etc/mail/aliases + if [ -f "/etc/mail/aliases.db" ]; then + if [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then + echo \ + "${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating" + /usr/bin/newaliases + fi + else + echo \ + "${name}: /etc/mail/aliases.db not present, generating" + /usr/bin/newaliases + fi + + # check couple of common db files, too + for f in genericstable virtusertable domaintable mailertable; do + 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 + fi + done +} + +run_rc_command "$1" + +case ${OSTYPE} in +DragonFly) + required_files= + if ! checkyesno sendmail_enable; then + name="sendmail_submit" + rcvar=`set_rcvar` + start_cmd="${command} ${sendmail_submit_flags}" + run_rc_command "$1" + fi + if ! checkyesno sendmail_outbound_enable; then + name="sendmail_outbound" + rcvar=`set_rcvar` + start_cmd="${command} ${sendmail_outbound_flags}" + run_rc_command "$1" + fi + name="sendmail_clientmqueue" + rcvar="sendmail_msp_queue_enable" + start_cmd="${command} ${sendmail_msp_queue_flags}" + pidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}" + required_files="/etc/mail/submit.cf" + run_rc_command "$1" + ;; +FreeBSD) + required_files= + + if ! checkyesno sendmail_enable; then + name="sendmail_submit" + rcvar=`set_rcvar` + start_cmd="${command} ${sendmail_submit_flags}" + run_rc_command "$1" + fi + + if ! checkyesno sendmail_outbound_enable; then + name="sendmail_outbound" + rcvar=`set_rcvar` + start_cmd="${command} ${sendmail_outbound_flags}" + run_rc_command "$1" + fi + + name="sendmail_clientmqueue" + rcvar="sendmail_msp_queue_enable" + start_cmd="${command} ${sendmail_msp_queue_flags}" + pidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}" + required_files="/etc/mail/submit.cf" + run_rc_command "$1" + ;; +esac diff --git a/etc/rc.serial b/etc/rc.d/serial similarity index 89% rename from etc/rc.serial rename to etc/rc.d/serial index 2d66b3ba42..becae67e91 100644 --- a/etc/rc.serial +++ b/etc/rc.d/serial @@ -24,13 +24,17 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD: src/etc/rc.serial,v 1.14.2.5 2002/05/07 07:47:17 sobomax Exp $ -# $DragonFly: src/etc/Attic/rc.serial,v 1.2 2003/06/17 04:24:45 dillon Exp $ +# $FreeBSD: src/etc/rc.d/serial,v 1.20 2003/05/05 03:26:50 bde Exp $ +# $DragonFly: src/etc/rc.d/serial,v 1.1 2003/07/24 06:35:37 dillon Exp $ # +# PROVIDE: serial +# REQUIRE: root +# KEYWORD: DragonFly FreeBSD + # Change some defaults for serial devices. # Standard defaults are: -# dtrwait 300 drainwait 0 +# dtrwait 300 drainwait `sysctl -n kern.drainwait` # initial cflag from = cread cs8 hupcl # initial iflag, lflag and oflag all 0 # speed 9600 @@ -44,10 +48,11 @@ default() { ci=$1; shift # call in device identifier co=$1; shift # call out device identifier + drainwait=`sysctl -n kern.drainwait` for i in $* do - comcontrol /dev/tty${ci}${i} dtrwait 300 drainwait 0 + comcontrol /dev/tty${ci}${i} dtrwait 300 drainwait $drainwait stty < /dev/ttyi${ci}${i} -clocal crtscts hupcl 9600 reprint ^R stty < /dev/ttyl${ci}${i} -clocal -crtscts -hupcl 0 stty < /dev/cuai${co}${i} -clocal crtscts hupcl 9600 reprint ^R @@ -87,9 +92,9 @@ modem() { comcontrol /dev/tty${ci}${i} dtrwait 100 drainwait 180 # Lock crtscts on. # Speed reasonable for V42bis. - stty < /dev/ttyi${ci}${i} crtscts 57600 + stty < /dev/ttyi${ci}${i} crtscts 115200 stty < /dev/ttyl${ci}${i} crtscts - stty < /dev/cuai${co}${i} crtscts 57600 + stty < /dev/cuai${co}${i} crtscts 115200 stty < /dev/cual${co}${i} crtscts done } @@ -148,7 +153,7 @@ terminal() { # modem c c 00 01 02 03 04 05 06 07 # Initialize all ports on a Cyclades-16ye. -# modem c c 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f +# modem c c 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f # Initialize all ports on a Digiboard 8. # modem D D 00 01 02 03 04 05 06 07 diff --git a/etc/rc.d/sppp b/etc/rc.d/sppp new file mode 100644 index 0000000000..94bc6fc4fd --- /dev/null +++ b/etc/rc.d/sppp @@ -0,0 +1,37 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/sppp,v 1.2 2003/04/18 17:55:05 mtm Exp $ +# $DragonFly: src/etc/rc.d/sppp,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: sppp +# REQUIRE: root +# BEFORE: netif +# KEYWORD: DragonFly 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 new file mode 100644 index 0000000000..32448e5715 --- /dev/null +++ b/etc/rc.d/sshd @@ -0,0 +1,75 @@ +#!/bin/sh +# +# $NetBSD: sshd,v 1.18 2002/04/29 08:23:34 lukem Exp $ +# $FreeBSD: src/etc/rc.d/sshd,v 1.3 2003/07/13 01:49:07 mtm Exp $ +# $DragonFly: src/etc/rc.d/sshd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: sshd +# REQUIRE: LOGIN +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="sshd" +rcvar=`set_rcvar` +keygen_cmd="sshd_keygen" +start_precmd="sshd_precmd" +pidfile="/var/run/${name}.pid" +extra_commands="keygen reload" +case ${OSTYPE} in +NetBSD) + command="/usr/sbin/${name}" + required_files="/etc/ssh/sshd_config" + ;; +esac + +sshd_keygen() +{ + ( + 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 + /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' + fi + + 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 + /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' + fi + ) +} + +sshd_precmd() +{ + 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 +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/swap1 b/etc/rc.d/swap1 new file mode 100644 index 0000000000..4e0be4b961 --- /dev/null +++ b/etc/rc.d/swap1 @@ -0,0 +1,56 @@ +#!/bin/sh +# +# $NetBSD: swap1,v 1.8 2002/03/24 15:52:41 lukem Exp $ +# $FreeBSD: src/etc/rc.d/swap1,v 1.3 2002/09/06 16:18:05 gordon Exp $ +# $DragonFly: src/etc/rc.d/swap1,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: localswap +# REQUIRE: disks +# KEYWORD: DragonFly FreeBSD NetBSD shutdown + +. /etc/rc.subr + +name="swap1" + +case ${OSTYPE} in +DragonFly) + start_cmd='swapon -a' + stop_cmd=':' + ;; + +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. +# +swap1_start() +{ + if ! checkyesno no_swap; then + swapctl -A -t blk + fi +} + +# Remove all block-type swap devices +# +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 new file mode 100644 index 0000000000..c48a18e400 --- /dev/null +++ b/etc/rc.d/swap2 @@ -0,0 +1,38 @@ +#!/bin/sh +# +# $NetBSD: swap2,v 1.6 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/swap2,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/swap2,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: nonlocalswap +# REQUIRE: mountcritremote +# BEFORE: DAEMON + +. /etc/rc.subr + +name="swap2" +start_cmd="swap2_start" + +swap2_start() +{ + # "Critical" file systems are now mounted. Go ahead and swap + # to files now, since they will be residing in the critical file + # systems (or, at least, they should be...). + # Check for no swap, and warn about it unless that is desired. + # + swapctl -A -t noblk; + if ! checkyesno no_swap; then + if swapctl -s | grep "no swap devices configured" > /dev/null; + then + warn "No swap space configured!" + fi + fi +} + +# Remove all non-block-type swap devices +# +stop_cmd="swapctl -U -t noblk" + +load_rc_config swap +run_rc_command "$1" diff --git a/etc/rc.d/syscons b/etc/rc.d/syscons new file mode 100644 index 0000000000..5007bd5cbc --- /dev/null +++ b/etc/rc.d/syscons @@ -0,0 +1,202 @@ +#!/bin/sh - +# +# Copyright (c) 2000 The FreeBSD Project +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD: src/etc/rc.d/syscons,v 1.9 2002/09/09 22:40:34 gordon Exp $ +# $DragonFly: src/etc/rc.d/syscons,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: syscons +# REQUIRE: LOGIN usbd +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="syscons" +start_precmd="syscons_precmd" +start_cmd="syscons_start" + +# stdin must be redirected because it might be for a serial console +# +kbddev=/dev/ttyv0 +viddev=/dev/ttyv0 + +syscons_precmd() +{ + if [ -c $kbddev ] && \ + [ -x /usr/sbin/ispcvt ] && \ + ! /usr/sbin/ispcvt + then + return 0 + fi + return 1 +} + +syscons_start() +{ + echo -n 'Configuring syscons:' + + # keymap + # + case ${keymap} in + [Nn][Oo] | '') + ;; + *) + echo -n ' keymap'; kbdcontrol < ${kbddev} -l ${keymap} + ;; + esac + + # keyrate + # + case ${keyrate} in + [Nn][Oo] | '') + ;; + *) + echo -n ' keyrate'; kbdcontrol < ${kbddev} -r ${keyrate} + ;; + esac + + # keybell + # + case ${keybell} in + [Nn][Oo] | '') + ;; + *) + echo -n ' keybell'; kbdcontrol < ${kbddev} -b ${keybell} + ;; + esac + + # change function keys + # + case ${keychange} in + [Nn][Oo] | '') + ;; + *) + echo -n ' keychange' + set - ${keychange} + while [ $# -gt 0 ]; do + kbdcontrol <${kbddev} -f "$1" "$2" + shift; shift + done + ;; + esac + + # cursor type + # + case ${cursor} in + [Nn][Oo] | '') + ;; + *) + echo -n ' cursor'; vidcontrol < ${viddev} -c ${cursor} + ;; + esac + + # screen mapping + # + case ${scrnmap} in + [Nn][Oo] | '') + ;; + *) + echo -n ' scrnmap'; vidcontrol < ${viddev} -l ${scrnmap} + ;; + esac + + # font 8x16 + # + case ${font8x16} in + [Nn][Oo] | '') + ;; + *) + echo -n ' font8x16'; vidcontrol < ${viddev} -f 8x16 ${font8x16} + ;; + esac + + # font 8x14 + # + case ${font8x14} in + [Nn][Oo] | '') + ;; + *) + echo -n ' font8x14'; vidcontrol < ${viddev} -f 8x14 ${font8x14} + ;; + esac + + # font 8x8 + # + case ${font8x8} in + [Nn][Oo] | '') + ;; + *) + echo -n ' font8x8'; vidcontrol < ${viddev} -f 8x8 ${font8x8} + ;; + esac + + # blank time + # + case ${blanktime} in + [Nn][Oo] | '') + ;; + *) + echo -n ' blanktime'; vidcontrol < ${viddev} -t ${blanktime} + ;; + esac + + # screen saver + # + case ${saver} in + [Nn][Oo] | '') + ;; + *) + echo -n ' screensaver' + for i in `kldstat | awk '$5 ~ "^splash_.*$" { print $5 }'`; do + kldunload ${i} + done + kldstat -v | grep -q _saver || kldload ${saver}_saver + ;; + esac + + # set this mode for all virtual screens + # + if [ -n "${allscreens_flags}" ]; then + echo -n ' allscreens' + for ttyv in /dev/ttyv*; do + vidcontrol ${allscreens_flags} < ${ttyv} > ${ttyv} 2>&1 + done + fi + + # set this keyboard mode for all virtual terminals + # + if [ -n "${allscreens_kbdflags}" ]; then + echo -n ' allscreens_kbd' + for ttyv in /dev/ttyv*; do + kbdcontrol ${allscreens_kbdflags} < ${ttyv} > ${ttyv} 2>&1 + done + fi + + echo '.' +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/sysctl b/etc/rc.d/sysctl new file mode 100644 index 0000000000..b993a793f2 --- /dev/null +++ b/etc/rc.d/sysctl @@ -0,0 +1,108 @@ +#!/bin/sh +# +# $NetBSD: sysctl,v 1.12 2002/04/29 12:10:23 lukem Exp $ +# $FreeBSD: src/etc/rc.d/sysctl,v 1.12 2003/04/24 08:20:47 mtm Exp $ +# $DragonFly: src/etc/rc.d/sysctl,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: sysctl +# REQUIRE: root +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="sysctl" +stop_cmd=":" + +case ${OSTYPE} in +DragonFly) + start_cmd="DragonFly_start" + extra_commands="reload lastload" + reload_cmd="DragonFly_start" + lastload_cmd="DragonFly_start last" + ;; + +FreeBSD) + start_cmd="FreeBSD_start" + extra_commands="reload lastload" + reload_cmd="FreeBSD_start" + lastload_cmd="FreeBSD_start last" + ;; +NetBSD) + start_cmd="NetBSD_start" + ;; +esac +FreeBSD_start() +{ + # + # Read in /etc/sysctl.conf and set things accordingly + # + if [ -f /etc/sysctl.conf ]; then + while read var comments + do + case ${var} in + \#*|'') + ;; + *) + mib=${var%=*} + val=${var#*=} + if current_value=`${SYSCTL} -n ${mib} 2>/dev/null`; then + case ${current_value} in + ${val}) + ;; + *) + sysctl ${var} + ;; + esac + elif [ "$1" = "last" ]; then + warn "sysctl ${mib} does not exist." + fi + ;; + esac + done < /etc/sysctl.conf + fi +} + +FreeBSD_start() +{ + # + # Read in /etc/sysctl.conf and set things accordingly + # + if [ -f /etc/sysctl.conf ]; then + while read var comments + do + case ${var} in + \#*|'') + ;; + *) + mib=${var%=*} + val=${var#*=} + + if current_value=`${SYSCTL} -n ${mib} 2>/dev/null`; then + case ${current_value} in + ${val}) + ;; + *) + sysctl ${var} + ;; + esac + elif [ "$1" = "last" ]; then + warn "sysctl ${mib} does not exist." + fi + ;; + esac + done < /etc/sysctl.conf + fi +} + +NetBSD_start() +{ + if [ -r /etc/sysctl.conf ]; then + echo "Setting sysctl variables:" + ${SYSCTL} -f /etc/sysctl.conf + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/sysdb b/etc/rc.d/sysdb new file mode 100644 index 0000000000..9628d6f235 --- /dev/null +++ b/etc/rc.d/sysdb @@ -0,0 +1,46 @@ +#!/bin/sh +# +# $NetBSD: sysdb,v 1.9 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/sysdb,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/sysdb,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# +# Note: dev_mkdb is required for 'ps' to work without complaining. + +# PROVIDE: sysdb +# REQUIRE: mountcritremote +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="sysdb" +start_cmd="sysdb_start" +stop_cmd=":" + +sysdb_start() +{ + # Build ps databases. If this kernel supports + # machdep.booted_kernel, use that to build the KVM db so dmesg + # will run work when we boot /netbsd.new, etc. + # + echo "Building databases..." + sleep 5 + booted_kernel=`sysctl -n machdep.booted_kernel 2>/dev/null` + #kvm_mkdb "${booted_kernel:-/netbsd}" + dev_mkdb + sleep 5 + + # Re-create /var/run/utmp, which is deleted by mountcritlocal + # but can't be recreated by it because install and chown may + # not be available then (possibly no /usr). + # + egrep '^utmp:' /etc/group > /dev/null + if [ $? ]; then + install -c -m 644 -g wheel /dev/null /var/run/utmp + else + install -c -m 664 -g utmp /dev/null /var/run/utmp + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/syslogd b/etc/rc.d/syslogd new file mode 100644 index 0000000000..cf5c394872 --- /dev/null +++ b/etc/rc.d/syslogd @@ -0,0 +1,87 @@ +#!/bin/sh +# +# $NetBSD: syslogd,v 1.12 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/syslogd,v 1.4 2002/10/01 13:29:44 ru Exp $ +# $DragonFly: src/etc/rc.d/syslogd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: syslogd +# REQUIRE: mountcritremote sysdb wscons +# BEFORE: SERVERS +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="syslogd" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" +required_files="/etc/syslog.conf" +start_precmd="syslogd_precmd" +extra_commands="reload" + +_sockfile="/var/run/syslogd.sockets" + +case ${OSTYPE} in +DragonFly) + pidfile="/var/run/syslog.pid" + evalargs="rc_flags=\"\`set_socketlist\` \$rc_flags\"" + altlog_proglist="named" + ;; + +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 + # + if [ ! -L /dev/log ]; then + 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 new file mode 100644 index 0000000000..ec79692e4c --- /dev/null +++ b/etc/rc.d/timed @@ -0,0 +1,20 @@ +#!/bin/sh +# +# $NetBSD: timed,v 1.5 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/timed,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/timed,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: timed +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="timed" +rcvar=`set_rcvar` +command="/usr/sbin/${name}" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ttys b/etc/rc.d/ttys new file mode 100644 index 0000000000..4482ebcfe1 --- /dev/null +++ b/etc/rc.d/ttys @@ -0,0 +1,63 @@ +#!/bin/sh +# +# $NetBSD: ttys,v 1.1.1.1 2000/03/10 11:53:24 lukem Exp $ +# $FreeBSD: src/etc/rc.d/ttys,v 1.3 2002/09/06 16:18:05 gordon Exp $ +# $DragonFly: src/etc/rc.d/ttys,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: tty +# REQUIRE: root +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="ttyflags" +start_cmd="ttyflags_start" +stop_cmd=":" + +ttyflags_start() +{ + case ${OSTYPE} in + DragonFly) + # 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 + ;; + + FreeBSD) + + # 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 +run_rc_command "$1" diff --git a/etc/rc.d/usbd b/etc/rc.d/usbd new file mode 100644 index 0000000000..c0b48f4d95 --- /dev/null +++ b/etc/rc.d/usbd @@ -0,0 +1,19 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/usbd,v 1.1 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/usbd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: usbd +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: DragonFly 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 0000000000..58584a5340 --- /dev/null +++ b/etc/rc.d/vinum @@ -0,0 +1,18 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/vinum,v 1.1 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/vinum,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: disks +# KEYWORD: DragonFly 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 new file mode 100644 index 0000000000..02bb21b18f --- /dev/null +++ b/etc/rc.d/virecover @@ -0,0 +1,78 @@ +#!/bin/sh +# +# $NetBSD: virecover,v 1.6 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/virecover,v 1.5 2003/05/05 09:53:32 mtm Exp $ +# $DragonFly: src/etc/rc.d/virecover,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: virecover +# REQUIRE: mountcritremote ldconfig +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD NetBSD +# +# XXX: should require `mail'! + +. /etc/rc.subr + +name="virecover" +stop_cmd=":" + +case ${OSTYPE} in +DragonFly) + start_cmd="virecover_start" + ;; +FreeBSD) + start_cmd="virecover_start" + ;; +NetBSD) + command="/usr/libexec/${name}" + ;; +esac + +virecover_start() +{ + [ -d /var/tmp/vi.recover ] || return + 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 +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.sysctl b/etc/rc.d/watchdogd similarity index 58% rename from etc/rc.sysctl rename to etc/rc.d/watchdogd index 546658c358..4b57a42c9d 100644 --- a/etc/rc.sysctl +++ b/etc/rc.d/watchdogd @@ -1,6 +1,6 @@ #!/bin/sh -# -# Copyright (c) 1999 Warner Losh + +# Copyright (c) 2003 Sean M. Kelly # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -12,10 +12,10 @@ # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) @@ -24,39 +24,29 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD: src/etc/rc.sysctl,v 1.4.4.6 2002/04/15 00:44:13 dougb Exp $ -# $DragonFly: src/etc/Attic/rc.sysctl,v 1.2 2003/06/17 04:24:45 dillon Exp $ +# $FreeBSD: src/etc/rc.d/watchdogd,v 1.1 2003/06/26 09:50:51 smkelly Exp $ +# $DragonFly: src/etc/rc.d/watchdogd,v 1.1 2003/07/24 06:35:37 dillon Exp $ # -# -# Read in /etc/sysctl.conf and set things accordingly -# +# PROVIDE: watchdogd +# REQUIRE: DAEMON +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="watchdogd" +rcvar="`set_rcvar`" +command="/usr/sbin/${name}" +start_precmd="watchdogd_precmd" +pidfile="/var/run/${name}.pid" -if [ -f /etc/sysctl.conf ]; then - while read var comments - do - case ${var} in - \#*|'') - ;; - *) - mib=${var%=*} - val=${var#*=} +watchdogd_precmd() +{ + if ! sysctl debug.watchdog >/dev/null 2>&1; then + err 1 "Your kernel doesn't have watchdog support." + fi + return 0 +} - if current_value=`sysctl -n ${mib} 2>/dev/null`; then - case ${current_value} in - ${val}) ;; - *) - sysctl ${var} - ;; - esac - else - case ${1} in - last) - echo "Warning: sysctl ${mib} does not exist" - ;; - esac - fi - ;; - esac - done < /etc/sysctl.conf -fi +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/wscons b/etc/rc.d/wscons new file mode 100644 index 0000000000..1a9c804313 --- /dev/null +++ b/etc/rc.d/wscons @@ -0,0 +1,171 @@ +#!/bin/sh +# +# $NetBSD: wscons,v 1.9 2002/04/26 00:06:54 lukem Exp $ +# $FreeBSD: src/etc/rc.d/wscons,v 1.4 2002/10/12 10:31:31 schweikh Exp $ +# $DragonFly: src/etc/rc.d/Attic/wscons,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: wscons +# REQUIRE: mountcritremote +# BEFORE: LOGIN + +. /etc/rc.subr + +name="wscons" +rcvar=$name +start_cmd="wscons_start" +stop_cmd=":" + +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]" + DOIT= + + while [ $# -gt 0 ]; do + case $1 in + -n) + DOIT=echo + ;; + -f) + config=$2 + shift + ;; + -font) + wsfld=$2 + shift + ;; + -screen) + wscfg=$2 + shift + ;; + *) + echo $usage + exit 1 + ;; + esac + shift + done + + + # args mean: + # screen idx scr emul + # font name width height enc file + ( while read type arg1 arg2 arg3 arg4 arg5; do + case "$type" in + \#*|"") + continue + ;; + + font) + name=$arg1 + width=$arg2 + height=$arg3 + enc=$arg4 + file=$arg5 + cmd=$wsfld + + case $width in + -) + ;; + *) + cmd="$cmd -w $width" + ;; + esac + case $height in + -) + ;; + *) + cmd="$cmd -h $height" + ;; + esac + case $enc in + -) + ;; + *) + cmd="$cmd -e $enc" + ;; + esac + cmd="$cmd -N $name $file" + eval $DOIT $cmd + ;; + + screen) + idx=$arg1 + scr=$arg2 + emul=$arg3 + cmd=$wscfg + + case $scr in + -) + ;; + *) + cmd="$cmd -t $scr" + ;; + esac + case $emul in + -) + ;; + *) + cmd="$cmd -e $emul" + ;; + esac + cmd="$cmd $idx" + eval $DOIT $cmd + ;; + + keyboard) + kbd=$arg1 + cmd=$wscfg + case $kbd in + -|auto) + cmd="$cmd -k" + ;; + *) + cmd="$cmd -k $kbd" + ;; + 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 +} + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/xdm b/etc/rc.d/xdm new file mode 100644 index 0000000000..51737ad8bf --- /dev/null +++ b/etc/rc.d/xdm @@ -0,0 +1,21 @@ +#!/bin/sh +# +# $NetBSD: xdm,v 1.5 2000/07/17 15:24:48 lukem Exp $ +# $DragonFly: src/etc/rc.d/Attic/xdm,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: xdm +# REQUIRE: DAEMON LOGIN wscons +# KEYWORD: shutdown + +. /etc/rc.subr + +name="xdm" +rcvar=$name +command="/usr/X11R6/bin/${name}" +pidfile="/var/run/${name}.pid" +required_files="/usr/X11R6/lib/X11/xdm/xdm-config" +extra_commands="reload" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/xfs b/etc/rc.d/xfs new file mode 100644 index 0000000000..247b1f100f --- /dev/null +++ b/etc/rc.d/xfs @@ -0,0 +1,22 @@ +#!/bin/sh +# +# $NetBSD: xfs,v 1.6 2002/03/22 04:34:01 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/xfs,v 1.2 2002/06/13 22:14:36 gordon Exp $ +# $DragonFly: src/etc/rc.d/Attic/xfs,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: xfs +# REQUIRE: mountall cleartmp +# BEFORE: LOGIN + +. /etc/rc.subr + +name="xfs" +rcvar=$name +command="/usr/X11R6/bin/${name}" +command_args="& sleep 2" +required_files="/usr/X11R6/lib/X11/fs/config" +extra_commands="reload" + +load_rc_config $name +run_rc_command "$1" diff --git a/etc/rc.d/ypbind b/etc/rc.d/ypbind new file mode 100644 index 0000000000..4e2e7cadb5 --- /dev/null +++ b/etc/rc.d/ypbind @@ -0,0 +1,61 @@ +#!/bin/sh +# +# $NetBSD: ypbind,v 1.5 2002/03/22 04:34:01 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/ypbind,v 1.6 2003/07/09 03:21:03 mtm Exp $ +# $DragonFly: src/etc/rc.d/ypbind,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ypbind +# REQUIRE: ypserv +# BEFORE: DAEMON +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="ypbind" +command="/usr/sbin/${name}" +start_precmd="ypbind_precmd" + +load_rc_config $name +case ${OSTYPE} in +DragonFly) + rcvar="nis_client_enable" + command_args="${nis_client_flags}" + ;; +FreeBSD) + rcvar="nis_client_enable" + command_args="${nis_client_flags}" + ;; +NetBSD) + rcvar=$name + ;; +esac + +ypbind_precmd() +{ + case ${OSTYPE} in + DragonFly) + if ! checkyesno rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + then + force_depend rpcbind || return 1 + fi + ;; + + FreeBSD) + if ! checkyesno rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + then + force_depend rpcbind || return 1 + fi + ;; + esac + + _domain=`domainname` + if [ -z "$_domain" ]; then + warn "NIS domainname(1) is not set." + return 1 + fi +} + +run_rc_command "$1" diff --git a/etc/rc.d/yppasswdd b/etc/rc.d/yppasswdd new file mode 100644 index 0000000000..0468537c78 --- /dev/null +++ b/etc/rc.d/yppasswdd @@ -0,0 +1,73 @@ +#!/bin/sh +# +# $NetBSD: yppasswdd,v 1.6 2002/03/22 04:34:01 thorpej Exp $ +# $FreeBSD: src/etc/rc.d/yppasswdd,v 1.7 2003/07/09 03:21:03 mtm Exp $ +# $DragonFly: src/etc/rc.d/yppasswdd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: yppasswdd +# REQUIRE: ypserv ypbind +# BEFORE: LOGIN +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="yppasswdd" +command="/usr/sbin/rpc.${name}" +start_precmd="yppasswdd_precmd" + +load_rc_config $name +case ${OSTYPE} in +DragonFly) + rcvar="nis_yppasswdd_enable" + command_args="${nis_yppasswdd_flags}" + ;; + +FreeBSD) + rcvar="nis_yppasswdd_enable" + command_args="${nis_yppasswdd_flags}" + ;; +NetBSD) + rcvar=$name + required_vars="rpcbind ypserv" + ;; +esac + +yppasswdd_precmd() +{ + case ${OSTYPE} in + DragonFly) + if ! checkyesno rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + then + force_depend rpcbind || return 1 + fi + if ! checkyesno nis_server_enable && \ + ! /etc/rc.d/ypserv forcestatus 1>/dev/null 2>&1 + then + force_depend ypserv || return 1 + fi + ;; + + FreeBSD) + if ! checkyesno rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + then + force_depend rpcbind || return 1 + fi + if ! checkyesno nis_server_enable && \ + ! /etc/rc.d/ypserv forcestatus 1>/dev/null 2>&1 + then + force_depend ypserv || return 1 + fi + ;; + esac + + _domain=`domainname` + if [ -z "$_domain" ]; then + warn "NIS domainname(1) is not set." + return 1 + fi +} + +run_rc_command "$1" diff --git a/etc/rc.d/ypserv b/etc/rc.d/ypserv new file mode 100644 index 0000000000..2ed826c1fe --- /dev/null +++ b/etc/rc.d/ypserv @@ -0,0 +1,62 @@ +#!/bin/sh +# +# $NetBSD: ypserv,v 1.5 2000/09/19 13:04:39 lukem Exp $ +# $FreeBSD: src/etc/rc.d/ypserv,v 1.7 2003/07/09 03:21:03 mtm Exp $ +# $DragonFly: src/etc/rc.d/ypserv,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ypserv +# REQUIRE: rpcbind +# KEYWORD: DragonFly FreeBSD NetBSD + +. /etc/rc.subr + +name="ypserv" +command="/usr/sbin/${name}" +start_precmd="ypserv_precmd" + +load_rc_config $name +case ${OSTYPE} in +FreeBSD) + rcvar="nis_server_enable" + command_args="${nis_server_flags}" + ;; +NetBSD) + rcvar=${name} + required_vars="rpcbind" + ;; +esac + +ypserv_precmd() +{ + case ${OSTYPE} in + DragonFly) + if ! checkyesno rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + then + force_depend rpcbind || return 1 + fi + ;; + + FreeBSD) + if ! checkyesno rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + then + force_depend rpcbind || return 1 + fi + ;; + esac + + _domain=`domainname` + if [ -z "$_domain" ]; then + warn "NIS domainname(1) is not set." + return 1 + fi + + if [ ! -d /var/yp/$_domain/. ]; then + warn "/var/yp/$_domain is not a directory." + return 1 + fi +} + +run_rc_command "$1" diff --git a/etc/rc.d/ypset b/etc/rc.d/ypset new file mode 100644 index 0000000000..19e3fa6f02 --- /dev/null +++ b/etc/rc.d/ypset @@ -0,0 +1,40 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/ypset,v 1.5 2003/07/09 03:21:03 mtm Exp $ +# $DragonFly: src/etc/rc.d/ypset,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ypset +# REQUIRE: ypbind +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="ypset" +rcvar="nis_ypset_enable" +command="/usr/sbin/${name}" +start_precmd="ypset_precmd" +load_rc_config $name +command_args="${nis_ypset_flags}" + +ypset_precmd() +{ + if ! checkyesno rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + then + force_depend rpcbind || return 1 + fi + if ! checkyesno nis_client_enable && \ + ! /etc/rc.d/ypbind forcestatus 1>/dev/null 2>&1 + then + force_depend ypbind || return 1 + fi + + _domain=`domainname` + if [ -z "$_domain" ]; then + warn "NIS domainname(1) is not set." + return 1 + fi +} + +run_rc_command "$1" diff --git a/etc/rc.d/ypupdated b/etc/rc.d/ypupdated new file mode 100644 index 0000000000..925f56fb74 --- /dev/null +++ b/etc/rc.d/ypupdated @@ -0,0 +1,39 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/ypupdated,v 1.4 2003/07/09 03:21:03 mtm Exp $ +# $DragonFly: src/etc/rc.d/ypupdated,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ypupdated +# REQUIRE: rpcbind ypserv +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="ypupdated" +rcvar="rpc_ypupdated_enable" +command="/usr/sbin/rpc.${name}" +start_precmd="rpc_ypupdated_precmd" + +rpc_ypupdated_precmd() +{ + if ! checkyesno rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + then + force_depend rpcbind || return 1 + fi + if ! checkyesno nis_server_enable && \ + ! /etc/rc.d/ypserv forcestatus 1>/dev/null 2>&1 + then + force_depend ypserv || return 1 + fi + + _domain=`domainname` + if [ -z "$_domain" ]; then + warn "NIS 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 0000000000..b32715f237 --- /dev/null +++ b/etc/rc.d/ypxfrd @@ -0,0 +1,40 @@ +#!/bin/sh +# +# $FreeBSD: src/etc/rc.d/ypxfrd,v 1.5 2003/07/09 03:21:03 mtm Exp $ +# $DragonFly: src/etc/rc.d/ypxfrd,v 1.1 2003/07/24 06:35:37 dillon Exp $ +# + +# PROVIDE: ypxfrd +# REQUIRE: rpcbind +# KEYWORD: DragonFly FreeBSD + +. /etc/rc.subr + +name="ypxfrd" +rcvar="nis_ypxfrd_enable" +command="/usr/sbin/rpc.${name}" +start_precmd="ypxfrd_precmd" +load_rc_config $name +command_args="${nis_ypxfrd_flags}" + +ypxfrd_precmd() +{ + if ! checkyesno rpcbind_enable && \ + ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 + then + force_depend rpcbind || return 1 + fi + if ! checkyesno nis_server_enable && \ + ! /etc/rc.d/ypserv forcestatus 1>/dev/null 2>&1 + then + force_depend ypserv || return 1 + fi + + _domain=`domainname` + if [ -z "$_domain" ]; then + warn "NIS domainname(1) is not set." + return 1 + fi +} + +run_rc_command "$1" diff --git a/etc/rc.isdn b/etc/rc.isdn deleted file mode 100644 index 100cd3edfb..0000000000 --- a/etc/rc.isdn +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 1999 Hellmuth Michaelis -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# $FreeBSD: src/etc/rc.isdn,v 1.5.2.5 2001/05/22 18:46:53 schweikh Exp $ -# $DragonFly: src/etc/Attic/rc.isdn,v 1.2 2003/06/17 04:24:45 dillon Exp $ -# - -#--------------------------------------------------------------------------- -# -# /etc/rc.isdn - isdn4bsd startup script -# -------------------------------------- -# -#--------------------------------------------------------------------------- - -case ${isdn_enable} in -[Yy][Ee][Ss]) - echo -n 'ISDN subsystem setup:' - - # Check for pcvt driver (VT100/VT220 emulator) - # - if [ -x /usr/sbin/ispcvt ]; then - if /usr/sbin/ispcvt; then - # No vidcontrol if we are using pcvt - # - isdn_screenflags=NO - fi - fi - - case ${isdn_flags} in - [Nn][Oo]) - isdn_flags='' - ;; - esac - - # Start the isdn daemon - # - if [ -x /usr/sbin/isdnd ]; then - echo -n ' isdnd' - case ${isdn_fsdev} in - [Nn][Oo] | '') - /usr/sbin/isdnd ${isdn_flags} - ;; - *) - # Change vidmode of ${isdn_fsdev} - # - case ${isdn_screenflags} in - [Nn][Oo]) - ;; - *) - if [ -x /usr/sbin/vidcontrol ]; then - /usr/sbin/vidcontrol < ${isdn_fsdev} > ${isdn_fsdev} 2>&1 ${isdn_screenflags} - fi - ;; - esac - - /usr/sbin/isdnd ${isdn_flags} -f -r ${isdn_fsdev} -t ${isdn_ttype} - ;; - esac - fi - - # Start isdntrace - # - case ${isdn_trace} in - [Yy][Ee][Ss]) - if [ -x /usr/sbin/isdntrace ]; then - echo -n ' isdntrace' - nohup /usr/sbin/isdntrace ${isdn_traceflags} >/dev/null 2>&1 & - fi - ;; - esac - - echo '.' - ;; -esac diff --git a/etc/rc.network b/etc/rc.network deleted file mode 100644 index 5f618a1336..0000000000 --- a/etc/rc.network +++ /dev/null @@ -1,889 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 1993 The FreeBSD Project -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# $FreeBSD: src/etc/rc.network,v 1.74.2.43 2003/02/08 21:10:25 gshapiro Exp $ -# $DragonFly: src/etc/Attic/rc.network,v 1.2 2003/06/17 04:24:45 dillon Exp $ -# From: @(#)netstart 5.9 (Berkeley) 3/30/91 -# - -# Note that almost all of the user-configurable behavior is no longer in -# this file, but rather in /etc/defaults/rc.conf. Please check that file -# first before contemplating any changes here. If you do need to change -# this file for some reason, we would like to know about it. - -# First pass startup stuff. -# -network_pass1() { - echo -n 'Doing initial network setup:' - - # Set the host name if it is not already set - # - if [ -z "`hostname -s`" ]; then - hostname ${hostname} - echo -n ' hostname' - fi - - # Establish ipfilter ruleset as early as possible (best in - # addition to IPFILTER_DEFAULT_BLOCK in the kernel config file) - - # check whether ipfilter and/or ipnat is enabled - ipfilter_active="NO" - case ${ipfilter_enable} in - [Yy][Ee][Ss]) - ipfilter_active="YES" - ;; - esac - case ${ipnat_enable} in - [Yy][Ee][Ss]) - ipfilter_active="YES" - ;; - esac - case ${ipfilter_active} in - [Yy][Ee][Ss]) - # 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 - echo 'Warning: IP-filter module failed to load.' - # avoid further errors - ipfilter_active="NO" - ipmon_enable="NO" - ipfilter_enable="NO" - ipnat_enable="NO" - ipfs_enable="NO" - fi - fi - # start ipmon before loading any rules - case "${ipmon_enable}" in - [Yy][Ee][Ss]) - echo -n ' ipmon' - ${ipmon_program:-/sbin/ipmon} ${ipmon_flags} - ;; - esac - case "${ipfilter_enable}" in - [Yy][Ee][Ss]) - if [ -r "${ipfilter_rules}" -o \ - -r "${ipv6_ipfilter_rules}" ]; then - echo -n ' ipfilter' - ${ipfilter_program:-/sbin/ipf} -Fa - if [ -r "${ipfilter_rules}" ]; then - ${ipfilter_program:-/sbin/ipf} \ - -f "${ipfilter_rules}" \ - ${ipfilter_flags} - fi - if [ -r "${ipv6_ipfilter_rules}" ]; then - ${ipfilter_program:-/sbin/ipf} -6 \ - -f "${ipv6_ipfilter_rules}" \ - ${ipfilter_flags} - fi - else - ipfilter_enable="NO" - echo -n ' NO IPF RULES' - fi - ;; - esac - case "${ipnat_enable}" in - [Yy][Ee][Ss]) - if [ -r "${ipnat_rules}" ]; then - echo -n ' ipnat' - eval ${ipnat_program:-/sbin/ipnat} -CF -f \ - "${ipnat_rules}" ${ipnat_flags} - else - ipnat_enable="NO" - echo -n ' NO IPNAT RULES' - fi - ;; - esac - # restore filter/NAT state tables after loading the rules - case "${ipfs_enable}" in - [Yy][Ee][Ss]) - 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 - ;; - esac - ;; - esac - - # Set the domainname if we're using NIS - # - case ${nisdomainname} in - [Nn][Oo] | '') - ;; - *) - domainname ${nisdomainname} - echo -n ' domain' - ;; - esac - - echo '.' - - # Initial ATM interface configuration - # - case ${atm_enable} in - [Yy][Ee][Ss]) - if [ -r /etc/rc.atm ]; then - . /etc/rc.atm - atm_pass1 - fi - ;; - esac - - # Attempt to create cloned interfaces. - for ifn in ${cloned_interfaces}; do - ifconfig ${ifn} create - done - - # Special options for sppp(4) interfaces go here. These need - # to go _before_ the general ifconfig section, 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 - - # gifconfig - network_gif_setup - - # Set up all the network interfaces, calling startup scripts if needed - # - case ${network_interfaces} in - [Aa][Uu][Tt][Oo]) - network_interfaces="`ifconfig -l`" - ;; - *) - network_interfaces="${network_interfaces} ${cloned_interfaces}" - ;; - esac - - dhcp_interfaces="" - for ifn in ${network_interfaces}; do - if [ -r /etc/start_if.${ifn} ]; then - . /etc/start_if.${ifn} - eval showstat_$ifn=1 - fi - - # Do the primary ifconfig if specified - # - eval ifconfig_args=\$ifconfig_${ifn} - - case ${ifconfig_args} in - '') - ;; - [Dd][Hh][Cc][Pp]) - # DHCP inits are done all in one go below - dhcp_interfaces="$dhcp_interfaces $ifn" - eval showstat_$ifn=1 - ;; - *) - ifconfig ${ifn} ${ifconfig_args} - eval showstat_$ifn=1 - ;; - esac - done - - if [ ! -z "${dhcp_interfaces}" ]; then - ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces} - fi - - for ifn in ${network_interfaces}; do - # Check to see if aliases need to be added - # - alias=0 - while : ; do - eval ifconfig_args=\$ifconfig_${ifn}_alias${alias} - if [ -n "${ifconfig_args}" ]; then - ifconfig ${ifn} ${ifconfig_args} alias - eval showstat_$ifn=1 - alias=$((${alias} + 1)) - else - break; - fi - done - - # Do ipx address if specified - # - eval ifconfig_args=\$ifconfig_${ifn}_ipx - if [ -n "${ifconfig_args}" ]; then - ifconfig ${ifn} ${ifconfig_args} - eval showstat_$ifn=1 - fi - done - - for ifn in ${network_interfaces}; do - eval showstat=\$showstat_${ifn} - if [ ! -z ${showstat} ]; then - ifconfig ${ifn} - fi - done - - # ISDN subsystem startup - # - case ${isdn_enable} in - [Yy][Ee][Ss]) - if [ -r /etc/rc.isdn ]; then - . /etc/rc.isdn - fi - ;; - esac - - # Start user ppp if required. This must happen before natd. - # - case ${ppp_enable} in - [Yy][Ee][Ss]) - # Establish ppp mode. - # - if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \ - -a "${ppp_mode}" != "dedicated" \ - -a "${ppp_mode}" != "background" ]; then - ppp_mode="auto" - fi - - ppp_command="/usr/sbin/ppp -quiet -${ppp_mode}" - - # Switch on NAT mode? - # - case ${ppp_nat} in - [Yy][Ee][Ss]) - ppp_command="${ppp_command} -nat" - ;; - esac - - ppp_command="${ppp_command} ${ppp_profile}" - - echo "Starting ppp as \"${ppp_user}\"" - su -m ${ppp_user} -c "exec ${ppp_command}" - ;; - esac - - # Re-Sync ipfilter so it picks up any new network interfaces - # - case ${ipfilter_active} in - [Yy][Ee][Ss]) - ${ipfilter_program:-/sbin/ipf} -y ${ipfilter_flags} >/dev/null - ;; - esac - unset ipfilter_active - - # Initialize IP filtering using ipfw - # - if /sbin/ipfw -q flush > /dev/null 2>&1; then - firewall_in_kernel=1 - else - firewall_in_kernel=0 - fi - - case ${firewall_enable} in - [Yy][Ee][Ss]) - if [ "${firewall_in_kernel}" -eq 0 ] && kldload ipfw; then - firewall_in_kernel=1 - echo 'Kernel firewall module loaded' - elif [ "${firewall_in_kernel}" -eq 0 ]; then - echo 'Warning: firewall kernel module failed to load' - fi - ;; - esac - - # Load the filters if required - # - case ${firewall_in_kernel} in - 1) - if [ -z "${firewall_script}" ]; then - firewall_script=/etc/rc.firewall - fi - - case ${firewall_enable} in - [Yy][Ee][Ss]) - if [ -r "${firewall_script}" ]; then - . "${firewall_script}" - echo -n 'Firewall rules loaded, starting divert daemons:' - - # Network Address Translation daemon - # - case ${natd_enable} in - [Yy][Ee][Ss]) - 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 - fi - echo -n ' natd'; ${natd_program:-/sbin/natd} ${natd_flags} - ;; - esac - - echo '.' - - 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 - - case ${firewall_logging} in - [Yy][Ee][Ss] | '') - echo 'Firewall logging=YES' - sysctl net.inet.ip.fw.verbose=1 >/dev/null - ;; - *) - ;; - esac - - ;; - esac - ;; - esac - - # Additional ATM interface configuration - # - if [ -n "${atm_pass1_done}" ]; then - atm_pass2 - fi - - # Configure routing - # - case ${defaultrouter} in - [Nn][Oo] | '') - ;; - *) - static_routes="default ${static_routes}" - route_default="default ${defaultrouter}" - ;; - esac - - # Set up any static routes. This should be done before router discovery. - # - if [ -n "${static_routes}" ]; then - for i in ${static_routes}; do - eval route_args=\$route_${i} - route add ${route_args} - done - fi - - echo -n 'Additional routing options:' - case ${tcp_extensions} in - [Yy][Ee][Ss] | '') - ;; - *) - echo -n ' tcp extensions=NO' - sysctl net.inet.tcp.rfc1323=0 >/dev/null - ;; - esac - - case ${icmp_bmcastecho} in - [Yy][Ee][Ss]) - echo -n ' broadcast ping responses=YES' - sysctl net.inet.icmp.bmcastecho=1 >/dev/null - ;; - esac - - case ${icmp_drop_redirect} in - [Yy][Ee][Ss]) - echo -n ' ignore ICMP redirect=YES' - sysctl net.inet.icmp.drop_redirect=1 >/dev/null - ;; - esac - - case ${icmp_log_redirect} in - [Yy][Ee][Ss]) - echo -n ' log ICMP redirect=YES' - sysctl net.inet.icmp.log_redirect=1 >/dev/null - ;; - esac - - case ${gateway_enable} in - [Yy][Ee][Ss]) - echo -n ' IP gateway=YES' - sysctl net.inet.ip.forwarding=1 >/dev/null - ;; - esac - - case ${forward_sourceroute} in - [Yy][Ee][Ss]) - echo -n ' do source routing=YES' - sysctl net.inet.ip.sourceroute=1 >/dev/null - ;; - esac - - case ${accept_sourceroute} in - [Yy][Ee][Ss]) - echo -n ' accept source routing=YES' - sysctl net.inet.ip.accept_sourceroute=1 >/dev/null - ;; - esac - - case ${tcp_keepalive} in - [Yy][Ee][Ss]) - echo -n ' TCP keepalive=YES' - sysctl net.inet.tcp.always_keepalive=1 >/dev/null - ;; - esac - - case ${tcp_drop_synfin} in - [Yy][Ee][Ss]) - echo -n ' drop SYN+FIN packets=YES' - sysctl net.inet.tcp.drop_synfin=1 >/dev/null - ;; - esac - - case ${ipxgateway_enable} in - [Yy][Ee][Ss]) - echo -n ' IPX gateway=YES' - sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null - ;; - esac - - case ${arpproxy_all} in - [Yy][Ee][Ss]) - echo -n ' ARP proxyall=YES' - sysctl net.link.ether.inet.proxyall=1 >/dev/null - ;; - esac - - case ${ip_portrange_first} in - [Nn][Oo] | '') - ;; - *) - echo -n " ip_portrange_first=$ip_portrange_first" - sysctl net.inet.ip.portrange.first=$ip_portrange_first >/dev/null - ;; - esac - - case ${ip_portrange_last} in - [Nn][Oo] | '') - ;; - *) - echo -n " ip_portrange_last=$ip_portrange_last" - sysctl net.inet.ip.portrange.last=$ip_portrange_last >/dev/null - ;; - esac - - echo '.' - - case ${ipsec_enable} in - [Yy][Ee][Ss]) - if [ -f ${ipsec_file} ]; then - echo ' ipsec: enabled' - setkey -f ${ipsec_file} - else - echo ' ipsec: file not found' - fi - ;; - esac - - echo -n 'Routing daemons:' - case ${router_enable} in - [Yy][Ee][Ss]) - echo -n " ${router}"; ${router} ${router_flags} - ;; - esac - - case ${ipxrouted_enable} in - [Yy][Ee][Ss]) - echo -n ' IPXrouted' - IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 - ;; - esac - - case ${mrouted_enable} in - [Yy][Ee][Ss]) - echo -n ' mrouted'; mrouted ${mrouted_flags} - ;; - esac - - case ${rarpd_enable} in - [Yy][Ee][Ss]) - echo -n ' rarpd'; rarpd ${rarpd_flags} - ;; - esac - echo '.' - - # Let future generations know we made it. - # - network_pass1_done=YES -} - -network_pass2() { - echo -n 'Doing additional network setup:' - case ${named_enable} in - [Yy][Ee][Ss]) - echo -n ' named'; ${named_program:-named} ${named_flags} - ;; - esac - - case ${ntpdate_enable} in - [Yy][Ee][Ss]) - echo -n ' ntpdate' - ${ntpdate_program:-ntpdate} ${ntpdate_flags} >/dev/null 2>&1 - ;; - esac - - case ${xntpd_enable} in - [Yy][Ee][Ss]) - echo -n ' ntpd'; ${xntpd_program:-ntpd} ${xntpd_flags} - ;; - esac - - case ${timed_enable} in - [Yy][Ee][Ss]) - echo -n ' timed'; timed ${timed_flags} - ;; - esac - - case ${portmap_enable} in - [Yy][Ee][Ss]) - echo -n ' portmap'; ${portmap_program:-/usr/sbin/portmap} ${portmap_flags} - ;; - esac - - # Start ypserv if we're an NIS server. - # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. - # - case ${nis_server_enable} in - [Yy][Ee][Ss]) - echo -n ' ypserv'; ypserv ${nis_server_flags} - - case ${nis_ypxfrd_enable} in - [Yy][Ee][Ss]) - echo -n ' rpc.ypxfrd' - rpc.ypxfrd ${nis_ypxfrd_flags} - ;; - esac - - case ${nis_yppasswdd_enable} in - [Yy][Ee][Ss]) - echo -n ' rpc.yppasswdd' - rpc.yppasswdd ${nis_yppasswdd_flags} - ;; - esac - ;; - esac - - # Start ypbind if we're an NIS client - # - case ${nis_client_enable} in - [Yy][Ee][Ss]) - echo -n ' ypbind'; ypbind ${nis_client_flags} - case ${nis_ypset_enable} in - [Yy][Ee][Ss]) - echo -n ' ypset'; ypset ${nis_ypset_flags} - ;; - esac - ;; - esac - - # Start keyserv if we are running Secure RPC - # - case ${keyserv_enable} in - [Yy][Ee][Ss]) - echo -n ' keyserv'; keyserv ${keyserv_flags} - ;; - esac - - # Start ypupdated if we are running Secure RPC and we are NIS master - # - case ${rpc_ypupdated_enable} in - [Yy][Ee][Ss]) - echo -n ' rpc.ypupdated'; rpc.ypupdated - ;; - esac - - # Start ATM daemons - if [ -n "${atm_pass2_done}" ]; then - atm_pass3 - fi - - echo '.' - network_pass2_done=YES -} - -network_pass3() { - echo -n 'Starting final network daemons:' - - case ${nfs_server_enable} in - [Yy][Ee][Ss]) - if [ -r /etc/exports ]; then - echo -n ' mountd' - - case ${weak_mountd_authentication} in - [Yy][Ee][Ss]) - mountd_flags="${mountd_flags} -n" - ;; - esac - - mountd ${mountd_flags} - - case ${nfs_reserved_port_only} in - [Yy][Ee][Ss]) - echo -n ' NFS on reserved port only=YES' - sysctl vfs.nfs.nfs_privport=1 >/dev/null - ;; - esac - - echo -n ' nfsd'; nfsd ${nfs_server_flags} - - case ${rpc_lockd_enable} in - [Yy][Ee][Ss]) - echo -n ' rpc.lockd'; rpc.lockd - ;; - esac - - case ${rpc_statd_enable} in - [Yy][Ee][Ss]) - echo -n ' rpc.statd'; rpc.statd - ;; - esac - fi - ;; - *) - case ${single_mountd_enable} in - [Yy][Ee][Ss]) - if [ -r /etc/exports ]; then - echo -n ' mountd' - - case ${weak_mountd_authentication} in - [Yy][Ee][Ss]) - mountd_flags="-n" - ;; - esac - - mountd ${mountd_flags} - fi - ;; - esac - ;; - esac - - case ${nfs_client_enable} in - [Yy][Ee][Ss]) - nfs_in_kernel=0 - # Handle absent nfs client support - if sysctl vfs.nfs >/dev/null 2>&1; then - nfs_in_kernel=1 - else - kldload nfs && nfs_in_kernel=1 - fi - if [ ${nfs_in_kernel} -eq 1 ] - then - echo -n ' nfsiod'; nfsiod ${nfs_client_flags} - 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 - - case ${amd_enable} in - [Yy][Ee][Ss]) - echo -n ' amd' - 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 - amd & - else - echo '' - echo 'Warning: amd will not load without arguments' - fi - ;; - *) - amd -p ${amd_flags} >/var/run/amd.pid \ - 2>/dev/null & - ;; - esac - ;; - esac - fi - ;; - esac - - # If /var/db/mounttab exists, some nfs-server has not been - # sucessfully 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 - - case ${rwhod_enable} in - [Yy][Ee][Ss]) - echo -n ' rwhod'; rwhod ${rwhod_flags} - ;; - esac - - # Kerberos servers run ONLY on the Kerberos server machine - case ${kerberos_server_enable} in - [Yy][Ee][Ss]) - case ${kerberos_stash} in - [Yy][Ee][Ss]) - stash_flag=-n - ;; - *) - stash_flag= - ;; - esac - - echo -n ' kerberosIV' - kerberos ${stash_flag} >> /var/log/kerberos.log & - - case ${kadmind_server_enable} in - [Yy][Ee][Ss]) - echo -n ' kadmindIV' - ( - sleep 20; - kadmind ${stash_flag} >/dev/null 2>&1 & - ) & - ;; - esac - unset stash_flag - ;; - esac - - case ${kerberos5_server_enable} in - [Yy][Ee][Ss]) - echo -n ' kerberos5' - ${kerberos5_server} & - - case ${kadmind5_server_enable} in - [Yy][Ee][Ss]) - echo -n ' kadmind5' - ${kadmind5_server} & - ;; - esac - ;; - esac - - case ${pppoed_enable} in - [Yy][Ee][Ss]) - if [ -n "${pppoed_provider}" ]; then - pppoed_flags="${pppoed_flags} -p ${pppoed_provider}" - fi - echo -n ' pppoed'; - _opts=$-; set -f - /usr/libexec/pppoed ${pppoed_flags} ${pppoed_interface} - set +f; set -${_opts} - ;; - esac - - case ${sshd_enable} in - [Yy][Ee][Ss]) - if [ -x /usr/bin/ssh-keygen ]; then - if [ ! -f /etc/ssh/ssh_host_key ]; then - echo ' creating ssh1 RSA host key'; - /usr/bin/ssh-keygen -t rsa1 -N "" \ - -f /etc/ssh/ssh_host_key - fi - if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then - echo ' creating ssh2 RSA host key'; - /usr/bin/ssh-keygen -t rsa -N "" \ - -f /etc/ssh/ssh_host_rsa_key - fi - if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then - echo ' creating ssh2 DSA host key'; - /usr/bin/ssh-keygen -t dsa -N "" \ - -f /etc/ssh/ssh_host_dsa_key - fi - fi - ;; - esac - - echo '.' - network_pass3_done=YES -} - -network_pass4() { - echo -n 'Additional TCP options:' - case ${log_in_vain} in - [Nn][Oo] | '') - log_in_vain=0 - ;; - [Yy][Ee][Ss]) - log_in_vain=1 - ;; - [0-9]*) - ;; - *) - echo " invalid log_in_vain setting: ${log_in_vain}" - log_in_vain=0 - ;; - esac - - if [ "${log_in_vain}" -ne 0 ]; then - echo -n " log_in_vain=${log_in_vain}" - sysctl net.inet.tcp.log_in_vain="${log_in_vain}" >/dev/null - sysctl net.inet.udp.log_in_vain="${log_in_vain}" >/dev/null - fi - - echo '.' - network_pass4_done=YES -} - -network_gif_setup() { - case ${gif_interfaces} in - [Nn][Oo] | '') - ;; - *) - for i in ${gif_interfaces}; do - eval peers=\$gifconfig_$i - case ${peers} in - '') - continue - ;; - *) - ifconfig $i create >/dev/null 2>&1 - ifconfig $i tunnel ${peers} - ifconfig $i up - ;; - esac - done - ;; - esac -} diff --git a/etc/rc.network6 b/etc/rc.network6 deleted file mode 100644 index a80e47d483..0000000000 --- a/etc/rc.network6 +++ /dev/null @@ -1,508 +0,0 @@ -#! /bin/sh -# -# Copyright (c) 2000 The KAME Project -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# $FreeBSD: src/etc/rc.network6,v 1.5.2.23 2002/07/24 18:25:42 ume Exp $ -# $DragonFly: src/etc/Attic/rc.network6,v 1.2 2003/06/17 04:24:45 dillon Exp $ -# - -# Note that almost all of the user-configurable behavior is not in this -# file, but rather in /etc/defaults/rc.conf. Please check that file -# first before contemplating any changes here. If you do need to change -# this file for some reason, we would like to know about it. - -# IPv6 startup - -network6_pass1() { - echo -n 'Doing IPv6 network setup:' - - # Initialize IP filtering using ip6fw - # - if /sbin/ip6fw -q flush > /dev/null 2>&1; then - ipv6_firewall_in_kernel=1 - else - ipv6_firewall_in_kernel=0 - fi - - case ${ipv6_firewall_enable} in - [Yy][Ee][Ss]) - if [ "${ipv6_firewall_in_kernel}" -eq 0 ] && kldload ip6fw; then - ipv6_firewall_in_kernel=1 - echo "Kernel IPv6 firewall module loaded." - elif [ "${ipv6_firewall_in_kernel}" -eq 0 ]; then - echo "Warning: IPv6 firewall kernel module failed to load." - fi - ;; - esac - - # Load the filters if required - # - case ${ipv6_firewall_in_kernel} in - 1) - if [ -z "${ipv6_firewall_script}" ]; then - ipv6_firewall_script=/etc/rc.firewall6 - fi - - case ${ipv6_firewall_enable} in - [Yy][Ee][Ss]) - if [ -r "${ipv6_firewall_script}" ]; then - . "${ipv6_firewall_script}" - echo -n 'IPv6 Firewall rules loaded.' - elif [ "`ip6fw l 65535`" = "65535 deny ipv6 from any to any" ]; then - echo -n "Warning: kernel has IPv6 firewall functionality, " - echo "but IPv6 firewall rules are not enabled." - echo " All ipv6 services are disabled." - fi - - case ${ipv6_firewall_logging} in - [Yy][Ee][Ss] | '') - echo 'IPv6 Firewall logging=YES' - sysctl net.inet6.ip6.fw.verbose=1 >/dev/null - ;; - *) - ;; - esac - - ;; - esac - ;; - esac - - case ${ipv6_network_interfaces} in - [Aa][Uu][Tt][Oo]) - # - # list of interfaces, and prefix for interfaces - # - ipv6_network_interfaces="`ifconfig -l`" - ;; - [Nn][Oo][Nn][Ee]) - ipv6_network_interfaces='' - ;; - esac - - # just to make sure - ifconfig lo0 up - - # disallow "internal" addresses to appear on the wire - route add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject - route add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject - - case ${ipv6_gateway_enable} in - [Yy][Ee][Ss]) - # act as a router - sysctl net.inet6.ip6.forwarding=1 - sysctl net.inet6.ip6.accept_rtadv=0 - - # wait for DAD - for i in $ipv6_network_interfaces; do - ifconfig $i up - done - sleep `sysctl -n net.inet6.ip6.dad_count` - sleep 1 - ;; - *) - # act as endhost - start with manual configuration - # Setup of net.inet6.ip6.accept_rtadv is done later by - # network6_interface_setup. - sysctl net.inet6.ip6.forwarding=0 - ;; - esac - - if [ -n "${ipv6_network_interfaces}" ]; then - # setting up interfaces - network6_interface_setup $ipv6_network_interfaces - - # wait for DAD's completion (for global addrs) - sleep `sysctl -n net.inet6.ip6.dad_count` - sleep 1 - fi - - case ${ipv6_gateway_enable} in - [Yy][Ee][Ss]) - # Filter out interfaces on which IPv6 addr init failed. - ipv6_working_interfaces="" - for i in ${ipv6_network_interfaces}; do - laddr=`network6_getladdr $i exclude_tentative` - case ${laddr} in - '') - ;; - *) - ipv6_working_interfaces="$i \ - ${ipv6_working_interfaces}" - ;; - esac - done - ipv6_network_interfaces=${ipv6_working_interfaces} - ;; - esac - - # 6to4 setup - network6_stf_setup - - # install the "default interface" to kernel, which will be used - # as the default route when there's no router. - network6_default_interface_setup - - # setup static routes - network6_static_routes_setup - - # setup faith - network6_faith_setup - - # ipv6_router - case ${ipv6_router_enable} in - [Yy][Ee][Ss]) - if [ -x ${ipv6_router} ]; then - echo -n " ${ipv6_router}" - ${ipv6_router} ${ipv6_router_flags} - fi - ;; - esac - - - case ${ipv6_gateway_enable} in - [Yy][Ee][Ss]) - # rtadvd - # This should 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 ${rtadvd_enable} in - [Yy][Ee][Ss]) - # default - case ${rtadvd_interfaces} in - '') - for i in ${ipv6_network_interfaces}; 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 - rtadvd ${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 - - # mroute6d - case ${mroute6d_enable} in - [Yy][Ee][Ss]) - if [ -x ${mroute6d_program} ]; then - echo -n " ${mroute6d_program}" - ${mroute6d_program} ${mroute6d_flags} - fi - ;; - esac - ;; - esac - - case ${ipv6_ipv4mapping} in - [Yy][Ee][Ss]) - echo -n ' IPv4 mapped IPv6 address support=YES' - sysctl net.inet6.ip6.v6only=0 >/dev/null - ;; - '' | *) - echo -n ' IPv4 mapped IPv6 address support=NO' - sysctl net.inet6.ip6.v6only=1 >/dev/null - ;; - esac - - echo '.' - - # Let future generations know we made it. - # - network6_pass1_done=YES -} - -network6_interface_setup() { - interfaces=$* - rtsol_interfaces='' - case ${ipv6_gateway_enable} in - [Yy][Ee][Ss]) - rtsol_available=no - ;; - *) - rtsol_available=yes - ;; - esac - for i in $interfaces; do - rtsol_interface=yes - eval prefix=\$ipv6_prefix_$i - if [ -n "${prefix}" ]; then - rtsol_available=no - rtsol_interface=no - laddr=`network6_getladdr $i` - hostid=`expr "${laddr}" : 'fe80::\(.*\)%\(.*\)'` - for j in ${prefix}; do - address=$j\:${hostid} - ifconfig $i inet6 ${address} prefixlen 64 alias - - case ${ipv6_gateway_enable} in - [Yy][Ee][Ss]) - # subnet-router anycast address - # (rfc2373) - ifconfig $i inet6 $j:: prefixlen 64 \ - alias anycast - ;; - esac - done - fi - eval ipv6_ifconfig=\$ipv6_ifconfig_$i - if [ -n "${ipv6_ifconfig}" ]; then - rtsol_available=no - rtsol_interface=no - ifconfig $i inet6 ${ipv6_ifconfig} alias - fi - - if [ ${rtsol_available} = yes -a ${rtsol_interface} = yes ] - then - case ${i} in - lo0|gif[0-9]*|stf[0-9]*|faith[0-9]*|lp[0-9]*|sl[0-9]*|tun[0-9]*) - ;; - *) - rtsol_interfaces="${rtsol_interfaces} ${i}" - ;; - esac - else - ifconfig $i inet6 - fi - done - - if [ ${rtsol_available} = yes -a -n "${rtsol_interfaces}" ]; then - # Act as endhost - automatically configured. - # You can configure only single interface, as - # specification assumes that autoconfigured host has - # single interface only. - sysctl net.inet6.ip6.accept_rtadv=1 - set ${rtsol_interfaces} - ifconfig $1 up - rtsol $1 - fi - - for i in $interfaces; do - alias=0 - while : ; do - eval ipv6_ifconfig=\$ipv6_ifconfig_${i}_alias${alias} - if [ -z "${ipv6_ifconfig}" ]; then - break; - fi - ifconfig $i inet6 ${ipv6_ifconfig} alias - alias=$((${alias} + 1)) - done - done -} - -network6_stf_setup() { - case ${stf_interface_ipv4addr} in - [Nn][Oo] | '') - ;; - *) - # assign IPv6 addr and interface route for 6to4 interface - stf_prefixlen=$((16+${stf_interface_ipv4plen:-0})) - OIFS="$IFS" - IFS=".$IFS" - set ${stf_interface_ipv4addr} - IFS="$OIFS" - ipv4_in_hexformat=`printf "%x:%x\n" \ - $(($1*256 + $2)) $(($3*256 + $4))` - case ${stf_interface_ipv6_ifid} in - [Aa][Uu][Tt][Oo] | '') - for i in ${ipv6_network_interfaces}; do - laddr=`network6_getladdr ${i}` - case ${laddr} in - '') - ;; - *) - break - ;; - esac - done - stf_interface_ipv6_ifid=`expr "${laddr}" : \ - 'fe80::\(.*\)%\(.*\)'` - case ${stf_interface_ipv6_ifid} in - '') - stf_interface_ipv6_ifid=0:0:0:1 - ;; - esac - ;; - esac - ifconfig stf0 inet6 2002:${ipv4_in_hexformat}:${stf_interface_ipv6_slaid:-0}:${stf_interface_ipv6_ifid} \ - prefixlen ${stf_prefixlen} - # disallow packets to malicious 6to4 prefix - route add -inet6 2002:e000:: -prefixlen 20 ::1 -reject - route add -inet6 2002:7f00:: -prefixlen 24 ::1 -reject - route add -inet6 2002:0000:: -prefixlen 24 ::1 -reject - route add -inet6 2002:ff00:: -prefixlen 24 ::1 -reject - ;; - esac -} - -network6_static_routes_setup() { - # Set up any static routes. - case ${ipv6_defaultrouter} in - [Nn][Oo] | '') - ;; - *) - ipv6_static_routes="default ${ipv6_static_routes}" - ipv6_route_default="default ${ipv6_defaultrouter}" - ;; - esac - case ${ipv6_static_routes} in - [Nn][Oo] | '') - ;; - *) - for i in ${ipv6_static_routes}; do - eval ipv6_route_args=\$ipv6_route_${i} - route add -inet6 ${ipv6_route_args} - done - ;; - esac -} - -network6_faith_setup() { - case ${ipv6_faith_prefix} in - [Nn][Oo] | '') - ;; - *) - sysctl net.inet6.ip6.keepfaith=1 - ifconfig faith0 create >/dev/null 2>&1 - ifconfig faith0 up - for prefix in ${ipv6_faith_prefix}; do - prefixlen=`expr "${prefix}" : ".*/\(.*\)"` - case ${prefixlen} in - '') - prefixlen=96 - ;; - *) - prefix=`expr "${prefix}" : \ - "\(.*\)/${prefixlen}"` - ;; - esac - route add -inet6 ${prefix} -prefixlen ${prefixlen} ::1 - route change -inet6 ${prefix} -prefixlen ${prefixlen} \ - -ifp faith0 - done - ;; - esac -} - -network6_default_interface_setup() { - # Choose IPv6 default interface if it is not clearly specified. - case ${ipv6_default_interface} in - '') - for i in ${ipv6_network_interfaces}; do - case $i in - lo0|faith[0-9]*) - continue - ;; - esac - laddr=`network6_getladdr $i exclude_tentative` - case ${laddr} in - '') - ;; - *) - ipv6_default_interface=$i - break - ;; - esac - done - ;; - esac - - # Disallow unicast packets without outgoing scope identifiers, - # or route such packets to a "default" interface, if it is specified. - route add -inet6 fe80:: -prefixlen 10 ::1 -reject - case ${ipv6_default_interface} in - [Nn][Oo] | '') - route add -inet6 ff02:: -prefixlen 16 ::1 -reject - ;; - *) - laddr=`network6_getladdr ${ipv6_default_interface}` - route add -inet6 ff02:: ${laddr} -prefixlen 16 -interface \ - -cloning - - # Disable installing the default interface with the - # case net.inet6.ip6.forwarding=0 and - # net.inet6.ip6.accept_rtadv=0, due to avoid conflict - # between the default router list and the manual - # configured default route. - case ${ipv6_gateway_enable} in - [Yy][Ee][Ss]) - ;; - *) - if [ `sysctl -n net.inet6.ip6.accept_rtadv` -eq 1 ] - then - ndp -I ${ipv6_default_interface} - fi - ;; - esac - ;; - esac -} - -network6_getladdr() { - ifconfig $1 2>/dev/null | while read proto addr rest; do - case ${proto} in - inet6) - case ${addr} in - fe80::*) - if [ -z "$2" ]; then - echo ${addr} - return - fi - case ${rest} in - *tentative*) - continue - ;; - *) - echo ${addr} - return - esac - esac - esac - done -} diff --git a/etc/rc.subr b/etc/rc.subr new file mode 100644 index 0000000000..d9a83665ed --- /dev/null +++ b/etc/rc.subr @@ -0,0 +1,1039 @@ +# $NetBSD: rc.subr,v 1.49 2002/05/21 12:31:01 lukem Exp $ +# $FreeBSD: src/etc/rc.subr,v 1.13 2003/06/09 17:31:06 mtm Exp $ +# $DragonFly: src/etc/rc.subr,v 1.1 2003/07/24 06:35:32 dillon Exp $ +# +# Copyright (c) 1997-2002 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Luke Mewburn. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# rc.subr +# functions used by various rc scripts +# + +# +# Operating System dependent/independent variables +# + +SYSCTL="/sbin/sysctl" +SYSCTL_N="${SYSCTL} -n" +CMD_OSTYPE="${SYSCTL_N} kern.ostype" +OSTYPE=`${CMD_OSTYPE}` + +case ${OSTYPE} in +DragonFly) + SYSCTL_W="${SYSCTL}" + ;; +FreeBSD) + SYSCTL_W="${SYSCTL}" + ;; +NetBSD) + SYSCTL_W="${SYSCTL} -w" + ;; +esac + +# +# functions +# --------- + +# +# set_rcvar base_var +# Set the variable name enabling a specific service. +# FreeBSD uses ${service}_enable, while NetBSD uses +# just the name of the service. For example: +# FreeBSD: sendmail_enable="YES" +# NetBSD : sendmail="YES" +# $1 - if $name is not the base to work of off, specify +# a different one +# +set_rcvar() +{ + if [ -z "$1" ]; then + base_var=${name} + else + base_var="$1" + fi + + case ${OSTYPE} in + FreeBSD) + echo ${base_var}_enable + ;; + NetBSD) + echo ${base_var} + ;; + *) + echo 'XXX' + ;; + esac +} + +# +# force_depend script +# Force a service to start. Intended for use by services +# to resolve dependency issues. It is assumed the caller +# has check to make sure this call is necessary +# $1 - filename of script, in /etc/rc.d, to run +# +force_depend() +{ + _depend="$1" + + info "${name} depends on ${_depend}, which will be forced to start." + if ! /etc/rc.d/${_depend} forcestart ; then + warn "Unable to force ${_depend}. It may already be running." + return 1 + fi + return 0 +} + +# +# checkyesno var +# Test $1 variable, and warn if not set to YES or NO. +# Return 0 if it's "yes" (et al), nonzero otherwise. +# +checkyesno() +{ + eval _value=\$${1} + debug "checkyesno: $1 is set to $_value." + case $_value in + + # "yes", "true", "on", or "1" + [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) + return 0 + ;; + + # "no", "false", "off", or "0" + [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) + return 1 + ;; + *) + warn "\$${1} is not set properly - see rc.conf(5)." + return 1 + ;; + esac +} + +# reverse_list list +# print the list in reverse order +# +reverse_list() +{ + _revlist= + for _revfile in $*; do + _revlist="$_revfile $_revlist" + done + echo $_revlist +} + +# +# mount_critical_filesystems type +# Go through the list of critical filesystems as provided in +# the rc.conf(5) variable $critical_filesystems_${type}, checking +# each one to see if it is mounted, and if it is not, mounting it. +# +mount_critical_filesystems() +{ + eval _fslist=\$critical_filesystems_${1} + for _fs in $_fslist; do + mount | ( + _ismounted=no + while read what _on on _type type; do + if [ $on = $_fs ]; then + _ismounted=yes + fi + done + if [ $_ismounted = no ]; then + mount $_fs >/dev/null 2>&1 + fi + ) + done +} + +# +# check_pidfile pidfile procname [interpreter] +# Parses the first line of pidfile for a PID, and ensures +# that the process is running and matches procname. +# Prints the matching PID upon success, nothing otherwise. +# interpreter is optional; see _find_processes() for details. +# +check_pidfile() +{ + _pidfile=$1 + _procname=$2 + _interpreter=$3 + if [ -z "$_pidfile" -o -z "$_procname" ]; then + err 3 'USAGE: check_pidfile pidfile procname [interpreter]' + fi + if [ ! -f $_pidfile ]; then + debug "pid file {$_pidfile): not readable." + return + fi + read _pid _junk < $_pidfile + if [ -z "$_pid" ]; then + debug "pid file {$_pidfile): no pid in file." + return + fi + _find_processes $_procname ${_interpreter:-.} '-p '"$_pid" +} + +# +# check_process procname [interpreter] +# Ensures that a process (or processes) named procname is running. +# Prints a list of matching PIDs. +# interpreter is optional; see _find_processes() for details. +# +check_process() +{ + _procname=$1 + _interpreter=$2 + if [ -z "$_procname" ]; then + err 3 'USAGE: check_process procname [interpreter]' + fi + _find_processes $_procname ${_interpreter:-.} '-ax' +} + +# +# _find_processes procname interpreter psargs +# Search for procname in the output of ps generated by psargs. +# Prints the PIDs of any matching processes, space separated. +# +# If interpreter == ".", check the following variations of procname +# against the first word of each command: +# procname +# `basename procname` +# `basename procname` + ":" +# "(" + `basename procname` + ")" +# +# If interpreter != ".", read the first line of procname, remove the +# leading #!, normalise whitespace, append procname, and attempt to +# match that against each command, either as is, or with extra words +# at the end. +# +_find_processes() +{ + if [ $# -ne 3 ]; then + err 3 'USAGE: _find_processes procname interpreter psargs' + fi + _procname=$1 + _interpreter=$2 + _psargs=$3 + + _pref= + if [ $_interpreter != "." ]; then # an interpreted script + read _interp < $_procname # read interpreter name + _interp=${_interp#\#!} # strip #! + set -- $_interp + if [ $_interpreter != $1 ]; then + warn "\$command_interpreter $_interpreter != $1" + fi + _interp="$* $_procname" # cleanup spaces, add _procname + _fp_args='_argv' + _fp_match='case "$_argv" in + ${_interp}|"${_interp} "*)' + else # a normal daemon + _procnamebn=${_procname##*/} + _fp_args='_arg0 _argv' + _fp_match='case "$_arg0" in + $_procname|$_procnamebn|${_procnamebn}:|"(${_procnamebn})")' + fi + + _proccheck=' + ps -o "pid,command" '"$_psargs"' | + while read _npid '"$_fp_args"'; do + case "$_npid" in + PID) + continue ;; + esac ; '"$_fp_match"' + echo -n "$_pref$_npid" ; + _pref=" " + ;; + esac + done' + +# debug "in _find_processes: proccheck is ($_proccheck)." + eval $_proccheck +} + +# +# wait_for_pids pid [pid ...] +# spins until none of the pids exist +# +wait_for_pids() +{ + _list=$* + if [ -z "$_list" ]; then + return + fi + _prefix= + while true; do + _nlist=""; + for _j in $_list; do + if kill -0 $_j 2>/dev/null; then + _nlist="${_nlist}${_nlist:+ }$_j" + fi + done + if [ -z "$_nlist" ]; then + break + fi + _list=$_nlist + echo -n ${_prefix:-"Waiting for PIDS: "}$_list + _prefix=", " + sleep 2 + done + if [ -n "$_prefix" ]; then + echo "." + fi +} + +# +# run_rc_command argument +# Search for argument in the list of supported commands, which is: +# "start stop restart rcvar status poll ${extra_commands}" +# If there's a match, run ${argument}_cmd or the default method +# (see below). +# +# If argument has a given prefix, then change the operation as follows: +# Prefix Operation +# ------ --------- +# fast Skip the pid check, and set rc_fast=yes +# force Set ${rcvar} to YES, and set rc_force=yes +# +# The following globals are used: +# +# Name Needed Purpose +# ---- ------ ------- +# name y Name of script. +# +# command n Full path to command. +# Not needed if ${rc_arg}_cmd is set for +# each keyword. +# +# command_args n Optional args/shell directives for command. +# +# command_interpreter n If not empty, command is interpreted, so +# call check_{pidfile,process}() appropriately. +# +# extra_commands n List of extra commands supported. +# +# pidfile n If set, use check_pidfile $pidfile $command, +# otherwise use check_process $command. +# In either case, only check if $command is set. +# +# procname n Process name to check for instead of $command. +# +# rcvar n This is checked with checkyesno to determine +# if the action should be run. +# +# ${name}_chroot n Directory to chroot to before running ${command} +# Requires /usr to be mounted. +# +# ${name}_chdir n Directory to cd to before running ${command} +# (if not using ${name}_chroot). +# +# ${name}_flags n Arguments to call ${command} with. +# NOTE: $flags from the parent environment +# can be used to override this. +# +# ${name}_nice n Nice level to run ${command} at. +# +# ${name}_user n User to run ${command} as, using su(1) if not +# using ${name}_chroot. +# Requires /usr to be mounted. +# +# ${name}_group n Group to run chrooted ${command} as. +# Requires /usr to be mounted. +# +# ${name}_groups n Comma separated list of supplementary groups +# to run the chrooted ${command} with. +# Requires /usr to be mounted. +# +# ${rc_arg}_cmd n If set, use this as the method when invoked; +# Otherwise, use default command (see below) +# +# ${rc_arg}_precmd n If set, run just before performing the +# ${rc_arg}_cmd method in the default +# operation (i.e, after checking for required +# bits and process (non)existence). +# If this completes with a non-zero exit code, +# don't run ${rc_arg}_cmd. +# +# ${rc_arg}_postcmd n If set, run just after performing the +# ${rc_arg}_cmd method, if that method +# returned a zero exit code. +# +# required_dirs n If set, check for the existence of the given +# directories before running the default +# (re)start command. +# +# required_files n If set, check for the readability of the given +# files before running the default (re)start +# command. +# +# required_vars n If set, perform checkyesno on each of the +# listed variables before running the default +# (re)start command. +# +# Default behaviour for a given argument, if no override method is +# provided: +# +# Argument Default behaviour +# -------- ----------------- +# start if !running && checkyesno ${rcvar} +# ${command} +# +# stop if ${pidfile} +# rc_pid=$(check_pidfile $pidfile $command) +# else +# rc_pid=$(check_process $command) +# kill $sig_stop $rc_pid +# wait_for_pids $rc_pid +# ($sig_stop defaults to TERM.) +# +# reload Similar to stop, except use $sig_reload instead, +# and doesn't wait_for_pids. +# $sig_reload defaults to HUP. +# +# restart Run `stop' then `start'. +# +# status Show if ${command} is running, etc. +# +# poll Wait for ${command} to exit. +# +# rcvar Display what rc.conf variable is used (if any). +# +# Variables available to methods, and after run_rc_command() has +# completed: +# +# Variable Purpose +# -------- ------- +# rc_arg Argument to command, after fast/force processing +# performed +# +# rc_flags Flags to start the default command with. +# Defaults to ${name}_flags, unless overridden +# by $flags from the environment. +# This variable may be changed by the precmd method. +# +# rc_pid PID of command (if appropriate) +# +# rc_fast Not empty if "fast" was provided (q.v.) +# +# rc_force Not empty if "force" was provided (q.v.) +# +# +run_rc_command() +{ + _return=0 + rc_arg=$1 + if [ -z "$name" ]; then + err 3 'run_rc_command: $name is not set.' + fi + + case "$rc_arg" in + fast*) # "fast" prefix; don't check pid + rc_arg=${rc_arg#fast} + rc_fast=yes + ;; + force*) # "force prefix; always start + rc_arg=${rc_arg#force} + rc_force=yes + if [ -n "${rcvar}" ]; then + eval ${rcvar}=YES + fi + ;; + esac + + eval _overide_command=\$${name}_program + if [ -n "$_overide_command" ]; then + command=$_overide_command + fi + + _keywords="start stop restart rcvar $extra_commands" + rc_pid= + _pidcmd= + _procname=${procname:-${command}} + + # setup pid check command if not fast + if [ -z "$rc_fast" -a -n "$_procname" ]; then + if [ -n "$pidfile" ]; then + _pidcmd='rc_pid=$(check_pidfile '"$pidfile $_procname $command_interpreter"')' + else + _pidcmd='rc_pid=$(check_process '"$_procname $command_interpreter"')' + fi + if [ -n "$_pidcmd" ]; then + _keywords="${_keywords} status poll" + fi + fi + + if [ -z "$rc_arg" ]; then + rc_usage "$_keywords" + fi + + if [ -n "$flags" ]; then # allow override from environment + rc_flags=$flags + else + eval rc_flags=\$${name}_flags + fi + eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \ + _nice=\$${name}_nice _user=\$${name}_user \ + _group=\$${name}_group _groups=\$${name}_groups + + if [ -n "$_user" ]; then # unset $_user if running as that user + if [ "$_user" = "$(id -un)" ]; then + unset _user + fi + fi + + # if ${rcvar} is set, and $1 is not + # "rcvar", then run + # checkyesno ${rcvar} + # and return if that failed + # + if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" ]; then + if ! checkyesno ${rcvar}; then + return 0 + fi + fi + + eval $_pidcmd # determine the pid if necessary + + for _elem in $_keywords; do + if [ "$_elem" != "$rc_arg" ]; then + continue + fi + + # if there's a custom ${XXX_cmd}, + # run that instead of the default + # + eval _cmd=\$${rc_arg}_cmd _precmd=\$${rc_arg}_precmd \ + _postcmd=\$${rc_arg}_postcmd + if [ -n "$_cmd" ]; then + # if the precmd failed and force + # isn't set, exit + # + if [ -n "$_precmd" ]; then + debug "run_rc_command: evaluating ${_precmd}()." + eval $_precmd + _return=$? + [ $_return -ne 0 ] && [ -z "$rc_force" ] && + return 1 + fi + + if [ -n "$_cmd" ]; then + debug "run_rc_command: evaluating ${_cmd}()." + eval $_cmd + _return=$? + [ $_return -ne 0 ] && [ -z "$rc_force" ] && + return 1 + fi + + if [ -n "$_postcmd" ]; then + debug "run_rc_command: evaluating ${_postcmd}()." + eval $_postcmd + _return=$? + fi + return $_return + fi + + case "$rc_arg" in # default operations... + + status) + if [ -n "$rc_pid" ]; then + echo "${name} is running as pid $rc_pid." + else + echo "${name} is not running." + return 1 + fi + ;; + + start) + if [ -n "$rc_pid" ]; then + echo "${name} already running? (pid=$rc_pid)." + exit 1 + fi + + if [ ! -x $command ]; then + info "run_rc_command: cannot run ($command)." + return 0 + fi + + # check for required variables, + # directories, and files + # + for _f in $required_vars; do + if ! checkyesno $_f; then + warn "\$${_f} is not set." + if [ -z "$rc_force" ]; then + return 1 + fi + fi + done + for _f in $required_dirs; do + if [ ! -d "${_f}/." ]; then + warn "${_f} is not a directory." + if [ -z "$rc_force" ]; then + return 1 + fi + fi + done + for _f in $required_files; do + if [ ! -r "${_f}" ]; then + warn "${_f} is not readable." + if [ -z "$rc_force" ]; then + return 1 + fi + fi + done + + # if the precmd failed and force + # isn't set, exit + # + if [ -n "${_precmd}" ]; then + debug "run_rc_command: evaluating ${_precmd}()." + eval $_precmd + _return=$? + [ $_return -ne 0 ] && [ -z "$rc_force" ] && + return 1 + fi + + # setup the command to run, and run it + # + echo "Starting ${name}." + if [ -n "$_chroot" ]; then + _doit="\ +${_nice:+nice -n $_nice }\ +chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\ +$_chroot $command $rc_flags $command_args" + else + _doit="\ +${_chdir:+cd $_chdir; }\ +${_nice:+nice -n $_nice }\ +$command $rc_flags $command_args" + if [ -n "$_user" ]; then + _doit="su -m $_user -c 'sh -c \"$_doit\"'" + fi + fi + + # if the cmd failed and force + # isn't set, exit + # + debug "run_rc_command: _doit: $_doit" + eval $_doit + _return=$? + [ $_return -ne 0 ] && [ -z "$rc_force" ] && return 1 + + # finally, run postcmd + # + if [ -n "${_postcmd}" ]; then + debug "run_rc_command: evaluating ${_postcmd}()." + eval $_postcmd + fi + ;; + + stop) + if [ -z "$rc_pid" ]; then + if [ -n "$pidfile" ]; then + echo \ + "${name} not running? (check $pidfile)." + else + echo "${name} not running?" + fi + exit 1 + fi + + # if the precmd failed and force + # isn't set, exit + # + if [ -n $_precmd ]; then + eval $_precmd + _return=$? + [ $_return -ne 0 ] && [ -z "$rc_force" ] && + return 1 + fi + + # send the signal to stop + # + echo "Stopping ${name}." + _doit="kill -${sig_stop:-TERM} $rc_pid" + if [ -n "$_user" ]; then + _doit="su -m $_user -c 'sh -c \"$_doit\"'" + fi + + # if the stop cmd failed and force + # isn't set, exit + # + eval $_doit + _return=$? + [ $_return -ne 0 ] && [ -z "$rc_force" ] && return 1 + + # wait for the command to exit, + # and run postcmd. + wait_for_pids $rc_pid + if [ -n "$_postcmd" ]; then + eval $_postcmd + _return=$? + fi + ;; + + reload) + if [ -z "$rc_pid" ]; then + if [ -n "$pidfile" ]; then + echo \ + "${name} not running? (check $pidfile)." + else + echo "${name} not running?" + fi + exit 1 + fi + echo "Reloading ${name} config files." + if [ -n "$_precmd" ]; then + eval $_precmd + _return=$? + [ $_return -ne 0 ] && [ -z "$rc_force" ] && + return 1 + fi + _doit="kill -${sig_reload:-HUP} $rc_pid" + if [ -n "$_user" ]; then + _doit="su -m $_user -c 'sh -c \"$_doit\"'" + fi + eval $_doit + _return=$? + [ $_return -ne 0 ] && [ -z "$rc_force" ] && return 1 + if [ -n "$_postcmd" ]; then + eval $_postcmd + _return=$? + fi + ;; + + restart) + if [ -n "$_precmd" ]; then + eval $_precmd + _return=$? + [ $_return -ne 0 ] && [ -z "$rc_force" ] && + return 1 + fi + # prevent restart being called more + # than once by any given script + # + if [ -n "$_rc_restart_done" ]; then + return 0 + fi + _rc_restart_done=YES + + ( $0 ${rc_force:+force}stop ) + $0 ${rc_force:+force}start + + if [ -n "$_postcmd" ]; then + eval $_postcmd + _return=$? + fi + ;; + + poll) + if [ -n "$rc_pid" ]; then + wait_for_pids $rc_pid + fi + ;; + + rcvar) + echo "# $name" + if [ -n "$rcvar" ]; then + if checkyesno ${rcvar}; then + echo "\$${rcvar}=YES" + else + echo "\$${rcvar}=NO" + fi + fi + ;; + + *) + rc_usage "$_keywords" + ;; + + esac + return $_return + done + + echo 1>&2 "$0: unknown directive '$rc_arg'." + rc_usage "$_keywords" + exit 1 +} + +# +# run_rc_script file arg +# Start the script `file' with `arg', and correctly handle the +# return value from the script. If `file' ends with `.sh', it's +# sourced into the current environment. If `file' appears to be +# a backup or scratch file, ignore it. Otherwise if it's +# executable run as a child process. +# +run_rc_script() +{ + _file=$1 + _arg=$2 + if [ -z "$_file" -o -z "$_arg" ]; then + err 3 'USAGE: run_rc_script file arg' + fi + + trap "echo 'Reboot interrupted'; exit 1" 3 + + unset name command command_args command_interpreter \ + extra_commands pidfile procname \ + rcvar required_dirs required_files required_vars + eval unset ${_arg}_cmd ${_arg}_precmd ${_arg}_postcmd + + case "$_file" in + *.sh) # run in current shell + set $_arg ; . $_file + ;; + *[~#]|*.OLD|*.orig) # scratch file; skip + warn "Ignoring scratch file $_file" + ;; + *) # run in subshell + if [ -x $_file ]; then + if [ -n "$rc_fast_and_loose" ]; then + set $_arg ; . $_file + else + ( trap "echo 'Reboot interrupted'; exit 1" 3 + set $_arg ; . $_file ) + fi + fi + ;; + esac +} + +# +# load_rc_config +# Source in the configuration file for a given command. +# +load_rc_config() +{ + _command=$1 + if [ -z "$_command" ]; then + err 3 'USAGE: load_rc_config command' + fi + + if [ -z "$_rc_conf_loaded" ]; then + if [ -r /etc/defaults/rc.conf ]; then + debug "Sourcing /etc/defaults/rc.conf" + . /etc/defaults/rc.conf + source_rc_confs + elif [ -r /etc/rc.conf ]; then + debug "Sourcing /etc/rc.conf (/etc/defaults/rc.conf doesn't exist)." + . /etc/rc.conf + fi + _rc_conf_loaded=YES + fi + if [ -f /etc/rc.conf.d/"$_command" ]; then + debug "Sourcing /etc/rc.conf.d/${_command}" + . /etc/rc.conf.d/"$_command" + fi + + # XXX - Deprecated variable name support + # + case ${OSTYPE} in + FreeBSD) + [ -n "$portmap_enable" ] && rpcbind_enable="$portmap_enable" + [ -n "$portmap_program" ] && rpcbind_program="$portmap_program" + [ -n "$portmap_flags" ] && rpcbind_flags="$portmap_flags" + [ -n "$single_mountd_enable" ] && mountd_enable="$single_mountd_enable" + [ -n "$xntpd_enable" ] && ntpd_enable="$xntpd_enable" + [ -n "$xntpd_program" ] && ntpd_program="$xntpd_program" + [ -n "$xntpd_flags" ] && ntpd_flags="$xntpd_flags" + [ -n "$dhcp_program" ] && dhclient_program="$dhcp_program" + [ -n "$dhcp_flags" ] && dhclient_flags="$dhcp_flags" + ;; + esac + +} + +# +# rc_usage commands +# Print a usage string for $0, with `commands' being a list of +# valid commands. +# +rc_usage() +{ + echo -n 1>&2 "Usage: $0 [fast|force](" + + _sep= + for _elem in $*; do + echo -n 1>&2 "$_sep$_elem" + _sep="|" + done + echo 1>&2 ")" + exit 1 +} + +# +# err exitval message +# Display message to stderr and log to the syslog, and exit with exitval. +# +err() +{ + exitval=$1 + shift + + if [ -x /usr/bin/logger ]; then + logger "$0: ERROR: $*" + fi + echo 1>&2 "$0: ERROR: $*" + exit $exitval +} + +# +# warn message +# Display message to stderr and log to the syslog. +# +warn() +{ + if [ -x /usr/bin/logger ]; then + logger "$0: WARNING: $*" + fi + echo 1>&2 "$0: WARNING: $*" +} + +# +# info message +# Display informational message to stdout and log to syslog. +# +info() +{ + if [ -x /usr/bin/logger ]; then + logger "$0: INFO: $*" + fi + echo "$0: INFO: $*" +} + +# +# debug message +# If debugging is enabled in rc.conf output message to stderr. +# BEWARE that you don't call any subroutine that itself calls this +# function. +# +debug() +{ + case ${rc_debug} in + [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) + if [ -x /usr/bin/logger ]; then + logger "$0: INFO: $*" + fi + echo 1>&2 "$0: DEBUG: $*" + ;; + esac +} + +# +# backup_file action file cur backup +# Make a backup copy of `file' into `cur', and save the previous +# version of `cur' as `backup' or use rcs for archiving. +# +# This routine checks the value of the backup_uses_rcs variable, +# which can be either YES or NO. +# +# The `action' keyword can be one of the following: +# +# add `file' is now being backed up (and is possibly +# being reentered into the backups system). `cur' +# is created and RCS files, if necessary, are +# created as well. +# +# update `file' has changed and needs to be backed up. +# If `cur' exists, it is copied to to `back' or +# checked into RCS (if the repository file is old), +# and then `file' is copied to `cur'. Another RCS +# check in done here if RCS is being used. +# +# remove `file' is no longer being tracked by the backups +# system. If RCS is not being used, `cur' is moved +# to `back', otherwise an empty file is checked in, +# and then `cur' is removed. +# +# +backup_file() +{ + _action=$1 + _file=$2 + _cur=$3 + _back=$4 + + if checkyesno backup_uses_rcs; then + _msg0="backup archive" + _msg1="update" + + # ensure that history file is not locked + if [ -f $_cur,v ]; then + rcs -q -u -U -M $_cur + fi + + # ensure after switching to rcs that the + # current backup is not lost + if [ -f $_cur ]; then + # no archive, or current newer than archive + if [ ! -f $_cur,v -o $_cur -nt $_cur,v ]; then + ci -q -f -u -t-"$_msg0" -m"$_msg1" $_cur + rcs -q -kb -U $_cur + co -q -f -u $_cur + fi + fi + + case $_action in + add|update) + cp -p $_file $_cur + ci -q -f -u -t-"$_msg0" -m"$_msg1" $_cur + rcs -q -kb -U $_cur + co -q -f -u $_cur + chown root:wheel $_cur $_cur,v + ;; + remove) + cp /dev/null $_cur + ci -q -f -u -t-"$_msg0" -m"$_msg1" $_cur + rcs -q -kb -U $_cur + chown root:wheel $_cur $_cur,v + rm $_cur + ;; + esac + else + case $_action in + add|update) + if [ -f $_cur ]; then + cp -p $_cur $_back + fi + cp -p $_file $_cur + chown root:wheel $_cur + ;; + remove) + mv -f $_cur $_back + ;; + esac + fi +} diff --git a/etc/rc.syscons b/etc/rc.syscons deleted file mode 100644 index 135d96d3cb..0000000000 --- a/etc/rc.syscons +++ /dev/null @@ -1,198 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2000 The FreeBSD Project -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# $FreeBSD: src/etc/rc.syscons,v 1.1.2.5 2002/11/04 07:03:59 dougb Exp $ -# $DragonFly: src/etc/Attic/rc.syscons,v 1.2 2003/06/17 04:24:45 dillon Exp $ -# Do syscons configuration -# - -# stdin must be redirected because it might be for a serial console -# -kbddev=/dev/ttyv0 -viddev=/dev/ttyv0 - -# Handle diskless boots, and other situations where syscons is not present -# -if [ -c "${kbddev}" ]; then - -echo -n 'Configuring syscons:' - -# keymap -# -case ${keymap} in -[Nn][Oo] | '') - ;; -*) - echo -n ' keymap'; kbdcontrol < ${kbddev} -l ${keymap} - ;; -esac - -# keyrate -# -case ${keyrate} in -[Nn][Oo] | '') - ;; -*) - echo -n ' keyrate'; kbdcontrol < ${kbddev} -r ${keyrate} - ;; -esac - -# keybell -# -case ${keybell} in -[Nn][Oo] | '') - ;; -*) - echo -n ' keybell'; kbdcontrol < ${kbddev} -b ${keybell} - ;; -esac - -# change function keys -# -case ${keychange} in -[Nn][Oo] | '') - ;; -*) - echo -n ' keychange' - set - ${keychange} - while [ $# -gt 0 ]; do - kbdcontrol <${kbddev} -f "$1" "$2" - shift; shift - done - ;; -esac - -# cursor type -# -case ${cursor} in -[Nn][Oo] | '') - ;; -*) - echo -n ' cursor'; vidcontrol < ${viddev} -c ${cursor} - ;; -esac - -# screen mapping -# -case ${scrnmap} in -[Nn][Oo] | '') - ;; -*) - echo -n ' scrnmap'; vidcontrol < ${viddev} -l ${scrnmap} - ;; -esac - -# font 8x16 -# -case ${font8x16} in -[Nn][Oo] | '') - ;; -*) - echo -n ' font8x16'; vidcontrol < ${viddev} -f 8x16 ${font8x16} - ;; -esac - -# font 8x14 -# -case ${font8x14} in -[Nn][Oo] | '') - ;; -*) - echo -n ' font8x14'; vidcontrol < ${viddev} -f 8x14 ${font8x14} - ;; -esac - -# font 8x8 -# -case ${font8x8} in -[Nn][Oo] | '') - ;; -*) - echo -n ' font8x8'; vidcontrol < ${viddev} -f 8x8 ${font8x8} - ;; -esac - -# blank time -# -case ${blanktime} in -[Nn][Oo] | '') - ;; -*) - echo -n ' blanktime'; vidcontrol < ${viddev} -t ${blanktime} - ;; -esac - -# screen saver -# -case ${saver} in -[Nn][Oo] | '') - ;; -*) - echo -n ' screensaver' - for i in `kldstat | awk '$5 ~ "^splash_.*$" { print $5 }'`; do - kldunload ${i} - done - kldstat -v | grep -q _saver || kldload ${saver}_saver - ;; -esac - -# mouse daemon -# -case ${moused_enable} in -[Yy][Ee][Ss]) - echo -n ' moused' - moused ${moused_flags} -p ${moused_port} -t ${moused_type} - case ${mousechar_start} in - [Nn][Oo] | '') - ;; - *) - echo -n ' mousechar_start'; vidcontrol < ${viddev} -M ${mousechar_start} - ;; - esac - vidcontrol < ${viddev} -m on - ;; -esac - -# set this mode for all virtual screens -# -if [ -n "${allscreens_flags}" ]; then - echo -n ' allscreens' - for ttyv in /dev/ttyv*; do - vidcontrol ${allscreens_flags} < ${ttyv} > ${ttyv} 2>&1 - done -fi - -# set this keyboard mode for all virtual terminals -# -if [ -n "${allscreens_kbdflags}" ]; then - echo -n ' allscreens_kbd' - for ttyv in /dev/ttyv*; do - kbdcontrol ${allscreens_kbdflags} < ${ttyv} > ${ttyv} 2>&1 - done -fi - -echo '.' -fi diff --git a/sbin/Makefile b/sbin/Makefile index adfd4028c8..33eb308b00 100644 --- a/sbin/Makefile +++ b/sbin/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.5 (Berkeley) 3/31/94 # $FreeBSD: src/sbin/Makefile,v 1.77.2.9 2002/08/08 09:03:46 ru Exp $ -# $DragonFly: src/sbin/Makefile,v 1.2 2003/06/17 04:27:31 dillon Exp $ - +# $DragonFly: src/sbin/Makefile,v 1.3 2003/07/24 06:35:38 dillon Exp $ +# # XXX MISSING: icheck ncheck SUBDIR= adjkerntz \ @@ -58,6 +58,7 @@ SUBDIR= adjkerntz \ ping6 \ quotacheck \ reboot \ + rcorder \ restore \ route \ routed \ diff --git a/sbin/rcorder/Makefile b/sbin/rcorder/Makefile new file mode 100644 index 0000000000..5e774f2c81 --- /dev/null +++ b/sbin/rcorder/Makefile @@ -0,0 +1,22 @@ +# $NetBSD: Makefile,v 1.1 1999/11/23 05:28:20 mrg Exp $ +# $FreeBSD: src/sbin/rcorder/Makefile,v 1.3 2002/06/21 15:52:05 obrien Exp $ +# $DragonFly: src/sbin/rcorder/Makefile,v 1.1 2003/07/24 06:35:38 dillon Exp $ + +PROG= rcorder +SRCS= ealloc.c hash.c rcorder.c +MAN= rcorder.8 + +LDADD+= -lutil +DPADD+= ${LIBUTIL} + +WARNS= 0 +# XXX hack for make's hash.[ch] +CFLAGS+= -DORDER -I. + +SRCS+= util.h +CLEANFILES+= util.h + +util.h: + ln -sf ${.CURDIR}/../../lib/libutil/libutil.h ${.TARGET} + +.include diff --git a/sbin/rcorder/ealloc.c b/sbin/rcorder/ealloc.c new file mode 100644 index 0000000000..086b397c26 --- /dev/null +++ b/sbin/rcorder/ealloc.c @@ -0,0 +1,124 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1989 by Berkeley Softworks + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Adam de Boor. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $NetBSD: ealloc.c,v 1.1.1.1 1999/11/19 04:30:56 mrg Exp $ + * $DragonFly: src/sbin/rcorder/ealloc.c,v 1.1 2003/07/24 06:35:38 dillon Exp $ + */ + +#include +#ifndef lint +__RCSID("$NetBSD: ealloc.c,v 1.1.1.1 1999/11/19 04:30:56 mrg Exp $"); +#endif /* not lint */ + +#include +#include +#include +#include + +#include "ealloc.h" + +static void enomem __P((void)); + +/* + * enomem -- + * die when out of memory. + */ +static void +enomem() +{ + errx(2, "Cannot allocate memory."); +} + +/* + * emalloc -- + * malloc, but die on error. + */ +void * +emalloc(len) + size_t len; +{ + void *p; + + if ((p = malloc(len)) == NULL) + enomem(); + return(p); +} + +/* + * estrdup -- + * strdup, but die on error. + */ +char * +estrdup(str) + const char *str; +{ + char *p; + + if ((p = strdup(str)) == NULL) + enomem(); + return(p); +} + +/* + * erealloc -- + * realloc, but die on error. + */ +void * +erealloc(ptr, size) + void *ptr; + size_t size; +{ + if ((ptr = realloc(ptr, size)) == NULL) + enomem(); + return(ptr); +} + +/* + * ecalloc -- + * calloc, but die on error. + */ +void * +ecalloc(nmemb, size) + size_t nmemb; + size_t size; +{ + void *ptr; + + if ((ptr = calloc(nmemb, size)) == NULL) + enomem(); + return(ptr); +} diff --git a/sbin/rcorder/ealloc.h b/sbin/rcorder/ealloc.h new file mode 100644 index 0000000000..d7e5709d2b --- /dev/null +++ b/sbin/rcorder/ealloc.h @@ -0,0 +1,9 @@ +/* + * $NetBSD: ealloc.h,v 1.1.1.1 1999/11/19 04:30:56 mrg Exp $ + * $DragonFly: src/sbin/rcorder/ealloc.h,v 1.1 2003/07/24 06:35:38 dillon Exp $ + */ + +void *emalloc __P((size_t len)); +char *estrdup __P((const char *str)); +void *erealloc __P((void *ptr, size_t size)); +void *ecalloc __P((size_t nmemb, size_t size)); diff --git a/sbin/rcorder/hash.c b/sbin/rcorder/hash.c new file mode 100644 index 0000000000..a9b296e16d --- /dev/null +++ b/sbin/rcorder/hash.c @@ -0,0 +1,439 @@ +/* + * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. + * Copyright (c) 1988, 1989 by Adam de Boor + * Copyright (c) 1989 by Berkeley Softworks + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Adam de Boor. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $NetBSD: hash.c,v 1.1.1.1 1999/11/19 04:30:56 mrg Exp $ + * $DragonFly: src/sbin/rcorder/hash.c,v 1.1 2003/07/24 06:35:38 dillon Exp $ + */ + +#ifdef MAKE_BOOTSTRAP +static char rcsid[] = "$NetBSD: hash.c,v 1.1.1.1 1999/11/19 04:30:56 mrg Exp $"; +#else +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: hash.c,v 1.1.1.1 1999/11/19 04:30:56 mrg Exp $"); +#endif +#endif /* not lint */ +#endif + +#include + +#include +#include +#include + +/* hash.c -- + * + * This module contains routines to manipulate a hash table. + * See hash.h for a definition of the structure of the hash + * table. Hash tables grow automatically as the amount of + * information increases. + */ +#include "sprite.h" +#ifndef ORDER +#include "make.h" +#endif /* ORDER */ +#include "hash.h" +#include "ealloc.h" + +/* + * Forward references to local procedures that are used before they're + * defined: + */ + +static void RebuildTable __P((Hash_Table *)); + +/* + * The following defines the ratio of # entries to # buckets + * at which we rebuild the table to make it larger. + */ + +#define rebuildLimit 8 + +/* + *--------------------------------------------------------- + * + * Hash_InitTable -- + * + * This routine just sets up the hash table. + * + * Results: + * None. + * + * Side Effects: + * Memory is allocated for the initial bucket area. + * + *--------------------------------------------------------- + */ + +void +Hash_InitTable(t, numBuckets) + register Hash_Table *t; /* Structure to use to hold table. */ + int numBuckets; /* How many buckets to create for starters. + * This number is rounded up to a power of + * two. If <= 0, a reasonable default is + * chosen. The table will grow in size later + * as needed. */ +{ + register int i; + register struct Hash_Entry **hp; + + /* + * Round up the size to a power of two. + */ + if (numBuckets <= 0) + i = 16; + else { + for (i = 2; i < numBuckets; i <<= 1) + continue; + } + t->numEntries = 0; + t->size = i; + t->mask = i - 1; + t->bucketPtr = hp = (struct Hash_Entry **)emalloc(sizeof(*hp) * i); + while (--i >= 0) + *hp++ = NULL; +} + +/* + *--------------------------------------------------------- + * + * Hash_DeleteTable -- + * + * This routine removes everything from a hash table + * and frees up the memory space it occupied (except for + * the space in the Hash_Table structure). + * + * Results: + * None. + * + * Side Effects: + * Lots of memory is freed up. + * + *--------------------------------------------------------- + */ + +void +Hash_DeleteTable(t) + Hash_Table *t; +{ + register struct Hash_Entry **hp, *h, *nexth = NULL; + register int i; + + for (hp = t->bucketPtr, i = t->size; --i >= 0;) { + for (h = *hp++; h != NULL; h = nexth) { + nexth = h->next; + free((char *)h); + } + } + free((char *)t->bucketPtr); + + /* + * Set up the hash table to cause memory faults on any future access + * attempts until re-initialization. + */ + t->bucketPtr = NULL; +} + +/* + *--------------------------------------------------------- + * + * Hash_FindEntry -- + * + * Searches a hash table for an entry corresponding to key. + * + * Results: + * The return value is a pointer to the entry for key, + * if key was present in the table. If key was not + * present, NULL is returned. + * + * Side Effects: + * None. + * + *--------------------------------------------------------- + */ + +Hash_Entry * +Hash_FindEntry(t, key) + Hash_Table *t; /* Hash table to search. */ + char *key; /* A hash key. */ +{ + register Hash_Entry *e; + register unsigned h; + register char *p; + + for (h = 0, p = key; *p;) + h = (h << 5) - h + *p++; + p = key; + for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next) + if (e->namehash == h && strcmp(e->name, p) == 0) + return (e); + return (NULL); +} + +/* + *--------------------------------------------------------- + * + * Hash_CreateEntry -- + * + * Searches a hash table for an entry corresponding to + * key. If no entry is found, then one is created. + * + * Results: + * The return value is a pointer to the entry. If *newPtr + * isn't NULL, then *newPtr is filled in with TRUE if a + * new entry was created, and FALSE if an entry already existed + * with the given key. + * + * Side Effects: + * Memory may be allocated, and the hash buckets may be modified. + *--------------------------------------------------------- + */ + +Hash_Entry * +Hash_CreateEntry(t, key, newPtr) + register Hash_Table *t; /* Hash table to search. */ + char *key; /* A hash key. */ + Boolean *newPtr; /* Filled in with TRUE if new entry created, + * FALSE otherwise. */ +{ + register Hash_Entry *e; + register unsigned h; + register char *p; + int keylen; + struct Hash_Entry **hp; + + /* + * Hash the key. As a side effect, save the length (strlen) of the + * key in case we need to create the entry. + */ + for (h = 0, p = key; *p;) + h = (h << 5) - h + *p++; + keylen = p - key; + p = key; + for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next) { + if (e->namehash == h && strcmp(e->name, p) == 0) { + if (newPtr != NULL) + *newPtr = FALSE; + return (e); + } + } + + /* + * The desired entry isn't there. Before allocating a new entry, + * expand the table if necessary (and this changes the resulting + * bucket chain). + */ + if (t->numEntries >= rebuildLimit * t->size) + RebuildTable(t); + e = (Hash_Entry *) emalloc(sizeof(*e) + keylen); + hp = &t->bucketPtr[h & t->mask]; + e->next = *hp; + *hp = e; + e->clientData = NULL; + e->namehash = h; + (void) strcpy(e->name, p); + t->numEntries++; + + if (newPtr != NULL) + *newPtr = TRUE; + return (e); +} + +/* + *--------------------------------------------------------- + * + * Hash_DeleteEntry -- + * + * Delete the given hash table entry and free memory associated with + * it. + * + * Results: + * None. + * + * Side Effects: + * Hash chain that entry lives in is modified and memory is freed. + * + *--------------------------------------------------------- + */ + +void +Hash_DeleteEntry(t, e) + Hash_Table *t; + Hash_Entry *e; +{ + register Hash_Entry **hp, *p; + + if (e == NULL) + return; + for (hp = &t->bucketPtr[e->namehash & t->mask]; + (p = *hp) != NULL; hp = &p->next) { + if (p == e) { + *hp = p->next; + free((char *)p); + t->numEntries--; + return; + } + } + (void)write(2, "bad call to Hash_DeleteEntry\n", 29); + abort(); +} + +/* + *--------------------------------------------------------- + * + * Hash_EnumFirst -- + * This procedure sets things up for a complete search + * of all entries recorded in the hash table. + * + * Results: + * The return value is the address of the first entry in + * the hash table, or NULL if the table is empty. + * + * Side Effects: + * The information in searchPtr is initialized so that successive + * calls to Hash_Next will return successive HashEntry's + * from the table. + * + *--------------------------------------------------------- + */ + +Hash_Entry * +Hash_EnumFirst(t, searchPtr) + Hash_Table *t; /* Table to be searched. */ + register Hash_Search *searchPtr;/* Area in which to keep state + * about search.*/ +{ + searchPtr->tablePtr = t; + searchPtr->nextIndex = 0; + searchPtr->hashEntryPtr = NULL; + return Hash_EnumNext(searchPtr); +} + +/* + *--------------------------------------------------------- + * + * Hash_EnumNext -- + * This procedure returns successive entries in the hash table. + * + * Results: + * The return value is a pointer to the next HashEntry + * in the table, or NULL when the end of the table is + * reached. + * + * Side Effects: + * The information in searchPtr is modified to advance to the + * next entry. + * + *--------------------------------------------------------- + */ + +Hash_Entry * +Hash_EnumNext(searchPtr) + register Hash_Search *searchPtr; /* Area used to keep state about + search. */ +{ + register Hash_Entry *e; + Hash_Table *t = searchPtr->tablePtr; + + /* + * The hashEntryPtr field points to the most recently returned + * entry, or is nil if we are starting up. If not nil, we have + * to start at the next one in the chain. + */ + e = searchPtr->hashEntryPtr; + if (e != NULL) + e = e->next; + /* + * If the chain ran out, or if we are starting up, we need to + * find the next nonempty chain. + */ + while (e == NULL) { + if (searchPtr->nextIndex >= t->size) + return (NULL); + e = t->bucketPtr[searchPtr->nextIndex++]; + } + searchPtr->hashEntryPtr = e; + return (e); +} + +/* + *--------------------------------------------------------- + * + * RebuildTable -- + * This local routine makes a new hash table that + * is larger than the old one. + * + * Results: + * None. + * + * Side Effects: + * The entire hash table is moved, so any bucket numbers + * from the old table are invalid. + * + *--------------------------------------------------------- + */ + +static void +RebuildTable(t) + register Hash_Table *t; +{ + register Hash_Entry *e, *next = NULL, **hp, **xp; + register int i, mask; + register Hash_Entry **oldhp; + int oldsize; + + oldhp = t->bucketPtr; + oldsize = i = t->size; + i <<= 1; + t->size = i; + t->mask = mask = i - 1; + t->bucketPtr = hp = (struct Hash_Entry **) emalloc(sizeof(*hp) * i); + while (--i >= 0) + *hp++ = NULL; + for (hp = oldhp, i = oldsize; --i >= 0;) { + for (e = *hp++; e != NULL; e = next) { + next = e->next; + xp = &t->bucketPtr[e->namehash & mask]; + e->next = *xp; + *xp = e; + } + } + free((char *)oldhp); +} diff --git a/sbin/rcorder/hash.h b/sbin/rcorder/hash.h new file mode 100644 index 0000000000..2903a3353f --- /dev/null +++ b/sbin/rcorder/hash.h @@ -0,0 +1,130 @@ +/* + * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. + * Copyright (c) 1988, 1989 by Adam de Boor + * Copyright (c) 1989 by Berkeley Softworks + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Adam de Boor. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)hash.h 8.1 (Berkeley) 6/6/93 + * $NetBSD: hash.h,v 1.1.1.1 1999/11/19 04:30:56 mrg Exp $ + * $DragonFly: src/sbin/rcorder/hash.h,v 1.1 2003/07/24 06:35:38 dillon Exp $ + */ + +/* hash.h -- + * + * This file contains definitions used by the hash module, + * which maintains hash tables. + */ + +#ifndef _HASH +#define _HASH + +/* + * The following defines one entry in the hash table. + */ + +typedef struct Hash_Entry { + struct Hash_Entry *next; /* Used to link together all the + * entries associated with the same + * bucket. */ + ClientData clientData; /* Arbitrary piece of data associated + * with key. */ + unsigned namehash; /* hash value of key */ + char name[1]; /* key string */ +} Hash_Entry; + +typedef struct Hash_Table { + struct Hash_Entry **bucketPtr; + /* Pointers to Hash_Entry, one + * for each bucket in the table. */ + int size; /* Actual size of array. */ + int numEntries; /* Number of entries in the table. */ + int mask; /* Used to select bits for hashing. */ +} Hash_Table; + +/* + * The following structure is used by the searching routines + * to record where we are in the search. + */ + +typedef struct Hash_Search { + Hash_Table *tablePtr; /* Table being searched. */ + int nextIndex; /* Next bucket to check (after + * current). */ + Hash_Entry *hashEntryPtr; /* Next entry to check in current + * bucket. */ +} Hash_Search; + +/* + * Macros. + */ + +/* + * ClientData Hash_GetValue(h) + * Hash_Entry *h; + */ + +#define Hash_GetValue(h) ((h)->clientData) + +/* + * Hash_SetValue(h, val); + * Hash_Entry *h; + * char *val; + */ + +#define Hash_SetValue(h, val) ((h)->clientData = (ClientData) (val)) + +#ifdef ORDER +/* + * Hash_GetKey(h); + * Hash_Entry *h; + */ + +#define Hash_GetKey(h) ((h)->name) +#endif /* ORDER */ + +/* + * Hash_Size(n) returns the number of words in an object of n bytes + */ + +#define Hash_Size(n) (((n) + sizeof (int) - 1) / sizeof (int)) + +void Hash_InitTable __P((Hash_Table *, int)); +void Hash_DeleteTable __P((Hash_Table *)); +Hash_Entry *Hash_FindEntry __P((Hash_Table *, char *)); +Hash_Entry *Hash_CreateEntry __P((Hash_Table *, char *, Boolean *)); +void Hash_DeleteEntry __P((Hash_Table *, Hash_Entry *)); +Hash_Entry *Hash_EnumFirst __P((Hash_Table *, Hash_Search *)); +Hash_Entry *Hash_EnumNext __P((Hash_Search *)); + +#endif /* _HASH */ diff --git a/sbin/rcorder/rcorder.8 b/sbin/rcorder/rcorder.8 new file mode 100644 index 0000000000..c09f638bda --- /dev/null +++ b/sbin/rcorder/rcorder.8 @@ -0,0 +1,168 @@ +.\" $NetBSD: rcorder.8,v 1.3 2000/07/17 14:16:22 mrg Exp $ +.\" $DragonFly: src/sbin/rcorder/rcorder.8,v 1.1 2003/07/24 06:35:38 dillon Exp $ +.\" +.\" Copyright (c) 1998 +.\" Perry E. Metzger. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgment: +.\" This product includes software developed for the NetBSD Project +.\" by Perry E. Metzger. +.\" 4. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD: src/sbin/rcorder/rcorder.8,v 1.3 2002/11/25 16:23:03 ru Exp $ +.\" +.Dd July 17, 2000 +.Dt RCORDER 8 +.Os +.Sh NAME +.Nm rcorder +.Nd print a dependency ordering of interdependent files +.Sh SYNOPSIS +.Nm +.Op Fl k Ar keep +.Op Fl s Ar skip +.Ar +.Sh DESCRIPTION +The +.Nm +utility is designed to print out a dependency ordering of a set of +interdependent files. +Typically it is used to find an execution +sequence for a set of shell scripts in which certain files must be +executed before others. +.Pp +Each file passed to +.Nm +must be annotated with special lines (which look like comments to the +shell) which indicate the dependencies the files have upon certain +points in the sequence, known as +.Dq conditions , +and which indicate, for each file, which +.Dq conditions +may be expected to be filled by that file. +.Pp +Within each file, a block containing a series of +.Dq Li REQUIRE , +.Dq Li PROVIDE , +.Dq Li BEFORE +and +.Dq Li KEYWORD +lines must appear. +The format of the lines is rigid. +Each line must begin with a single +.Ql # , +followed by a single space, followed by +.Dq Li PROVIDE: , +.Dq Li REQUIRE: , +.Dq Li BEFORE: , +or +.Dq Li KEYWORD: . +No deviation is permitted. +Each dependency line is then followed by a series of conditions, +separated by whitespace. +Multiple +.Dq Li PROVIDE , +.Dq Li REQUIRE , +.Dq Li BEFORE +and +.Dq Li KEYWORD +lines may appear, but all such lines must appear in a sequence without +any intervening lines, as once a line that does not follow the format +is reached, parsing stops. +.Pp +The options are as follows: +.Bl -tag -width indent +.It Fl k +Add the specified keyword to the +.Dq "keep list" . +If any +.Fl k +option is given, only those files containing the matching keyword are listed. +.It Fl s +Add the specified keyword to the +.Dq "skip list" . +If any +.Fl s +option is given, files containing the matching keyword are not listed. +.El +.Pp + An example block follows: +.Bd -literal -offset indent +# REQUIRE: networking syslog +# REQUIRE: usr +# PROVIDE: dns nscd +.Ed +.Pp +This block states that the file in which it appears depends upon the +.Dq Li networking , +.Dq Li syslog , +and +.Dq Li usr +conditions, and provides the +.Dq Li dns +and +.Dq Li nscd +conditions. +.Pp +A file may contain zero +.Dq Li PROVIDE +lines, in which case it provides no conditions, and may contain zero +.Dq Li REQUIRE +lines, in which case it has no dependencies. +There must be at least one file with no dependencies in the set of +arguments passed to +.Nm +in order for it to find a starting place in the dependency ordering. +.Sh DIAGNOSTICS +The +.Nm +utility may print one of the following error messages and exit with a non-zero +status if it encounters an error while processing the file list. +.Bl -diag +.It "Requirement %s has no providers, aborting." +No file has a +.Dq Li PROVIDE +line corresponding to a condition present in a +.Dq Li REQUIRE +line in another file. +.It "Circular dependency on provision %s, aborting." +A set of files has a circular dependency which was detected while +processing the stated condition. +.It "Circular dependency on file %s, aborting." +A set of files has a circular dependency which was detected while +processing the stated file. +.El +.Sh SEE ALSO +.Xr rc 8 +.Sh HISTORY +The +.Nm +utility first appeared in +.Nx 1.5 . +.Sh AUTHORS +.An -nosplit +Written by +.An Perry E. Metzger Aq perry@piermont.com +and +.An Matthew R. Green Aq mrg@eterna.com.au . diff --git a/sbin/rcorder/rcorder.c b/sbin/rcorder/rcorder.c new file mode 100644 index 0000000000..49f86a2c41 --- /dev/null +++ b/sbin/rcorder/rcorder.c @@ -0,0 +1,822 @@ +/* + * Copyright (c) 1998, 1999 Matthew R. Green + * All rights reserved. + * Copyright (c) 1998 + * Perry E. Metzger. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed for the NetBSD Project + * by Perry E. Metzger. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: rcorder.c,v 1.7 2000/08/04 07:33:55 enami Exp $ + * $DragonFly: src/sbin/rcorder/rcorder.c,v 1.1 2003/07/24 06:35:38 dillon Exp $ + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "ealloc.h" +#include "sprite.h" +#include "hash.h" + +#ifdef DEBUG +int debug = 0; +# define DPRINTF(args) if (debug) { fflush(stdout); fprintf args; } +#else +# define DPRINTF(args) +#endif + +#define REQUIRE_STR "# REQUIRE:" +#define REQUIRE_LEN (sizeof(REQUIRE_STR) - 1) +#define REQUIRES_STR "# REQUIRES:" +#define REQUIRES_LEN (sizeof(REQUIRES_STR) - 1) +#define PROVIDE_STR "# PROVIDE:" +#define PROVIDE_LEN (sizeof(PROVIDE_STR) - 1) +#define PROVIDES_STR "# PROVIDES:" +#define PROVIDES_LEN (sizeof(PROVIDES_STR) - 1) +#define BEFORE_STR "# BEFORE:" +#define BEFORE_LEN (sizeof(BEFORE_STR) - 1) +#define KEYWORD_STR "# KEYWORD:" +#define KEYWORD_LEN (sizeof(KEYWORD_STR) - 1) +#define KEYWORDS_STR "# KEYWORDS:" +#define KEYWORDS_LEN (sizeof(KEYWORDS_STR) - 1) + +int exit_code; +int file_count; +char **file_list; + +typedef int bool; +#define TRUE 1 +#define FALSE 0 +typedef bool flag; +#define SET TRUE +#define RESET FALSE + +Hash_Table provide_hash_s, *provide_hash; + +typedef struct provnode provnode; +typedef struct filenode filenode; +typedef struct f_provnode f_provnode; +typedef struct f_reqnode f_reqnode; +typedef struct strnodelist strnodelist; + +struct provnode { + flag head; + flag in_progress; + filenode *fnode; + provnode *next, *last; +}; + +struct f_provnode { + provnode *pnode; + f_provnode *next; +}; + +struct f_reqnode { + Hash_Entry *entry; + f_reqnode *next; +}; + +struct strnodelist { + filenode *node; + strnodelist *next; + char s[1]; +}; + +struct filenode { + char *filename; + flag in_progress; + filenode *next, *last; + f_reqnode *req_list; + f_provnode *prov_list; + strnodelist *keyword_list; +}; + +filenode fn_head_s, *fn_head; + +strnodelist *bl_list; +strnodelist *keep_list; +strnodelist *skip_list; + +void do_file __P((filenode *fnode)); +void strnode_add __P((strnodelist **, char *, filenode *)); +int skip_ok __P((filenode *fnode)); +int keep_ok __P((filenode *fnode)); +void satisfy_req __P((f_reqnode *rnode, char *filename)); +void crunch_file __P((char *)); +void parse_require __P((filenode *, char *)); +void parse_provide __P((filenode *, char *)); +void parse_before __P((filenode *, char *)); +void parse_keywords __P((filenode *, char *)); +filenode *filenode_new __P((char *)); +void add_require __P((filenode *, char *)); +void add_provide __P((filenode *, char *)); +void add_before __P((filenode *, char *)); +void add_keyword __P((filenode *, char *)); +void insert_before __P((void)); +Hash_Entry *make_fake_provision __P((filenode *)); +void crunch_all_files __P((void)); +void initialize __P((void)); +void generate_ordering __P((void)); +int main __P((int, char *[])); + +int +main(argc, argv) + int argc; + char *argv[]; +{ + int ch; + + while ((ch = getopt(argc, argv, "dk:s:")) != -1) + switch (ch) { + case 'd': +#ifdef DEBUG + debug = 1; +#else + warnx("debugging not compiled in, -d ignored"); +#endif + break; + case 'k': + strnode_add(&keep_list, optarg, 0); + break; + case 's': + strnode_add(&skip_list, optarg, 0); + break; + default: + /* XXX should crunch it? */ + break; + } + argc -= optind; + argv += optind; + + file_count = argc; + file_list = argv; + + DPRINTF((stderr, "parse_args\n")); + initialize(); + DPRINTF((stderr, "initialize\n")); + crunch_all_files(); + DPRINTF((stderr, "crunch_all_files\n")); + generate_ordering(); + DPRINTF((stderr, "generate_ordering\n")); + + exit(exit_code); +} + +/* + * initialise various variables. + */ +void +initialize() +{ + + fn_head = &fn_head_s; + + provide_hash = &provide_hash_s; + Hash_InitTable(provide_hash, file_count); +} + +/* generic function to insert a new strnodelist element */ +void +strnode_add(listp, s, fnode) + strnodelist **listp; + char *s; + filenode *fnode; +{ + strnodelist *ent; + + ent = emalloc(sizeof *ent + strlen(s)); + ent->node = fnode; + strcpy(ent->s, s); + ent->next = *listp; + *listp = ent; +} + +/* + * below are the functions that deal with creating the lists + * from the filename's given and the dependancies and provisions + * in each of these files. no ordering or checking is done here. + */ + +/* + * we have a new filename, create a new filenode structure. + * fill in the bits, and put it in the filenode linked list + */ +filenode * +filenode_new(filename) + char *filename; +{ + filenode *temp; + + temp = emalloc(sizeof(*temp)); + memset(temp, 0, sizeof(*temp)); + temp->filename = estrdup(filename); + temp->req_list = NULL; + temp->prov_list = NULL; + temp->keyword_list = NULL; + temp->in_progress = RESET; + /* + * link the filenode into the list of filenodes. + * note that the double linking means we can delete a + * filenode without searching for where it belongs. + */ + temp->next = fn_head->next; + if (temp->next != NULL) + temp->next->last = temp; + temp->last = fn_head; + fn_head->next = temp; + return (temp); +} + +/* + * add a requirement to a filenode. + */ +void +add_require(fnode, s) + filenode *fnode; + char *s; +{ + Hash_Entry *entry; + f_reqnode *rnode; + int new; + + entry = Hash_CreateEntry(provide_hash, s, &new); + if (new) + Hash_SetValue(entry, NULL); + rnode = emalloc(sizeof(*rnode)); + rnode->entry = entry; + rnode->next = fnode->req_list; + fnode->req_list = rnode; +} + +/* + * add a provision to a filenode. if this provision doesn't + * have a head node, create one here. + */ +void +add_provide(fnode, s) + filenode *fnode; + char *s; +{ + Hash_Entry *entry; + f_provnode *f_pnode; + provnode *pnode, *head; + int new; + + entry = Hash_CreateEntry(provide_hash, s, &new); + head = Hash_GetValue(entry); + + /* create a head node if necessary. */ + if (head == NULL) { + head = emalloc(sizeof(*head)); + head->head = SET; + head->in_progress = RESET; + head->fnode = NULL; + head->last = head->next = NULL; + Hash_SetValue(entry, head); + } +#if 0 + /* + * Don't warn about this. We want to be able to support + * scripts that do two complex things: + * + * - Two independent scripts which both provide the + * same thing. Both scripts must be executed in + * any order to meet the barrier. An example: + * + * Script 1: + * + * PROVIDE: mail + * REQUIRE: LOGIN + * + * Script 2: + * + * PROVIDE: mail + * REQUIRE: LOGIN + * + * - Two interdependent scripts which both provide the + * same thing. Both scripts must be executed in + * graph order to meet the barrier. An example: + * + * Script 1: + * + * PROVIDE: nameservice dnscache + * REQUIRE: SERVERS + * + * Script 2: + * + * PROVIDE: nameservice nscd + * REQUIRE: dnscache + */ + else if (new == 0) { + warnx("file `%s' provides `%s'.", fnode->filename, s); + warnx("\tpreviously seen in `%s'.", + head->next->fnode->filename); + } +#endif + + pnode = emalloc(sizeof(*pnode)); + pnode->head = RESET; + pnode->in_progress = RESET; + pnode->fnode = fnode; + pnode->next = head->next; + pnode->last = head; + head->next = pnode; + if (pnode->next != NULL) + pnode->next->last = pnode; + + f_pnode = emalloc(sizeof(*f_pnode)); + f_pnode->pnode = pnode; + f_pnode->next = fnode->prov_list; + fnode->prov_list = f_pnode; +} + +/* + * put the BEFORE: lines to a list and handle them later. + */ +void +add_before(fnode, s) + filenode *fnode; + char *s; +{ + strnodelist *bf_ent; + + bf_ent = emalloc(sizeof *bf_ent + strlen(s)); + bf_ent->node = fnode; + strcpy(bf_ent->s, s); + bf_ent->next = bl_list; + bl_list = bf_ent; +} + +/* + * add a key to a filenode. + */ +void +add_keyword(fnode, s) + filenode *fnode; + char *s; +{ + + strnode_add(&fnode->keyword_list, s, fnode); +} + +/* + * loop over the rest of a REQUIRE line, giving each word to + * add_require() to do the real work. + */ +void +parse_require(node, buffer) + filenode *node; + char *buffer; +{ + char *s; + + while ((s = strsep(&buffer, " \t\n")) != NULL) + if (*s != '\0') + add_require(node, s); +} + +/* + * loop over the rest of a PROVIDE line, giving each word to + * add_provide() to do the real work. + */ +void +parse_provide(node, buffer) + filenode *node; + char *buffer; +{ + char *s; + + while ((s = strsep(&buffer, " \t\n")) != NULL) + if (*s != '\0') + add_provide(node, s); +} + +/* + * loop over the rest of a BEFORE line, giving each word to + * add_before() to do the real work. + */ +void +parse_before(node, buffer) + filenode *node; + char *buffer; +{ + char *s; + + while ((s = strsep(&buffer, " \t\n")) != NULL) + if (*s != '\0') + add_before(node, s); +} + +/* + * loop over the rest of a KEYWORD line, giving each word to + * add_keyword() to do the real work. + */ +void +parse_keywords(node, buffer) + filenode *node; + char *buffer; +{ + char *s; + + while ((s = strsep(&buffer, " \t\n")) != NULL) + if (*s != '\0') + add_keyword(node, s); +} + +/* + * given a file name, create a filenode for it, read in lines looking + * for provision and requirement lines, building the graphs as needed. + */ +void +crunch_file(filename) + char *filename; +{ + FILE *fp; + char *buf; + int require_flag, provide_flag, before_flag, keywords_flag; + enum { BEFORE_PARSING, PARSING, PARSING_DONE } state; + filenode *node; + char delims[3] = { '\\', '\\', '\0' }; + struct stat st; + + if ((fp = fopen(filename, "r")) == NULL) { + warn("could not open %s", filename); + return; + } + + if (fstat(fileno(fp), &st) == -1) { + warn("could not stat %s", filename); + fclose(fp); + return; + } + + if (!S_ISREG(st.st_mode)) { +#if 0 + warnx("%s is not a file", filename); +#endif + fclose(fp); + return; + } + + node = filenode_new(filename); + + /* + * we don't care about length, line number, don't want # for comments, + * and have no flags. + */ + for (state = BEFORE_PARSING; state != PARSING_DONE && + (buf = fparseln(fp, NULL, NULL, delims, 0)) != NULL; free(buf)) { + require_flag = provide_flag = before_flag = keywords_flag = 0; + if (strncmp(REQUIRE_STR, buf, REQUIRE_LEN) == 0) + require_flag = REQUIRE_LEN; + else if (strncmp(REQUIRES_STR, buf, REQUIRES_LEN) == 0) + require_flag = REQUIRES_LEN; + else if (strncmp(PROVIDE_STR, buf, PROVIDE_LEN) == 0) + provide_flag = PROVIDE_LEN; + else if (strncmp(PROVIDES_STR, buf, PROVIDES_LEN) == 0) + provide_flag = PROVIDES_LEN; + else if (strncmp(BEFORE_STR, buf, BEFORE_LEN) == 0) + before_flag = BEFORE_LEN; + else if (strncmp(KEYWORD_STR, buf, KEYWORD_LEN) == 0) + keywords_flag = KEYWORD_LEN; + else if (strncmp(KEYWORDS_STR, buf, KEYWORDS_LEN) == 0) + keywords_flag = KEYWORDS_LEN; + else { + if (state == PARSING) + state = PARSING_DONE; + continue; + } + + state = PARSING; + if (require_flag) + parse_require(node, buf + require_flag); + else if (provide_flag) + parse_provide(node, buf + provide_flag); + else if (before_flag) + parse_before(node, buf + before_flag); + else if (keywords_flag) + parse_keywords(node, buf + keywords_flag); + } + fclose(fp); +} + +Hash_Entry * +make_fake_provision(node) + filenode *node; +{ + Hash_Entry *entry; + f_provnode *f_pnode; + provnode *head, *pnode; + static int i = 0; + int new; + char buffer[30]; + + do { + snprintf(buffer, sizeof buffer, "fake_prov_%08d", i++); + entry = Hash_CreateEntry(provide_hash, buffer, &new); + } while (new == 0); + head = emalloc(sizeof(*head)); + head->head = SET; + head->in_progress = RESET; + head->fnode = NULL; + head->last = head->next = NULL; + Hash_SetValue(entry, head); + + pnode = emalloc(sizeof(*pnode)); + pnode->head = RESET; + pnode->in_progress = RESET; + pnode->fnode = node; + pnode->next = head->next; + pnode->last = head; + head->next = pnode; + if (pnode->next != NULL) + pnode->next->last = pnode; + + f_pnode = emalloc(sizeof(*f_pnode)); + f_pnode->pnode = pnode; + f_pnode->next = node->prov_list; + node->prov_list = f_pnode; + + return (entry); +} + +/* + * go through the BEFORE list, inserting requirements into the graph(s) + * as required. in the before list, for each entry B, we have a file F + * and a string S. we create a "fake" provision (P) that F provides. + * for each entry in the provision list for S, add a requirement to + * that provisions filenode for P. + */ +void +insert_before() +{ + Hash_Entry *entry, *fake_prov_entry; + provnode *pnode; + f_reqnode *rnode; + strnodelist *bl; + int new; + + while (bl_list != NULL) { + bl = bl_list->next; + + fake_prov_entry = make_fake_provision(bl_list->node); + + entry = Hash_CreateEntry(provide_hash, bl_list->s, &new); + if (new == 1) + warnx("file `%s' is before unknown provision `%s'", bl_list->node->filename, bl_list->s); + + for (pnode = Hash_GetValue(entry); pnode; pnode = pnode->next) { + if (pnode->head) + continue; + + rnode = emalloc(sizeof(*rnode)); + rnode->entry = fake_prov_entry; + rnode->next = pnode->fnode->req_list; + pnode->fnode->req_list = rnode; + } + + free(bl_list); + bl_list = bl; + } +} + +/* + * loop over all the files calling crunch_file() on them to do the + * real work. after we have built all the nodes, insert the BEFORE: + * lines into graph(s). + */ +void +crunch_all_files() +{ + int i; + + for (i = 0; i < file_count; i++) + crunch_file(file_list[i]); + insert_before(); +} + +/* + * below are the functions that traverse the graphs we have built + * finding out the desired ordering, printing each file in turn. + * if missing requirements, or cyclic graphs are detected, a + * warning will be issued, and we will continue on.. + */ + +/* + * given a requirement node (in a filename) we attempt to satisfy it. + * we do some sanity checking first, to ensure that we have providers, + * aren't already satisfied and aren't already being satisfied (ie, + * cyclic). if we pass all this, we loop over the provision list + * calling do_file() (enter recursion) for each filenode in this + * provision. + */ +void +satisfy_req(rnode, filename) + f_reqnode *rnode; + char *filename; +{ + Hash_Entry *entry; + provnode *head; + + entry = rnode->entry; + head = Hash_GetValue(entry); + + if (head == NULL) { + warnx("requirement `%s' in file `%s' has no providers.", + Hash_GetKey(entry), filename); + exit_code = 1; + return; + } + + /* return if the requirement is already satisfied. */ + if (head->next == NULL) + return; + + /* + * if list is marked as in progress, + * print that there is a circular dependency on it and abort + */ + if (head->in_progress == SET) { + warnx("Circular dependency on provision `%s' in file `%s'.", + Hash_GetKey(entry), filename); + exit_code = 1; + return; + } + + head->in_progress = SET; + + /* + * while provision_list is not empty + * do_file(first_member_of(provision_list)); + */ + while (head->next != NULL) + do_file(head->next->fnode); +} + +int +skip_ok(fnode) + filenode *fnode; +{ + strnodelist *s; + strnodelist *k; + + for (s = skip_list; s; s = s->next) + for (k = fnode->keyword_list; k; k = k->next) + if (strcmp(k->s, s->s) == 0) + return (0); + + return (1); +} + +int +keep_ok(fnode) + filenode *fnode; +{ + strnodelist *s; + strnodelist *k; + + for (s = keep_list; s; s = s->next) + for (k = fnode->keyword_list; k; k = k->next) + if (strcmp(k->s, s->s) == 0) + return (1); + + /* an empty keep_list means every one */ + return (!keep_list); +} + +/* + * given a filenode, we ensure we are not a cyclic graph. if this + * is ok, we loop over the filenodes requirements, calling satisfy_req() + * for each of them.. once we have done this, remove this filenode + * from each provision table, as we are now done. + */ +void +do_file(fnode) + filenode *fnode; +{ + f_reqnode *r, *r_tmp; + f_provnode *p, *p_tmp; + provnode *pnode; + int was_set; + + DPRINTF((stderr, "do_file on %s.\n", fnode->filename)); + + /* + * if fnode is marked as in progress, + * print that fnode; is circularly depended upon and abort. + */ + if (fnode->in_progress == SET) { + warnx("Circular dependency on file `%s'.", + fnode->filename); + was_set = exit_code = 1; + } else + was_set = 0; + + /* mark fnode */ + fnode->in_progress = SET; + + /* + * for each requirement of fnode -> r + * satisfy_req(r, filename) + */ + r = fnode->req_list; + while (r != NULL) { + r_tmp = r; + satisfy_req(r, fnode->filename); + r = r->next; + free(r_tmp); + } + fnode->req_list = NULL; + + /* + * for each provision of fnode -> p + * remove fnode from provision list for p in hash table + */ + p = fnode->prov_list; + while (p != NULL) { + p_tmp = p; + pnode = p->pnode; + if (pnode->next != NULL) { + pnode->next->last = pnode->last; + } + if (pnode->last != NULL) { + pnode->last->next = pnode->next; + } + free(pnode); + p = p->next; + free(p_tmp); + } + fnode->prov_list = NULL; + + /* do_it(fnode) */ + DPRINTF((stderr, "next do: ")); + + /* if we were already in progress, don't print again */ + if (was_set == 0 && skip_ok(fnode) && keep_ok(fnode)) + printf("%s\n", fnode->filename); + + if (fnode->next != NULL) { + fnode->next->last = fnode->last; + } + if (fnode->last != NULL) { + fnode->last->next = fnode->next; + } + + DPRINTF((stderr, "nuking %s\n", fnode->filename)); + free(fnode->filename); + free(fnode); +} + +void +generate_ordering() +{ + + /* + * while there remain undone files{f}, + * pick an arbitrary f, and do_file(f) + * Note that the first file in the file list is perfectly + * arbitrary, and easy to find, so we use that. + */ + + /* + * N.B.: the file nodes "self delete" after they execute, so + * after each iteration of the loop, the head will be pointing + * to something totally different. The loop ends up being + * executed only once for every strongly connected set of + * nodes. + */ + while (fn_head->next != NULL) { + DPRINTF((stderr, "generate on %s\n", fn_head->next->filename)); + do_file(fn_head->next); + } +} diff --git a/sbin/rcorder/sprite.h b/sbin/rcorder/sprite.h new file mode 100644 index 0000000000..3ef429db88 --- /dev/null +++ b/sbin/rcorder/sprite.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1989 by Berkeley Softworks + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Adam de Boor. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)sprite.h 8.1 (Berkeley) 6/6/93 + * $NetBSD: sprite.h,v 1.1 1999/11/23 05:28:22 mrg Exp $ + * $DragonFly: src/sbin/rcorder/sprite.h,v 1.1 2003/07/24 06:35:38 dillon Exp $ + */ + +/* + * sprite.h -- + * + * Common constants and type declarations for Sprite. + */ + +#ifndef _SPRITE +#define _SPRITE + + +/* + * A boolean type is defined as an integer, not an enum. This allows a + * boolean argument to be an expression that isn't strictly 0 or 1 valued. + */ + +typedef int Boolean; +#ifndef TRUE +#define TRUE 1 +#endif /* TRUE */ +#ifndef FALSE +#define FALSE 0 +#endif /* FALSE */ + +/* + * Functions that must return a status can return a ReturnStatus to + * indicate success or type of failure. + */ + +typedef int ReturnStatus; + +/* + * The following statuses overlap with the first 2 generic statuses + * defined in status.h: + * + * SUCCESS There was no error. + * FAILURE There was a general error. + */ + +#define SUCCESS 0x00000000 +#define FAILURE 0x00000001 + + +/* + * A nil pointer must be something that will cause an exception if + * referenced. There are two nils: the kernels nil and the nil used + * by user processes. + */ + +#define NIL ~0 +#define USER_NIL 0 +#ifndef NULL +#define NULL 0 +#endif /* NULL */ + +/* + * An address is just a pointer in C. It is defined as a character pointer + * so that address arithmetic will work properly, a byte at a time. + */ + +typedef char *Address; + +/* + * ClientData is an uninterpreted word. It is defined as an int so that + * kdbx will not interpret client data as a string. Unlike an "Address", + * client data will generally not be used in arithmetic. + * But we don't have kdbx anymore so we define it as void (christos) + */ + +typedef void *ClientData; + +#endif /* _SPRITE */ diff --git a/usr.sbin/mergemaster/mergemaster.sh b/usr.sbin/mergemaster/mergemaster.sh index 52b917df56..afcf0792ad 100644 --- a/usr.sbin/mergemaster/mergemaster.sh +++ b/usr.sbin/mergemaster/mergemaster.sh @@ -8,15 +8,15 @@ # Copyright 1998-2003 Douglas Barton # DougB@FreeBSD.org -# $FreeBSD: src/usr.sbin/mergemaster/mergemaster.sh,v 1.6.2.17 2003/03/10 06:55:48 dougb Exp $ -# $DragonFly: src/usr.sbin/mergemaster/mergemaster.sh,v 1.2 2003/06/17 04:29:57 dillon Exp $ +# $FreeBSD: src/usr.sbin/mergemaster/mergemaster.sh,v 1.46 2003/05/03 06:35:19 dougb Exp $ +# $DragonFly: src/usr.sbin/mergemaster/mergemaster.sh,v 1.3 2003/07/24 06:35:39 dillon Exp $ PATH=/bin:/usr/bin:/usr/sbin display_usage () { VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4` echo "mergemaster version ${VERSION_NUMBER}" - echo 'Usage: mergemaster [-scrvahipC] [-m /path]' + echo 'Usage: mergemaster [-scrvahipCP] [-m /path]' echo ' [-t /path] [-d] [-u N] [-w N] [-D /path]' echo "Options:" echo " -s Strict comparison (diff every pair of files)" @@ -28,6 +28,7 @@ display_usage () { echo ' -i Automatically install files that do not exist in destination directory' echo ' -p Pre-buildworld mode, only compares crucial files' echo ' -C Compare local rc.conf variables to the defaults' + echo ' -P Preserve files that are overwritten' echo " -m /path/directory Specify location of source to do the make in" echo " -t /path/directory Specify temp root directory" echo " -d Add date and time to directory name (e.g., /var/tmp/temproot.`date +%m%d.%H.%M`)" @@ -238,7 +239,7 @@ fi # Check the command line options # -while getopts ":ascrvhipCm:t:du:w:D:" COMMAND_LINE_ARGUMENT ; do +while getopts ":ascrvhipCPm:t:du:w:D:" COMMAND_LINE_ARGUMENT ; do case "${COMMAND_LINE_ARGUMENT}" in s) STRICT=yes @@ -270,6 +271,9 @@ while getopts ":ascrvhipCm:t:du:w:D:" COMMAND_LINE_ARGUMENT ; do C) COMP_CONFS=yes ;; + P) + PRESERVE_FILES=yes + ;; p) PRE_WORLD=yes unset COMP_CONFS @@ -300,6 +304,11 @@ while getopts ":ascrvhipCm:t:du:w:D:" COMMAND_LINE_ARGUMENT ; do esac done +# Don't force the user to set this in the mergemaster rc file +if [ -n "${PRESERVE_FILES}" -a -z "${PRESERVE_FILES_DIR}" ]; then + PRESERVE_FILES_DIR=/var/tmp/mergemaster/preserved-files-`date +%y%m%d-%H%M%S` +fi + echo '' # If the user has a pager defined, make sure we can run it @@ -352,9 +361,10 @@ case "${DONT_CHECK_PAGER}" in esac # If user has a pager defined, or got assigned one above, use it. -# If not, use more. +# If not, use less. # -PAGER=${PAGER:-more} +PAGER=${PAGER:-less} +PAGER="${PAGER} -c" if [ -n "${VERBOSE}" -a ! "${PAGER}" = "more" ]; then echo " *** You have ${PAGER} defined as your pager so we will use that" @@ -547,11 +557,16 @@ case "${RERUN}" in ;; esac + # Avoid trying to update MAKEDEV if /dev is on a devfs + if /sbin/sysctl vfs.devfs.generation > /dev/null 2>&1 ; then + rm -f ${TEMPROOT}/dev/MAKEDEV ${TEMPROOT}/dev/MAKEDEV.local + fi + ;; # End of the "RERUN" test esac -# We really don't want to deal with derived files like login.conf.db, pwd.db, -# passwd, or spwd.db. Instead, we want to compare the masters, and run *_mkdb. +# We really don't want to have to deal with files like login.conf.db, pwd.db, +# or spwd.db. Instead, we want to compare the text versions, and run *_mkdb. # Prompt the user to do so below, as needed. # rm -f ${TEMPROOT}/etc/*.db ${TEMPROOT}/etc/passwd @@ -592,51 +607,73 @@ fi CONFIRMED_UMASK=${NEW_UMASK:-0022} -# Warn users who still have ${DESTDIR}/etc/sysconfig # -if [ -e "${DESTDIR}/etc/sysconfig" ]; then +# Warn users who still have old rc files +# +for file in atm devfs diskless1 diskless2 isdn network network6 pccard \ + serial syscons sysctl alpha amd64 i386 ia64 sparc64; do + if [ -f "${DESTDIR}/etc/rc.${file}" ]; then + OLD_RC_PRESENT=1 + break + fi +done + +case "${OLD_RC_PRESENT}" in +1) echo '' - echo " *** There is a sysconfig file on this system in ${DESTDIR}/etc/." + echo " *** There are elements of the old rc system in ${DESTDIR}/etc/." echo '' - echo ' Starting with FreeBSD version 2.2.2 those settings moved from' - echo ' /etc/sysconfig to /etc/rc.conf. If you are upgrading an older' - echo ' system make sure that you transfer your settings by hand from' - echo ' sysconfig to rc.conf and install the rc.conf file. If you' - echo ' have already made this transition, you should consider' - echo ' renaming or deleting the sysconfig file.' + echo ' While these scripts will not hurt anything, they are not' + echo ' functional on an up to date system, and can be removed.' echo '' + case "${AUTO_RUN}" in '') - echo -n "Continue with the merge process? [yes] " - read CONT_OR_NOT + echo -n 'Move these files to /var/tmp/mergemaster/old_rc? [yes] ' + read MOVE_OLD_RC - case "${CONT_OR_NOT}" in - [nN]*) - exit 0 - ;; + case "${MOVE_OLD_RC}" in + [nN]*) ;; *) - echo " *** Continuing" - echo '' + mkdir -p /var/tmp/mergemaster/old_rc + for file in atm devfs diskless1 diskless2 isdn network network6 pccard \ + serial syscons sysctl alpha amd64 i386 ia64 sparc64; do + if [ -f "${DESTDIR}/etc/rc.${file}" ]; then + mv ${DESTDIR}/etc/rc.${file} /var/tmp/mergemaster/old_rc/ + fi + done + echo ' The files have been moved' + press_to_continue ;; esac ;; *) ;; esac -fi +esac # Use the umask/mode information to install the files # Create directories as needed # do_install_and_rm () { + case "${PRESERVE_FILES}" in + [Yy][Ee][Ss]) + if [ -f "${3}/${2##*/}" ]; then + mkdir -p ${PRESERVE_FILES_DIR}/${2%/*} + cp ${3}/${2##*/} ${PRESERVE_FILES_DIR}/${2%/*} + fi + ;; + esac + install -m "${1}" "${2}" "${3}" && rm -f "${2}" } +# 4095 = "obase=10;ibase=8;07777" | bc find_mode () { local OCTAL - OCTAL=`perl -e 'printf "%04o\n", (((stat("$ARGV[0]"))[2] & 07777) &~ \ - oct("$ARGV[1]"))' "${1}" "${CONFIRMED_UMASK}"` - echo "${OCTAL}" + OCTAL=$(( ~$(echo "obase=10; ibase=8; ${CONFIRMED_UMASK}" | bc) & 4095 & + $(echo "obase=10; ibase=8; $(stat -f "%OMp%OLp" ${1})" | bc) )) + printf "%04o\n" ${OCTAL} } mm_install () { @@ -1007,7 +1044,7 @@ esac case "${PRE_WORLD}" in '') ;; *) - MAKE_CONF="${SOURCEDIR}/defaults/make.conf" + MAKE_CONF="${SOURCEDIR%etc}share/examples/etc/make.conf" (echo '' echo '*** Comparing make variables'