diff options
author | Darren Embry <dse@webonastick.com> | 2012-05-17 19:17:01 -0400 |
---|---|---|
committer | Darren Embry <dse@webonastick.com> | 2012-05-17 19:17:01 -0400 |
commit | 416e1530bd166d3db6f517a222069383c1a21098 (patch) | |
tree | bcb10b1fde90afed5d3b266e334461f1872c0c75 /etc/rc.initial.setlanip | |
parent | cd485c4fce152548b8aa450863d39bcca52c1f2c (diff) | |
download | pfsense-416e1530bd166d3db6f517a222069383c1a21098.zip pfsense-416e1530bd166d3db6f517a222069383c1a21098.tar.gz |
normalize indentation
Diffstat (limited to 'etc/rc.initial.setlanip')
-rwxr-xr-x | etc/rc.initial.setlanip | 420 |
1 files changed, 210 insertions, 210 deletions
diff --git a/etc/rc.initial.setlanip b/etc/rc.initial.setlanip index e74313f..7f3cb2c 100755 --- a/etc/rc.initial.setlanip +++ b/etc/rc.initial.setlanip @@ -30,255 +30,255 @@ POSSIBILITY OF SUCH DAMAGE. */ - /* parse the configuration and include all functions used below */ - require_once("config.inc"); - require_once("functions.inc"); - require_once("filter.inc"); - require_once("shaper.inc"); - require_once("rrd.inc"); +/* parse the configuration and include all functions used below */ +require_once("config.inc"); +require_once("functions.inc"); +require_once("filter.inc"); +require_once("shaper.inc"); +require_once("rrd.inc"); - function console_get_interface_from_ppp($realif) { - global $config; +function console_get_interface_from_ppp($realif) { + global $config; - if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { - foreach ($config['ppps']['ppp'] as $pppid => $ppp) { - if ($realif == $ppp['if']) { - $ifaces = explode(",", $ppp['ports']); - return $ifaces[0]; - } + if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { + foreach ($config['ppps']['ppp'] as $pppid => $ppp) { + if ($realif == $ppp['if']) { + $ifaces = explode(",", $ppp['ports']); + return $ifaces[0]; } } - - return ""; } - function prompt_for_enable_dhcp_server() { - global $config, $fp, $interface; - if($interface == "wan") { - if($config['interfaces']['lan']) - return "n"; - } - /* only allow DHCP server to be enabled when static IP is - configured on this interface */ - if (is_ipaddr($config['interfaces'][$interface]['ipaddr'])) { - do { - $good = false; - $upperifname = strtoupper($interface); - echo "\n" . gettext("Do you want to enable the DHCP server on {$upperifname}? [y|n]") . " "; - $yn = strtolower(chop(fgets($fp))); - if ($yn[0] == "y" or $yn[0] == "n") + return ""; +} + +function prompt_for_enable_dhcp_server() { + global $config, $fp, $interface; + if($interface == "wan") { + if($config['interfaces']['lan']) + return "n"; + } + /* only allow DHCP server to be enabled when static IP is + configured on this interface */ + if (is_ipaddr($config['interfaces'][$interface]['ipaddr'])) { + do { + $good = false; + $upperifname = strtoupper($interface); + echo "\n" . gettext("Do you want to enable the DHCP server on {$upperifname}? [y|n]") . " "; + $yn = strtolower(chop(fgets($fp))); + if ($yn[0] == "y" or $yn[0] == "n") $good = true; - } while (!$good); - } - return $yn; + } while (!$good); } + return $yn; +} - $fp = fopen('php://stdin', 'r'); - $addr_blank = false; +$fp = fopen('php://stdin', 'r'); +$addr_blank = false; - /* build an interface collection */ - $ifdescrs = get_configured_interface_with_descr(false, true); - $j = count($ifdescrs); +/* build an interface collection */ +$ifdescrs = get_configured_interface_with_descr(false, true); +$j = count($ifdescrs); - /* grab interface that we will operate on, unless there is only one - interface */ - if ($j > 1) { - echo "Available interfaces:\n\n"; - $x=1; - foreach($ifdescrs as $iface) { - echo "{$x} - {$iface}\n"; - $x++; - } - echo "\nEnter the number of the interface you wish to configure: "; - $intnum = chop(fgets($fp)); - } else { - $intnum = $j; +/* grab interface that we will operate on, unless there is only one + interface */ +if ($j > 1) { + echo "Available interfaces:\n\n"; + $x=1; + foreach($ifdescrs as $iface) { + echo "{$x} - {$iface}\n"; + $x++; } + echo "\nEnter the number of the interface you wish to configure: "; + $intnum = chop(fgets($fp)); +} else { + $intnum = $j; +} - if($intnum < 1) - exit; - if($intnum > $j) - exit; +if($intnum < 1) + exit; +if($intnum > $j) + exit; - $index = 1; - foreach ($ifdescrs as $ifname => $ifdesc) { - if ($intnum == $index) { - $interface = $ifname; - break; - } else { - $index++; - } - } - if(!$interface) { - echo "Invalid interface!\n"; - exit; +$index = 1; +foreach ($ifdescrs as $ifname => $ifdesc) { + if ($intnum == $index) { + $interface = $ifname; + break; + } else { + $index++; } +} +if(!$interface) { + echo "Invalid interface!\n"; + exit; +} - $ifaceassigned = ""; - do { - if($interface == "wan") { - $upperifname = strtoupper($interface); - echo gettext("Configure {$upperifname} interface via DHCP? [y|n]") . "\n> "; - $intdhcp = chop(fgets($fp)); - if(strtolower($intdhcp) == "y" || strtolower($intdhcp) == "yes") { - $ifppp = console_get_interface_from_ppp(get_real_interface("wan")); - if (!empty($ifppp)) - $ifaceassigned = $ifppp; - $intip = "dhcp"; - $intbits = ""; - $isintdhcp = true; - $restart_dhcpd = true; - } - } - - if($isintdhcp == false or $interface <> "wan") { - do { - $upperifname = strtoupper($interface); - echo "\n" . gettext("Enter the new {$upperifname} IPv4 address. Press <ENTER> for none:") . "\n> "; - $intip = chop(fgets($fp)); - $addr_blank = false; - } while (!(is_ipaddr($intip) || $intip == '')); - if ($intip != '') { - echo "\n" . gettext("Subnet masks are entered as bit counts (as in CIDR notation) in {$g['product_name']}.") . "\n"; - echo "e.g. 255.255.255.0 = 24\n"; - echo " 255.255.0.0 = 16\n"; - echo " 255.0.0.0 = 8\n"; - do { - $upperifname = strtoupper($interface); - echo "\n" . gettext("Enter the new {$upperifname} IPv4 subnet bit count:") . "\n> "; - $intbits = chop(fgets($fp)); - $restart_dhcpd = true; - } while (!is_numeric($intbits) || ($intbits < 1) || ($intbits > 31)); - } +$ifaceassigned = ""; +do { + if($interface == "wan") { + $upperifname = strtoupper($interface); + echo gettext("Configure {$upperifname} interface via DHCP? [y|n]") . "\n> "; + $intdhcp = chop(fgets($fp)); + if(strtolower($intdhcp) == "y" || strtolower($intdhcp) == "yes") { $ifppp = console_get_interface_from_ppp(get_real_interface("wan")); if (!empty($ifppp)) $ifaceassigned = $ifppp; + $intip = "dhcp"; + $intbits = ""; + $isintdhcp = true; + $restart_dhcpd = true; + } + } + + if($isintdhcp == false or $interface <> "wan") { + do { + $upperifname = strtoupper($interface); + echo "\n" . gettext("Enter the new {$upperifname} IPv4 address. Press <ENTER> for none:") . "\n> "; + $intip = chop(fgets($fp)); + $addr_blank = false; + } while (!(is_ipaddr($intip) || $intip == '')); + if ($intip != '') { + echo "\n" . gettext("Subnet masks are entered as bit counts (as in CIDR notation) in {$g['product_name']}.") . "\n"; + echo "e.g. 255.255.255.0 = 24\n"; + echo " 255.255.0.0 = 16\n"; + echo " 255.0.0.0 = 8\n"; + do { + $upperifname = strtoupper($interface); + echo "\n" . gettext("Enter the new {$upperifname} IPv4 subnet bit count:") . "\n> "; + $intbits = chop(fgets($fp)); + $restart_dhcpd = true; + } while (!is_numeric($intbits) || ($intbits < 1) || ($intbits > 31)); } + $ifppp = console_get_interface_from_ppp(get_real_interface("wan")); + if (!empty($ifppp)) + $ifaceassigned = $ifppp; + } - } while ($addr_blank); +} while ($addr_blank); - if (!empty($ifaceassigned)) - $config['interfaces'][$interface]['if'] = $ifaceassigned; - $config['interfaces'][$interface]['ipaddr'] = $intip; - $config['interfaces'][$interface]['subnet'] = $intbits; - $config['interfaces'][$interface]['enable'] = true; +if (!empty($ifaceassigned)) + $config['interfaces'][$interface]['if'] = $ifaceassigned; +$config['interfaces'][$interface]['ipaddr'] = $intip; +$config['interfaces'][$interface]['subnet'] = $intbits; +$config['interfaces'][$interface]['enable'] = true; - if($g['services_dhcp_server_enable']) - $yn = prompt_for_enable_dhcp_server(); +if($g['services_dhcp_server_enable']) + $yn = prompt_for_enable_dhcp_server(); - // TODO: Add DHCP IPv6 support - if ($yn == "y") { - do { - echo gettext("Enter the start address of the client address range:") . " "; - $dhcpstartip = chop(fgets($fp)); - if ($dhcpstartip === "") { - fclose($fp); - exit(0); - } - } while (!(is_ipaddr($dhcpstartip))); +// TODO: Add DHCP IPv6 support +if ($yn == "y") { + do { + echo gettext("Enter the start address of the client address range:") . " "; + $dhcpstartip = chop(fgets($fp)); + if ($dhcpstartip === "") { + fclose($fp); + exit(0); + } + } while (!(is_ipaddr($dhcpstartip))); - do { - echo gettext("Enter the end address of the client address range:") . " "; - $dhcpendip = chop(fgets($fp)); - if ($dhcpendip === "") { - fclose($fp); - exit(0); - } - } while (!(is_ipaddr($dhcpendip))); - $restart_dhcpd = true; - $config['dhcpd'][$interface]['enable'] = true; - $config['dhcpd'][$interface]['range']['from'] = $dhcpstartip; - $config['dhcpd'][$interface]['range']['to'] = $dhcpendip; - } else { - /* TODO - this line is causing a "Fatal error: Cannot unset - string offsets in /etc/rc.initial.setlanip" on below line - number */ - if($config['dhcpd'][$interface]) - unset($config['dhcpd'][$interface]['enable']); - echo "Disabling DHCPD..."; - services_dhcpd_configure(); - echo "Done!\n"; - } + do { + echo gettext("Enter the end address of the client address range:") . " "; + $dhcpendip = chop(fgets($fp)); + if ($dhcpendip === "") { + fclose($fp); + exit(0); + } + } while (!(is_ipaddr($dhcpendip))); + $restart_dhcpd = true; + $config['dhcpd'][$interface]['enable'] = true; + $config['dhcpd'][$interface]['range']['from'] = $dhcpstartip; + $config['dhcpd'][$interface]['range']['to'] = $dhcpendip; +} else { + /* TODO - this line is causing a "Fatal error: Cannot unset + string offsets in /etc/rc.initial.setlanip" on below line + number */ + if($config['dhcpd'][$interface]) + unset($config['dhcpd'][$interface]['enable']); + echo "Disabling DHCPD..."; + services_dhcpd_configure(); + echo "Done!\n"; +} - if ($config['system']['webgui']['protocol'] == "https") { +if ($config['system']['webgui']['protocol'] == "https") { - do { - $good = false; - echo "\n" . gettext("Do you want to revert to HTTP as the webConfigurator protocol? (y/n)") . " "; - $yn = strtolower(chop(fgets($fp))); - if ($yn[0] == "y" or $yn[0] == "n") - $good = true; - } while (!$good); + do { + $good = false; + echo "\n" . gettext("Do you want to revert to HTTP as the webConfigurator protocol? (y/n)") . " "; + $yn = strtolower(chop(fgets($fp))); + if ($yn[0] == "y" or $yn[0] == "n") + $good = true; + } while (!$good); - if ($yn == "y") { - $config['system']['webgui']['protocol'] = "http"; - $restart_webgui = true; - } + if ($yn == "y") { + $config['system']['webgui']['protocol'] = "http"; + $restart_webgui = true; } +} - if (isset($config['system']['webgui']['noantilockout'])) { - echo "\n" . gettext("Note: the anti-lockout rule on {$interface} has been re-enabled.") . "\n"; - unset($config['system']['webgui']['noantilockout']); - } +if (isset($config['system']['webgui']['noantilockout'])) { + echo "\n" . gettext("Note: the anti-lockout rule on {$interface} has been re-enabled.") . "\n"; + unset($config['system']['webgui']['noantilockout']); +} - if($config['interfaces']['lan']) { - if($config['dhcpd']) - if($config['dhcpd']['wan']) - unset($config['dhcpd']['wan']); - } +if($config['interfaces']['lan']) { + if($config['dhcpd']) + if($config['dhcpd']['wan']) + unset($config['dhcpd']['wan']); +} - if(!$config['interfaces']['lan']) { - unset($config['interfaces']['lan']); - if($config['dhcpd']['lan']) - unset($config['dhcpd']['lan']); - unset($config['shaper']); - unset($config['ezshaper']); - unset($config['nat']); - system("rm /var/dhcpd/var/db/* >/dev/null 2>/dev/null"); - services_dhcpd_configure(); - } +if(!$config['interfaces']['lan']) { + unset($config['interfaces']['lan']); + if($config['dhcpd']['lan']) + unset($config['dhcpd']['lan']); + unset($config['shaper']); + unset($config['ezshaper']); + unset($config['nat']); + system("rm /var/dhcpd/var/db/* >/dev/null 2>/dev/null"); + services_dhcpd_configure(); +} - $upperifname = strtoupper($interface); - echo "\nPlease wait while the changes are saved to {$upperifname}..."; - write_config(gettext("{$interface} IP configuration from console menu")); - interface_reconfigure(strtolower($upperifname)); - echo " Reloading filter..."; - filter_configure_sync(); - echo "\n"; - if($restart_dhcpd) { - echo " DHCPD..."; - services_dhcpd_configure(); - } - if($restart_webgui) { - echo " restarting webConfigurator... "; - mwexec("/etc/rc.restart_webgui"); - } +$upperifname = strtoupper($interface); +echo "\nPlease wait while the changes are saved to {$upperifname}..."; +write_config(gettext("{$interface} IP configuration from console menu")); +interface_reconfigure(strtolower($upperifname)); +echo " Reloading filter..."; +filter_configure_sync(); +echo "\n"; +if($restart_dhcpd) { + echo " DHCPD..."; + services_dhcpd_configure(); +} +if($restart_webgui) { + echo " restarting webConfigurator... "; + mwexec("/etc/rc.restart_webgui"); +} - if ($intip != '') { - if (is_ipaddr($intip)) { - echo "\n\n" . gettext("The IPv4 {$upperifname} address has been set to ") . "{$intip}/{$intbits}\n"; - } else { - echo "\n\n" . gettext("The IPv4 {$upperifname} address has been set to ") . "{$intip}\n"; +if ($intip != '') { + if (is_ipaddr($intip)) { + echo "\n\n" . gettext("The IPv4 {$upperifname} address has been set to ") . "{$intip}/{$intbits}\n"; + } else { + echo "\n\n" . gettext("The IPv4 {$upperifname} address has been set to ") . "{$intip}\n"; + } + if (count($ifdescrs) == "1" or $interface = "lan") { + if ($debug) { + echo "ifdescrs count is " . count($ifdescrs) . "\n"; + echo "interface is {$interface} \n"; } - if (count($ifdescrs) == "1" or $interface = "lan") { - if ($debug) { - echo "ifdescrs count is " . count($ifdescrs) . "\n"; - echo "interface is {$interface} \n"; - } - echo gettext('You can now access the webConfigurator by opening the following URL in your web browser:') . "\n"; - if(!empty($config['system']['webgui']['port'])) { - $webuiport = $config['system']['webgui']['port']; - echo " {$config['system']['webgui']['protocol']}://{$intip}:{$port}/\n"; - } else { - echo " {$config['system']['webgui']['protocol']}://{$intip}/\n"; - } + echo gettext('You can now access the webConfigurator by opening the following URL in your web browser:') . "\n"; + if(!empty($config['system']['webgui']['port'])) { + $webuiport = $config['system']['webgui']['port']; + echo " {$config['system']['webgui']['protocol']}://{$intip}:{$port}/\n"; + } else { + echo " {$config['system']['webgui']['protocol']}://{$intip}/\n"; } } +} - echo "\n" . gettext('Press <ENTER> to continue.'); +echo "\n" . gettext('Press <ENTER> to continue.'); - fgets($fp); - fclose($fp); +fgets($fp); +fclose($fp); ?> |