Home | History | Annotate | Line # | Download | only in rc.d
rtadvd revision 1.6.56.2
      1       1.1    lukem #!/bin/sh
      2       1.1    lukem #
      3  1.6.56.2      tls # $NetBSD: rtadvd,v 1.6.56.2 2014/08/19 23:45:51 tls Exp $
      4       1.1    lukem #
      5       1.1    lukem 
      6       1.1    lukem # PROVIDE: rtadvd
      7       1.2    lukem # REQUIRE: DAEMON
      8       1.5  thorpej # BEFORE:  LOGIN
      9       1.1    lukem 
     10       1.6  mycroft $_rc_subr_loaded . /etc/rc.subr
     11       1.1    lukem 
     12  1.6.56.2      tls name=rtadvd
     13       1.4    lukem rcvar=$name
     14  1.6.56.2      tls command="/usr/sbin/$name"
     15  1.6.56.1      tls pidfile="/var/run/$name.pid"
     16  1.6.56.2      tls extra_commands=reload
     17  1.6.56.2      tls start_precmd=rtadvd_prestart
     18  1.6.56.2      tls reload_precmd=rtadvd_prereload
     19       1.1    lukem 
     20  1.6.56.2      tls rtadvd_prereload()
     21       1.1    lukem {
     22  1.6.56.2      tls 	local chdir="$(getent passwd _rtadvd | cut -d: -f6)"
     23  1.6.56.2      tls 	local conf=/etc/rtadvd.conf myflags o confdir
     24  1.6.56.2      tls 	
     25  1.6.56.2      tls 	[ -z "$chdir" -o "$chdir" = / ] && return 0
     26  1.6.56.2      tls 
     27  1.6.56.2      tls 	if [ -n "$flags" ]; then
     28  1.6.56.2      tls 		myflags=$flags
     29  1.6.56.2      tls 	else
     30  1.6.56.2      tls 		eval myflags=\$${name}_flags
     31  1.6.56.2      tls 	fi
     32  1.6.56.2      tls 	set -- ${myflags}
     33  1.6.56.2      tls 	while getopts c:dDfM:Rs o; do
     34  1.6.56.2      tls 		case "$1" in
     35  1.6.56.2      tls 		-c)	conf="$OPTARG";;
     36  1.6.56.2      tls 		esac
     37  1.6.56.2      tls 		shift
     38  1.6.56.2      tls 	done
     39  1.6.56.2      tls 	confdir=$(dirname "$conf")
     40  1.6.56.2      tls 	
     41  1.6.56.2      tls 	echo "$name: copying $conf to $chdir$conf"
     42  1.6.56.2      tls 	cp "$conf" "$chdir$conf"
     43  1.6.56.2      tls 
     44  1.6.56.2      tls 	# Provide a link to the chrooted dump file
     45  1.6.56.2      tls 	ln -snf "$chdir/var/run/$name.dump" /var/run
     46  1.6.56.2      tls }
     47  1.6.56.2      tls 
     48  1.6.56.2      tls rtadvd_prestart()
     49  1.6.56.2      tls {
     50  1.6.56.2      tls 	if [ "$ip6mode" != router ]; then
     51       1.1    lukem 		warn \
     52       1.1    lukem 	"${name} cannot be used on IPv6 host, only on an IPv6 router."
     53       1.1    lukem 		return 1
     54       1.1    lukem 	fi
     55  1.6.56.2      tls 
     56  1.6.56.2      tls 	rtadvd_prereload
     57       1.1    lukem }
     58       1.1    lukem 
     59       1.3    lukem load_rc_config $name
     60       1.1    lukem run_rc_command "$1"
     61