#!/bin/bash MCORE_LIBDIR="@@MCORE_LIBDIR@@" source @@SYSCONFDIR@@/mcore/mcore.conf source ${MCORE_LIBDIR}/include/common.global.class source ${MCORE_LIBDIR}/include/daemon.global.class die() { echo "ERROR: $@"; exit 1; } control_service() { local command="$1" local service="$2" local chrooted if [[ ! -x ${MROOT}@@SYSVRCDDIR@@/${service} ]] then eecho "Service '${service}' unknown!" return 1 fi if [[ -n ${MROOT} ]] && [[ ${MROOT} != / ]] then case "${command}" in start|stop|restart|reload) eecho "Command not available while \$MROOT is set" return 1 ;; esac fi case "${command}" in start) @@SYSVRCDDIR@@/"${service}" start ;; stop) @@SYSVRCDDIR@@/"${service}" stop ;; restart) @@SYSVRCDDIR@@/"${service}" restart ;; reload) @@SYSVRCDDIR@@/"${service}" reload ;; enable) rc-config add "${service}" ;; disable) rc-config del "${service}" ;; status) @@SYSVRCDDIR@@/"${service}" status ;; enabled) rc-config show "${service}" ;; runlevel) eecho "function on todo" ;; *) return 1 ;; esac } # very basic getops for argv in $* do case $1 in --start|--stop|--restart|--reload|--enable|--disable|--status|--enabled|--runlevel) command="${1//--}" ;; --service) shift; service="$1" ;; esac shift done [[ -n ${command} ]] || die "No command given" control_service "${command}" "${service}" ;;