Project

General

Profile

« Previous | Next » 

Revision e7012ec3

Added by Scott Ullrich almost 20 years ago

revert to 1.2b9 rc.newwanip

View differences:

etc/rc.newwanip
1 1
#!/usr/local/bin/php -f
2 2
<?php
3
/* $Id$ */
4 3
/*
5
	rc.newwanip
6
	part of m0n0wall (http://m0n0.ch/wall)
7

  
8
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
9
	All rights reserved.
10

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

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

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

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

  
7
        Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
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.
31 30
*/
32 31

  
33
	/* parse the configuration and include all functions used below */
34
	require_once("config.inc");
35
	require_once("functions.inc");
32
        /* parse the configuration and include all functions used below */
33
        require_once("config.inc");
34
        require_once("functions.inc");
36 35

  
37
	/* WAN IP address has changed */
38
	$curwanip = get_current_wan_address();
36
        /* WAN IP address has changed */
39 37

  
40
	/*	dhclient or MPD told us that the IP address has changed;
41
		let's see if that's really true to avoid reloading things
42
		when it's not really necessary (dhclient likes to
43
		execute its dhclient-exit-hooks also on renewals)
44
	*/
45
	if (file_exists("{$g['vardb_path']}/wanip")) {
46
		$oldwanip = chop(file_get_contents("{$g['vardb_path']}/wanip"));
38
        /* make sure to wait until the boot scripts have finished */
39
        while (file_exists("{$g['varrun_path']}/booting")) {
40
                sleep(1);
41
        }
47 42

  
48
		if ($curwanip == $oldwanip)
49
			return 0;	/* nothing to do */
50
	}
43
        $curwanip = get_current_wan_address();
51 44

  
52
	/* relaunch pftpx */
53
	system_start_ftp_helpers();
45
        /*      dhclient or MPD told us that the IP address has changed;
46
                let's see if that's really true to avoid reloading things
47
                when it's not really necessary (dhclient likes to
48
                execute its dhclient-exit-hooks also on renewals)
49
        */
50
        if (file_exists("{$g['vardb_path']}/wanip")) {
51
                $oldwanip = chop(file_get_contents("{$g['vardb_path']}/wanip"));
54 52

  
55
	/* resync ipfilter */
56
	filter_configure_sync();
53
                if ($curwanip == $oldwanip)
54
                        return 0;       /* nothing to do */
55
        }
56

  
57
        /* reload firewall rules */
58
        filter_rules_generate();
59

  
60
        /* flush NAT table */
61
        filter_flush_nat_table();
62

  
63
        /* reconfigure IPsec tunnels */
64
        vpn_ipsec_configure(true);
57 65

  
58
	/* reconfigure IPsec tunnels */
59
	vpn_ipsec_configure(true);
60

  
61
	/* regenerate resolv.conf if DNS overrides are allowed or the BigPond
62
	   client is enabled */
63
	if (isset($config['system']['dnsallowoverride']) ||
64
			($config['interfaces']['wan']['ipaddr'] == "bigpond"))
65
		system_resolvconf_generate(true);
66

  
67
	/* fire up the BigPond client, if necessary */
68
	if ($config['interfaces']['wan']['ipaddr'] == "bigpond")
69
		interfaces_wan_bigpond_configure($curwanip);
70

  
71
	/* write current WAN IP to file */
72
	$fd = @fopen("{$g['vardb_path']}/wanip", "w");
73
	if ($fd) {
74
		fwrite($fd, $curwanip);
75
		fclose($fd);
76
	}
77

  
78
	/* Update dynamic DNS */
79
	services_dyndns_configure();
80
?>
66
        /* regenerate resolv.conf if DNS overrides are allowed or the BigPond
67
           client is enabled */
68
        if (isset($config['system']['dnsallowoverride']) ||
69
                        ($config['interfaces']['wan']['ipaddr'] == "bigpond"))
70
                system_resolvconf_generate(true);
71

  
72
        /* fire up the BigPond client, if necessary */
73
        if ($config['interfaces']['wan']['ipaddr'] == "bigpond")
74
                interfaces_wan_bigpond_configure($curwanip);
75

  
76
        /* perform RFC 2136 DNS update */
77
        services_dnsupdate_process();
78

  
79
        /* write current WAN IP to file */
80
        $fd = @fopen("{$g['vardb_path']}/wanip", "w");
81
        if ($fd) {
82
                fwrite($fd, $curwanip);
83
                fclose($fd);
84
        }
85
	
86
	filter_configure_sync();
87
	
88
?>

Also available in: Unified diff