Merge from vendor branch SENDMAIL:
[dragonfly.git] / etc / rc.d / atm1
1 #!/bin/sh
2 #
3 # Copyright (c) 2000  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.d/atm1,v 1.12 2003/04/18 17:55:05 mtm Exp $
28 # $DragonFly: src/etc/rc.d/atm1,v 1.3 2005/11/19 21:47:32 swildner Exp $
29 #
30
31 # PROVIDE: atm1
32 # REQUIRE: root
33 # BEFORE: netif
34
35 . /etc/rc.subr
36
37 name="atm"
38 rcvar="atm_enable"
39 start_cmd="atm_start"
40 stop_cmd=":"
41
42 # ATM networking startup script
43 #
44 # Initial interface configuration.
45 # N.B. /usr is not mounted.
46 #
47 atm_start()
48 {
49         # Locate all probed ATM adapters
50         atmdev=`atm sh stat int | while read dev junk; do
51                 case ${dev} in
52                 hea[0-9] | hea[0-9][0-9])
53                         echo "${dev} "
54                         ;;
55                 hfa[0-9] | hfa[0-9][0-9])
56                         echo "${dev} "
57                         ;;
58                 idt[0-9] | idt[0-9][0-9])
59                         echo "${dev} "
60                         ;;
61                 *)
62                         continue
63                         ;;
64                 esac
65         done`
66
67         if [ -z "${atmdev}" ]; then
68                 echo 'No ATM adapters found'
69                 return 0
70         fi
71
72         # Load microcode into FORE adapters (if needed)
73         if [ `expr "${atmdev}" : '.*hfa.*'` -ne 0 ]; then
74                 fore_dnld
75         fi
76
77         # Configure physical interfaces
78         ilmid=0
79         for phy in ${atmdev}; do
80                 echo -n "Configuring ATM device ${phy}:"
81
82                 # Define network interfaces
83                 eval netif_args=\$atm_netif_${phy}
84                 if [ -n "${netif_args}" ]; then
85                         atm set netif ${phy} ${netif_args} || continue
86                 else
87                         echo ' missing network interface definition'
88                         continue
89                 fi
90
91                 # Override physical MAC address
92                 eval macaddr_args=\$atm_macaddr_${phy}
93                 if [ -n "${macaddr_args}" ]; then
94                         case ${macaddr_args} in
95                         [Nn][Oo] | '')
96                                 ;;
97                         *)
98                                 atm set mac ${phy} ${macaddr_args} || continue
99                                 ;;
100                         esac
101                 fi
102
103                 # Configure signalling manager
104                 eval sigmgr_args=\$atm_sigmgr_${phy}
105                 if [ -n "${sigmgr_args}" ]; then
106                         atm attach ${phy} ${sigmgr_args} || continue
107                 else
108                         echo ' missing signalling manager definition'
109                         continue
110                 fi
111
112                 # Configure UNI NSAP prefix
113                 eval prefix_args=\$atm_prefix_${phy}
114                 if [ `expr "${sigmgr_args}" : '[uU][nN][iI].*'` -ne 0 ]; then
115                         if [ -z "${prefix_args}" ]; then
116                                 echo ' missing NSAP prefix for UNI interface'
117                                 continue
118                         fi
119
120                         case ${prefix_args} in
121                         ILMI)
122                                 ilmid=1
123                                 ;;
124                         *)
125                                 atm set prefix ${phy} ${prefix_args} || continue
126                                 ;;
127                         esac
128                 fi
129
130                 atm_phy="${atm_phy} ${phy}"
131                 echo '.'
132         done
133
134         echo -n 'Starting initial ATM daemons:'
135         # Start ILMI daemon (if needed)
136         case ${ilmid} in
137         1)
138                 echo -n ' ilmid'
139                 ilmid
140                 ;;
141         esac
142
143         echo '.'
144 }
145
146 load_rc_config $name
147 run_rc_command "$1"