--- mcore-src/trunk/mcore-tools/daemon/client/include/system.client.class 2013/05/08 12:02:09 2057 +++ mcore-src/trunk/mcore-tools/daemon/client/include/system.client.class 2013/05/08 12:57:23 2061 @@ -81,7 +81,7 @@ mecho " del - deletes a service from all runlevels" } -set_system_service() +helper_system_service_sysvinit() { local command="$1" local service="$2" @@ -93,6 +93,7 @@ if [[ ! -x ${MROOT}/etc/rc.d/init.d/${service} ]] then eecho "Service '${service}' unkown!" + return 1 fi case "${command}" in @@ -107,6 +108,43 @@ esac } +helper_system_service_systemd() +{ + local command="$1" + local service="$2" + local opts="$3" + + [[ -z ${command} ]] && help_system_service && return 1 + [[ -z ${service} ]] && help_system_service && return 1 + + if [[ -n $(systemctl status ${service} | grep 'Reason: No such file or directory') ]] + then + eecho "Service '${service}' unkown!" + return 1 + fi + + case "${command}" in + start) systemctl start "${service}" ;; + stop) systemctl stop "${service}" ;; + restart) systemctl try-restart "${service}" ;; + reload) systemctl reload-or-try-restart "${service}" ;; + status) systemctl status "${service}" ;; + add) systemctl enable "${service}" ;; + del) systemctl disable "${service}" ;; + *) help_system_service && return ;; + esac +} + +set_system_service() +{ + if [[ -x $(type -P systemctl) ]] + then + helper_system_service_systemd $* + else + helper_system_service_sysvinit $* + fi +} + set_system_passwd() { local user="$1"