aboutsummaryrefslogtreecommitdiff
path: root/trunk/templates/vserver-legacy/files/etc/rc.d/rc.sysvinit
blob: 916e59ee48fae10d9d75b2f33df0746adf07754d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
#
# rc.sysvinit   This file provides basic compatibility with SystemV style
#               startup scripts.  The SystemV style init system places 
#               start/stop scripts for each runlevel into directories such as
#               /etc/rc.d/rc3.d/ (for runlevel 3) instead of starting them
#               from /etc/rc.d/rc.M.  This makes for a lot more init scripts,
#               and a more complicated execution path to follow through if
#               something goes wrong.  For this reason, Slackware has always
#               used the traditional BSD style init script layout.
#
#               However, many binary packages exist that install SystemV
#               init scripts.  With rc.sysvinit in place, most well-written
#               startup scripts will work.  This is primarily intended to
#               support commercial software, though, and probably shouldn't
#               be considered bug free.
#
#               Written by Patrick Volkerding <volkerdi@slackware.com>, 1999
#               from an example by Miquel van Smoorenburg <miquels@cistron.nl>.

# Run an init script:
startup() {
  case "$1" in
  *.sh)
    sh "$@"
    ;;
  *)
    "$@"
    ;;
  esac
}

# Set onlcr to avoid staircase effect.
stty onlcr 0>&1

if [ "$runlevel" = "" ]; then
  runlevel=$RUNLEVEL
  export runlevel
  prevlevel=$PREVLEVEL
  export prevlevel
fi

# Run kill scripts in the previous runlevel if not "none"
if [ ! "$prevlevel" = "N" ]; then
  for script in /etc/rc.d/rc$prevlevel.d/K* ; do
    if [ -x $script ]; then
      startup $script stop
    fi
  done
fi

# Now do the startup scripts:
for script in /etc/rc.d/rc$runlevel.d/S* ; do
  if [ -x $script ]; then
    startup $script start
  fi
done