void-packages/templates/initscripts/files/rc.single

58 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
#
# /etc/rc.single: Single-user startup script.
#
export HOME=/
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
umask 022
. /etc/rc.subr
. /etc/rc.conf
_rc_conf_loaded=true
if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then
# Determine the shutdown order of the /etc/rc.d scripts,
# and perform the operation
#
files=$(rcorder ${rcshutdown_rcorder_flags} /etc/rc.d/*)
for _rc_elem in $(reverse_list $files); do
run_rc_script $_rc_elem stop
done
fi
if [ "$PREVLEVEL" != "N" ]; then
echo -n "=> Sending SIGTERM to processes... "
killall5 -15 &> /dev/null
sleep 5
echo "done."
echo -n "=> Sending SIGKILL to processes... "
killall5 -9
sleep 1
echo "done."
if [ -x /sbin/udevadm -a -d /sys/block ]; then
/etc/rc.d/udevd start
/etc/rc.d/udev_events start
else
# Static /dev, our last resort
echo "=> Using static /dev filesystem"
fi
# Start syslogd.
if [ -x /etc/rc.d/syslogd -a -x /etc/rc.d/klogd ]; then
/etc/rc.d/klogd start
/etc/rc.d/syslogd start
fi
fi
if [ "$RUNLEVEL" = "1" ]; then
echo
echo "*** Entering single-user mode..."
# make sure /dev/initctl is in place
kill -HUP 1
exec /sbin/init -t1 S
fi