[go: up one dir, main page]

File: rcS

package info (click to toggle)
file-rc 0.4.3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 76 kB
  • ctags: 22
  • sloc: sh: 779; makefile: 51
file content (111 lines) | stat: -rw-r--r-- 2,584 bytes parent folder | download
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#! /bin/bash

#   rcS - Help to boot the system into single user mode
#   Copyright (c) 1998  Martin Schulze <joey@debian.org>
#                       Winfried Trmper <winni@xpilot.org>
#                       Miquel van Smoorenburg <miquels@cistron.nl>

#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.

#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.

#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#  Ideas taken from rcS as provided by the sysvinit package and from
#  the file-rc /etc/init.d/rc program

PATH=/sbin:/bin:/usr/sbin:/usr/bin
runlevel=S
prevlevel=N
umask 022
export PATH runlevel prevlevel

CFGFILE="/etc/runlevel.conf"

#
#       See if system needs to be setup.
#
if [ -x /sbin/unconfigured.sh ]
then
  /sbin/unconfigured.sh
fi

#
#       Source defaults.
#
. /etc/default/rcS
export VERBOSE

#
#       Trap CTRL-C &c only in this shell so we can interrupt
#       subprocesses.
#
trap ":" INT QUIT TSTP

function element() {
    local element list IFS


    element="$1"
	
    [ "$2" = "in" ] && shift
    list="$2"
    [ "$list" = "-" ] && return 1
    [ "$list" = "*" ] && return 0

    IFS=","
    set -- $list
    case $element in
	"$1" | "$2" | "$3" | "$4" | "$5" | "$6" | "$7" | "$8" | "$9")
	    return 0
    esac
    return 1
}

CMDLIST="set centerline=here"

# read the file...
while read  SORT_NO  OFF_LEVELS  ON_LEVELS  CMD  OPTIONS
do
    case "$SORT_NO" in
	"#*" | "") continue ;;
    esac
    [ ! -f "$CMD" ] && continue

      # continue only if CMD was not started in previous runlevel
    if element "$runlevel" in "$ON_LEVELS"
    then
	# append CMD to the list of
	case "$CMD" in
	*.sh)	CMDLIST="$CMDLIST; . $CMD start" ;;
	*)	[ -x "$CMD" ] && CMDLIST="$CMDLIST; $CMD start" ;;
	esac
    fi

done < $CFGFILE

# Execute the commands collected above
sh -c "$CMDLIST"

#
#       For compatibility, run the files in /etc/rc.boot too.
#
[ -d /etc/rc.boot ] && run-parts /etc/rc.boot

#
#       Finish setup if needed.
#
if [ -x /sbin/setup.sh ]
then
  /sbin/setup.sh
fi