adds fkvm_loaded flag
[freebsd-src/fkvm-freebsd.git] / etc / pccard_ether
blob841c1a086830d78dbd58f9f0715be59195fce8b0
1 #!/bin/sh -
3 # $FreeBSD$
5 # pccard_ether interfacename [start|stop|restart]
7 # example: pccard_ether fxp0 start
10 . /etc/rc.subr
11 . /etc/network.subr
13 name="pccard_ether"
14 start_precmd="checkauto"
15 start_cmd="pccard_ether_start"
16 stop_precmd="checkauto"
17 stop_cmd="pccard_ether_stop"
18 restart_precmd="checkauto"
19 restart_cmd="pccard_ether_restart"
21 setup_routes()
23 # Add default route into $static_routes
24 case ${defaultrouter} in
25 [Nn][Oo] | '')
28 static_routes="default ${static_routes}"
29 route_default="default ${defaultrouter}"
31 esac
33 # Add private route for this interface into $static_routes
34 eval ifx_routes=\$static_routes_${ifn}
35 if [ -n "${ifx_routes}" ]; then
36 static_routes="${ifx_routes} ${static_routes}"
39 # Set up any static routes if specified
40 if [ -n "${static_routes}" ]; then
41 for i in ${static_routes}; do
42 eval route_args=\$route_${i}
43 route add ${route_args}
44 done
48 remove_routes()
50 # Delete static route if specified
51 eval ifx_routes=\$static_routes_${ifn}
52 if [ -n "${ifx_routes}" ]; then
53 for i in ${ifx_routes}; do
54 eval route_args=\$route_${i}
55 route delete ${route_args}
56 done
60 checkauto()
62 if [ -z "$rc_force" ]; then
63 # Ignore interfaces with the NOAUTO keyword
64 autoif $ifn || exit 0
68 pccard_ether_start()
70 ifexists $ifn || exit 1
72 if [ -z "$rc_force" ]; then
73 for uif in `ifconfig -ul`; do
74 if [ "${uif}" = "${ifn}" ]; then
75 # Interface is already up, so ignore it.
76 exit 0
78 done
81 /etc/rc.d/netif quietstart $ifn
83 # Do route configuration if needed.
84 # XXX: should probably do this by calling rc.d/routing.
85 if [ -n "`ifconfig_getargs $ifn`" ]; then
86 if ! dhcpif $ifn; then
87 setup_routes
91 # XXX: IPv6 setup should be done in some way.
94 pccard_ether_stop()
96 if [ -n "`ifconfig_getargs $ifn`" ]; then
97 if ! dhcpif $ifn; then
98 remove_routes
102 /etc/rc.d/netif quietstop $ifn
104 # clean ARP table
105 ifexists $ifn && arp -d -i $ifn -a
108 pccard_ether_restart()
110 # Hand implemented because the default implementation runs
111 # the equivalent of "$0 start; $0 stop" and this script
112 # doesn't support that syntax
113 pccard_ether_stop
114 pccard_ether_start
117 ifn=$1
118 shift
119 if [ -z "$*" ]; then
120 args="start"
121 else
122 args=$*
125 load_rc_config pccard_ether
126 run_rc_command $args