#!/sbin/openrc-run # Copyright 1999-2017 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 DAEMON="/usr/bin/${RC_SVCNAME}" PID_DIR=${PID_DIR:-/var/run/${RC_SVCNAME}} PID_FILE=${PID_DIR}/${RC_SVCNAME}.pid USER=${RC_SVCNAME} GROUP=${RC_SVCNAME} DAEMON_ARGS=() depend() { need net use netmount } _init_req_file() { local filepath="${1}" if ! [ -f "${filepath}" ]; then touch "${filepath}" > /dev/null && chown ${USER}:${GROUP} "${filepath}" || \ ( eerror "Cannot create: ${filepath}" && return 1 ) fi } checkconfig() { if [ ! -d ${PID_DIR} ]; then checkpath -q -d -o ${USER}:${GROUP} -m 0755 ${PID_DIR} || return 1 fi ## /etc/conf.d/fiche: config file for /etc/init.d/fiche ## (!!!) Most important is providing DOMAIN and BASEDIR [[ -n "${domain}" && ( -n "${basedir}" && -d "${basedir}" ) ]] && DAEMON_ARGS+=("-d ${domain} -o ${basedir}/") || { eerror "You are not use DOMAIN or BASEDIR is not found..." eerror "Please, see configuration file: /etc/conf.d/${RC_SVCNAME}" return 1 } [[ "${https}" == "true" ]] && DAEMON_ARGS+=("-S") [ -z "${port}" ] || DAEMON_ARGS+=("-p ${port}") [ -z "${while_list}" ] || { _init_req_file "${while_list}" || return 1 ewarn "${while_list} — not implemented yet" DAEMON_ARGS+=("-w ${while_list}") } [ -z "${ban_list}" ] || { _init_req_file "${ban_list}" || return 1 ewarn "${ban_list} — not implemented yet" DAEMON_ARGS+=("-b ${ban_list}") } [ -z "${slug_size}" ] || DAEMON_ARGS+=("-s ${slug_size}") [ -z "${buffer_size}" ] || DAEMON_ARGS+=("-B ${buffer_size}") [ -z "${logfile}" ] || { _init_req_file "${logfile}" || return 1 DAEMON_ARGS+=("-l ${logfile}") } [ -z "${fiche_args}" ] || DAEMON_ARGS+=("${fiche_args}") } start() { checkconfig || return 1 ebegin "Starting ${RC_SVCNAME}" start-stop-daemon --start --background --make-pidfile --pidfile "${PID_FILE}" \ --user "${USER}" --exec "${DAEMON}" -- ${DAEMON_ARGS[@]} eend ${?} } stop() { ebegin "Stopping ${RC_SVCNAME}" start-stop-daemon --stop --quiet --pidfile "${PID_FILE}" --user "${USER}" eend ${?} } # vim: set ft=gentoo-init-d ts=4 :