Skip to content

Instantly share code, notes, and snippets.

@j0inty
Created October 8, 2016 15:35
Show Gist options
  • Save j0inty/2a62af892758d65bd2d19fa36309cf49 to your computer and use it in GitHub Desktop.
Save j0inty/2a62af892758d65bd2d19fa36309cf49 to your computer and use it in GitHub Desktop.
/etc/init.d/amavisd-milter
#!/sbin/openrc-run
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
NAME="amavisd-milter"
DAEMON="/usr/sbin/${NAME}"
depend() {
before postfix
use logger dns sendmail
need amavisd
}
command="${DAEMON:-/usr/sbin/amavisd-milter}"
pidfile="${PIDFILE:-/run/amavis/amavisd-milter.pid}"
name="Amavis Milter Daemon"
description=""
description_reload="Send the SIGHUP to the daemon and the process id of running daemon can be found in ${pidfile}"
#required_files="${CONFIG_FILE}"
command_args="${DOPTIONS:-"-D server"}"
command_background="false"
# onlyy need for ackground
start_stop_daemon_args="--user ${RUNAS_USER} --group ${RUNAS_GROUP}"
extra_started_commands="reload"
#start() {
# ebegin "Starting ${NAME}"
# start-stop-daemon --start --quiet --exec "${DAEMON}" \
# --stdout ${LOG_FILE} --stderr ${LOG_FILE} \
# --user ${RUNAS_USER} --group ${RUNAS_GROUP} \
# --pidfile "${PIDFILE}" -- ${DOPTIONS}
# eend $? "Failed to start ${NAME}"
#}
#
#stop() {
# ebegin "Stopping ${NAME}"
# start-stop-daemon --stop --name "${NAME}"
# eend $? "Failed to stop ${NAME}"
#}
restart() {
svc_stop
# needed to avoid potential mi_stop errors
sleep 4
svc_start
}
start_pre() {
# Creating the pid file directory
checkpath --directory --owner ${RUNAS_USER}:${RUNAS_GROUP} --mode 0775 "$(dirname "${PIDFILE}")"
# Creating the temp directory
checkpath --directory --owner ${RUNAS_USER}:${RUNAS_GROUP} --mode 0777 "$(dirname "${AM_TMP}")"
if [ ${DEBUG_LEVEL} -gt 0 ]; then
command_args="${command_args} -d${DEBUG_LEVEL}"
fi
}
start_post() {
# only get the path to file from ${SOCKET} if "local:" or "unix:"
checkpath --file --mode 0777 ${SOCKET##*:}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment