summaryrefslogtreecommitdiffstats
path: root/rc/rc.single
blob: 4291eb0b73b90694a1ac5442722fd50105e550ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
#
# /etc/rc.single: single-user startup script
#

# Load configuration
. /etc/rc.conf

if [ "$PREVLEVEL" = "2" ]; then
	# Shutdown services
	if [ "${SERVICES[*]}" ]; then
		for service in "${SERVICES[@]}"; do
			R_SERVICES=($service ${R_SERVICES[@]})
		done
		for service in "${R_SERVICES[@]}"; do
			/etc/rc.d/$service stop &> /tmp/rc.$$
			/usr/bin/logger -t $service -f /tmp/rc.$$
			/bin/rm -f /tmp/rc.$$
		done
	fi
fi

if [ "$PREVLEVEL" != "N" ]; then
	# Terminate all processes
	/sbin/killall5 -15
	/bin/sleep 5
	/sbin/killall5 -9

	# Start udev
	/bin/mount -n -t proc none /proc
	/bin/mount -n -t sysfs none /sys
	/sbin/start_udev
  
	if [ -f /etc/rc.d/$SYSLOG -a -x /etc/rc.d/$SYSLOG ]; then
		/etc/rc.d/$SYSLOG start &> /dev/null
	fi	
fi

if [ "$RUNLEVEL" = "1" ]; then
	# Enter single-user mode
	exec /sbin/init -t1 S
fi

# End of file