Contents of /mcore-src/trunk/mcore-tools/src/modules/sysvinit/sysvinit.client.class.in
Parent Directory | Revision Log
Revision 2269 -
(show annotations)
(download)
Tue Jan 14 10:34:57 2014 UTC (10 years, 3 months ago) by niro
File size: 1620 byte(s)
Tue Jan 14 10:34:57 2014 UTC (10 years, 3 months ago) by niro
File size: 1620 byte(s)
-use global argv arrays GLOBAL_ARGV and CLASS_ARGV to fix whitespace issues with the read cmd. escaping works with this now. every class must use the CLASS_ARGV array for arguments
1 | # $Id$ |
2 | |
3 | provide basic-init sysvinit |
4 | require basic-system |
5 | |
6 | set_system_service() |
7 | { |
8 | local command="${CLASS_ARGV[0]}" |
9 | local service="${CLASS_ARGV[1]}" |
10 | local opts="${CLASS_ARGV[2]}" |
11 | |
12 | [[ -z ${command} ]] && help_system_service && return 1 |
13 | [[ -z ${service} ]] && help_system_service && return 1 |
14 | |
15 | if [[ ! -x ${MROOT}@@SYSVRCDDIR@@/${service} ]] |
16 | then |
17 | eecho "Service '${service}' unknown!" |
18 | return 1 |
19 | fi |
20 | |
21 | if [[ -n ${MROOT} ]] && [[ ${MROOT} != / ]] |
22 | then |
23 | case "${command}" in |
24 | start|stop|restart|reload) |
25 | eecho "Command not available while \$MROOT is set" |
26 | return 1 |
27 | ;; |
28 | esac |
29 | fi |
30 | |
31 | case "${command}" in |
32 | start) @@SYSVRCDDIR@@/"${service}" start ;; |
33 | stop) @@SYSVRCDDIR@@/"${service}" stop ;; |
34 | restart) @@SYSVRCDDIR@@/"${service}" restart ;; |
35 | reload) @@SYSVRCDDIR@@/"${service}" reload ;; |
36 | enable) rc-config add "${service}" ;; |
37 | disable) rc-config del "${service}" ;; |
38 | *) help_system_service && return ;; |
39 | esac |
40 | } |
41 | |
42 | get_system_service() |
43 | { |
44 | local command="${CLASS_ARGV[0]}" |
45 | local service="${CLASS_ARGV[1]}" |
46 | |
47 | [[ -z ${command} ]] && help_system_service && return 1 |
48 | [[ -z ${service} ]] && help_system_service && return 1 |
49 | |
50 | if [[ ! -x ${MROOT}@@SYSVRCDDIR@@/${service} ]] |
51 | then |
52 | eecho "Service '${service}' unknown!" |
53 | return 1 |
54 | fi |
55 | |
56 | if [[ -n ${MROOT} ]] && [[ ${MROOT} != / ]] |
57 | then |
58 | case "${command}" in |
59 | status) |
60 | eecho "Command not available while \$MROOT is set" |
61 | return 1 |
62 | ;; |
63 | esac |
64 | fi |
65 | |
66 | case "${command}" in |
67 | status) @@SYSVRCDDIR@@/"${service}" status ;; |
68 | enabled) rc-config show "${service}" ;; |
69 | runlevel) eecho "function on todo" ;; |
70 | *) help_system_service && return ;; |
71 | esac |
72 | } |