Switch to OpenNTPD by default. For the moment, the documentation is
[dragonfly.git] / etc / rc.d / network1
1 #!/bin/sh
2 #
3 # $FreeBSD: src/etc/rc.d/network1,v 1.147 2003/06/06 13:00:43 mtm Exp $
4 # $DragonFly: src/etc/rc.d/Attic/network1,v 1.3 2004/09/18 07:16:32 asmodai Exp $
5 #
6
7 # PROVIDE: network1
8 # REQUIRE: atm1 ipfilter mountcritlocal pccard serial sppp sysctl tty
9 # KEYWORD: DragonFly  nostart
10
11 . /etc/rc.subr
12
13 name="network1"
14 start_cmd="network_start"
15 stop_cmd="network_stop"
16
17 network_gif_setup() {
18         case ${gif_interfaces} in
19         [Nn][Oo] | '')
20                 ;;
21         *)
22                 for i in ${gif_interfaces}; do
23                         eval peers=\$gifconfig_$i
24                         case ${peers} in
25                         '')
26                                 continue
27                                 ;;
28                         *)
29                                 ifconfig $i create >/dev/null 2>&1
30                                 ifconfig $i tunnel ${peers}
31                                 ifconfig $i up
32                                 ;;
33                         esac
34                 done
35                 ;;
36         esac
37 }
38
39 network_start()
40 {
41         # set hostname, turn on network
42         #
43         echo -n "Doing initial network setup:"
44
45         # Set the host name if it is not already set
46         #
47         if [ -z "`hostname -s`" ]; then
48                 hostname ${hostname}
49                 echo -n ' hostname'
50         fi
51
52         # Set the domainname if we're using NIS
53         #
54         case ${nisdomainname} in
55         [Nn][Oo]|'')
56                 ;;
57         *)
58                 domainname ${nisdomainname}
59                 echo -n ' domain'
60                 ;;
61         esac
62
63         echo '.'
64
65         # Attempt to create cloned interfaces.
66         for ifn in ${cloned_interfaces}; do
67                 ifconfig ${ifn} create
68         done
69
70         # gifconfig
71         network_gif_setup
72
73         # Set up all the network interfaces, calling startup scripts if needed
74         #
75         case ${network_interfaces} in
76         [Aa][Uu][Tt][Oo])
77                 network_interfaces="`ifconfig -l`"
78                 ;;
79         *)
80                 network_interfaces="${network_interfaces} ${cloned_interfaces}"
81                 ;;
82         esac
83
84         dhcp_interfaces=""
85         for ifn in ${network_interfaces}; do
86                 if [ -r /etc/start_if.${ifn} ]; then
87                         . /etc/start_if.${ifn}
88                         eval showstat_$ifn=1
89                 fi
90
91                 # Do the primary ifconfig if specified
92                 #
93                 eval ifconfig_args=\$ifconfig_${ifn}
94
95                 case ${ifconfig_args} in
96                 '')
97                         ;;
98                 [Dd][Hh][Cc][Pp])
99                         # DHCP inits are done all in one go below
100                         dhcp_interfaces="$dhcp_interfaces $ifn"
101                         eval showstat_$ifn=1
102                         ;;
103                 *)
104                         ifconfig ${ifn} ${ifconfig_args}
105                         eval showstat_$ifn=1
106                         ;;
107                 esac
108         done
109
110         if [ ! -z "${dhcp_interfaces}" ]; then
111                 ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces}
112         fi
113
114         for ifn in ${network_interfaces}; do
115                 # Check to see if aliases need to be added
116                 #
117                 alias=0
118                 while : ; do
119                         eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
120                         if [ -n "${ifconfig_args}" ]; then
121                                 ifconfig ${ifn} ${ifconfig_args} alias
122                                 eval showstat_$ifn=1
123                                 alias=$((${alias} + 1))
124                         else
125                                 break;
126                         fi
127                 done
128
129                 # Do ipx address if specified
130                 #
131                 eval ifconfig_args=\$ifconfig_${ifn}_ipx
132                 if [ -n "${ifconfig_args}" ]; then
133                         ifconfig ${ifn} ${ifconfig_args}
134                         eval showstat_$ifn=1
135                 fi
136         done
137
138         # Display ifconfiged interfaces
139         for ifn in ${network_interfaces}; do
140                 eval showstat=\$showstat_${ifn}
141                 if [ ! -z ${showstat} ]; then
142                         ifconfig ${ifn}
143                 fi
144         done
145
146         # Resync ipfilter
147         /etc/rc.d/ipfilter resync
148 }
149
150 network_stop()
151 {
152         echo -n "Stopping network:"
153
154         # flush routes
155         #
156         echo -n " flush routes"
157         route -n flush
158
159         echo '.'
160 }
161
162 load_rc_config $name
163 run_rc_command "$1"