Project

General

Profile

« Previous | Next » 

Revision 7488a9e0

Added by Renato Botelho over 12 years ago

Fix whitespace and indent

View differences:

etc/rc.newwanip
1 1
#!/usr/local/bin/php -f
2 2
<?php
3 3
/*
4
        rc.newwanip
5
        Copyright (C) 2006 Scott Ullrich (sullrich@gmail.com)
6
        part of pfSense (http://www.pfsense.com)
7

  
8
		Originally part of m0n0wall (http://m0n0.ch)
9
        Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
10
        All rights reserved.
11

  
12
        Redistribution and use in source and binary forms, with or without
13
        modification, are permitted provided that the following conditions are met:
14

  
15
        1. Redistributions of source code must retain the above copyright notice,
16
           this list of conditions and the following disclaimer.
17

  
18
        2. Redistributions in binary form must reproduce the above copyright
19
           notice, this list of conditions and the following disclaimer in the
20
           documentation and/or other materials provided with the distribution.
21

  
22
        THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
        INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
        AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
        AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
        OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
        SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
        INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
        CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
        ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
        POSSIBILITY OF SUCH DAMAGE.
4
	rc.newwanip
5
	Copyright (C) 2006 Scott Ullrich (sullrich@gmail.com)
6
	part of pfSense (http://www.pfsense.com)
7

  
8
	Originally part of m0n0wall (http://m0n0.ch)
9
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11

  
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14

  
15
	1. Redistributions of source code must retain the above copyright notice,
16
	this list of conditions and the following disclaimer.
17

  
18
	2. Redistributions in binary form must reproduce the above copyright
19
	notice, this list of conditions and the following disclaimer in the
20
	documentation and/or other materials provided with the distribution.
21

  
22
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32 32
*/
33 33

  
34 34
/* parse the configuration and include all functions used below */
......
43 43
require_once("rrd.inc");
44 44

  
45 45
// Do not process while booting
46
if($g['booting']) 
46
if($g['booting'])
47 47
	exit;
48 48

  
49 49
function restart_packages() {
......
52 52
	/* restart packages */
53 53
	system_ntp_configure(false);
54 54
	mwexec_bg("/usr/local/sbin/ntpdate_sync_once.sh", true);
55
	log_error("{$g['product_name']} package system has detected an ip change $oldip ->  $curwanip ... Restarting packages.");		
55
	log_error("{$g['product_name']} package system has detected an ip change $oldip ->  $curwanip ... Restarting packages.");
56 56
	send_event("service reload packages");
57 57
}
58 58

  
......
62 62
log_error("rc.newwanip: Informational is starting {$argument}.");
63 63

  
64 64
if(empty($argument)) {
65
    $curwanip = get_interface_ip();
66
    $interface = "wan";
67
    $interface_real = get_real_interface();
65
	$curwanip = get_interface_ip();
66
	$interface = "wan";
67
	$interface_real = get_real_interface();
68 68
} else {
69
        $interface = convert_real_interface_to_friendly_interface_name($argument);
70
        $interface_real = $argument;
71
        $curwanip = find_interface_ip($interface_real, true);
72
        if($curwanip == "")
73
                $curwanip = get_interface_ip($interface);
69
	$interface = convert_real_interface_to_friendly_interface_name($argument);
70
	$interface_real = $argument;
71
	$curwanip = find_interface_ip($interface_real, true);
72
	if($curwanip == "")
73
		$curwanip = get_interface_ip($interface);
74 74
}
75 75

  
76 76
log_error("rc.newwanip: on (IP address: {$curwanip}) (interface: {$interface}) (real interface: {$interface_real}).");
77 77

  
78 78
if($curwanip == "0.0.0.0" || !is_ipaddr($curwanip)) {
79
        log_error("rc.newwanip: Failed to update {$interface} IP, restarting...");
79
	log_error("rc.newwanip: Failed to update {$interface} IP, restarting...");
80 80
	send_event("interface reconfigure {$interface}");
81
        exit;
81
	exit;
82 82
}
83 83

  
84 84
if (empty($interface)) {
......
166 166
filter_configure();
167 167

  
168 168
if (is_ipaddr($oldip) && $curwanip == $oldip) {
169
	/* We need to force sync VPNs on such even when the IP is the same. Even with 
170
	 * the same IP the VPN software is unhappy with the IP disappearing, and we 
169
	/* We need to force sync VPNs on such even when the IP is the same. Even with
170
	 * the same IP the VPN software is unhappy with the IP disappearing, and we
171 171
	 * could be failing back in which case we need to switch IPs back anyhow. */
172 172

  
173 173
	/* reconfigure IPsec tunnels */

Also available in: Unified diff