Initial import from FreeBSD RELENG_4:
[dragonfly.git] / etc / rc.network
1 #!/bin/sh -
2 #
3 # Copyright (c) 1993  The FreeBSD Project
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 #    notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 #    notice, this list of conditions and the following disclaimer in the
13 #    documentation and/or other materials provided with the distribution.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 # SUCH DAMAGE.
26 #
27 # $FreeBSD: src/etc/rc.network,v 1.74.2.43 2003/02/08 21:10:25 gshapiro Exp $
28 #       From: @(#)netstart      5.9 (Berkeley) 3/30/91
29 #
30
31 # Note that almost all of the user-configurable behavior is no longer in
32 # this file, but rather in /etc/defaults/rc.conf.  Please check that file
33 # first before contemplating any changes here.  If you do need to change
34 # this file for some reason, we would like to know about it.
35
36 # First pass startup stuff.
37 #
38 network_pass1() {
39         echo -n 'Doing initial network setup:'
40
41         # Set the host name if it is not already set
42         #
43         if [ -z "`hostname -s`" ]; then
44                 hostname ${hostname}
45                 echo -n ' hostname'
46         fi
47
48         # Establish ipfilter ruleset as early as possible (best in
49         # addition to IPFILTER_DEFAULT_BLOCK in the kernel config file)
50
51         # check whether ipfilter and/or ipnat is enabled
52         ipfilter_active="NO"
53         case ${ipfilter_enable} in
54         [Yy][Ee][Ss])
55                 ipfilter_active="YES"
56                 ;;
57         esac
58         case ${ipnat_enable} in
59         [Yy][Ee][Ss])
60                 ipfilter_active="YES"
61                 ;;
62         esac
63         case ${ipfilter_active} in
64         [Yy][Ee][Ss])
65                 # load ipfilter kernel module if needed
66                 if ! sysctl net.inet.ipf.fr_pass > /dev/null 2>&1; then
67                         if kldload ipl; then
68                                 echo 'IP-filter module loaded.'
69                         else
70                                 echo 'Warning: IP-filter module failed to load.'
71                                 # avoid further errors
72                                 ipfilter_active="NO"
73                                 ipmon_enable="NO"
74                                 ipfilter_enable="NO"
75                                 ipnat_enable="NO"
76                                 ipfs_enable="NO"
77                         fi
78                 fi
79                 # start ipmon before loading any rules
80                 case "${ipmon_enable}" in
81                 [Yy][Ee][Ss])
82                         echo -n ' ipmon'
83                         ${ipmon_program:-/sbin/ipmon} ${ipmon_flags}
84                         ;;
85                 esac
86                 case "${ipfilter_enable}" in
87                 [Yy][Ee][Ss])
88                         if [ -r "${ipfilter_rules}" -o \
89                              -r "${ipv6_ipfilter_rules}" ]; then
90                                 echo -n ' ipfilter'
91                                 ${ipfilter_program:-/sbin/ipf} -Fa
92                                 if [ -r "${ipfilter_rules}" ]; then
93                                         ${ipfilter_program:-/sbin/ipf} \
94                                             -f "${ipfilter_rules}" \
95                                             ${ipfilter_flags}
96                                 fi
97                                 if [ -r "${ipv6_ipfilter_rules}" ]; then
98                                         ${ipfilter_program:-/sbin/ipf} -6 \
99                                             -f "${ipv6_ipfilter_rules}" \
100                                             ${ipfilter_flags}
101                                 fi
102                         else
103                                 ipfilter_enable="NO"
104                                 echo -n ' NO IPF RULES'
105                         fi
106                         ;;
107                 esac
108                 case "${ipnat_enable}" in
109                 [Yy][Ee][Ss])
110                         if [ -r "${ipnat_rules}" ]; then
111                                 echo -n ' ipnat'
112                                 eval ${ipnat_program:-/sbin/ipnat} -CF -f \
113                                     "${ipnat_rules}" ${ipnat_flags}
114                         else
115                                 ipnat_enable="NO"
116                                 echo -n ' NO IPNAT RULES'
117                         fi
118                         ;;
119                 esac
120                 # restore filter/NAT state tables after loading the rules
121                 case "${ipfs_enable}" in
122                 [Yy][Ee][Ss])
123                         if [ -r "/var/db/ipf/ipstate.ipf" ]; then
124                                 echo -n ' ipfs'
125                                 ${ipfs_program:-/sbin/ipfs} -R ${ipfs_flags}
126                                 # remove files to avoid reloading old state
127                                 # after an ungraceful shutdown
128                                 rm -f /var/db/ipf/ipstate.ipf
129                                 rm -f /var/db/ipf/ipnat.ipf
130                         fi
131                         ;;
132                 esac
133                 ;;
134         esac
135
136         # Set the domainname if we're using NIS
137         #
138         case ${nisdomainname} in
139         [Nn][Oo] | '')
140                 ;;
141         *)
142                 domainname ${nisdomainname}
143                 echo -n ' domain'
144                 ;;
145         esac
146
147         echo '.'
148
149         # Initial ATM interface configuration
150         #
151         case ${atm_enable} in
152         [Yy][Ee][Ss])
153                 if [ -r /etc/rc.atm ]; then
154                         . /etc/rc.atm
155                         atm_pass1
156                 fi
157                 ;;
158         esac
159
160         # Attempt to create cloned interfaces.
161         for ifn in ${cloned_interfaces}; do
162                 ifconfig ${ifn} create
163         done
164
165         # Special options for sppp(4) interfaces go here.  These need
166         # to go _before_ the general ifconfig section, since in the case
167         # of hardwired (no link1 flag) but required authentication, you
168         # cannot pass auth parameters down to the already running interface.
169         #
170         for ifn in ${sppp_interfaces}; do
171                 eval spppcontrol_args=\$spppconfig_${ifn}
172                 if [ -n "${spppcontrol_args}" ]; then
173                         # The auth secrets might contain spaces; in order
174                         # to retain the quotation, we need to eval them
175                         # here.
176                         eval spppcontrol ${ifn} ${spppcontrol_args}
177                 fi
178         done
179
180         # gifconfig
181         network_gif_setup
182
183         # Set up all the network interfaces, calling startup scripts if needed
184         #
185         case ${network_interfaces} in
186         [Aa][Uu][Tt][Oo])
187                 network_interfaces="`ifconfig -l`"
188                 ;;
189         *)
190                 network_interfaces="${network_interfaces} ${cloned_interfaces}"
191                 ;;
192         esac
193
194         dhcp_interfaces=""
195         for ifn in ${network_interfaces}; do
196                 if [ -r /etc/start_if.${ifn} ]; then
197                         . /etc/start_if.${ifn}
198                         eval showstat_$ifn=1
199                 fi
200
201                 # Do the primary ifconfig if specified
202                 #
203                 eval ifconfig_args=\$ifconfig_${ifn}
204
205                 case ${ifconfig_args} in
206                 '')
207                         ;;
208                 [Dd][Hh][Cc][Pp])
209                         # DHCP inits are done all in one go below
210                         dhcp_interfaces="$dhcp_interfaces $ifn"
211                         eval showstat_$ifn=1
212                         ;;
213                 *)
214                         ifconfig ${ifn} ${ifconfig_args}
215                         eval showstat_$ifn=1
216                         ;;
217                 esac
218         done
219
220         if [ ! -z "${dhcp_interfaces}" ]; then
221                 ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces}
222         fi
223
224         for ifn in ${network_interfaces}; do
225                 # Check to see if aliases need to be added
226                 #
227                 alias=0
228                 while : ; do
229                         eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
230                         if [ -n "${ifconfig_args}" ]; then
231                                 ifconfig ${ifn} ${ifconfig_args} alias
232                                 eval showstat_$ifn=1
233                                 alias=$((${alias} + 1))
234                         else
235                                 break;
236                         fi
237                 done
238
239                 # Do ipx address if specified
240                 #
241                 eval ifconfig_args=\$ifconfig_${ifn}_ipx
242                 if [ -n "${ifconfig_args}" ]; then
243                         ifconfig ${ifn} ${ifconfig_args}
244                         eval showstat_$ifn=1
245                 fi
246         done
247
248         for ifn in ${network_interfaces}; do
249                 eval showstat=\$showstat_${ifn}
250                 if [ ! -z ${showstat} ]; then
251                         ifconfig ${ifn}
252                 fi
253         done
254
255         # ISDN subsystem startup
256         #
257         case ${isdn_enable} in
258         [Yy][Ee][Ss])
259                 if [ -r /etc/rc.isdn ]; then
260                         . /etc/rc.isdn
261                 fi
262                 ;;
263         esac
264
265         # Start user ppp if required.  This must happen before natd.
266         #
267         case ${ppp_enable} in
268         [Yy][Ee][Ss])
269                 # Establish ppp mode.
270                 #
271                 if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \
272                         -a "${ppp_mode}" != "dedicated" \
273                         -a "${ppp_mode}" != "background" ]; then
274                         ppp_mode="auto"
275                 fi
276
277                 ppp_command="/usr/sbin/ppp -quiet -${ppp_mode}"
278
279                 # Switch on NAT mode?
280                 #
281                 case ${ppp_nat} in
282                 [Yy][Ee][Ss])
283                         ppp_command="${ppp_command} -nat"
284                         ;;
285                 esac
286
287                 ppp_command="${ppp_command} ${ppp_profile}"
288
289                 echo "Starting ppp as \"${ppp_user}\""
290                 su -m ${ppp_user} -c "exec ${ppp_command}"
291                 ;;
292         esac
293
294         # Re-Sync ipfilter so it picks up any new network interfaces
295         #
296         case ${ipfilter_active} in
297         [Yy][Ee][Ss])
298                 ${ipfilter_program:-/sbin/ipf} -y ${ipfilter_flags} >/dev/null
299                 ;;
300         esac
301         unset ipfilter_active
302
303         # Initialize IP filtering using ipfw
304         #
305         if /sbin/ipfw -q flush > /dev/null 2>&1; then
306                 firewall_in_kernel=1
307         else
308                 firewall_in_kernel=0
309         fi
310
311         case ${firewall_enable} in
312         [Yy][Ee][Ss])
313                 if [ "${firewall_in_kernel}" -eq 0 ] && kldload ipfw; then
314                         firewall_in_kernel=1
315                         echo 'Kernel firewall module loaded'
316                 elif [ "${firewall_in_kernel}" -eq 0 ]; then
317                         echo 'Warning: firewall kernel module failed to load'
318                 fi
319                 ;;
320         esac
321
322         # Load the filters if required
323         #
324         case ${firewall_in_kernel} in
325         1)
326                 if [ -z "${firewall_script}" ]; then
327                         firewall_script=/etc/rc.firewall
328                 fi
329
330                 case ${firewall_enable} in
331                 [Yy][Ee][Ss])
332                         if [ -r "${firewall_script}" ]; then
333                                 . "${firewall_script}"
334                                 echo -n 'Firewall rules loaded, starting divert daemons:'
335
336                                 # Network Address Translation daemon
337                                 #
338                                 case ${natd_enable} in
339                                 [Yy][Ee][Ss])
340                                         if [ -n "${natd_interface}" ]; then
341                                                 if echo ${natd_interface} | \
342                                                         grep -q -E '^[0-9]+(\.[0-9]+){0,3}$'; then
343                                                         natd_flags="$natd_flags -a ${natd_interface}"
344                                                 else
345                                                         natd_flags="$natd_flags -n ${natd_interface}"
346                                                 fi
347                                         fi
348                                         echo -n ' natd'; ${natd_program:-/sbin/natd} ${natd_flags}
349                                         ;;
350                                 esac
351
352                                 echo '.'
353
354                         elif [ "`ipfw l 65535`" = "65535 deny ip from any to any" ]; then
355                                 echo 'Warning: kernel has firewall functionality,' \
356                                      'but firewall rules are not enabled.'
357                                 echo '           All ip services are disabled.'
358                         fi
359
360                         case ${firewall_logging} in
361                         [Yy][Ee][Ss] | '')
362                                 echo 'Firewall logging=YES'
363                                 sysctl net.inet.ip.fw.verbose=1 >/dev/null
364                                 ;;
365                         *)
366                                 ;;
367                         esac
368
369                         ;;
370                 esac
371                 ;;
372         esac
373
374         # Additional ATM interface configuration
375         #
376         if [ -n "${atm_pass1_done}" ]; then
377                 atm_pass2
378         fi
379
380         # Configure routing
381         #
382         case ${defaultrouter} in
383         [Nn][Oo] | '')
384                 ;;
385         *)
386                 static_routes="default ${static_routes}"
387                 route_default="default ${defaultrouter}"
388                 ;;
389         esac
390
391         # Set up any static routes.  This should be done before router discovery.
392         #
393         if [ -n "${static_routes}" ]; then
394                 for i in ${static_routes}; do
395                         eval route_args=\$route_${i}
396                         route add ${route_args}
397                 done
398         fi
399
400         echo -n 'Additional routing options:'
401         case ${tcp_extensions} in
402         [Yy][Ee][Ss] | '')
403                 ;;
404         *)
405                 echo -n ' tcp extensions=NO'
406                 sysctl net.inet.tcp.rfc1323=0 >/dev/null
407                 ;;
408         esac
409
410         case ${icmp_bmcastecho} in
411         [Yy][Ee][Ss])
412                 echo -n ' broadcast ping responses=YES'
413                 sysctl net.inet.icmp.bmcastecho=1 >/dev/null
414                 ;;
415         esac
416
417         case ${icmp_drop_redirect} in
418         [Yy][Ee][Ss])
419                 echo -n ' ignore ICMP redirect=YES'
420                 sysctl net.inet.icmp.drop_redirect=1 >/dev/null
421                 ;;
422         esac
423
424         case ${icmp_log_redirect} in
425         [Yy][Ee][Ss])
426                 echo -n ' log ICMP redirect=YES'
427                 sysctl net.inet.icmp.log_redirect=1 >/dev/null
428                 ;;
429         esac
430
431         case ${gateway_enable} in
432         [Yy][Ee][Ss])
433                 echo -n ' IP gateway=YES'
434                 sysctl net.inet.ip.forwarding=1 >/dev/null
435                 ;;
436         esac
437
438         case ${forward_sourceroute} in
439         [Yy][Ee][Ss])
440                 echo -n ' do source routing=YES'
441                 sysctl net.inet.ip.sourceroute=1 >/dev/null
442                 ;;
443         esac
444
445         case ${accept_sourceroute} in
446         [Yy][Ee][Ss])
447                 echo -n ' accept source routing=YES'
448                 sysctl net.inet.ip.accept_sourceroute=1 >/dev/null
449                 ;;
450         esac
451
452         case ${tcp_keepalive} in
453         [Yy][Ee][Ss])
454                 echo -n ' TCP keepalive=YES'
455                 sysctl net.inet.tcp.always_keepalive=1 >/dev/null
456                 ;;
457         esac
458
459         case ${tcp_drop_synfin} in
460         [Yy][Ee][Ss])
461                 echo -n ' drop SYN+FIN packets=YES'
462                 sysctl net.inet.tcp.drop_synfin=1 >/dev/null
463                 ;;
464         esac
465
466         case ${ipxgateway_enable} in
467         [Yy][Ee][Ss])
468                 echo -n ' IPX gateway=YES'
469                 sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null
470                 ;;
471         esac
472
473         case ${arpproxy_all} in
474         [Yy][Ee][Ss])
475                 echo -n ' ARP proxyall=YES'
476                 sysctl net.link.ether.inet.proxyall=1 >/dev/null
477                 ;;
478         esac
479
480         case ${ip_portrange_first} in
481         [Nn][Oo] | '')
482                 ;;
483         *)
484                 echo -n " ip_portrange_first=$ip_portrange_first"
485                 sysctl net.inet.ip.portrange.first=$ip_portrange_first >/dev/null
486                 ;;
487         esac
488
489         case ${ip_portrange_last} in
490         [Nn][Oo] | '')
491                 ;;
492         *)
493                 echo -n " ip_portrange_last=$ip_portrange_last"
494                 sysctl net.inet.ip.portrange.last=$ip_portrange_last >/dev/null
495                 ;;
496         esac
497
498         echo '.'
499
500         case ${ipsec_enable} in
501         [Yy][Ee][Ss])
502                 if [ -f ${ipsec_file} ]; then
503                     echo ' ipsec: enabled'
504                     setkey -f ${ipsec_file}
505                 else
506                     echo ' ipsec: file not found'
507                 fi
508                 ;;
509         esac
510
511         echo -n 'Routing daemons:'
512         case ${router_enable} in
513         [Yy][Ee][Ss])
514                 echo -n " ${router}";   ${router} ${router_flags}
515                 ;;
516         esac
517
518         case ${ipxrouted_enable} in
519         [Yy][Ee][Ss])
520                 echo -n ' IPXrouted'
521                 IPXrouted ${ipxrouted_flags} > /dev/null 2>&1
522                 ;;
523         esac
524
525         case ${mrouted_enable} in
526         [Yy][Ee][Ss])
527                 echo -n ' mrouted';     mrouted ${mrouted_flags}
528                 ;;
529         esac
530
531         case ${rarpd_enable} in
532         [Yy][Ee][Ss])
533                 echo -n ' rarpd';       rarpd ${rarpd_flags}
534                 ;;
535         esac
536         echo '.'
537
538         # Let future generations know we made it.
539         #
540         network_pass1_done=YES
541 }
542
543 network_pass2() {
544         echo -n 'Doing additional network setup:'
545         case ${named_enable} in
546         [Yy][Ee][Ss])
547                 echo -n ' named';       ${named_program:-named} ${named_flags}
548                 ;;
549         esac
550
551         case ${ntpdate_enable} in
552         [Yy][Ee][Ss])
553                 echo -n ' ntpdate'
554                 ${ntpdate_program:-ntpdate} ${ntpdate_flags} >/dev/null 2>&1
555                 ;;
556         esac
557
558         case ${xntpd_enable} in
559         [Yy][Ee][Ss])
560                 echo -n ' ntpd';        ${xntpd_program:-ntpd} ${xntpd_flags}
561                 ;;
562         esac
563
564         case ${timed_enable} in
565         [Yy][Ee][Ss])
566                 echo -n ' timed';       timed ${timed_flags}
567                 ;;
568         esac
569
570         case ${portmap_enable} in
571         [Yy][Ee][Ss])
572                 echo -n ' portmap';     ${portmap_program:-/usr/sbin/portmap} ${portmap_flags}
573                 ;;
574         esac
575
576         # Start ypserv if we're an NIS server.
577         # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
578         #
579         case ${nis_server_enable} in
580         [Yy][Ee][Ss])
581                 echo -n ' ypserv'; ypserv ${nis_server_flags}
582
583                 case ${nis_ypxfrd_enable} in
584                 [Yy][Ee][Ss])
585                         echo -n ' rpc.ypxfrd'
586                         rpc.ypxfrd ${nis_ypxfrd_flags}
587                         ;;
588                 esac
589
590                 case ${nis_yppasswdd_enable} in
591                 [Yy][Ee][Ss])
592                         echo -n ' rpc.yppasswdd'
593                         rpc.yppasswdd ${nis_yppasswdd_flags}
594                         ;;
595                 esac
596                 ;;
597         esac
598
599         # Start ypbind if we're an NIS client
600         #
601         case ${nis_client_enable} in
602         [Yy][Ee][Ss])
603                 echo -n ' ypbind'; ypbind ${nis_client_flags}
604                 case ${nis_ypset_enable} in
605                 [Yy][Ee][Ss])
606                         echo -n ' ypset';       ypset ${nis_ypset_flags}
607                         ;;
608                 esac
609                 ;;
610         esac
611
612         # Start keyserv if we are running Secure RPC
613         #
614         case ${keyserv_enable} in
615         [Yy][Ee][Ss])
616                 echo -n ' keyserv';     keyserv ${keyserv_flags}
617                 ;;
618         esac
619
620         # Start ypupdated if we are running Secure RPC and we are NIS master
621         #
622         case ${rpc_ypupdated_enable} in
623         [Yy][Ee][Ss])
624                 echo -n ' rpc.ypupdated';       rpc.ypupdated
625                 ;;
626         esac
627
628         # Start ATM daemons
629         if [ -n "${atm_pass2_done}" ]; then
630                 atm_pass3
631         fi
632
633         echo '.'
634         network_pass2_done=YES
635 }
636
637 network_pass3() {
638         echo -n 'Starting final network daemons:'
639
640         case ${nfs_server_enable} in
641         [Yy][Ee][Ss])
642                 if [ -r /etc/exports ]; then
643                         echo -n ' mountd'
644
645                         case ${weak_mountd_authentication} in
646                         [Yy][Ee][Ss])
647                                 mountd_flags="${mountd_flags} -n"
648                                 ;;
649                         esac
650
651                         mountd ${mountd_flags}
652
653                         case ${nfs_reserved_port_only} in
654                         [Yy][Ee][Ss])
655                                 echo -n ' NFS on reserved port only=YES'
656                                 sysctl vfs.nfs.nfs_privport=1 >/dev/null
657                                 ;;
658                         esac
659
660                         echo -n ' nfsd';        nfsd ${nfs_server_flags}
661
662                         case ${rpc_lockd_enable} in
663                         [Yy][Ee][Ss])
664                                 echo -n ' rpc.lockd';   rpc.lockd
665                                 ;;
666                         esac
667
668                         case ${rpc_statd_enable} in
669                         [Yy][Ee][Ss])
670                                 echo -n ' rpc.statd';   rpc.statd
671                                 ;;
672                         esac
673                 fi
674                 ;;
675         *)
676                 case ${single_mountd_enable} in
677                 [Yy][Ee][Ss])
678                         if [ -r /etc/exports ]; then
679                                 echo -n ' mountd'
680
681                                 case ${weak_mountd_authentication} in
682                                 [Yy][Ee][Ss])
683                                         mountd_flags="-n"
684                                         ;;
685                                 esac
686
687                                 mountd ${mountd_flags}
688                         fi
689                         ;;
690                 esac
691                 ;;
692         esac
693
694         case ${nfs_client_enable} in
695         [Yy][Ee][Ss])
696                 nfs_in_kernel=0
697                 # Handle absent nfs client support
698                 if sysctl vfs.nfs >/dev/null 2>&1; then
699                         nfs_in_kernel=1
700                 else
701                         kldload nfs && nfs_in_kernel=1
702                 fi
703                 if [ ${nfs_in_kernel} -eq 1 ]
704                 then
705                         echo -n ' nfsiod';      nfsiod ${nfs_client_flags}
706                         if [ -n "${nfs_access_cache}" ]; then
707                                 echo -n " NFS access cache time=${nfs_access_cache}"
708                                 sysctl vfs.nfs.access_cache_timeout=${nfs_access_cache} >/dev/null
709                         fi
710
711                         if [ -n "${nfs_bufpackets}" ]; then
712                                 sysctl vfs.nfs.bufpackets=${nfs_bufpackets} \
713                                         > /dev/null
714                         fi
715
716                         case ${amd_enable} in
717                         [Yy][Ee][Ss])
718                                 echo -n ' amd'
719                                 case ${amd_map_program} in
720                                 [Nn][Oo] | '')
721                                         ;;
722                                 *)
723                                         amd_flags="${amd_flags} `eval \
724                                                 ${amd_map_program}`"
725                                         ;;
726                                 esac
727                 
728                                 case "${amd_flags}" in
729                                 '')
730                                         if [ -r /etc/amd.conf ]; then
731                                                 amd &
732                                         else
733                                                 echo ''
734                         echo 'Warning: amd will not load without arguments'
735                                         fi
736                                         ;;
737                                 *)
738                                         amd -p ${amd_flags} >/var/run/amd.pid \
739                                                 2>/dev/null &
740                                         ;;
741                                 esac
742                                 ;;
743                         esac
744                 fi
745                 ;;
746         esac
747
748         # If /var/db/mounttab exists, some nfs-server has not been
749         # sucessfully notified about a previous client shutdown.
750         # If there is no /var/db/mounttab, we do nothing.
751         if [ -f /var/db/mounttab ]; then
752                 rpc.umntall -k
753         fi
754
755         case ${rwhod_enable} in
756         [Yy][Ee][Ss])
757                 echo -n ' rwhod';       rwhod ${rwhod_flags}
758                 ;;
759         esac
760
761         # Kerberos servers run ONLY on the Kerberos server machine
762         case ${kerberos_server_enable} in
763         [Yy][Ee][Ss])
764                 case ${kerberos_stash} in
765                 [Yy][Ee][Ss])
766                         stash_flag=-n
767                         ;;
768                 *)
769                         stash_flag=
770                         ;;
771                 esac
772
773                 echo -n ' kerberosIV'
774                 kerberos ${stash_flag} >> /var/log/kerberos.log &
775
776                 case ${kadmind_server_enable} in
777                 [Yy][Ee][Ss])
778                         echo -n ' kadmindIV'
779                         (
780                                 sleep 20;
781                                 kadmind ${stash_flag} >/dev/null 2>&1 &
782                         ) &
783                         ;;
784                 esac
785                 unset stash_flag
786                 ;;
787         esac
788
789         case ${kerberos5_server_enable} in
790         [Yy][Ee][Ss])
791                 echo -n ' kerberos5'
792                 ${kerberos5_server} &
793
794                 case ${kadmind5_server_enable} in
795                 [Yy][Ee][Ss])
796                         echo -n ' kadmind5'
797                         ${kadmind5_server} &
798                         ;;
799                 esac
800                 ;;
801         esac
802
803         case ${pppoed_enable} in
804         [Yy][Ee][Ss])
805                 if [ -n "${pppoed_provider}" ]; then
806                         pppoed_flags="${pppoed_flags} -p ${pppoed_provider}"
807                 fi
808                 echo -n ' pppoed';
809                 _opts=$-; set -f
810                 /usr/libexec/pppoed ${pppoed_flags} ${pppoed_interface}
811                 set +f; set -${_opts}
812                 ;;
813         esac
814
815         case ${sshd_enable} in
816         [Yy][Ee][Ss])
817                 if [ -x /usr/bin/ssh-keygen ]; then
818                         if [ ! -f /etc/ssh/ssh_host_key ]; then
819                                 echo ' creating ssh1 RSA host key';
820                                 /usr/bin/ssh-keygen -t rsa1 -N "" \
821                                         -f /etc/ssh/ssh_host_key
822                         fi
823                         if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
824                                 echo ' creating ssh2 RSA host key';
825                                 /usr/bin/ssh-keygen -t rsa -N "" \
826                                         -f /etc/ssh/ssh_host_rsa_key
827                         fi
828                         if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then
829                                 echo ' creating ssh2 DSA host key';
830                                 /usr/bin/ssh-keygen -t dsa -N "" \
831                                         -f /etc/ssh/ssh_host_dsa_key
832                         fi
833                 fi
834                 ;;
835         esac
836
837         echo '.'
838         network_pass3_done=YES
839 }
840
841 network_pass4() {
842         echo -n 'Additional TCP options:'
843         case ${log_in_vain} in
844         [Nn][Oo] | '')
845                 log_in_vain=0
846                 ;;
847         [Yy][Ee][Ss])
848                 log_in_vain=1
849                 ;;
850         [0-9]*)
851                 ;;
852         *)
853                 echo " invalid log_in_vain setting: ${log_in_vain}"
854                 log_in_vain=0
855                 ;;
856         esac
857
858         if [ "${log_in_vain}" -ne 0 ]; then
859                 echo -n " log_in_vain=${log_in_vain}"
860                 sysctl net.inet.tcp.log_in_vain="${log_in_vain}" >/dev/null
861                 sysctl net.inet.udp.log_in_vain="${log_in_vain}" >/dev/null
862         fi
863
864         echo '.'
865         network_pass4_done=YES
866 }
867
868 network_gif_setup() {
869         case ${gif_interfaces} in
870         [Nn][Oo] | '')
871                 ;;
872         *)
873                 for i in ${gif_interfaces}; do
874                         eval peers=\$gifconfig_$i
875                         case ${peers} in
876                         '')
877                                 continue
878                                 ;;
879                         *)
880                                 ifconfig $i create >/dev/null 2>&1
881                                 ifconfig $i tunnel ${peers}
882                                 ifconfig $i up
883                                 ;;
884                         esac
885                 done
886                 ;;
887         esac
888 }