#!/sbin/openrc-run # Copyright 1999-2017 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 CONFFILE="/etc/openarc/${SVCNAME}.conf" depend() { use dns logger net before mta } check_cfg() { if [ ! -f "${CONFFILE}" ] ; then eerror "Configuration file ${CONFFILE} is missing" return 1 fi # create /var/run/openarc mkdir -p /var/run/openarc >& /dev/null chown ${OPENARC_USER}:${OPENARC_GROUP} /var/run/openarc >& /dev/null PIDFILE=$(sed -ne 's/^[[:space:]]*PidFile[[:space:]]\+//p' "${CONFFILE}") local PIDDIR="${PIDFILE%/*}" if [ ! -d "${PIDDIR}" ] ; then checkpath -q -d -o ${OPENARC_USER}:${OPENARC_GROUP} -m 0755 "${PIDDIR}" || return 1 fi if [ -z "${PIDFILE}" ] ; then eerror "Configuration file needs PidFile setting - recommend adding 'PidFile /var/run/openarc/${SVCNAME}.pid' to ${CONFFILE}" return 1 fi if egrep -q '^[[:space:]]*Background[[:space:]]+false' "${CONFFILE}" ; then eerror "${SVCNAME} service cannot run with Background key set to false!" return 1 fi ebegin "Checking your configfile (${CONFFILE})" openarc -c "${CONFFILE}" -n eend $? "Configuration error. Please fix your configfile (${CONFFILE})" } start() { check_cfg || return 1 ebegin "Starting OpenARC" start-stop-daemon --start --pidfile "${PIDFILE}" \ --exec /usr/sbin/openarc -- -c "${CONFFILE}" eend $? } stop() { check_cfg || return 1 ebegin "Stopping OpenARC" start-stop-daemon --stop --pidfile "${PIDFILE}" eend $? }