Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2164 by niro, Fri Jan 10 13:59:40 2014 UTC revision 2652 by niro, Tue Nov 10 15:02:21 2015 UTC
# Line 5  require basic-system Line 5  require basic-system
5    
6  set_system_service()  set_system_service()
7  {  {
8   local command="$1"   local command="${CLASS_ARGV[0]}"
9   local service="$2"   local service="${CLASS_ARGV[1]}"
10   local opts="$3"   local opts="${CLASS_ARGV[2]}"
11    
12   [[ -z ${command} ]] && help_system_service && return 1   [[ -z ${command} ]] && help_system_service && return 1
13   [[ -z ${service} ]] && help_system_service && return 1   [[ -z ${service} ]] && help_system_service && return 1
14    
  local chrooted  
  if [[ -n ${MROOT} ]] && [[ ${MROOT} != / ]]  
  then  
  chrooted="system_chroot"  
  case ${command} in  
  start|stop|restart|reload)  
  eecho "Command not available while \$MROOT is set"  
  return 1  
  ;;  
  esac  
  fi  
   
  if [[ -n $(${chrooted} systemctl status ${service} | grep 'Reason: No such file or directory') ]]  
  then  
  eecho "Service '${service}' unkown!"  
  return 1  
  fi  
   
  # auto-append .service to fix issues while $MROOT is set  
  if [[ -n $(echo ${service} | grep -v '.service$\|.target$\|.mount$\|.socket$\|.timer$') ]]  
  then  
  service="${service}.service"  
  decho "\$service replaced with '${service}'"  
  fi  
   
15   case "${command}" in   case "${command}" in
16   start) ${chrooted} systemctl start "${service}" ;;   start) mcore-system-service --start --service "${service}" ;;
17   stop) ${chrooted} systemctl stop "${service}" ;;   stop) mcore-system-service --stop --service "${service}" ;;
18   restart) ${chrooted} systemctl try-restart "${service}" ;;   restart) mcore-system-service --restart --service "${service}" ;;
19   reload) ${chrooted} systemctl reload-or-try-restart "${service}" ;;   reload) mcore-system-service --reload --service "${service}" ;;
20   enable) ${chrooted} systemctl enable "${service}" ;;   enable) mcore-system-service --enable --service "${service}" ;;
21   disable) ${chrooted} systemctl disable "${service}" ;;   disable) mcore-system-service --disable --service "${service}" ;;
22   *) help_system_service && return ;;   *) help_system_service && return 1 ;;
23   esac   esac
24  }  }
25    
26  get_system_service()  get_system_service()
27  {  {
28   local command="$1"   local command="${CLASS_ARGV[0]}"
29   local service="$2"   local service="${CLASS_ARGV[1]}"
30    
31   [[ -z ${command} ]] && help_system_service && return 1   [[ -z ${command} ]] && help_system_service && return 1
32   [[ -z ${service} ]] && help_system_service && return 1   [[ -z ${service} ]] && help_system_service && return 1
33    
  local chrooted  
  if [[ -n ${MROOT} ]] && [[ ${MROOT} != / ]]  
  then  
  chrooted="system_chroot"  
  case ${command} in  
  status)  
  eecho "Command not available while \$MROOT is set"  
  return 1  
  ;;  
  esac  
  fi  
   
  if [[ -n $(${chrooted} systemctl status ${service} | grep 'Reason: No such file or directory') ]]  
  then  
  eecho "Service '${service}' unkown!"  
  return 1  
  fi  
   
34   case "${command}" in   case "${command}" in
35   status) ${chrooted} systemctl status "${service}" ;;   status) mcore-system-service --status --service "${service}" ;;
36   enabled) ${chrooted} systemctl is-enabled "${service}"; rvecho "$?" ;;   enabled) mcore-system-service --enabled --service "${service}" ;;
37   runlevel) rvecho "$(readline ${MROOT}/etc/systemd/system/default.target)" ;;   runlevel) mcore-system-service --runlevel ;;
38   *) help_system_service && return ;;   *) help_system_service && return 1 ;;
39   esac   esac
40  }  }

Legend:
Removed from v.2164  
changed lines
  Added in v.2652