3 # $NetBSD: named,v 1.21 2009/04/25 15:46:19 christos Exp $
7 # REQUIRE: NETWORKING mountcritremote syslogd
11 $_rc_subr_loaded .
/etc
/rc.subr
15 command="/usr/sbin/${name}"
16 pidfile
="/var/run/${name}/${name}.pid"
17 start_precmd
="named_precmd"
18 extra_commands
="reload"
19 required_dirs
="$named_chrootdir" # if it is set, it must exist
25 echo "Migrating $src to $dst"
29 for f
in $
(find .
-type f
)
42 if ! cmp $f $dst/$f; then
50 echo "Cannot complete migration because files are different"
51 echo "Run 'diff -r $src $dst' resolve the differences"
61 if [ -z "$named_chrootdir" ]; then
65 # If running in a chroot cage, ensure that the appropriate files
66 # exist inside the cage, as well as helper symlinks into the cage
69 # As this is called after the is_running and required_dir checks
70 # are made in run_rc_command(), we can safely assume ${named_chrootdir}
71 # exists and named isn't running at this point (unless forcestart
74 case "$($command -v)" in
75 BIND
*) # 9 no group, named-xfer, or ndc
78 rc_flags
="-g named $rc_flags"
79 if [ ! -x "${named_chrootdir}/usr/libexec/named-xfer" -o \
80 "${named_chrootdir}/usr/libexec/named-xfer" -ot \
81 /usr
/libexec
/named-xfer
]; then
82 rm -f "${named_chrootdir}/usr/libexec/named-xfer"
83 cp -p /usr
/libexec
/named-xfer \
84 "${named_chrootdir}/usr/libexec"
86 ln -fs "${named_chrootdir}/var/run/ndc" /var
/run
/ndc
92 if [ ! -c "${named_chrootdir}/dev/$i" ]; then
93 rm -f "${named_chrootdir}/dev/$i"
95 /bin
/pax
-rw -pe "$i" "${named_chrootdir}/dev")
99 if [ ! -h /etc
/namedb
]; then
100 named_migrate
/etc
/namedb
${named_chrootdir}
102 if [ \
( -r /etc
/named.conf \
) -a \
( ! -h /etc
/named.conf \
) -a \
103 \
( ! -r ${named_chrootdir}/etc
/named.conf \
) ]
105 mv /etc
/named.conf
${named_chrootdir}/etc
/named.conf
106 ln -s ${named_chrootdir}/etc
/named.conf
/etc
/named.conf
108 if [ \
( ! -r ${named_chrootdir}/etc
/named.conf \
) -a \
109 \
( -r ${named_chrootdir}/etc
/namedb
/named.conf \
) ]; then
110 ln -s namedb
/named.conf
${named_chrootdir}/etc
113 if [ -f /etc
/localtime
]; then
114 cmp -s /etc
/localtime
"${named_chrootdir}/etc/localtime" || \
115 cp -p /etc
/localtime
"${named_chrootdir}/etc/localtime"
118 local piddir
="$(dirname "${pidfile}")"
119 mkdir
-p "${named_chrootdir}${piddir}" "${piddir}"
120 chmod 755 "${named_chrootdir}${piddir}" "${piddir}"
121 chown named
:named
"${named_chrootdir}${piddir}" "${piddir}"
122 ln -fs "${named_chrootdir}${pidfile}" "${pidfile}"
124 # Change run_rc_commands()'s internal copy of $named_flags
126 rc_flags
="-u named -t ${named_chrootdir} $rc_flags"