Index: etc/rc.d/resolv @@ -36,23 +36,27 @@ name="resolv" desc="Create /etc/resolv.conf from kenv" stop_cmd=':' +start_cmd="resolv_start" -load_rc_config $name - +resolv_start() +{ # if the info is available via dhcp/kenv # build the resolv.conf # -if [ -n "`/bin/kenv dhcp.domain-name-servers 2> /dev/null`" ]; then - interface="`/bin/kenv boot.netif.name`" - ( - if [ -n "`/bin/kenv dhcp.domain-name 2> /dev/null`" ]; then - echo domain `/bin/kenv dhcp.domain-name` + if [ -n "`/bin/kenv dhcp.domain-name-servers 2> /dev/null`" ]; then + interface="`/bin/kenv boot.netif.name`" + ( + if [ -n "`/bin/kenv dhcp.domain-name 2> /dev/null`" ]; then + echo domain `/bin/kenv dhcp.domain-name` + fi + + set -- `/bin/kenv dhcp.domain-name-servers` + for ns in `IFS=','; echo $*`; do + echo nameserver $ns + done + ) | /sbin/resolvconf -a ${interface}:dhcp4 fi +} - set -- `/bin/kenv dhcp.domain-name-servers` - for ns in `IFS=','; echo $*`; do - echo nameserver $ns - done - ) | /sbin/resolvconf -a ${interface}:dhcp4 -fi - +load_rc_config $name +run_rc_command "$1" Index: etc/rc.d/securelevel @@ -14,12 +14,13 @@ start_cmd="securelevel_start" stop_cmd=":" +securelevel_start() +{ + # Last chance to set sysctl variables that failed the first time. # -/etc/rc.d/sysctl lastload + /etc/rc.d/sysctl lastload -securelevel_start() -{ if [ ${kern_securelevel} -ge 0 ]; then echo 'Raising kernel security level: ' ${SYSCTL} kern.securelevel=${kern_securelevel} Index: etc/rc.d/serial @@ -42,6 +42,13 @@ # except for serial consoles the initial iflag, lflag and oflag are from # and clocal is locked on. +. /etc/rc.subr + +name="serial" +desc="Serial configuration example" +stop_cmd=':' +start_cmd=':' + default() { # Reset everything changed by the other functions to initial defaults. @@ -166,3 +173,6 @@ # Initialize all ports on a Digiboard 8. # modem D 00 01 02 03 04 05 06 07 + +load_rc_config $name +run_rc_command "$1" Index: etc/rc.d/tmp @@ -35,9 +35,8 @@ name="tmp" desc="Configure tmpfs" stop_cmd=':' +start_cmd="tmp_start" -load_rc_config $name - mount_tmpmfs() { if ! /bin/df /tmp | grep -q "^/dev/md[0-9].* /tmp"; then @@ -46,27 +45,33 @@ fi } +tmp_start() +{ # If we do not have a writable /tmp, create a memory # filesystem for /tmp. If /tmp is a symlink (e.g. to /var/tmp, # then it should already be writable). # -case "${tmpmfs}" in -[Aa][Uu][Tt][Oo]) - if _tmpdir=$(mktemp -d -q /tmp/.diskless.XXXXXX); then - rmdir ${_tmpdir} - else - if [ -h /tmp ]; then - echo "*** /tmp is a symlink to a non-writable area!" - echo "dropping into shell, ^D to continue anyway." - /bin/sh + case "${tmpmfs}" in + [Aa][Uu][Tt][Oo]) + if _tmpdir=$(mktemp -d -q /tmp/.diskless.XXXXXX); then + rmdir ${_tmpdir} else + if [ -h /tmp ]; then + echo "*** /tmp is a symlink to a non-writable area!" + echo "dropping into shell, ^D to continue anyway." + /bin/sh + else + mount_tmpmfs + fi + fi + ;; + *) + if checkyesno tmpmfs; then mount_tmpmfs fi - fi - ;; -*) - if checkyesno tmpmfs; then - mount_tmpmfs - fi - ;; -esac + ;; + esac +} + +load_rc_config $name +run_rc_command "$1" Index: etc/rc.d/var @@ -37,9 +37,8 @@ name="var" desc="Populate /var directory" stop_cmd=':' +start_cmd="var_start" -load_rc_config $name - populate_var() { /usr/sbin/mtree -deiU -f /etc/mtree/BSD.var.dist -p /var > /dev/null @@ -52,61 +51,67 @@ esac } +var_start() +{ # If we do not have a writable /var, create a memory filesystem for /var # unless told otherwise by rc.conf. We don't have /usr yet so use mkdir # instead of touch to test. We want mount to record its mounts so we # have to make sure /var/db exists before doing the mount -a. # -case "${varmfs}" in -[Yy][Ee][Ss]) - mount_md ${varsize} /var "${varmfs_flags}" - ;; -[Nn][Oo]) - ;; -*) - if /bin/mkdir -p /var/.diskless 2> /dev/null; then - rmdir /var/.diskless - else + case "${varmfs}" in + [Yy][Ee][Ss]) mount_md ${varsize} /var "${varmfs_flags}" - fi -esac + ;; + [Nn][Oo]) + ;; + *) + if /bin/mkdir -p /var/.diskless 2> /dev/null; then + rmdir /var/.diskless + else + mount_md ${varsize} /var "${varmfs_flags}" + fi + esac # If we have an empty looking /var, populate it, but only if we have # /usr available. Hopefully, we'll eventually find a workaround, but # in realistic diskless setups, we're probably ok. -case "${populate_var}" in -[Yy][Ee][Ss]) - populate_var - ;; -[Nn][Oo]) - exit 0 - ;; -*) - if [ -d /var/run -a -d /var/db -a -d /var/empty ] ; then - true - elif [ -x /usr/sbin/mtree ] ; then + case "${populate_var}" in + [Yy][Ee][Ss]) populate_var - else - # We need mtree to populate /var so try mounting /usr. - # If this does not work, we can not boot so it is OK to - # try to mount out of order. - mount /usr - if [ ! -x /usr/sbin/mtree ] ; then - exit 1 - else + ;; + [Nn][Oo]) + return 0 + ;; + *) + if [ -d /var/run -a -d /var/db -a -d /var/empty ] ; then + true + elif [ -x /usr/sbin/mtree ] ; then populate_var + else + # We need mtree to populate /var so try mounting /usr. + # If this does not work, we can not boot so it is OK to + # try to mount out of order. + mount /usr + if [ ! -x /usr/sbin/mtree ] ; then + return 1 + else + populate_var + fi fi - fi - ;; -esac + ;; + esac # Make sure we have /var/log/utx.lastlogin and /var/log/utx.log files -if [ ! -f /var/log/utx.lastlogin ]; then - cp /dev/null /var/log/utx.lastlogin - chmod 644 /var/log/utx.lastlogin -fi -if [ ! -f /var/log/utx.log ]; then - cp /dev/null /var/log/utx.log - chmod 644 /var/log/utx.log -fi + if [ ! -f /var/log/utx.lastlogin ]; then + cp /dev/null /var/log/utx.lastlogin + chmod 644 /var/log/utx.lastlogin + fi + if [ ! -f /var/log/utx.log ]; then + cp /dev/null /var/log/utx.log + chmod 644 /var/log/utx.log + fi +} + +load_rc_config $name +run_rc_command "$1"