comparison core/rc/rc.start @ 566:ddb052f876cd

core/rc: move etc services to rc, closes #1666
author David Demelier <markand@malikania.fr>
date Fri, 05 Jul 2019 20:58:54 +0200
parents core/etc/rc.start@79f1635bda5f
children dbd752e285f6
comparison
equal deleted inserted replaced
565:15992f10ced3 566:ddb052f876cd
1 #!/bin/sh
2 #
3 # /etc/rc.start: runlevel control script
4 #
5 # Copyright (c) 2019 David Demelier <markand@malikania.fr>
6 #
7 # Permission to use, copy, modify, and/or distribute this software for any
8 # purpose with or without fee is hereby granted, provided that the above
9 # copyright notice and this permission notice appear in all copies.
10 #
11 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #
19
20 if [ "$#" -ne 1 ]; then
21 echo "usage: $0 runlevel" 1>&2
22 exit 1
23 fi
24
25 if [ -f /etc/rc.conf ]; then
26 source /etc/rc.conf
27 fi
28
29 # Start user services requested in rc.conf(5).
30 for s in $SERVICES; do
31 #
32 # Services are requested in the form name[:runlevel], if runlevel is
33 # specified the service is started only if the system runlevel is
34 # greater or equal to the request.
35 #
36 name="${s%%:*}"
37 level="${s##*:}"
38
39 # No minimum level, set to requested.
40 if [ "$level" = "$name" ]; then
41 level="$1"
42 fi
43
44 if [ -x /etc/rc.d/$name ] && [ "$level" -le "$1" ]; then
45 /etc/rc.d/$name start
46 fi
47 done