1 |
29edaa0b
|
Scott Ullrich
|
#!/usr/local/bin/php -f
|
2 |
|
|
<?php
|
3 |
|
|
/* $Id$ */
|
4 |
|
|
/*
|
5 |
|
|
rc.dhclient_cron
|
6 |
34e2973e
|
Chris Buechler
|
part of pfSense (https://www.pfsense.org)
|
7 |
29edaa0b
|
Scott Ullrich
|
Copyright (C) 2006 Scott Ullrich
|
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 |
|
|
require_once("config.inc");
|
33 |
|
|
require_once("functions.inc");
|
34 |
|
|
|
35 |
|
|
/* invalidate cache */
|
36 |
|
|
vc_invalidate();
|
37 |
|
|
|
38 |
|
|
unlink_if_exists("/tmp/config.cache");
|
39 |
|
|
|
40 |
a55e9c70
|
Ermal Lu?i
|
$iflist = get_configured_interface_with_descr();
|
41 |
|
|
foreach($iflist as $ifname => $interface) {
|
42 |
|
|
$real_interface = get_real_interface($ifname);
|
43 |
|
|
if($config['interfaces'][$ifname]['ipaddr'] == "dhcp") {
|
44 |
29edaa0b
|
Scott Ullrich
|
$pid = find_dhclient_process($real_interface);
|
45 |
|
|
if($pid == 0 or !$pid) {
|
46 |
|
|
/* dhclient is not running for interface, kick it */
|
47 |
|
|
log_error("DHCLIENT was not running for {$real_interface} ... Launching new instance.");
|
48 |
|
|
exec("/sbin/dhclient $real_interface");
|
49 |
|
|
}
|
50 |
|
|
}
|
51 |
|
|
}
|
52 |
|
|
|
53 |
a55e9c70
|
Ermal Lu?i
|
?>
|