]>
Commit | Line | Data |
---|---|---|
73d9a908 | 1 | #!/bin/sh |
66c36198 PM |
2 | ############################################################################### |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
73d9a908 MT |
21 | |
22 | . /etc/sysconfig/rc | |
23 | . ${rc_functions} | |
24 | ||
25 | # This sets a few default terminal options. | |
26 | stty sane | |
27 | ||
28 | # These 3 signals will not cause our script to exit | |
29 | trap "" INT QUIT TSTP | |
30 | ||
31 | [ "${1}" != "" ] && runlevel=${1} | |
32 | ||
33 | if [ "${runlevel}" = "" ]; then | |
34 | echo "Usage: ${0} <runlevel>" >&2 | |
35 | exit 1 | |
36 | fi | |
37 | ||
38 | previous=${PREVLEVEL} | |
39 | [ "${previous}" = "" ] && previous=N | |
40 | ||
41 | if [ ! -d ${rc_base}/rc${runlevel}.d ]; then | |
42 | boot_mesg "${rc_base}/rc${runlevel}.d does not exist." ${WARNING} | |
43 | boot_mesg_flush | |
44 | exit 1 | |
45 | fi | |
46 | ||
47 | # Attempt to stop all service started by previous runlevel, | |
48 | # and killed in this runlevel | |
49 | if [ "${previous}" != "N" ]; then | |
50 | for i in $(ls -v ${rc_base}/rc${runlevel}.d/K* 2> /dev/null) | |
51 | do | |
52 | check_script_status | |
53 | ||
54 | suffix=${i#$rc_base/rc$runlevel.d/K[0-9][0-9]} | |
55 | prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix | |
56 | sysinit_start=$rc_base/rcsysinit.d/S[0-9][0-9]$suffix | |
57 | ||
58 | if [ "${runlevel}" != "0" ] && [ "${runlevel}" != "6" ]; then | |
59 | if [ ! -f ${prev_start} ] && [ ! -f ${sysinit_start} ]; then | |
60 | boot_mesg -n "WARNING:\n\n${i} can't be" ${WARNING} | |
61 | boot_mesg -n " executed because it was not" | |
62 | boot_mesg -n " not started in the previous" | |
63 | boot_mesg -n " runlevel (${previous})." | |
64 | boot_mesg "" ${NORMAL} | |
65 | boot_mesg_flush | |
66 | continue | |
67 | fi | |
68 | fi | |
69 | ${i} stop | |
70 | error_value=${?} | |
71 | ||
72 | if [ "${error_value}" != "0" ]; then | |
73 | print_error_msg | |
74 | fi | |
75 | done | |
76 | fi | |
77 | ||
78 | #Start all functions in this runlevel | |
79 | for i in $( ls -v ${rc_base}/rc${runlevel}.d/S* 2> /dev/null) | |
80 | do | |
ecb061e4 AF |
81 | suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]} |
82 | ||
f077f824 MT |
83 | # Skip if initscript is disabled at bootprompt |
84 | grep "skipinit=$suffix" /proc/cmdline >/dev/null 2>&1 && continue | |
ecb061e4 | 85 | |
73d9a908 | 86 | if [ "${previous}" != "N" ]; then |
73d9a908 MT |
87 | stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix |
88 | prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix | |
89 | ||
90 | [ -f ${prev_start} ] && [ ! -f ${stop} ] && continue | |
91 | fi | |
92 | ||
93 | check_script_status | |
94 | ||
95 | case ${runlevel} in | |
96 | 0|6) | |
97 | ${i} stop | |
98 | ;; | |
99 | *) | |
100 | ${i} start | |
101 | ;; | |
102 | esac | |
103 | error_value=${?} | |
104 | ||
105 | if [ "${error_value}" != "0" ]; then | |
106 | print_error_msg | |
107 | fi | |
108 | done |