Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/src/modules/systemd/mcore-system-service.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2671 - (hide annotations) (download)
Fri Dec 4 12:11:42 2015 UTC (8 years, 6 months ago) by niro
File size: 1883 byte(s)
-argv support breaks systemd logic, removed
1 niro 2648 #!/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 [[ -n ${MROOT} ]] && [[ ${MROOT} != / ]]
17     then
18     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     eecho "Service '${service}' unknown!"
30     return 1
31     fi
32    
33     # auto-append .service to fix issues while $MROOT is set
34     if [[ -n $(echo ${service} | grep -v '.service$\|.target$\|.mount$\|.socket$\|.timer$') ]]
35     then
36     service="${service}.service"
37     decho "\$service replaced with '${service}'"
38     fi
39    
40     case "${command}" in
41 niro 2671 start) ${chrooted} systemctl start "${service}" ;;
42     stop) ${chrooted} systemctl stop "${service}" ;;
43     #restart) ${chrooted} systemctl try-restart "${service}" ;;
44     restart) ${chrooted} systemctl restart "${service}" ;;
45     reload) ${chrooted} systemctl reload-or-try-restart "${service}" ;;
46     enable) ${chrooted} systemctl enable "${service}" ;;
47     disable) ${chrooted} systemctl disable "${service}" ;;
48     status) ${chrooted} systemctl status "${service}" ;;
49 niro 2648 enabled) ${chrooted} systemctl is-enabled "${service}"; rvecho "$?" ;;
50     runlevel) rvecho "$(readline ${MROOT}@@SYSTEMDSYSTEMCONFDIR@@/default.target)" ;;
51     *) return 1 ;;
52     esac
53     }
54    
55     # very basic getops
56     for argv in $*
57     do
58     case $1 in
59     --start|--stop|--restart|--reload|--enable|--disable|--status|--enabled|--runlevel) command="${1//--}" ;;
60     --service) shift; service="$1" ;;
61     esac
62     shift
63     done
64    
65     [[ -n ${command} ]] || die "No command given"
66 niro 2651 control_service "${command}" "${service}"