Contents of /mcore-src/trunk/mcore-tools/src/modules/sysvinit/mcore-system-service.in
Parent Directory | Revision Log
Revision 2666 -
(show annotations)
(download)
Fri Dec 4 10:56:16 2015 UTC (8 years, 6 months ago) by niro
File size: 1418 byte(s)
Fri Dec 4 10:56:16 2015 UTC (8 years, 6 months ago) by niro
File size: 1418 byte(s)
-support additional argvs
1 | #!/bin/bash |
2 | |
3 | MCORE_LIBDIR="@@MCORE_LIBDIR@@" |
4 | source @@SYSCONFDIR@@/mcore/mcore.conf |
5 | source ${MCORE_LIBDIR}/include/common.global.class |
6 | source ${MCORE_LIBDIR}/include/daemon.global.class |
7 | |
8 | die() { echo "ERROR: $@"; exit 1; } |
9 | |
10 | control_service() |
11 | { |
12 | local command="$1" |
13 | local service="$2" |
14 | local argv="$3" |
15 | local chrooted |
16 | |
17 | if [[ ! -x ${MROOT}@@SYSVRCDDIR@@/${service} ]] |
18 | then |
19 | eecho "Service '${service}' unknown!" |
20 | return 1 |
21 | fi |
22 | |
23 | if [[ -n ${MROOT} ]] && [[ ${MROOT} != / ]] |
24 | then |
25 | case "${command}" in |
26 | start|stop|restart|reload) |
27 | eecho "Command not available while \$MROOT is set" |
28 | return 1 |
29 | ;; |
30 | esac |
31 | fi |
32 | |
33 | case "${command}" in |
34 | start) @@SYSVRCDDIR@@/"${service}" start "${argv}" ;; |
35 | stop) @@SYSVRCDDIR@@/"${service}" stop "${argv}" ;; |
36 | restart) @@SYSVRCDDIR@@/"${service}" restart "${argv}" ;; |
37 | reload) @@SYSVRCDDIR@@/"${service}" reload "${argv}" ;; |
38 | enable) rc-config add "${service}" ;; |
39 | disable) rc-config del "${service}" ;; |
40 | status) @@SYSVRCDDIR@@/"${service}" status "${argv}" ;; |
41 | enabled) rc-config show "${service}" ;; |
42 | runlevel) eecho "function on todo" ;; |
43 | *) return 1 ;; |
44 | esac |
45 | } |
46 | |
47 | # very basic getops |
48 | for argv in $* |
49 | do |
50 | case $1 in |
51 | --start|--stop|--restart|--reload|--enable|--disable|--status|--enabled|--runlevel) command="${1//--}" ;; |
52 | --service) shift; service="$1" ;; |
53 | esac |
54 | shift |
55 | done |
56 | |
57 | [[ -n ${command} ]] || die "No command given" |
58 | control_service "${command}" "${service}" |