Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/src/modules/sysvinit/sysvinit.client.class.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2090 - (hide annotations) (download)
Fri May 10 13:37:51 2013 UTC (11 years ago) by niro
Original Path: mcore-src/trunk/mcore-tools/daemon/client/include/sysvinit.client.class
File size: 1562 byte(s)
-use enable|disable commands to add|remove services from runlevels
1 niro 2079 # $Id$
2    
3     provide basic-init sysvinit
4     require basic-system
5    
6     set_system_service()
7     {
8     local command="$1"
9     local service="$2"
10     local opts="$3"
11    
12     [[ -z ${command} ]] && help_system_service && return 1
13     [[ -z ${service} ]] && help_system_service && return 1
14    
15     if [[ ! -x ${MROOT}/etc/rc.d/init.d/${service} ]]
16     then
17     eecho "Service '${service}' unkown!"
18     return 1
19     fi
20    
21 niro 2088 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 niro 2079 case "${command}" in
32     start) /etc/rc.d/init.d/"${service}" start ;;
33     stop) /etc/rc.d/init.d/"${service}" stop ;;
34     restart) /etc/rc.d/init.d/"${service}" restart ;;
35     reload) /etc/rc.d/init.d/"${service}" reload ;;
36 niro 2090 enable) rc-config add "${service}" ;;
37     disable) rc-config del "${service}" ;;
38 niro 2079 *) help_system_service && return ;;
39     esac
40     }
41    
42     get_system_service()
43     {
44     local command="$1"
45     local service="$2"
46    
47     [[ -z ${command} ]] && help_system_service && return 1
48     [[ -z ${service} ]] && help_system_service && return 1
49    
50     if [[ ! -x ${MROOT}/etc/rc.d/init.d/${service} ]]
51     then
52     eecho "Service '${service}' unkown!"
53     return 1
54     fi
55    
56 niro 2088 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 niro 2079 case "${command}" in
67     status) /etc/rc.d/init.d/"${service}" status ;;
68     enabled) rc-config show "${service}" ;;
69     runlevel) eecho "function on todo" ;;
70     *) help_system_service && return ;;
71     esac
72     }