mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-01 01:17:02 +00:00
d241b07ec3
PR: ports/105601 Submitted by: Nicolas Szalay <nico@rottenbytes.info> Approved by: maintainer timeout (3 weeks)
104 lines
2.4 KiB
Bash
104 lines
2.4 KiB
Bash
#!/bin/sh
|
|
#
|
|
# Init script : ucarp for FreeBSD
|
|
# By Nico <nico@rottenbytes.info>
|
|
#
|
|
# PROVIDE: ucarp
|
|
# REQUIRE: DAEMON
|
|
# KEYWORD: shutdown
|
|
#
|
|
# Add the following lines to /etc/rc.conf to enable & configure ucarp:
|
|
#
|
|
# ucarp_enable (bool): Set it to "YES" to enable ucarp
|
|
# Default is "NO".
|
|
# ucarp_if: Set interface to use for ucarp checks
|
|
# Default is "eth0"
|
|
# ucarp_src: Set source (real) IP address of that host
|
|
# ucarp_vhid: Set virtual IP identifier (1-255)
|
|
# Default is "1"
|
|
# ucarp_pass: Set password
|
|
# Default is "dumbp4ss"
|
|
# ucarp_preempt (bool): Set it to "YES" to become a master as soon as possible
|
|
# Default is "NO"
|
|
# ucarp_addr: Set virtual shared IP address
|
|
# ucarp_advbase: Set advertisement frequency (seconds)
|
|
# ucarp_advskew: Set advertisement skew (0-255)
|
|
# ucarp_upscript: Run <file> to become a master
|
|
# ucarp_downscript: Run <file> to become a backup
|
|
# ucarp_deadratio: Set ratio to consider a host as dead
|
|
# ucarp_shutdown (bool): Set it to "YES" to call shutdown script at exit
|
|
# Default is "YES"
|
|
# ucarp_facility: Set syslog facility
|
|
# Default is "daemon"
|
|
|
|
. %%RC_SUBR%%
|
|
|
|
name="ucarp"
|
|
rcvar=`set_rcvar`
|
|
|
|
load_rc_config $name
|
|
|
|
: ${ucarp_enable="NO"}
|
|
: ${ucarp_if="eth0"}
|
|
: ${ucarp_vhid="1"}
|
|
: ${ucarp_pass="dumbp4ss"}
|
|
: ${ucarp_preempt="NO"}
|
|
: ${ucarp_shutdown="YES"}
|
|
: ${ucarp_facility="daemon"}
|
|
|
|
command=%%PREFIX%%/sbin/ucarp
|
|
command_args="-i ${ucarp_if} -v ${ucarp_vhid} -p ${ucarp_pass} -f ${ucarp_facility} -B "
|
|
start_precmd="build_command_args"
|
|
|
|
build_command_args()
|
|
{
|
|
if [ ${ucarp_preempt} = "YES" ]
|
|
then
|
|
command_args=${command_args}"-P "
|
|
fi
|
|
|
|
if [ ${ucarp_shutdown} = "YES" ]
|
|
then
|
|
command_args=${command_args}"-z "
|
|
fi
|
|
|
|
# Mandatory arguments
|
|
if [ -z ${ucarp_src} ]
|
|
then
|
|
echo "source address is not set ! please set it"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z ${ucarp_addr} ]
|
|
then
|
|
echo "virtual address is not set ! please set it"
|
|
exit 1
|
|
fi
|
|
|
|
command_args=${command_args}"-s ${ucarp_src} -a ${ucarp_addr} "
|
|
|
|
# Optional args
|
|
if ! [ -z ${ucarp_upscript} ]
|
|
then
|
|
command_args=${command_args}"-u ${ucarp_upscript} "
|
|
fi
|
|
if ! [ -z ${ucarp_downscript} ]
|
|
then
|
|
command_args=${command_args}"-d ${ucarp_downscript} "
|
|
fi
|
|
if ! [ -z ${ucarp_deadratio} ]
|
|
then
|
|
command_args=${command_args}"-r ${ucarp_deadratio} "
|
|
fi
|
|
if ! [ -z ${ucarp_advbase} ]
|
|
then
|
|
command_args=${command_args}"-b ${ucarp_advbase} "
|
|
fi
|
|
if ! [ -z ${ucarp_advskew} ]
|
|
then
|
|
command_args=${command_args}"-k ${ucarp_advskew} "
|
|
fi
|
|
}
|
|
|
|
run_rc_command "$1"
|