summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorBenedikt Boehm <hollow@gentoo.org>2005-09-04 07:56:33 +0000
committerBenedikt Boehm <hollow@gentoo.org>2005-09-04 07:56:33 +0000
commitf9a50a41412540a7f4d6b8f02a108177009b137e (patch)
treedcdb456dd5dc70dafcdc5307c4fdb5cf137586b3 /sbin
parentremove rc-lists for unused runlevels (diff)
downloadbaselayout-vserver-f9a50a41412540a7f4d6b8f02a108177009b137e.tar.gz
baselayout-vserver-f9a50a41412540a7f4d6b8f02a108177009b137e.tar.bz2
baselayout-vserver-f9a50a41412540a7f4d6b8f02a108177009b137e.zip
remove useless stuff
svn path=/baselayout-vserver/trunk/; revision=25
Diffstat (limited to 'sbin')
-rwxr-xr-xsbin/rc528
1 files changed, 7 insertions, 521 deletions
diff --git a/sbin/rc b/sbin/rc
index fc6f10e..1dc7ebf 100755
--- a/sbin/rc
+++ b/sbin/rc
@@ -6,64 +6,14 @@ trap ":" INT QUIT TSTP
source /sbin/functions.sh
umask 022
-try() {
- local errstr
- local retval=0
-
- if [ -c /dev/null ]; then
- errstr="$((eval $*) 2>&1 >/dev/null)"
- else
- errstr="$((eval $*) 2>&1)"
- fi
- retval=$?
- if [ "${retval}" -ne 0 ]
- then
- splash "critical" &
-
- echo -e "${ENDCOL}${NORMAL}[${BAD} oops ${NORMAL}]"
- echo
- eerror "The \"${1}\" command failed with error:"
- echo
- echo "${errstr#*: }"
- echo
- eerror "Since this is a critical task, startup cannot continue."
- echo
- /sbin/sulogin ${CONSOLE}
- einfo "Unmounting filesystems"
- if [ -c /dev/null ]; then
- /bin/mount -a -o remount,ro &>/dev/null
- else
- /bin/mount -a -o remount,ro
- fi
- einfo "Rebooting"
- /sbin/reboot -f
- fi
-
- return ${retval}
-}
-
# Check that $1 exists ...
check_statedir() {
[ -z "$1" ] && return 0
if [ ! -d "$1" ] ; then
if ! mkdir -p "$1" &>/dev/null ; then
- splash "critical" &
echo
eerror "For Gentoo to function properly, \"$1\" needs to exist."
- if [[ ${RC_FORCE_AUTO} == "yes" ]] ; then
- eerror "Attempting to create \"$1\" for you ..."
- mount -o remount,rw /
- mkdir -p "$1"
- else
- eerror "Please mount your root partition read/write, and execute:"
- echo
- eerror " # mkdir -p $1"
- echo; echo
- /sbin/sulogin ${CONSOLE}
- fi
- einfo "Unmounting filesystems"
- /bin/mount -a -o remount,ro &>/dev/null
einfo "Rebooting"
/sbin/reboot -f
fi
@@ -72,109 +22,6 @@ check_statedir() {
return 0
}
-udev_version() {
- local version=0
-
- if [ -x "/sbin/udev" ]
- then
- version=$(/sbin/udev -V)
- # We need it without a leading '0', else bash do the wrong thing
- version="${version##0}"
- # Older udev's will print nothing
- [ -z "${version}" ] && version=0
- fi
-
- echo "${version}"
-}
-
-# void noblock_read(var)
-#
-# reads a line of input into var like regular read
-# but it does not block waiting for input
-#
-noblock_read() {
- local old_tty_settings="$(stty -g)"
- stty -icanon min 0 time 0
- read "$@"
- stty "${old_tty_settings}"
-}
-
-# bool user_want_interactive(void)
-#
-# return 0 if user wants interactive mode
-#
-user_want_interactive() {
- local user_input
- noblock_read user_input
- [[ ${user_input} == *"I"* || ${user_input} == *"i"* ]]
-}
-
-# void do_interactive
-#
-# starts, skips, continues or drops to the shell
-# depending on user selection
-#
-do_interactive() {
- local service="$1"
- shift
-
- local start_text="Start service"
- local skip_text="Skip service"
- local continue_text="Continue boot process"
- local shell_text="Exit to shell"
-
- echo
- echo "About to start the service ${service}"
- PS3="Enter your selection: "
- select action in "${start_text}" "${skip_text}" "${continue_text}" \
- "${shell_text}"
- do
- case ${action} in
- "${start_text}")
- "$@"
- break
- ;;
- "${skip_text}")
- break
- ;;
- "${continue_text}")
- interactive="no"
- "$@"
- break
- ;;
- "${shell_text}")
- echo
- sulogin "${CONSOLE}"
- ;;
- esac
- done
-}
-
-populate_udev() {
- # Now populate /dev
- /sbin/udevstart
-
- # Not provided by sysfs but needed
- ln -snf /proc/self/fd /dev/fd
- ln -snf fd/0 /dev/stdin
- ln -snf fd/1 /dev/stdout
- ln -snf fd/2 /dev/stderr
- [ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core
-
- # Create nodes that udev can't
- [ -x /sbin/dmsetup ] && /sbin/dmsetup mknodes &>/dev/null
- [ -x /sbin/lvm ] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null
- [ -x /sbin/evms_activate ] && /sbin/evms_activate -q &>/dev/null
-
- # Create problematic directories
- mkdir -p /dev/{pts,shm}
-
- # Same thing as /dev/.devfsd
- touch /dev/.udev
-
- return 0
-}
-
get_critical_services() {
local x=
CRITICAL_SERVICES=
@@ -186,7 +33,7 @@ get_critical_services() {
CRITICAL_SERVICES="${CRITICAL_SERVICES} ${x##*/}"
done
else
- CRITICAL_SERVICES="checkroot hostname modules checkfs localmount clock"
+ CRITICAL_SERVICES="hostname"
fi
export CRITICAL_SERVICES
@@ -200,256 +47,22 @@ argv1="$1"
# First time boot stuff goes here. Note that 'sysinit' is an internal runlevel
# used to bring up local filesystems, and should not be started with /sbin/rc
# directly ...
-if [[ ( ${RUNLEVEL} == "S" || ${RUNLEVEL} == "1" ) && ${argv1} = "sysinit" ]]
+if [[ ${argv1} = "sysinit" ]]
then
# Setup initial $PATH just in case
PATH="/bin:/sbin:/usr/bin:/usr/sbin:${PATH}"
- # Help users recover their systems incase these go missing
- [ -c /dev/null ] && dev_null=1 || dev_null=0
- [ -c /dev/console ] && dev_console=1 || dev_console=0
-
echo
echo -e "${GOOD}Gentoo Linux${GENTOO_VERS}; ${BRACKET}http://www.gentoo.org/${NORMAL}"
echo -e " Copyright 1999-2005 Gentoo Foundation; Distributed under the GPLv2"
echo
- echo -e "Press ${GOOD}I${NORMAL} to enter interactive boot mode"
- echo
+
check_statedir /proc
-
- ebegin "Mounting proc at /proc"
- if [[ ${RC_USE_FSTAB} = "yes" ]] ; then
- mntcmd=$(get_mount_fstab /proc)
- else
- unset mntcmd
- fi
- try mount -n ${mntcmd:--t proc proc /proc}
- eend $?
-
- # Read off the kernel commandline to see if there's any special settings
- # especially check to see if we need to set the CDBOOT environment variable
- # Note: /proc MUST be mounted
- if [ "$(get_KV)" -ge "$(KV_to_int '2.6.0')" ] ; then
- if [[ -d /sys ]] ; then
- ebegin "Mounting sysfs at /sys"
- if [[ ${RC_USE_FSTAB} = "yes" ]] ; then
- mntcmd=$(get_mount_fstab /sys)
- else
- unset mntcmd
- fi
- try mount -n ${mntcmd:--t sysfs sysfs /sys}
- eend $?
- else
- ewarn "No /sys to mount sysfs needed in 2.6 and later kernels!"
- fi
- fi
-
check_statedir /dev
- # Fix weird bug where there is a /dev/.devfsd in a unmounted /dev
- devfs_automounted="no"
- if [ -e "/dev/.devfsd" ]
- then
- mymounts="$(awk '($3 == "devfs") { print "yes"; exit 0 }' /proc/mounts)"
- if [ "${mymounts}" != "yes" ]
- then
- rm -f /dev/.devfsd
- else
- devfs_automounted="yes"
- fi
- 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" ]
- then
- ebegin "Using existing device nodes in /dev"
- eend 0
- else
- fellback_to_devfs="no"
- case "${RC_DEVICES}" in
- devfs) devfs="yes"
- udev="no"
- ;;
- udev) devfs="yes"
- udev="yes"
- fellback_to_devfs="yes"
- ;;
- auto|*) devfs="yes"
- udev="yes"
- ;;
- esac
-
- # Check udev prerequisites and kernel params
- if [ "${udev}" = "yes" ]
- then
- if get_bootparam "noudev" || \
- [ ! -x /sbin/udev -o -e "/dev/.devfsd" ] || \
- [ "$(get_KV)" -lt "$(KV_to_int '2.6.0')" ]
- then
- udev="no"
- fi
- fi
-
- # Check devfs prerequisites and kernel params
- if [ "${devfs}" = "yes" ]
- then
- if get_bootparam "nodevfs" || [ "${udev}" = "yes" ]
- then
- devfs="no"
- fi
- fi
-
- # Actually start setting up /dev now
- if [[ ${udev} = "yes" ]] ; then
- # Setup temporary storage for /dev
- ebegin "Mounting /dev for udev"
- if [[ ${RC_USE_FSTAB} = "yes" ]] ; then
- mntcmd=$(get_mount_fstab /dev)
- else
- unset mntcmd
- fi
- if [[ -n ${mntcmd} ]] ; then
- try mount -n ${mntcmd}
- else
- if egrep -qs tmpfs /proc/filesystems ; then
- mntcmd="tmpfs"
- else
- mntcmd="ramfs"
- fi
- # many video drivers require exec access in /dev #92921
- try mount -n -t ${mntcmd} udev /dev -o exec,nosuid,mode=0755
- fi
- eend $?
-
- # Selinux lovin; /selinux should be mounted by selinux-patched init
- if [[ -x /sbin/restorecon ]] && [[ -c /selinux/null ]] ; then
- restorecon /dev &> /selinux/null
- fi
-
- # Actually get udev rolling
- ebegin "Configuring system to use udev"
- if [[ ${RC_DEVICE_TARBALL} = "yes" ]] && [[ -s /lib/udev-state/devices.tar.bz2 ]]
- then
- einfo " Populating /dev with device nodes ..."
- try tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev
- fi
- populate_udev
-
- # Setup hotplugging (if possible)
- if [ -e /proc/sys/kernel/hotplug ] ; then
- if [ "$(udev_version)" -ge "48" ] ; then
- einfo " Setting /sbin/udevsend as hotplug agent ..."
- echo "/sbin/udevsend" > /proc/sys/kernel/hotplug
- elif [ -x /sbin/hotplug ] ; then
- einfo " Using /sbin/hotplug as hotplug agent ..."
- else
- einfo " Setting /sbin/udev as hotplug agent ..."
- echo "/sbin/udev" > /proc/sys/kernel/hotplug
- fi
- fi
- eend 0
-
- # With devfs, /dev can be mounted by the kernel ...
- elif [ "${devfs}" = "yes" ]
- then
- mymounts="$(awk '($2 == "devfs") { print "yes"; exit 0 }' /proc/filesystems)"
- # Is devfs support compiled in?
- if [ "${mymounts}" = "yes" ]
- then
- if [ "${devfs_automounted}" = "no" ]
- then
- ebegin "Mounting devfs at /dev"
- try mount -n -t devfs devfs /dev
- eend $?
- else
- ebegin "Kernel automatically mounted devfs at /dev"
- eend 0
- fi
- ebegin "Starting devfsd"
- /sbin/devfsd /dev >/dev/null
- eend $? "Could not start /sbin/devfsd"
- else
- devfs="no"
- fi
-
- # Did the user want udev in the config file but for
- # some reason, udev support didnt work out ?
- if [ "${fellback_to_devfs}" = "yes" ]
- then
- ewarn "You wanted udev but support for it was not available!"
- ewarn "Please review your system after it's booted!"
- fi
- fi
-
- # OK, if we got here, things are probably not right :)
- if [ "${devfs}" = "no" ] && [ "${udev}" = "no" ]
- then
- clear
- echo
- einfo "The Gentoo Linux system initialization scripts have detected that"
- einfo "your system does not support DEVFS or UDEV. Since Gentoo Linux"
- einfo "has been designed with these dynamic /dev managers in mind, it is"
- einfo "highly suggested that you build support for it into your kernel."
- einfo "Please read the Gentoo Handbook for more information!"
- echo
- einfo " http://www.gentoo.org/doc/en/handbook/"
- echo
- einfo "Thanks for using Gentoo! :)"
- echo
- read -t 15 -p "(hit Enter to continue or wait 15 seconds ...)"
- fi
- fi
-
- # From linux-2.5.68 we need to mount /dev/pts again ...
- if [ "$(get_KV)" -ge "$(KV_to_int '2.5.68')" ]
- then
- have_devpts="$(awk '($2 == "devpts") { print "yes"; exit 0 }' /proc/filesystems)"
-
- if [ "${have_devpts}" = "yes" ]
- then
- # Only try to create /dev/pts if we have /dev mounted dynamically,
- # else it might fail as / might be still mounted readonly.
- if [ ! -d /dev/pts ] && \
- [ "${devfs}" = "yes" -o "${udev}" = "yes" ]
- then
- # Make sure we have /dev/pts
- mkdir -p /dev/pts &>/dev/null || \
- ewarn "Could not create /dev/pts!"
- fi
-
- if [[ -d /dev/pts ]] ; then
- ebegin "Mounting devpts at /dev/pts"
- if [[ ${RC_USE_FSTAB} = "yes" ]] ; then
- mntcmd=$(get_mount_fstab /dev/pts)
- else
- unset mntcmd
- fi
- try mount -n ${mntcmd:--t devpts -o gid=5,mode=0620 devpts /dev/pts}
- eend $?
- fi
- fi
- fi
-
# Start logging console output since we have all /dev stuff setup
bootlog start
- # Swap needs to be activated *after* /dev has been fully setup so that
- # the fstab can be properly parsed. This first pass we send to /dev/null
- # in case the user has swap points setup on different partitions. We
- # will run swapon again in localmount and that one will report errors.
- ebegin "Activating (possible) swap"
- /sbin/swapon -a >& /dev/null
- eend 0
-
- # Set the console loglevel to 1 for a cleaner boot
- # the logger should anyhow dump the ring-0 buffer at start to the
- # logs, and that with dmesg can be used to check for problems
- /bin/dmesg -n 1
-
# We set the forced softlevel from the kernel command line
# It needs to be run right after proc is mounted for the
# boot runlevel
@@ -485,31 +98,18 @@ then
# defaults.
get_critical_services
- splash "rc_init" "${argv1}"
-
export START_CRITICAL="yes"
# We do not want to break compatibility, so we do not fully integrate
# these into /sbin/rc, but rather start them by hand ...
for x in ${CRITICAL_SERVICES}
do
- splash "svc_start" "${x}"
- user_want_interactive && interactive="yes"
if ! start_critical_service "${x}" ; then
- splash "critical" &>/dev/null &
-
echo
eerror "One of more critical startup scripts failed to start!"
- eerror "Please correct this, and reboot ..."
- echo; echo
- /sbin/sulogin ${CONSOLE}
- einfo "Unmounting filesystems"
- /bin/mount -a -o remount,ro &>/dev/null
einfo "Rebooting"
/sbin/reboot -f
fi
-
- splash "svc_started" "${x}" "0"
done
unset START_CRITICAL
@@ -517,57 +117,15 @@ then
# /var/log should be writable now, so starting saving the boot output
bootlog sync
- # have to run this after /var/run is mounted rw #85304
- if [ -x /sbin/irqbalance -a "$(get_KV)" -ge "$(KV_to_int '2.5.0')" ]
- then
- ebegin "Starting irqbalance"
- /sbin/irqbalance
- eend $?
- fi
-
# Check that $svcdir exists ...
check_statedir "${svcdir}"
- # Should we use tmpfs/ramfs/ramdisk for caching dependency and
- # general initscript data? Note that the 'gentoo=<fs>' kernel
- # option should override any other setting ...
- for fs in tmpfs ramfs ramdisk
- do
- if get_bootparam "${fs}"
- then
- svcmount="yes"
- svcfstype="${fs}"
- break
- fi
- done
- if [ "${svcmount}" = "yes" ]
- then
- ebegin "Mounting ${svcfstype} at ${svcdir}"
- case "${svcfstype}" in
- ramfs)
- try mount -n -t ramfs svcdir "${svcdir}" \
- -o rw,mode=0755,size="${svcsize}"k
- ;;
- ramdisk)
- try dd if=/dev/zero of=/dev/ram0 bs=1k count="${svcsize}"
- try /sbin/mke2fs -i 1024 -vm0 /dev/ram0 "${svcsize}"
- try mount -n -t ext2 /dev/ram0 "${svcdir}" -o rw
- ;;
- tmpfs|*)
- try mount -n -t tmpfs svcdir "${svcdir}" \
- -o rw,mode=0755,size="${svcsize}"k
- ;;
- esac
- eend 0
- fi
-
# Clear $svcdir from stale entries, but leave the caches around, as it
# should help speed things up a bit
rm -rf $(ls -d1 "${svcdir}/"* 2>/dev/null | \
grep -ve '\(depcache\|deptree\|envcache\)')
echo "sysinit" > "${svcdir}/softlevel"
- echo "${interactive}" > "${svcdir}/interactive"
# Update the dependency cache
/sbin/depscan.sh -u
@@ -584,20 +142,6 @@ then
done
)
- # If the user's /dev/null or /dev/console are missing, we
- # should help them out and explain how to rectify the situation
- if [ ${dev_null} -eq 0 -o ${dev_console} -eq 0 ] \
- && [ -e /usr/share/baselayout/issue.devfix ]
- then
- # Backup current /etc/issue
- if [ -e /etc/issue -a ! -e /etc/issue.devfix ]
- then
- mv /etc/issue /etc/issue.devfix
- fi
-
- cp /usr/share/baselayout/issue.devfix /etc/issue
- fi
-
# Setup login records ... this has to be done here because when
# we exit this runlevel, init will write a boot record to utmp
# If /var/run is readonly, then print a warning, not errors
@@ -619,7 +163,7 @@ then
exit 0
fi # Sysinit ends here
-if [[ ( ${RUNLEVEL} == "S" || ${RUNLEVEL} == "1" ) && ${argv1} == "boot" ]]
+if [[ ${argv1} == "boot" ]]
then
setup_defaultlevels
@@ -638,25 +182,10 @@ then
# if there is one
argv1="${BOOTLEVEL}"
-elif [[ ${RUNLEVEL} != "S" && ${RUNLEVEL} != "1" && -e ${svcdir}/ksoftlevel ]]
+elif [[ -e ${svcdir}/ksoftlevel ]]
then
argv1="$(< ${svcdir}/ksoftlevel)"
rm -f "${svcdir}/ksoftlevel"
-elif [[ ${RUNLEVEL} != "S" && ${RUNLEVEL} != "1" && ${argv1} == "single" ]]
-then
- /sbin/telinit S
- exit 0
-elif [[ ( ${RUNLEVEL} == "S" || ${RUNLEVEL} == "1" ) && ${argv1} != "single" ]]
-then
- level=$(awk -v level="${argv1}" '
- $2 == level {
- split($0, fields, ":")
- print fields[2]
- exit
- }' /etc/inittab 2>/dev/null)
- [[ -z ${level} ]] && level=3
- /sbin/telinit "${level}"
- exit 0
fi
source "${svclib}/sh/rc-services.sh"
@@ -694,18 +223,10 @@ else
rm -rf "${svcdir}"/failed/*
fi
-splash "rc_init" "${argv1}"
-
if [ "${SOFTLEVEL}" = "reboot" -o "${SOFTLEVEL}" = "shutdown" ]
then
myscripts=
-elif [ "${SOFTLEVEL}" = "single" ]
-then
- get_critical_services
-
- myscripts="${CRITICAL_SERVICES}"
-
elif [ ! -d "/etc/runlevels/${SOFTLEVEL}" ]
then
eerror "ERROR: runlevel ${SOFTLEVEL} does not exist; exiting ..."
@@ -722,9 +243,6 @@ else
mylevels="$(dolisting "/etc/runlevels/${SOFTLEVEL}/")"
fi
- [ "${OLDSOFTLEVEL}" = "${BOOTLEVEL}" -o "${OLDSOFTLEVEL}" = "single" ] \
- && /bin/dmesg -n 1
-
for x in ${mylevels}
do
[ -L "${x}" ] && myscripts="${myscripts} ${x##*/}"
@@ -793,8 +311,7 @@ dep_stop() {
}
# Stop services
-if [[ ${SOFTLEVEL} != "single" && \
- ${SOFTLEVEL} != "reboot" && \
+if [[ ${SOFTLEVEL} != "reboot" && \
${SOFTLEVEL} != "shutdown" ]]
then
for i in $(get_stop_services) ; do
@@ -858,11 +375,6 @@ if [[ ${SOFTLEVEL} == "reboot" || ${SOFTLEVEL} == "shutdown" ]] ; then
exit 0
fi
-if [[ ${SOFTLEVEL} == "single" ]] ; then
- /sbin/sulogin ${CONSOLE}
- exit 0
-fi
-
# Move the old softscritps directory to a different one
# and make the new softscripts directory the current
@@ -886,18 +398,10 @@ get_start_services() {
trace_dependencies ${list}
}
-[[ -e "${svcdir}/interactive" ]] \
- && interactive="$(<"${svcdir}/interactive")"
-
# Start scripts
for i in $(get_start_services) ; do
if service_stopped "${i}" ; then
- user_want_interactive && interactive="yes"
- if [[ ${interactive} == "yes" ]]; then
- do_interactive "${i}" start_service "${i}"
- else
- start_service "${i}"
- fi
+ start_service "${i}"
fi
done
@@ -913,33 +417,15 @@ rm -rf "${svcdir}/softscripts.old" &>/dev/null
#/sbin/depscan.sh &>/dev/null
-# We want devfsd running after a change of runlevel (this is mostly if we return
-# from runlevel 'single')
-if [ -z "`ps --no-heading -C 'devfsd'`" -a \
- -n "`gawk '/\/dev devfs/ { print }' /proc/mounts 2>/dev/null`" ]
-then
- if [ "${RC_DEVFSD_STARTUP}" != "no" ]
- then
- /sbin/devfsd /dev &>/dev/null
- fi
-fi
-
# Runlevel end, so clear stale fail list
rm -rf "${svcdir}/failed" &>/dev/null
# If we were in the boot runlevel, it is done now ...
if [[ -n ${BOOT} ]]; then
unset BOOT
- # Save our interactive mode into the default runlevel
- echo "${interactive}" > "${svcdir}/interactive"
-else
- # As we're not boot, we remove the interactive file
- [[ -e "${svcdir}/interactive" ]] && rm -f "${svcdir}/interactive"
fi
# Remove the cached CONSOLETYPE
unset CONSOLETYPE
-splash "rc_exit"
-
# vim:ts=4