diff --git a/etc.Linux/rc.conf b/etc.Linux/rc.conf index 72ab631a..d1c216f3 100644 --- a/etc.Linux/rc.conf +++ b/etc.Linux/rc.conf @@ -7,18 +7,18 @@ rc_tty_number=12 # Use this variable to control the /dev management behavior. -# auto - let the scripts figure out what's best at boot # devfs - use devfs (requires sys-fs/devfsd) # mdev - use mdev (requires sys-apps/busybox) # udev - use udev (requires sys-fs/udev) # static - let the user manage /dev (YOU need to create ALL device nodes) -rc_devices="auto" +# Leave it blank to let rc work it out (udev, mdev, devfs, static) +#rc_devices="" # UDEV OPTION: # Set to "yes" if you want to save /dev to a tarball on shutdown # and restore it on startup. This is useful if you have a lot of # custom device nodes that udev does not handle/know about. -RC_DEVICE_TARBALL="no" +rc_device_tarball="NO" # Sets the level at which logging of messages is done to the # console. See dmesg(8) for more info. diff --git a/sh.BSD/init.sh b/sh.BSD/init.sh index 71902c51..a9797c95 100755 --- a/sh.BSD/init.sh +++ b/sh.BSD/init.sh @@ -2,13 +2,6 @@ # Copyright 2007-2008 Roy Marples # All rights reserved. Released under the 2-clause BSD license. -# void single_user() -# Drop to a shell, remount / ro, and then reboot -single_user() -{ - exit 1 -} - # This basically mounts $svcdir as a ramdisk, but preserving its content # which allows us to run depscan.sh # FreeBSD has a nice ramdisk - we don't set a size as we should always @@ -17,7 +10,7 @@ single_user() # FreeBSD-7 supports tmpfs now :) mount_svcdir() { - local dotmp=false release=false + local dotmp=false release=false retval=0 if [ -e "${RC_SVCDIR}"/deptree ]; then dotmp=true if ! mount -t tmpfs none "${RC_LIBDIR}"/tmp 2>/dev/null; then @@ -34,12 +27,15 @@ mount_svcdir() newfs -b 4096 -i 1024 -n /dev/md0 mount -o rw,noexec,nosuid /dev/md0 "${RC_SVCDIR}" fi + retval=$? if ${dotmp}; then cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \ "${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null umount "${RC_LIBDIR}"/tmp ${release} && mdconfig -d -u 1 fi + + return ${retval} } . "${RC_LIBDIR}"/sh/functions.sh diff --git a/sh.Linux/init.sh b/sh.Linux/init.sh index 8be70792..5b37df8e 100755 --- a/sh.Linux/init.sh +++ b/sh.Linux/init.sh @@ -39,25 +39,6 @@ KV_to_int() echo "${KV_int}" } -single_user() -{ - if [ "${RC_SYS}" = "VPS" ]; then - einfo "Halting" - halt -f - return - fi - - sulogin ${CONSOLE} - einfo "Unmounting filesystems" - if [ -c /dev/null ]; then - mount -a -o remount,ro 2>/dev/null - else - mount -a -o remount,ro - fi - einfo "Rebooting" - reboot -f -} - # This basically mounts $svcdir as a ramdisk, but preserving its content # which allows us to run depscan.sh # The tricky part is finding something our kernel supports @@ -65,7 +46,7 @@ single_user() mount_svcdir() { local fs= fsopts="-o rw,noexec,nodev,nosuid" devdir="none" devtmp="none" x= - local svcsize=${svcsize:-1024} + local svcsize=${rc_svcsize:-1024} if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then fs="tmpfs" @@ -79,15 +60,15 @@ mount_svcdir() devtmp="/dev/ram1" fs="ext2" for x in ${devdir} ${devtmp}; do - dd if=/dev/zero of="${x}" bs=1k count="${rc_svcsize:-1024}" - mkfs -t "${fs}" -i 1024 -vm0 "${x}" "${rc_svcsize:-1024}" + dd if=/dev/zero of="${x}" bs=1k count="${svcsize}" + mkfs -t "${fs}" -i 1024 -vm0 "${x}" "${svcsize}" done else echo eerror "OpenRC requires tmpfs, ramfs or 2 ramdisks + ext2" eerror "compiled into the kernel" echo - single_user + return 1 fi local dotmp=false @@ -98,7 +79,7 @@ mount_svcdir() "${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null fi - # If we have no entry in fstab for $svcdir, provide our own + # If we have no entry in fstab for $RC_SVCDIR, provide our own if fstabinfo --quiet "${RC_SVCDIR}"; then mount -n "${RC_SVCDIR}" else @@ -190,22 +171,18 @@ if [ "${RC_UNAME}" != "GNU/kFreeBSD" -a "${RC_SYS}" != "VPS" ]; then fi # Try to figure out how the user wants /dev handled -# - check $RC_DEVICES from /etc/conf.d/rc -# - check boot parameters -# - make sure the required binaries exist -# - make sure the kernel has support -if [ "${rc_devices}" = "static" -o "${RC_SYS}" = "VPS" ]; then +if [ "${rc_devices}" = "static" \ + -o "${RC_SYS}" = "VPS" \ + -o "${RC_UNAME}" = "GNU/kFreeBSD" ] +then ebegin "Using existing device nodes in /dev" eend 0 -elif [ "${RC_UNAME}" = "GNU/kFreeBSD" ]; then - ebegin "Using kFreeBSD devfs in /dev" - eend 0 else case ${rc_devices} in devfs) managers="devfs udev mdev";; udev) managers="udev devfs mdev";; mdev) managers="mdev udev devfs";; - auto|*) managers="udev devfs mdev";; + *) managers="udev devfs mdev";; esac for m in ${managers}; do @@ -222,7 +199,8 @@ else fi # Mount required stuff as user may not have then in /etc/fstab -for x in "devpts /dev/pts 0755 ,gid=5,mode=0620" "tmpfs /dev/shm 1777 ,nodev"; do +for x in "devpts /dev/pts 0755 ,gid=5,mode=0620" "tmpfs /dev/shm 1777 ,nodev" +do set -- ${x} grep -Eq "[[:space:]]+$1$" /proc/filesystems || continue mountinfo -q "$2" && continue diff --git a/sh/init-common-post.sh b/sh/init-common-post.sh index a246a846..cb449998 100644 --- a/sh/init-common-post.sh +++ b/sh/init-common-post.sh @@ -1,10 +1,12 @@ # Copyright 2007-2008 Roy Marples # All rights reserved. Released under the 2-clause BSD license. +retval=0 + # mount $svcdir as something we can write to if it's not rw # On vservers, / is always rw at this point, so we need to clean out # the old service state data -if [ "${RC_SVCDIR}" != "/" ] && mkdir "${RC_SVCDIR}/.test.$$" 2>/dev/null; then +if [ "${RC_SVCDIR}" != "/" ] && mkdir "${RC_SVCDIR}/.test.$$" 2>/dev/null; then rmdir "${RC_SVCDIR}/.test.$$" for x in ${RC_SVCDIR:-/lib/rc/init.d}/*; do [ -e "${x}" ] || continue @@ -15,6 +17,7 @@ if [ "${RC_SVCDIR}" != "/" ] && mkdir "${RC_SVCDIR}/.test.$$" 2>/dev/null; then done else mount_svcdir + retval=$? fi echo "sysinit" > "${RC_SVCDIR}/softlevel" @@ -22,4 +25,4 @@ echo "sysinit" > "${RC_SVCDIR}/softlevel" # sysinit is now done, so allow init scripts to run normally [ -e /dev/.rcsysinit ] && rm -f /dev/.rcsysinit -exit 0 +exit ${retval}