source: bootscripts/clfs/init.d/rc @ d66bf46

clfs-1.2clfs-2.1clfs-3.0.0-systemdclfs-3.0.0-sysvinitsystemdsysvinit
Last change on this file since d66bf46 was d66bf46, checked in by Jim Gifford <clfs@…>, 17 years ago

Update bootscripts to follow our standards

  • Property mode set to 100644
File size: 2.3 KB
Line 
1#!/bin/sh
2########################################################################
3# Begin $rc_base/init.d/rc
4#
5# Description : Main Run Level Control Script
6#
7# Authors     : Gerard Beekmans  - gerard@linuxfromscratch.org
8#
9# Version     : 00.00
10#
11# Notes       :
12#
13########################################################################
14
15. /etc/sysconfig/rc
16. ${rc_functions}
17
18# This sets a few default terminal options.
19stty sane
20
21# These 3 signals will not cause our script to exit
22trap "" INT QUIT TSTP
23
24[ "${1}" != "" ] && runlevel=${1}
25
26if [ "${runlevel}" = "" ]; then
27        echo "Usage: ${0} <runlevel>" >&2
28        exit 1
29fi
30
31previous=${PREVLEVEL}
32[ "${previous}" = "" ] && previous=N
33
34if [ ! -d ${rc_base}/rc${runlevel}.d ]; then
35        boot_mesg "${rc_base}/rc${runlevel}.d does not exist." ${WARNING}
36        boot_mesg_flush
37        exit 1
38fi
39
40# Attempt to stop all service started by previous runlevel,
41# and killed in this runlevel
42if [ "${previous}" != "N" ]; then
43        for i in $(ls -v ${rc_base}/rc${runlevel}.d/K* 2> /dev/null)
44        do
45                check_script_status
46
47                suffix=${i#$rc_base/rc$runlevel.d/K[0-9][0-9]}
48                prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix
49                sysinit_start=$rc_base/rcsysinit.d/S[0-9][0-9]$suffix
50
51                if [ "${runlevel}" != "0" ] && [ "${runlevel}" != "6" ]; then
52                        if [ ! -f ${prev_start} ] && [ ! -f ${sysinit_start} ]; then
53                                boot_log "${i} cant be started in runlevel ${runlevel}, because it was not started in runlevel ${previous}"
54                                boot_mesg -n "WARNING:\n\n${i} can't be" ${WARNING}
55                                boot_mesg -n " executed because it was not"
56                                boot_mesg -n " not started in the previous"
57                                boot_mesg -n " runlevel (${previous})."
58                                boot_mesg "" ${NORMAL}
59                                boot_mesg_flush
60                                continue
61                        fi
62                fi
63                ${i} stop
64                error_value=${?}
65
66                if [ "${error_value}" != "0" ]; then
67                        print_error_msg
68                fi
69        done
70fi
71
72#Start all functions in this runlevel
73for i in $( ls -v ${rc_base}/rc${runlevel}.d/S* 2> /dev/null)
74do
75        if [ "${previous}" != "N" ]; then
76                suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]}
77                stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix
78                prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix
79
80                [ -f ${prev_start} ] && [ ! -f ${stop} ] && continue
81        fi
82
83        check_script_status
84
85        case ${runlevel} in
86                0|6)
87                        ${i} stop
88                        ;;
89                *)
90                        ${i} start
91                        ;;
92        esac
93        error_value=${?}
94
95        if [ "${error_value}" != "0" ]; then
96                print_error_msg
97        fi
98done
99
100# End $rc_base/init.d/rc
Note: See TracBrowser for help on using the repository browser.