1
|
#!/usr/local/bin/php -f
|
2
|
<?php
|
3
|
/*
|
4
|
rc.linkup - devd hotplug actions
|
5
|
part of pfSense
|
6
|
|
7
|
Copyright (C) 2003-2005 Scott Ullrich <sullrich@gmail.com>.
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
2. Redistributions in binary form must reproduce the above copyright
|
17
|
notice, this list of conditions and the following disclaimer in the
|
18
|
documentation and/or other materials provided with the distribution.
|
19
|
|
20
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
POSSIBILITY OF SUCH DAMAGE.
|
30
|
*/
|
31
|
|
32
|
/* parse the configuration and include all functions used below */
|
33
|
require_once("globals.inc");
|
34
|
require_once("config.inc");
|
35
|
require_once("interfaces.inc");
|
36
|
|
37
|
function handle_argument_group($iface, $argument2) {
|
38
|
global $config;
|
39
|
|
40
|
$ipaddr = $config['interfaces'][$iface]['ipaddr'];
|
41
|
if (is_ipaddr($ipaddr)) {
|
42
|
log_error("Hotplug event detected for {$iface} but ignoring since interface is configured with static ip({$ipaddr})");
|
43
|
$iface = get_real_interface($iface);
|
44
|
exec("/usr/sbin/arp -d -i {$iface} -a");
|
45
|
} else {
|
46
|
switch ($argument2) {
|
47
|
case "stop":
|
48
|
case "down":
|
49
|
log_error("DEVD Ethernet detached event for {$iface}");
|
50
|
interface_bring_down($iface);
|
51
|
break;
|
52
|
case "start":
|
53
|
case "up":
|
54
|
log_error("DEVD Ethernet attached event for {$iface}");
|
55
|
$riface = get_real_interface($iface);
|
56
|
exec("/usr/sbin/arp -d -i {$riface} -a");
|
57
|
log_error("HOTPLUG: Configuring interface {$iface}");
|
58
|
interface_configure($iface);
|
59
|
break;
|
60
|
}
|
61
|
}
|
62
|
}
|
63
|
|
64
|
if ($g['booting'] == true) {
|
65
|
/* ignore all linkup events */
|
66
|
} else {
|
67
|
foreach($_SERVER['argv'] as $argv) {
|
68
|
switch($argv) {
|
69
|
case "start":
|
70
|
$action = "start";
|
71
|
break;
|
72
|
case "stop":
|
73
|
$action = "stop";
|
74
|
break;
|
75
|
case "/etc/rc.linkup":
|
76
|
break;
|
77
|
default:
|
78
|
$interface = convert_real_interface_to_friendly_interface_name($argv);
|
79
|
if($interface == "") {
|
80
|
unset($interface);
|
81
|
}
|
82
|
break;
|
83
|
}
|
84
|
if(($action) && ($interface)) {
|
85
|
handle_argument_group($interface, $action);
|
86
|
unset ($action, $interface);
|
87
|
}
|
88
|
}
|
89
|
}
|
90
|
|
91
|
?>
|