1 1.1 lukem #!/bin/sh 2 1.1 lukem # 3 1.8.6.1 snj # $NetBSD: rtadvd,v 1.8.6.1 2016/11/21 07:29:25 snj 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.8 roy name=rtadvd 13 1.4 lukem rcvar=$name 14 1.8 roy command="/usr/sbin/$name" 15 1.7 roy pidfile="/var/run/$name.pid" 16 1.8 roy extra_commands=reload 17 1.8 roy start_precmd=rtadvd_prestart 18 1.8 roy reload_precmd=rtadvd_prereload 19 1.1 lukem 20 1.8 roy rtadvd_prereload() 21 1.1 lukem { 22 1.8 roy local chdir="$(getent passwd _rtadvd | cut -d: -f6)" 23 1.8 roy local conf=/etc/rtadvd.conf myflags o confdir 24 1.8.6.1 snj local cflag=false 25 1.8 roy 26 1.8.6.1 snj [ -z "${chdir}" ] || [ "/${chdir}" = // ] && return 0 27 1.8 roy 28 1.8.6.1 snj if [ -n "${flags}" ]; then 29 1.8.6.1 snj myflags=${flags} 30 1.8 roy else 31 1.8 roy eval myflags=\$${name}_flags 32 1.8 roy fi 33 1.8 roy set -- ${myflags} 34 1.8 roy while getopts c:dDfM:Rs o; do 35 1.8.6.1 snj # ignore other args, they are processed by rtadvd itself 36 1.8.6.1 snj case "${o}" in 37 1.8.6.1 snj c) conf="${OPTARG}" 38 1.8.6.1 snj case "${conf}" in 39 1.8.6.1 snj /*) ;; 40 1.8.6.1 snj *) echo "${name}: config file (${conf}) must be" \ 41 1.8.6.1 snj "full pathname" 42 1.8.6.1 snj return 1 43 1.8.6.1 snj ;; 44 1.8.6.1 snj esac 45 1.8.6.1 snj cflag=true;; 46 1.8 roy esac 47 1.8 roy done 48 1.8 roy 49 1.8.6.1 snj ${cflag} || test -f "${conf}" && { 50 1.8.6.1 snj confdir=$(dirname "${conf}") 51 1.8.6.1 snj echo "${name}: copying ${conf} to ${chdir}${conf}" 52 1.8.6.1 snj mkdir -p "${chdir}${confdir}" 53 1.8.6.1 snj cp "${conf}" "${chdir}${conf}" || return 1 54 1.8.6.1 snj } 55 1.8.6.1 snj 56 1.8.6.1 snj # Make sure /var/run exists in the chroot 57 1.8.6.1 snj mkdir -p "${chdir}/var/run" 58 1.8.6.1 snj 59 1.8.6.1 snj # Provide links to the chrooted dump & pid files 60 1.8.6.1 snj ln -snf "${chdir}/var/run/${name}.dump" /var/run 61 1.8.6.1 snj 62 1.8.6.1 snj # Note: actual chroot is done by rtadvd itself 63 1.8.6.1 snj 64 1.8.6.1 snj return 0 65 1.8 roy } 66 1.8 roy 67 1.8 roy rtadvd_prestart() 68 1.8 roy { 69 1.8 roy if [ "$ip6mode" != router ]; then 70 1.1 lukem warn \ 71 1.1 lukem "${name} cannot be used on IPv6 host, only on an IPv6 router." 72 1.1 lukem return 1 73 1.1 lukem fi 74 1.8 roy 75 1.8 roy rtadvd_prereload 76 1.1 lukem } 77 1.1 lukem 78 1.3 lukem load_rc_config $name 79 1.1 lukem run_rc_command "$1" 80