8ad774dbf7
script was needed ... the unnecessary script change was never committed, but the comment that described it was... No functional change.
80 lines
1.5 KiB
Bash
Executable File
80 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# $NetBSD: rtadvd,v 1.10 2016/11/19 01:14:58 kre Exp $
|
|
#
|
|
|
|
# PROVIDE: rtadvd
|
|
# REQUIRE: DAEMON
|
|
# BEFORE: LOGIN
|
|
|
|
$_rc_subr_loaded . /etc/rc.subr
|
|
|
|
name=rtadvd
|
|
rcvar=$name
|
|
command="/usr/sbin/$name"
|
|
pidfile="/var/run/$name.pid"
|
|
extra_commands=reload
|
|
start_precmd=rtadvd_prestart
|
|
reload_precmd=rtadvd_prereload
|
|
|
|
rtadvd_prereload()
|
|
{
|
|
local chdir="$(getent passwd _rtadvd | cut -d: -f6)"
|
|
local conf=/etc/rtadvd.conf myflags o confdir
|
|
local cflag=false
|
|
|
|
[ -z "${chdir}" ] || [ "/${chdir}" = // ] && return 0
|
|
|
|
if [ -n "${flags}" ]; then
|
|
myflags=${flags}
|
|
else
|
|
eval myflags=\$${name}_flags
|
|
fi
|
|
set -- ${myflags}
|
|
while getopts c:dDfM:Rs o; do
|
|
# ignore other args, they are processed by rtadvd itself
|
|
case "${o}" in
|
|
c) conf="${OPTARG}"
|
|
case "${conf}" in
|
|
/*) ;;
|
|
*) echo "${name}: config file (${conf}) must be" \
|
|
"full pathname"
|
|
return 1
|
|
;;
|
|
esac
|
|
cflag=true;;
|
|
esac
|
|
done
|
|
|
|
${cflag} || test -f "${conf}" && {
|
|
confdir=$(dirname "${conf}")
|
|
echo "${name}: copying ${conf} to ${chdir}${conf}"
|
|
mkdir -p "${chdir}${confdir}"
|
|
cp "${conf}" "${chdir}${conf}" || return 1
|
|
}
|
|
|
|
# Make sure /var/run exists in the chroot
|
|
mkdir -p "${chdir}/var/run"
|
|
|
|
# Provide a link to the chrooted dump file
|
|
ln -snf "${chdir}/var/run/${name}.dump" /var/run
|
|
|
|
# Note: actual chroot is done by rtadvd itself
|
|
|
|
return 0
|
|
}
|
|
|
|
rtadvd_prestart()
|
|
{
|
|
if [ "$ip6mode" != router ]; then
|
|
warn \
|
|
"${name} cannot be used on IPv6 host, only on an IPv6 router."
|
|
return 1
|
|
fi
|
|
|
|
rtadvd_prereload
|
|
}
|
|
|
|
load_rc_config $name
|
|
run_rc_command "$1"
|