ports/security/tinc/files/tincd.in
Dirk Meyer 844ac0f7df - fix restart when shutdown is slow
PR:		228357
Reported by:	CUI Hao
2019-04-29 08:34:08 +00:00

90 lines
1.7 KiB
Bash

#!/bin/sh
# $FreeBSD$
#
# PROVIDE: tincd
# REQUIRE: ipfilter FILESYSTEMS sysctl netif
# BEFORE: SERVERS routing
#
# Define these tincd_* variables in one of these files:
# /etc/rc.conf
# /etc/rc.conf.local
# /etc/rc.conf.d/tincd
#
# tincd_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable tincd.
# tincd_cfg (str): Set to "" by default.
# Set it to NETNAMEs to use (ex.: "vpn1 vpn2").
# tincd_flags (str): Set to "" by default.
# Set it to flags to use (ex.: "-d 1 --logfile").
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
tincd_enable=${tincd_enable:-"NO"}
. /etc/rc.subr
name="tincd"
rcvar="tincd_enable"
command="%%PREFIX%%/sbin/tincd"
start_cmd="tincd_start"
stop_cmd="tincd_stop"
reload_cmd="tincd_reload"
extra_commands="reload"
procname=${command:-tincd}
ldconfig_command="/sbin/ldconfig"
load_rc_config $name
tincd_start()
{
${ldconfig_command} -elf -m %%LOCALBASE%%/lib
if test -z "${tincd_cfg}"
then
echo "Starting tincd"
$command
else
for cfg in ${tincd_cfg}
do
echo "Starting tincd for: ${cfg}"
$command -n $cfg $tincd_flags
done
fi
# code deliberately borrowed from /etc/rc.d/netif
if [ -f /etc/rc.d/ipfilter ] ; then
# Resync ipfilter
/etc/rc.d/ipfilter quietresync
fi
}
tincd_stop()
{
if test -z "${tincd_cfg}"
then
echo "Stopping tincd"
$command -k
else
for cfg in $tincd_cfg
do
echo "Stopping tincd for: ${cfg}"
$command -n $cfg -k
done
fi
wait_for_pids $rc_pid
}
tincd_reload()
{
if test -z "${tincd_cfg}"
then
echo "Sending HUP to tincd"
$command --kill=HUP
else
for cfg in $tincd_cfg
do
echo "Sending HUP to tincd for: ${cfg}"
$command -n $cfg --kill=HUP
done
fi
}
run_rc_command "$1"
# eof