summaryrefslogtreecommitdiffstats
path: root/etc/rc.initial.setports
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2004-11-21 06:34:47 +0000
committerScott Ullrich <sullrich@pfsense.org>2004-11-21 06:34:47 +0000
commit9425bdc12b384e795927b0c7f7d5ba2cb5ada18d (patch)
tree6bb190e0244eca43706e467b1c482936f2a048bd /etc/rc.initial.setports
parent2e9ab96b89a7fc5fcb766bbbfe45fd2a8442b380 (diff)
downloadpfsense-9425bdc12b384e795927b0c7f7d5ba2cb5ada18d.zip
pfsense-9425bdc12b384e795927b0c7f7d5ba2cb5ada18d.tar.gz
"The firewall" -> pfSense
Diffstat (limited to 'etc/rc.initial.setports')
-rwxr-xr-xetc/rc.initial.setports114
1 files changed, 57 insertions, 57 deletions
diff --git a/etc/rc.initial.setports b/etc/rc.initial.setports
index 049879a..205c5b0 100755
--- a/etc/rc.initial.setports
+++ b/etc/rc.initial.setports
@@ -3,20 +3,20 @@
/*
rc.initial.setports
part of m0n0wall (http://m0n0.ch/wall)
-
+
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -32,11 +32,11 @@
/* parse the configuration and include all functions used below */
require_once("config.inc");
require_once("functions.inc");
-
+
$fp = fopen('php://stdin', 'r');
-
+
$iflist = get_interface_list();
-
+
echo <<<EOD
Valid interfaces are:
@@ -48,33 +48,33 @@ EOD;
echo sprintf("% -8s%s%s\n", $iface, $ifa['mac'],
$ifa['up'] ? " (up)" : "");
}
-
+
echo <<<EOD
Do you want to set up VLANs first?
If you're not going to use VLANs, or only for optional interfaces, you
should say no here and use the webGUI to configure VLANs later, if required.
-Do you want to set up VLANs now? (y/n)
+Do you want to set up VLANs now? (y/n)
EOD;
-
+
if (strcasecmp(chop(fgets($fp)), "y") == 0)
vlan_setup();
-
+
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
-
+
echo "\n\nVLAN interfaces:\n\n";
$i = 0;
foreach ($config['vlans']['vlan'] as $vlan) {
-
+
echo sprintf("% -8s%s\n", "vlan{$i}",
"VLAN tag {$vlan['tag']}, interface {$vlan['if']}");
-
+
$iflist['vlan' . $i] = array();
$i++;
}
}
-
+
echo <<<EOD
If you don't know the names of your interfaces, you may choose to use
@@ -82,14 +82,14 @@ auto-detection. In that case, disconnect all interfaces before you begin,
and reconnect each one when prompted to do so.
EOD;
-
+
do {
echo "\nEnter the LAN interface name or 'a' for auto-detection: ";
$lanif = chop(fgets($fp));
if ($lanif === "") {
exit(0);
}
-
+
if ($lanif === "a")
$lanif = autodetect_interface("LAN", $fp);
else if (!array_key_exists($lanif, $iflist)) {
@@ -98,7 +98,7 @@ EOD;
continue;
}
} while (!$lanif);
-
+
do {
echo "\nEnter the WAN interface name or 'a' for auto-detection: ";
$wanif = chop(fgets($fp));
@@ -113,11 +113,11 @@ EOD;
continue;
}
} while (!$wanif);
-
+
/* optional interfaces */
$i = 0;
$optif = array();
-
+
while (1) {
if ($optif[$i])
$i++;
@@ -125,7 +125,7 @@ EOD;
echo "\nEnter the Optional {$i1} interface name or 'a' for auto-detection\n" .
"(or nothing if finished): ";
$optif[$i] = chop(fgets($fp));
-
+
if ($optif[$i]) {
if ($optif[$i] === "a") {
$ad = autodetect_interface("Optional " . $i1, $fp);
@@ -143,15 +143,15 @@ EOD;
break;
}
}
-
+
/* check for double assignments */
$ifarr = array_merge(array($lanif, $wanif), $optif);
-
+
for ($i = 0; $i < (count($ifarr)-1); $i++) {
for ($j = ($i+1); $j < count($ifarr); $j++) {
if ($ifarr[$i] == $ifarr[$j]) {
echo <<<EOD
-
+
Error: you can't assign the same interface name twice!
EOD;
@@ -160,9 +160,9 @@ EOD;
}
}
}
-
+
echo <<<EOD
-
+
The interfaces will be assigned as follows:
LAN -> {$lanif}
@@ -176,13 +176,13 @@ EOD;
echo <<<EOD
-The firewall will reboot after saving the changes.
+pfSense will reboot after saving the changes.
-Do you want to proceed? (y/n)
+Do you want to proceed? (y/n)
EOD;
-
+
if (strcasecmp(chop(fgets($fp)), "y") == 0) {
-
+
$config['interfaces']['lan']['if'] = $lanif;
if (preg_match("/^(wi|awi|an)/", $lanif)) {
if (!is_array($config['interfaces']['lan']['wireless']))
@@ -190,7 +190,7 @@ EOD;
} else {
unset($config['interfaces']['lan']['wireless']);
}
-
+
$config['interfaces']['wan']['if'] = $wanif;
if (preg_match("/^(wi|awi|an)/", $wanif)) {
if (!is_array($config['interfaces']['wan']['wireless']))
@@ -198,13 +198,13 @@ EOD;
} else {
unset($config['interfaces']['wan']['wireless']);
}
-
+
for ($i = 0; $i < count($optif); $i++) {
if (!is_array($config['interfaces']['opt' . ($i+1)]))
$config['interfaces']['opt' . ($i+1)] = array();
-
+
$config['interfaces']['opt' . ($i+1)]['if'] = $optif[$i];
-
+
/* wireless interface? */
if (preg_match("/^(wi|awi|an)/", $optif[$i])) {
if (!is_array($config['interfaces']['opt' . ($i+1)]['wireless']))
@@ -212,26 +212,26 @@ EOD;
} else {
unset($config['interfaces']['opt' . ($i+1)]['wireless']);
}
-
+
unset($config['interfaces']['opt' . ($i+1)]['enable']);
$config['interfaces']['opt' . ($i+1)]['descr'] = "OPT" . ($i+1);
}
-
+
/* remove all other (old) optional interfaces */
for (; isset($config['interfaces']['opt' . ($i+1)]); $i++)
unset($config['interfaces']['opt' . ($i+1)]);
-
+
write_config();
-
+
echo <<<EOD
-The firewall is rebooting now.
+pfSense is rebooting now.
EOD;
-
+
system_reboot_sync();
}
-
+
function autodetect_interface($ifname, $fp) {
$iflist_prev = get_interface_list();
echo <<<EOD
@@ -242,44 +242,44 @@ Then press ENTER to continue.
EOD;
fgets($fp);
$iflist = get_interface_list();
-
+
foreach ($iflist_prev as $ifn => $ifa) {
if (!$ifa['up'] && $iflist[$ifn]['up']) {
echo "Detected link-up on interface {$ifn}.\n";
return $ifn;
}
}
-
+
echo "No link-up detected.\n";
-
+
return null;
}
-
+
function vlan_setup() {
global $iflist, $config, $g, $fp;
-
+
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
-
+
echo <<<EOD
WARNING: all existing VLANs will be cleared if you proceed!
-Do you want to proceed? (y/n)
+Do you want to proceed? (y/n)
EOD;
-
+
if (strcasecmp(chop(fgets($fp)), "y") != 0)
return;
}
-
+
$config['vlans']['vlan'] = array();
echo "\n";
-
+
while (1) {
$vlan = array();
-
+
echo "\nEnter the parent interface name for the new VLAN (or nothing if finished): ";
$vlan['if'] = chop(fgets($fp));
-
+
if ($vlan['if']) {
if (!array_key_exists($vlan['if'], $iflist)) {
echo "\nInvalid interface name '{$vlan['if']}'\n";
@@ -288,15 +288,15 @@ EOD;
} else {
break;
}
-
+
echo "Enter the VLAN tag (1-4094): ";
$vlan['tag'] = chop(fgets($fp));
-
+
if (!is_numericint($vlan['tag']) || ($vlan['tag'] < 1) || ($vlan['tag'] > 4094)) {
echo "\nInvalid VLAN tag '{$vlan['tag']}'\n";
continue;
}
-
+
$config['vlans']['vlan'][] = $vlan;
}
}
OpenPOWER on IntegriCloud