Created
October 12, 2011 04:33
-
-
Save nanasess/1280284 to your computer and use it in GitHub Desktop.
tcpserver startup scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# $Id$ | |
# | |
# PROVIDE: tcpserver-pop3 | |
# REQUIRE: NETWORKING SERVERS | |
# BEFORE: DAEMON | |
# KEYWORD: shutdown | |
export PATH=/usr/local/bin:/var/qmail/bin:$PATH | |
export QMAILQUEUE="/usr/local/bin/qmail-scanner-queue" | |
tcpserver_pop3_enable="${tcpserver_pop3_enable:-"NO"}" | |
tcpserver_pop3_pidfile="${tcpserver_pop3_pidfile:-"/var/run/tcpserver_pop3.pid"}" | |
TCPSERVER=tcpserver | |
TCPSERVER_OPTS="-RHv 0 pop3" | |
HOSTNAME=`hostname` | |
VCHKPW=/usr/local/vpopmail/bin/vchkpw | |
QMAIL_POPUP=qmail-popup | |
POP3D=qmail-pop3d | |
MBOXTYPE=Maildir | |
SPLOGGER=splogger | |
. /etc/rc.subr | |
name="tcpserver_pop3" | |
rcvar=`set_rcvar` | |
pidfile=${tcpserver_pop3_pidfile} | |
timeout=10 | |
load_rc_config "${name}" | |
# Subvert the check_pid_file procname check | |
if [ -f $pidfile ]; then | |
read rc_pid junk < $pidfile | |
if [ ! -z "$rc_pid" ]; then | |
procname=`ps -o comm= $rc_pid` | |
fi | |
fi | |
command="/usr/sbin/daemon" | |
flags="-p ${pidfile} ${TCPSERVER} ${TCPSERVER_OPTS} ${QMAIL_POPUP} ${HOSTNAME} ${VCHKPW} ${POP3D} ${MBOXTYPE} 2>&1 | ${SPLOGGER} pop3d 3 &" | |
start_precmd="touch ${pidfile}" | |
stop_cmd="tcpserver_stop" | |
tcpserver_stop() { | |
rc_pid=$(check_pidfile $pidfile $procname) | |
if [ -z "$rc_pid" ]; then | |
[ -n "$rc_fast" ] && return 0 | |
if [ -n "$pidfile" ]; then | |
echo "${name} not running? (check $pidfile)." | |
else | |
echo "${name} not running?" | |
fi | |
return 1 | |
fi | |
echo "Stopping ${name}." | |
tcpserver_wait_max_for_pid ${timeout} ${rc_pid} | |
kill -KILL ${rc_pid} 2> /dev/null && echo "Killed." | |
echo -n > ${pidfile} | |
} | |
tcpserver_wait_max_for_pid() { | |
_timeout=$1 | |
shift | |
_pid=$1 | |
_prefix= | |
while [ $_timeout -gt 0 ] ; do | |
echo -n ${_prefix:-"Waiting (max $_timeout secs) for PIDS: "}$_pid | |
_prefix=", " | |
sleep 2 | |
kill -0 $_pid 2> /dev/null || break | |
_timeout=$(($_timeout-2)) | |
done | |
if [ -n "$_prefix" ]; then | |
echo ". " | |
fi | |
} | |
run_rc_command "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# $Id$ | |
# | |
# PROVIDE: tcpserver-smtp | |
# REQUIRE: NETWORKING SERVERS | |
# BEFORE: DAEMON | |
# KEYWORD: shutdown | |
export PATH=/usr/local/bin:/var/qmail/bin:$PATH | |
export QMAILQUEUE="/usr/local/bin/qmail-scanner-queue" | |
tcpserver_smtp_enable="${tcpserver_smtp_enable:-"NO"}" | |
tcpserver_smtp_pidfile="${tcpserver_smtp_pidfile:-"/var/run/tcpserver_smtp.pid"}" | |
TCPSERVER=tcpserver | |
TCPSERVER_OPTS="-RHv -c 40" | |
TCP_SMTP=/usr/local/vpopmail/etc/tcp.smtp.cdb | |
SMTPD_PORT=smtp | |
SMTPD=qmail-smtpd | |
SMTPD_UID=89 | |
SMTPD_GID=89 | |
SPLOGGER=splogger | |
. /etc/rc.subr | |
name="tcpserver_smtp" | |
rcvar=`set_rcvar` | |
pidfile=${tcpserver_smtp_pidfile} | |
timeout=10 | |
load_rc_config "${name}" | |
# Subvert the check_pid_file procname check | |
if [ -f $pidfile ]; then | |
read rc_pid junk < $pidfile | |
if [ ! -z "$rc_pid" ]; then | |
procname=`ps -o comm= $rc_pid` | |
fi | |
fi | |
command="/usr/sbin/daemon" | |
flags="-p ${pidfile} ${TCPSERVER} ${TCPSERVER_OPTS} -x ${TCP_SMTP} -u ${SMTPD_UID} -g ${SMTPD_GID} 0 ${SMTPD_PORT} ${SMTPD} 2>&1 | ${SPLOGGER} ${SMTPD_PORT} 4 &" | |
start_precmd="touch ${pidfile}" | |
stop_cmd="tcpserver_stop" | |
tcpserver_stop() { | |
rc_pid=$(check_pidfile $pidfile $procname) | |
if [ -z "$rc_pid" ]; then | |
[ -n "$rc_fast" ] && return 0 | |
if [ -n "$pidfile" ]; then | |
echo "${name} not running? (check $pidfile)." | |
else | |
echo "${name} not running?" | |
fi | |
return 1 | |
fi | |
echo "Stopping ${name}." | |
tcpserver_wait_max_for_pid ${timeout} ${rc_pid} | |
kill -KILL ${rc_pid} 2> /dev/null && echo "Killed." | |
echo -n > ${pidfile} | |
} | |
tcpserver_wait_max_for_pid() { | |
_timeout=$1 | |
shift | |
_pid=$1 | |
_prefix= | |
while [ $_timeout -gt 0 ] ; do | |
echo -n ${_prefix:-"Waiting (max $_timeout secs) for PIDS: "}$_pid | |
_prefix=", " | |
sleep 2 | |
kill -0 $_pid 2> /dev/null || break | |
_timeout=$(($_timeout-2)) | |
done | |
if [ -n "$_prefix" ]; then | |
echo ". " | |
fi | |
} | |
run_rc_command "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# $Id$ | |
# | |
# PROVIDE: tcpserver-submission | |
# REQUIRE: NETWORKING SERVERS | |
# BEFORE: DAEMON | |
# KEYWORD: shutdown | |
export PATH=/usr/local/bin:/var/qmail/bin:$PATH | |
export QMAILQUEUE="/usr/local/bin/qmail-scanner-queue" | |
tcpserver_submission_enable="${tcpserver_submission_enable:-"NO"}" | |
tcpserver_submission_pidfile="${tcpserver_submission_pidfile:-"/var/run/tcpserver_submission.pid"}" | |
TCPSERVER=tcpserver | |
TCPSERVER_OPTS="-RHv -c 40" | |
TCP_SMTP=/usr/local/vpopmail/etc/tcp.smtp.cdb | |
SMTPD_PORT=submission | |
SMTPD=qmail-smtpd | |
SMTPD_UID=89 | |
SMTPD_GID=89 | |
SPLOGGER=splogger | |
. /etc/rc.subr | |
name="tcpserver_submission" | |
rcvar=`set_rcvar` | |
pidfile=${tcpserver_submission_pidfile} | |
timeout=10 | |
load_rc_config "${name}" | |
# Subvert the check_pid_file procname check | |
if [ -f $pidfile ]; then | |
read rc_pid junk < $pidfile | |
if [ ! -z "$rc_pid" ]; then | |
procname=`ps -o comm= $rc_pid` | |
fi | |
fi | |
command="/usr/sbin/daemon" | |
flags="-p ${pidfile} ${TCPSERVER} ${TCPSERVER_OPTS} -x ${TCP_SMTP} -u ${SMTPD_UID} -g ${SMTPD_GID} 0 ${SMTPD_PORT} ${SMTPD} 2>&1 | ${SPLOGGER} ${SMTPD_PORT} 4 &" | |
start_precmd="touch ${pidfile}" | |
stop_cmd="tcpserver_stop" | |
tcpserver_stop() { | |
rc_pid=$(check_pidfile $pidfile $procname) | |
if [ -z "$rc_pid" ]; then | |
[ -n "$rc_fast" ] && return 0 | |
if [ -n "$pidfile" ]; then | |
echo "${name} not running? (check $pidfile)." | |
else | |
echo "${name} not running?" | |
fi | |
return 1 | |
fi | |
echo "Stopping ${name}." | |
tcpserver_wait_max_for_pid ${timeout} ${rc_pid} | |
kill -KILL ${rc_pid} 2> /dev/null && echo "Killed." | |
echo -n > ${pidfile} | |
} | |
tcpserver_wait_max_for_pid() { | |
_timeout=$1 | |
shift | |
_pid=$1 | |
_prefix= | |
while [ $_timeout -gt 0 ] ; do | |
echo -n ${_prefix:-"Waiting (max $_timeout secs) for PIDS: "}$_pid | |
_prefix=", " | |
sleep 2 | |
kill -0 $_pid 2> /dev/null || break | |
_timeout=$(($_timeout-2)) | |
done | |
if [ -n "$_prefix" ]; then | |
echo ". " | |
fi | |
} | |
run_rc_command "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment