source: bootscripts/lfs/init.d/rc@ 13e7d79

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.0 7.1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 13e7d79 was 13e7d79, checked in by Bruce Dubbs <bdubbs@…>, 13 years ago

Fix binutils extracted directory version in binutils
build instructions. This will be reverted at the next upstream release
when the tarball name is again synced with the extracted directory
name.

Fix bootscripts to properly export IN_BOOT variable.

Adjust minimum kernel for the host sysem to 2.6.25
due to a udev requirement.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@9592 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 3.4 KB
Line 
1#!/bin/sh
2########################################################################
3# Begin rc
4#
5# Description : Main Run Level Control Script
6#
7# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
8# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
9#
10# Version : LFS 7.0
11#
12########################################################################
13
14. /lib/boot/functions
15
16print_error_msg()
17{
18 echo_failure
19 # $i is set when called
20 boot_mesg -n "FAILURE:\n\nYou should not be reading this error message.\n\n" ${FAILURE}
21 boot_mesg -n " It means that an unforeseen error took"
22 boot_mesg -n " place in ${i}, which exited with a return value of"
23 boot_mesg " ${error_value}.\n"
24 boot_mesg_flush
25 boot_mesg -n "If you're able to track this"
26 boot_mesg -n " error down to a bug in one of the files provided by"
27 boot_mesg -n " the LFS book, please be so kind to inform us at"
28 boot_mesg " lfs-dev@linuxfromscratch.org.\n"
29 boot_mesg_flush
30 boot_mesg -n "Press Enter to continue..." ${INFO}
31 boot_mesg "" ${NORMAL}
32 wait_for_user
33}
34
35check_script_status()
36{
37 # $i is set when called
38 if [ ! -f ${i} ]; then
39 boot_mesg "${i} is not a valid symlink." ${WARNING}
40 echo_warning
41 continue
42 fi
43
44 if [ ! -x ${i} ]; then
45 boot_mesg "${i} is not executable, skipping." ${WARNING}
46 echo_warning
47 continue
48 fi
49}
50
51# This sets a few default terminal options.
52stty sane
53
54# These 3 signals will not cause our script to exit
55trap "" INT QUIT TSTP
56
57[ "${1}" != "" ] && runlevel=${1}
58
59if [ "${runlevel}" = "" ]; then
60 echo "Usage: ${0} <runlevel>" >&2
61 exit 1
62fi
63
64previous=${PREVLEVEL}
65[ "${previous}" = "" ] && previous=N
66
67if [ ! -d /etc/rc.d/rc${runlevel}.d ]; then
68 boot_mesg "/etc/rc.d/rc${runlevel}.d does not exist."
69 exit 1
70fi
71
72# Attempt to stop all services started by the previous runlevel,
73# and killed in this runlevel
74if [ "${previous}" != "N" ]; then
75 for i in $(ls -v /etc/rc.d/rc${runlevel}.d/K* 2> /dev/null)
76 do
77 check_script_status
78
79 suffix=${i#/etc/rc.d/rc$runlevel.d/K[0-9][0-9]}
80 prev_start=/etc/rc.d/rc$previous.d/S[0-9][0-9]$suffix
81 sysinit_start=/etc/rc.d/rcsysinit.d/S[0-9][0-9]$suffix
82
83 if [ "${runlevel}" != "0" ] && [ "${runlevel}" != "6" ]; then
84 if [ ! -f ${prev_start} ] && [ ! -f ${sysinit_start} ]; then
85 boot_mesg -n "WARNING:\n\n${i} can't be" ${WARNING}
86 boot_mesg -n " executed because it was not"
87 boot_mesg -n " not started in the previous"
88 boot_mesg -n " runlevel (${previous})."
89 boot_mesg "" ${NORMAL}
90 boot_mesg_flush
91 continue
92 fi
93 fi
94 ${i} stop
95 error_value=${?}
96
97 if [ "${error_value}" != "0" ]; then
98 print_error_msg
99 fi
100 done
101fi
102
103if [ "${previous}" = "N" ]; then
104 IN_BOOT=1
105 export IN_BOOT
106fi
107
108#Start all functions in this runlevel
109for i in $( ls -v /etc/rc.d/rc${runlevel}.d/S* 2> /dev/null)
110do
111 if [ "${previous}" != "N" ]; then
112 suffix=${i#/etc/rc.d/rc$runlevel.d/S[0-9][0-9]}
113 stop=/etc/rc.d/rc$runlevel.d/K[0-9][0-9]$suffix
114 prev_start=/etc/rc.d/rc$previous.d/S[0-9][0-9]$suffix
115
116 [ -f ${prev_start} ] && [ ! -f ${stop} ] && continue
117 fi
118
119 check_script_status
120
121 case ${runlevel} in
122 0|6)
123 ${i} stop
124 ;;
125 *)
126 ${i} start
127 ;;
128 esac
129 error_value=${?}
130
131 if [ "${error_value}" != "0" ]; then
132 print_error_msg
133 fi
134done
135
136# End rc
Note: See TracBrowser for help on using the repository browser.