1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-25 09:34:11 +00:00
freebsd-ports/net/ifstated/files/ifstated.in
Doug Barton 83eb2c3700 In the rc.d scripts, change assignments to rcvar to use the
literal name_enable wherever possible, and ${name}_enable
when it's not, to prepare for the demise of set_rcvar().

In cases where I had to hand-edit unusual instances also
modify formatting slightly to be more uniform (and in
some cases, correct). This includes adding some $FreeBSD$
tags, and most importantly moving rcvar= to right after
name= so it's clear that one is derived from the other.
2012-01-14 08:57:23 +00:00

103 lines
2.8 KiB
Bash

#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: ifstated
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable ifstated:
#
# ifstated_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable ifstated.
# ifstated_flags (str): Set to "" by default.
# Extra flags passed to start command.
#
# With no profiles defined, the default configuration file will be
# used (%%PREFIX%%/etc/ifstated.conf).
#
# For profiles (separate ifstated intances):
#
# ifstated_profiles (str): Set to "" by default.
# Define profile names (e.g. "dns
# http ssh").
# ifstated_<name>_configfile (str):
# [Required] Path to the configuration
# file for profile <name>.
# ifstated_<name>_enable (bool): Set to ${ifstated_enable} by default.
# Set it to "YES" or "NO" to
# independently enable or disable
# profile <name>.
# ifstated_<name>_flags (str): Set to ${ifstated_flags} by default.
# Extra flags passed to start command
# for profile <name>.
#
. /etc/rc.subr
name="ifstated"
rcvar=ifstated_enable
command="%%PREFIX%%/sbin/ifstated"
pidfile="/var/run/${name}.pid"
command_args="-p \"${pidfile}\""
load_rc_config $name
: ${ifstated_enable:="NO"}
if [ -n "$2" ]
then
profile="$2"
if [ "x${ifstated_profiles}" != "x" ]
then
pidfile="/var/run/${name}.${profile}.pid"
eval ifstated_configfile="\${ifstated_${profile}_configfile:-}"
if [ "x${ifstated_configfile}" = "x" ]
then
echo "You must define a configuration file (ifstated_${profile}_configile)." >&2
exit 1
fi
required_files="${ifstated_configfile}"
command_args="-f \"${ifstated_configfile}\" -p \"${pidfile}\""
eval ifstated_enable="\${ifstated_${profile}_enable:=${ifstated_enable}}"
eval ifstated_flags="\${ifstated_${profile}_flags:=${ifstated_flags}}"
else
echo "$0: extra argument ignored." >&2
fi
else
if [ "x${ifstated_profiles}" != "x" -a "x$1" != "x" ]
then
for profile in ${ifstated_profiles}
do
eval ifstated_enable_tmp="\${ifstated_${profile}_enable:=${ifstated_enable}}"
case "x${ifstated_enable_tmp}"
in
x|x[Nn][Oo])
continue
;;
x[Yy][Ee][Ss])
;;
*)
echo "Bad value \"${ifstated_enable_tmp}\" for ifstated_${profile}_enable. Profile ${profile} skipped." >&2
continue
;;
esac
echo "===> ifstated profile: ${profile}"
'%%PREFIX%%/etc/rc.d/ifstated' "$1" "${profile}"
done
exit 0
fi
fi
run_rc_command "$1"