]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/initscripts/init.d/rc
Fix special character output at setup.
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / rc
CommitLineData
73d9a908
MT
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_mesg -n "WARNING:\n\n${i} can't be" ${WARNING}
54 boot_mesg -n " executed because it was not"
55 boot_mesg -n " not started in the previous"
56 boot_mesg -n " runlevel (${previous})."
57 boot_mesg "" ${NORMAL}
58 boot_mesg_flush
59 continue
60 fi
61 fi
62 ${i} stop
63 error_value=${?}
64
65 if [ "${error_value}" != "0" ]; then
66 print_error_msg
67 fi
68 done
69fi
70
71#Start all functions in this runlevel
72for i in $( ls -v ${rc_base}/rc${runlevel}.d/S* 2> /dev/null)
73do
ecb061e4
AF
74 suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]}
75
76 # Skip if initskript is disabled at bootprompt
77 grep "skipinit=$suffix" /proc/cmdline > /dev/null && continue
78
73d9a908 79 if [ "${previous}" != "N" ]; then
73d9a908
MT
80 stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix
81 prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix
82
83 [ -f ${prev_start} ] && [ ! -f ${stop} ] && continue
84 fi
85
86 check_script_status
87
88 case ${runlevel} in
89 0|6)
90 ${i} stop
91 ;;
92 *)
93 ${i} start
94 ;;
95 esac
96 error_value=${?}
97
98 if [ "${error_value}" != "0" ]; then
99 print_error_msg
100 fi
101done
102
103# End $rc_base/init.d/rc