]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - etc/rc.d/localpkg
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / etc / rc.d / localpkg
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: localpkg
7 # REQUIRE: abi
8 # BEFORE:  securelevel
9 # KEYWORD: shutdown
10
11 . /etc/rc.subr
12
13 name="localpkg"
14 start_cmd="pkg_start"
15 stop_cmd="pkg_stop"
16
17 pkg_start()
18 {
19         local initdone
20
21         # For each dir in $local_startup, search for init scripts matching *.sh
22         #
23         case ${local_startup} in
24         [Nn][Oo] | '')
25                 ;;
26         *)
27                 initdone=
28                 find_local_scripts_old
29                 for script in ${zlist} ${slist}; do
30                         if [ -z "${initdone}" -a -f "${script}" ]; then
31                                 echo -n 'Local package initialization:'
32                                 initdone=yes
33                         fi
34                         if [ -x "${script}" ]; then
35                                 (set -T
36                                 trap 'exit 1' 2
37                                 ${script} start)
38                         elif [ -f "${script}" -o -L "${script}" ]; then
39                                 echo -n " (skipping ${script}, not executable)"
40                         fi
41                 done
42                 [ -n "${initdone}" ] && echo '.'
43                 ;;
44         esac
45 }
46
47 pkg_stop()
48 {
49         local initdone
50
51         case ${local_startup} in
52         [Nn][Oo] | '')
53                 ;;
54         *)
55                 initdone=
56                 find_local_scripts_old
57                 for script in `reverse_list ${slist} ${zlist}`; do
58                         if [ -z "${initdone}" -a -f "${script}" ]; then
59                                 echo -n 'Shutting down local packages:'
60                                 initdone=yes
61                         fi
62                         if [ -x "${script}" ]; then
63                                 if [ `sysctl -n debug.bootverbose` -eq 1 ]; then
64                                         echo "==>" ${script}
65                                 fi
66                                 (set -T
67                                 trap 'exit 1' 2
68                                 ${script} stop)
69                         fi
70                 done
71                 [ -n "${initdone}" ] && echo '.'
72                 ;;
73         esac
74 }
75
76 load_rc_config $name
77 run_rc_command "$1"