Changeset View
Changeset View
Standalone View
Standalone View
net-p2p/mt-recorder/files/mt-recorder.in
- This file was added.
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
svn:mime-type | null | text/plain \ No newline at end of property |
#!/bin/sh | |||||
# $FreeBSD$ | |||||
# PROVIDE: mt-recorder | |||||
# REQUIRE: LOGIN cleanvar | |||||
# KEYWORD: shutdown | |||||
# Add the following lines to /etc/rc.conf to enable: | |||||
# mt_recorder_enable (bool) Set to "NO" by default. | |||||
# Set it to "YES" to enable mt_recorder | |||||
# mt_recorder_options (str) Set to "" by default | |||||
# mt_recorder_user (str) Set to "%%MT_RECORDER_USER%%" by default. | |||||
# mt_recorder_group (str) Set to "%%MT_RECORDER_GROUP%%" by default. | |||||
# mt_recorder_config_file (str) Set to "%%PREFIX%%/etc/mt-recorder.conf" by default. | |||||
# mt_recorder_data_dir (str) Set to "%%MT_RECORDER_DATA%%" by default. | |||||
# mt_recorder_run_dir (str) Set to "%%MT_RECORDER_RUN%%" by default. | |||||
# mt_recorder_syslog_enable (bool) Set to "NO" by default. | |||||
# | |||||
# mt_recorder_limits_enable (bool) Set to "NO" by default. | |||||
# Set it to "YES" to enable mt_recorder_limits | |||||
# mt_recorder_limits_args (str) Set to "-e -U ${mt_recorder_user}" by default | |||||
. /etc/rc.subr | |||||
name="mt_recorder" | |||||
rcvar=mt_recorder_enable | |||||
load_rc_config ${name} | |||||
: ${mt_recorder_enable:="NO"} | |||||
: ${mt_recorder_options:=""} | |||||
: ${mt_recorder_user:="%%MT_RECORDER_USER%%"} | |||||
: ${mt_recorder_group:="%%MT_RECORDER_GROUP%%"} | |||||
: ${mt_recorder_config_file:="%%PREFIX%%/etc/mt-recorder.conf"} | |||||
: ${mt_recorder_data_dir:="%%MT_RECORDER_DATA%%"} | |||||
: ${mt_recorder_run_dir:="%%MT_RECORDER_RUN%%"} | |||||
: ${mt_recorder_syslog_enable:="NO"} | |||||
: ${mt_recorder_limits_enable:="NO"} | |||||
: ${mt_recorder_limits_args:="-e -U ${mt_recorder_user}"} | |||||
start_precmd="${name}_precmd" | |||||
stop_postcmd="${name}_poststop" | |||||
pidfile="${mt_recorder_run_dir}/mt-recorder.pid" | |||||
required_files="${mt_recorder_config_file}" | |||||
_mt_recorder_program="%%PREFIX%%/sbin/mt-recorder" | |||||
_mt_recorder_arguments="--config=${mt_recorder_config_file} ${mt_recorder_options}" | |||||
command="/usr/sbin/daemon" | |||||
command_args="-f" | |||||
checkyesno mt_recorder_syslog_enable && command_args="-S -T mt-recorder" | |||||
command_args="${command_args} -P ${pidfile} -R 60 -- ${_mt_recorder_program} ${_mt_recorder_arguments}" | |||||
#procname=${_mt_recorder_program} # do not override procname as program runs under daemon | |||||
mt_recorder_checkdirs() | |||||
{ | |||||
local dir | |||||
for dir in "${mt_recorder_data_dir}" "${mt_recorder_data_dir}/log" "${mt_recorder_run_dir}" | |||||
do | |||||
install -d -o "${mt_recorder_user}" -g "${mt_recorder_group}" -m 770 "${dir}" | |||||
done | |||||
cd "${mt_recorder_data_dir}" | |||||
checkyesno mt_recorder_syslog_enable && newsyslog -C | |||||
} | |||||
mt_recorder_precmd() | |||||
{ | |||||
pid=$(check_pidfile "${pidfile}" "${command}") | |||||
if [ -n "${pid}" ] | |||||
then | |||||
echo "another mt_recorder is running on pid: ${pid}" | |||||
return 1 | |||||
else | |||||
rm -f "${pidfile}" | |||||
fi | |||||
mt_recorder_checkdirs | |||||
if checkyesno mt_recorder_limits_enable | |||||
then | |||||
eval $(/usr/bin/limits ${mt_recorder_limits_args}) 2>/dev/null | |||||
else | |||||
return 0 | |||||
fi | |||||
} | |||||
mt_recorder_poststop() | |||||
{ | |||||
rm -f "${pidfile}" | |||||
rm -f "${lock_file}" | |||||
} | |||||
run_rc_command "$1" |