Contents of /mcore-src/trunk/mcore-tools/src/modules/sysvinit/mcore-system-service.in
Parent Directory | Revision Log
Revision 2651 -
(show annotations)
(download)
Tue Nov 10 15:00:32 2015 UTC (8 years, 7 months ago) by niro
File size: 1351 byte(s)
Tue Nov 10 15:00:32 2015 UTC (8 years, 7 months ago) by niro
File size: 1351 byte(s)
-fixed a typo
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 chrooted |
15 | |
16 | if [[ ! -x ${MROOT}@@SYSVRCDDIR@@/${service} ]] |
17 | then |
18 | eecho "Service '${service}' unknown!" |
19 | return 1 |
20 | fi |
21 | |
22 | if [[ -n ${MROOT} ]] && [[ ${MROOT} != / ]] |
23 | then |
24 | case "${command}" in |
25 | start|stop|restart|reload) |
26 | eecho "Command not available while \$MROOT is set" |
27 | return 1 |
28 | ;; |
29 | esac |
30 | fi |
31 | |
32 | case "${command}" in |
33 | start) @@SYSVRCDDIR@@/"${service}" start ;; |
34 | stop) @@SYSVRCDDIR@@/"${service}" stop ;; |
35 | restart) @@SYSVRCDDIR@@/"${service}" restart ;; |
36 | reload) @@SYSVRCDDIR@@/"${service}" reload ;; |
37 | enable) rc-config add "${service}" ;; |
38 | disable) rc-config del "${service}" ;; |
39 | status) @@SYSVRCDDIR@@/"${service}" status ;; |
40 | enabled) rc-config show "${service}" ;; |
41 | runlevel) eecho "function on todo" ;; |
42 | *) return 1 ;; |
43 | esac |
44 | } |
45 | |
46 | # very basic getops |
47 | for argv in $* |
48 | do |
49 | case $1 in |
50 | --start|--stop|--restart|--reload|--enable|--disable|--status|--enabled|--runlevel) command="${1//--}" ;; |
51 | --service) shift; service="$1" ;; |
52 | esac |
53 | shift |
54 | done |
55 | |
56 | [[ -n ${command} ]] || die "No command given" |
57 | control_service "${command}" "${service}" |