Merge branch 'org.openembedded.dev' of git://git.openembedded.net/openembedded into...
[vuplus_openembedded] / packages / sysvinit / sysvinit / opendreambox / rcS
1 #!/bin/sh
2 #
3 # rcS           Call all S??* scripts in /etc/rcS.d in
4 #               numerical/alphabetical order.
5 #
6 # Version:      @(#)/etc/init.d/rcS  2.76  19-Apr-1999  miquels@cistron.nl
7 #
8
9 PATH=/sbin:/bin:/usr/sbin:/usr/bin
10 runlevel=S
11 prevlevel=N
12 umask 022
13 export PATH runlevel prevlevel
14
15 #       Make sure proc is mounted
16 #
17 [ -d "/proc/1" ] || mount /proc
18
19 #
20 #       See if system needs to be setup. This is ONLY meant to
21 #       be used for the initial setup after a fresh installation!
22 #
23 if [ -x /sbin/unconfigured.sh ]
24 then
25   /sbin/unconfigured.sh
26 fi
27
28 #
29 #       Source defaults.
30 #
31 . /etc/default/rcS
32
33 #
34 #       Trap CTRL-C &c only in this shell so we can interrupt subprocesses.
35 #
36 trap ":" INT QUIT TSTP
37
38 #
39 #       Do we have /proc/progress and set VERBOSE to "no" ?
40 #       If so, calculate the number of scripts and the incremental step
41 #
42
43 # HACK: progress needs LCD to create /proc device entry
44 modprobe lcd
45
46 if [ "$VERBOSE" = no ]; then
47     if [ -e /proc/progress ]; then
48         set `ls -1 /etc/rc$runlevel.d/S* | wc`
49         numscripts=$1
50         # bootup, the first script, increments until 25.
51         # the userspace then picks up at 50
52         PROGRESS_incstep=`expr 25 / $1`
53         PROGRESS_value=25
54         PROGRESS=yes
55         export PROGRESS_value PROGRESS_incstep
56     fi
57 fi
58 export VERBOSE PROGRESS
59
60 #
61 #       Call all parts in order.
62 #
63 for i in /etc/rcS.d/S??*
64 do
65         # Ignore dangling symlinks for now.
66         [ ! -f "$i" ] && continue
67
68         # Handle verbosity
69         [ "$VERBOSE" = very ] && echo "INIT: Running $i..."
70         if [ "$PROGRESS" = yes ]; then
71                 export PROGRESS_value=`expr $PROGRESS_value + $PROGRESS_incstep`
72                 echo "$PROGRESS_value Starting $i..." >/proc/progress
73         fi
74
75         case "$i" in
76                 *.sh)
77                         # Source shell script for speed.
78                         (
79                                 trap - INT QUIT TSTP
80                                 set start
81                                 . $i
82                         )
83                         ;;
84                 *)
85                         # No sh extension, so fork subprocess.
86                         $i start
87                         ;;
88         esac
89
90         #
91         # Report status based on result code
92         #
93         result=$?
94         if [ "$PROGRESS" = yes ]; then
95                 if [ "$result" = 0 ]; then
96                     echo "=s" >/proc/progress
97                 else
98                     echo "=f" >/proc/progress
99                 fi
100         fi
101 done
102
103 #
104 #       For compatibility, run the files in /etc/rc.boot too.
105 #
106 [ -d /etc/rc.boot ] && run-parts /etc/rc.boot
107
108 #
109 #       Finish setup if needed. The comment above about
110 #       /sbin/unconfigured.sh applies here as well!
111 #
112 if [ -x /sbin/setup.sh ]
113 then
114   /sbin/setup.sh
115 fi
116