]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.d/named
This commit was generated by cvs2svn to compensate for changes in r107937,
[FreeBSD/FreeBSD.git] / etc / rc.d / named
1 #!/bin/sh
2 #
3 # $NetBSD: named,v 1.10 2002/03/22 04:33:59 thorpej Exp $
4 # $FreeBSD$
5 #
6
7 # PROVIDE: named
8 # REQUIRE: SERVERS
9 # BEFORE:  DAEMON
10 # KEYWORD: FreeBSD NetBSD
11
12 . /etc/rc.subr
13
14 name="named"
15 rcvar=`set_rcvar`
16 command="/usr/sbin/${name}"
17 pidfile="/var/run/${name}.pid"
18 start_precmd="named_precmd"
19 required_dirs="$named_chrootdir"        # if it is set, it must exist
20 extra_commands="reload"
21
22 case ${OSTYPE} in
23 FreeBSD)
24         nuser=bind
25         ngroup=bind
26         ;;
27 NetBSD)
28         nuser=named
29         ngroup=named
30         ;;
31 esac
32
33 # If running in a chroot cage, ensure that the appropriate files
34 # exist inside the cage, as well as helper symlinks into the cage
35 # from outside.
36 #
37 # As this is called after the is_running and required_dir checks
38 # are made in run_rc_command(), we can safely assume ${named_chrootdir}
39 # exists and named isn't running at this point (unless forcestart
40 # is used).
41 #
42 chroot_autoupdate()
43 {
44         # If the named-xfer in the system is newer than the one in the
45         # chroot directory or if it (in the chrootdir) doesn't exist
46         # copy it over
47         #
48         if [ ! -x "${named_chrootdir}/usr/libexec/named-xfer" -o \
49             "${named_chrootdir}/usr/libexec/named-xfer" -ot \
50             /usr/libexec/named-xfer ]; then
51                 rm -f "${named_chrootdir}/usr/libexec/named-xfer"
52                 cp -p /usr/libexec/named-xfer "${named_chrootdir}/usr/libexec"
53         fi
54
55         # Copy /dev/null over, if neccessary. Preserve everything (perms,
56         # ownership, mod times).
57         #
58         if [ ! -c "${named_chrootdir}/dev/null" ]; then
59         rm -f "${named_chrootdir}/dev/null"
60                 ( cd /dev ; /bin/pax -rw -pe null "${named_chrootdir}/dev" )
61         fi
62
63         # Copy local timezone information if it's not up-to-date.
64         #
65         if [ -f /etc/localtime ]; then
66                 cmp -s /etc/localtime "${named_chrootdir}/etc/localtime" || \
67                 cp -p /etc/localtime "${named_chrootdir}/etc/localtime"
68         fi
69 }
70
71 # Make symlinks to the correct pid and ndc socket files
72 #
73 make_symlinks()
74 {
75         ln -fs "${named_chrootdir}/var/run/named.pid" /var/run/named.pid
76         ln -fs "${named_chrootdir}/var/run/ndc" /var/run/ndc
77
78 }
79
80 named_precmd()
81 {
82         case ${OSTYPE} in
83         FreeBSD)
84                 ! checkyesno named_rcng && return 0
85                 # Is the user using a sandbox?
86                 if [ -z "$named_chrootdir" ]; then
87                         rc_flags="-u $nuser -g $ngroup $rc_flags"
88                         return 0
89                 fi
90
91                 # Do the following checks only if the user wants them done
92                 checkyesno named_chroot_autoupdate && chroot_autoupdate
93                 ;;
94         NetBSD)
95                 chroot_autoupdate
96                 ;;
97         esac
98
99         case ${OSTYPE} in
100         FreeBSD)
101                 # Make the symlinks only if the user wants them done.
102                 checkyesno named_symlink_enable && make_symlinks
103                 ;;
104         NetBSD)
105                 make_symlinks
106                 ;;
107         esac
108
109         #       Change run_rc_commands()'s internal copy of $named_flags
110         #
111         case ${OSTYPE} in
112         FreeBSD)
113                 ! checkyesno named_rcng && return
114                 ;;
115         esac
116         rc_flags="-u $nuser -g $ngroup -t ${named_chrootdir} $rc_flags"
117 }
118
119 load_rc_config $name
120 # The following variable requires that rc.conf be loaded first
121 #
122 required_dirs="$named_chrootdir"        # if it is set, it must exist
123
124 run_rc_command "$1"