Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2084 - (hide annotations) (download)
Fri May 10 13:15:26 2013 UTC (11 years ago) by niro
Original Path: mcore-src/trunk/mcore-tools/daemon/client/include/systemd.client.class
File size: 1877 byte(s)
-honor $MROOT variable
1 niro 2079 # $Id$
2    
3     provide basic-init systemd
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 niro 2084 local chrooted
16     if [[ -n ${MROOT} ]] && [[ ${MROOT} != / ]]
17 niro 2079 then
18 niro 2084 chrooted="system_chroot"
19     case ${command} in
20     start|stop|restart|reload)
21     eecho "Command not available while \$MROOT is set"
22     return 1
23     ;;
24     esac
25     fi
26    
27     if [[ -n $(${chrooted} systemctl status ${service} | grep 'Reason: No such file or directory') ]]
28     then
29 niro 2079 eecho "Service '${service}' unkown!"
30     return 1
31     fi
32    
33     case "${command}" in
34 niro 2084 start) ${chrooted} systemctl start "${service}" ;;
35     stop) ${chrooted} systemctl stop "${service}" ;;
36     restart) ${chrooted} systemctl try-restart "${service}" ;;
37     reload) ${chrooted} systemctl reload-or-try-restart "${service}" ;;
38     add) ${chrooted} systemctl enable "${service}" ;;
39     del) ${chrooted} systemctl disable "${service}" ;;
40 niro 2079 *) help_system_service && return ;;
41     esac
42     }
43    
44     get_system_service()
45     {
46     local command="$1"
47     local service="$2"
48    
49     [[ -z ${command} ]] && help_system_service && return 1
50     [[ -z ${service} ]] && help_system_service && return 1
51    
52 niro 2084 local chrooted
53     if [[ -n ${MROOT} ]] && [[ ${MROOT} != / ]]
54 niro 2079 then
55 niro 2084 chrooted="system_chroot"
56     case ${command} in
57     status)
58     eecho "Command not available while \$MROOT is set"
59     return 1
60     ;;
61     esac
62     fi
63    
64     if [[ -n $(${chrooted} systemctl status ${service} | grep 'Reason: No such file or directory') ]]
65     then
66 niro 2079 eecho "Service '${service}' unkown!"
67     return 1
68     fi
69    
70     case "${command}" in
71 niro 2084 status) ${chrooted} systemctl status "${service}" ;;
72     enabled) ${chrooted} systemctl is-enabled "${service}"; rvecho "$?" ;;
73 niro 2079 runlevel) rvecho "$(readline ${MROOT}/etc/systemd/system/default.target)" ;;
74     *) help_system_service && return ;;
75     esac
76     }