#!/bin/sh # # $FreeBSD: head/ftp/pure-ftpd/files/pure-ftpd.in 380792 2015-03-08 19:38:18Z sunpoet $ # # PROVIDE: pureftpd # REQUIRE: NETWORKING SERVERS # BEFORE: DAEMON # KEYWORD: shutdown # Add the following lines to /etc/rc.conf to enable pure-ftpd: # # pureftpd_enable="yes" # # Add the following lines to /etc/rc.conf to enable pure-authd daemon: # # pureftpd_authd_enable="yes" # pureftpd_authdscript="/full/path/to/auth_script" # pureftpd_authsocket="/var/run/ftpd.sock" # # Add the following lines to /etc/rc.conf to enable uploadscript daemon: # # pureftpd_upload_enable="yes" # pureftpd_uploadscript="/full/path/to/upload_script" . /etc/rc.subr name=pureftpd rcvar=pureftpd_enable load_rc_config $name command=%%PREFIX%%/sbin/pure-config.pl pidfile=${pidfile:-"/var/run/pure-ftpd.pid"} procname=pure-ftpd pureftpd_config=${pureftpd_config:-"%%PREFIX%%/etc/pure-ftpd.conf"} pureftpd_enable=${pureftpd_enable:-"no"} required_files=${pureftpd_config} # authd command_authd=%%PREFIX%%/sbin/pure-authd pidfile_authd=${pidfile_authd:-"/var/run/pure-authd.pid"} pureftpd_authd_enable=${pureftpd_authd_enable:-"no"} pureftpd_authdscript=${pureftpd_authdscript:-"%%PREFIX%%/sbin/pure-alwaysfail"} pureftpd_authsocket=${pureftpd_authsocket:-"/var/run/ftpd.sock"} # uploadscript command_upload=%%PREFIX%%/sbin/pure-uploadscript pidfile_uploadscript=${pidfile_uploadscript:-"/var/run/pure-uploadscript.pid"} pureftpd_upload_enable=${pureftpd_upload_enable:-"no"} pureftpd_uploadscript=${pureftpd_uploadscript:-"/usr/bin/touch"} # command_args command_args="${pureftpd_config} -g${pidfile}" command_authd_args="-B -p ${pidfile_authd} -r ${pureftpd_authdscript} -s ${pureftpd_authsocket}" command_upload_args="-B -p ${pidfile_uploadscript} -r ${pureftpd_uploadscript}" start_precmd=start_precmd start_postcmd=start_postcmd stop_postcmd=stop_postcmd start_precmd() { if checkyesno pureftpd_authd_enable && test -x ${pureftpd_authdscript}; then echo "Starting ${command_authd}." ${command_authd} ${command_authd_args} fi } start_postcmd() { if checkyesno pureftpd_upload_enable; then echo "Starting ${command_upload}." ${command_upload} ${command_upload_args} fi } stop_postcmd() { if checkyesno pureftpd_authd_enable; then pid=$(check_pidfile ${pidfile_authd} ${command_authd}) if [ -z ${pid} ]; then echo "pure-authd not running? (check ${pidfile_authd})." return 1 fi echo "Stopping ${command_authd}." kill -${sig_stop:-TERM} ${pid} [ $? -ne 0 ] && [ -z "$rc_force" ] && return 1 wait_for_pids ${pid} fi if checkyesno pureftpd_upload_enable; then pid=$(check_pidfile ${pidfile_uploadscript} ${command_upload}) if [ -z ${pid} ]; then echo "Upload script not running? (check ${pidfile_uploadscript})." return 1 fi echo "Stopping ${command_upload}." kill -${sig_stop:-TERM} ${pid} [ $? -ne 0 ] && [ -z "$rc_force" ] && return 1 wait_for_pids ${pid} fi } run_rc_command "$1"