]> TLD Linux GIT Repositories - rc-scripts.git/blob - rc.d/init.d/single
- from PLD
[rc-scripts.git] / rc.d / init.d / single
1 #!/bin/sh
2 #
3 # single        Script for sedding up administrative/rescue shell.
4 #
5 # chkconfig:    1 00 00
6 # description:  This file is executed by init when it goes into runlevel \
7 #               1, which is the administrative state. It kills all \
8 #               deamons and then puts the system into single user mode. \
9 #               Note that the file systems are kept mounted. \
10 #
11 # Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
12 #
13
14 # Source function library.
15 . /etc/rc.d/init.d/functions
16
17 case "$1" in
18   stop*)
19         exit 0
20         ;;
21   start*)
22         # Kill all processes.
23         [ "${BASH+bash}" = bash ] && enable kill
24
25         run_cmd "Sending all processes the TERM signal" killall5 -15
26         sleep 5
27         run_cmd "Sending all processes the KILL signal" killall5 -9
28
29         rm -f /var/lock/subsys/* >/dev/null 2>&1
30
31         # this looks nicer
32         [ -x /usr/bin/clear ] && /usr/bin/clear
33
34         # make sure modprobe is working
35         if [ -f /proc/sys/kernel/modprobe ]; then
36                 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
37         fi
38
39         # If they want to run something in single user mode, might as well run it...
40         for i in /etc/rc.d/rc1.d/S[0-9][0-9]*; do
41                 # Check if the script is there.
42                 [ ! -f $i ] && continue
43
44                 # Don't run [KS]??foo.{rpmsave,rpmorig} scripts
45                 [ "${i%.rpmsave}" != "${i}" ] && continue
46                 [ "${i%.rpmorig}" != "${i}" ] && continue
47                 [ "${i%.rpmnew}" != "${i}" ] && continue
48                 [ "$i" = "/etc/rc.d/rc1.d/S00single" ] && continue
49                 $i start
50         done
51
52         # Now go to the single user level.
53         show "Telling INIT to go to single user mode"; ok
54         exec init -t1 S
55         ;;
56 esac