]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/pccard_ether
Reimplement the groff(1) warnings elimination fixes in a better way.
[FreeBSD/FreeBSD.git] / etc / pccard_ether
1 #!/bin/sh -
2 #
3 # $FreeBSD$
4 #
5 # pccard_ether interfacename [start|stop] [ifconfig option]
6 #
7 # example: pccard_ether ep0 start -link0
8 #
9
10 stop_dhcp() {
11         if [ -r /sbin/dhclient ]; then
12                 pidfile="/var/run/dhclient.${interface}.pid"
13                 if [ -s ${pidfile} ]; then
14                         kill `cat ${pidfile}`
15                         rm ${pidfile}
16                 fi
17         elif [ -r /usr/local/sbin/dhcpc ]; then
18                 pidfile="/var/run/dhcpc.${interface}.pid"
19                 if [ -s ${pidfile} ]; then
20                         kill `cat ${pidfile}`
21                         rm ${pidfile}
22                 fi
23         fi
24 }
25
26 start_dhcp() {
27         stop_dhcp
28         if [ -r /sbin/dhclient ]; then
29                 pidfile="/var/run/dhclient.${interface}.pid"
30                 /sbin/dhclient -pf ${pidfile} $interface
31         elif [ -r /usr/local/sbin/dhcpc ]; then
32                 /usr/local/sbin/dhcpc $interface
33         else
34                 echo "DHCP client software not available (isc-dhcp2)"
35         fi
36 }
37
38 # Suck in the configuration variables
39 #
40 if [ -r /etc/defaults/rc.conf ]; then
41         . /etc/defaults/rc.conf
42         source_rc_confs
43 elif [ -r /etc/rc.conf ]; then
44         . /etc/rc.conf
45 fi
46
47 interface=$1
48 shift
49 startstop=$1
50 shift
51
52 case ${startstop} in
53 [Ss][Tt][Aa][Rr][Tt] | '')
54         case ${pccard_ifconfig} in
55         [Nn][Oo] | '')
56                 ;;
57         [Dd][Hh][Cc][Pp])
58                 start_dhcp
59                 ;;
60         *)
61                 ifconfig ${interface} ${pccard_ifconfig} $*
62                 ;;
63         esac
64
65         case ${defaultrouter} in
66         [Nn][Oo] | '')
67                 ;;
68         *)
69                 static_routes="default ${static_routes}"
70                 route_default="default ${defaultrouter}"
71                 ;;
72         esac
73
74         # Set up any static routes.
75         #
76         if [ -n "${static_routes}" ]; then
77                 # flush beforehand, just in case....
78                 route -n flush
79                 arp -d -a
80                 for i in ${static_routes}; do
81                         eval route_args=\$route_${i}
82                         route add ${route_args}
83                 done
84         fi
85
86         # IPv6 setup
87         case ${ipv6_enable} in
88         [Yy][Ee][Ss])
89                 case ${ipv6_gateway_enable} in
90                 [Yy][Ee][Ss])
91                         ;;
92                 *)
93                         sysctl -w net.inet6.ip6.forwarding=0
94                         sysctl -w net.inet6.ip6.accept_rtadv=1
95                         ifconfig ${interface} up
96                         rtsol ${interface}
97                         ;;
98                 esac
99                 ;;
100         esac
101         ;;
102 # Stop the interface
103 *)
104         /sbin/ifconfig ${interface} delete
105         stop_dhcp
106         ;;
107 esac