Commit bf8356c9 authored by Franco Fichtner's avatar Franco Fichtner

rc.initial: apply PSR2 style

parent 0fe885b9
...@@ -44,80 +44,82 @@ print "\n*** Welcome to {$product} {$version} ({$machine}/${flavour}) on {$hostn ...@@ -44,80 +44,82 @@ print "\n*** Welcome to {$product} {$version} ({$machine}/${flavour}) on {$hostn
$iflist = get_configured_interface_with_descr(false, true); $iflist = get_configured_interface_with_descr(false, true);
if (empty($iflist)) { if (empty($iflist)) {
printf("\n\tNo network interfaces are assigned.\n"); printf("\n\tNo network interfaces are assigned.\n");
return; return;
} }
foreach($iflist as $ifname => $friendly) { foreach ($iflist as $ifname => $friendly) {
/* point to this interface's config */ /* point to this interface's config */
$ifconf = $config['interfaces'][$ifname]; $ifconf = $config['interfaces'][$ifname];
/* look for 'special cases' */ /* look for 'special cases' */
$class = ""; $class = "";
if (isset($ifconf['ipaddr'])) { if (isset($ifconf['ipaddr'])) {
switch($ifconf['ipaddr']) { switch ($ifconf['ipaddr']) {
case "dhcp": case "dhcp":
$class = "/DHCP4"; $class = "/DHCP4";
break; break;
case "pppoe": case "pppoe":
$class = "/PPPoE"; $class = "/PPPoE";
break; break;
case "pptp": case "pptp":
$class = "/PPTP"; $class = "/PPTP";
break; break;
case "l2tp": case "l2tp":
$class = "/L2TP"; $class = "/L2TP";
break; break;
} }
} }
$class6 = null; $class6 = null;
if (isset($ifconf['ipaddrv6'])) { if (isset($ifconf['ipaddrv6'])) {
switch($ifconf['ipaddrv6']) { switch ($ifconf['ipaddrv6']) {
case "dhcp6": case "dhcp6":
$class6 = "/DHCP6"; $class6 = "/DHCP6";
break; break;
case "slaac": case "slaac":
$class6 = "/SLAAC"; $class6 = "/SLAAC";
break; break;
case "6rd": case "6rd":
$class6 = "/6RD"; $class6 = "/6RD";
break; break;
case "6to4": case "6to4":
$class6 = "/6to4"; $class6 = "/6to4";
break; break;
case "track6": case "track6":
$class6 = "/t6"; $class6 = "/t6";
break; break;
} }
} }
$ipaddr = get_interface_ip($ifname); $ipaddr = get_interface_ip($ifname);
$subnet = get_interface_subnet($ifname); $subnet = get_interface_subnet($ifname);
$ipaddr6 = get_interface_ipv6($ifname); $ipaddr6 = get_interface_ipv6($ifname);
$subnet6 = get_interface_subnetv6($ifname); $subnet6 = get_interface_subnetv6($ifname);
$realif = get_real_interface($ifname); $realif = get_real_interface($ifname);
$tobanner = "{$friendly} ({$realif})"; $tobanner = "{$friendly} ({$realif})";
printf("\n %-15s -> ", $tobanner); printf("\n %-15s -> ", $tobanner);
$v6first = false; $v6first = false;
if (!empty($ipaddr) && !empty($subnet)) { if (!empty($ipaddr) && !empty($subnet)) {
printf("v4%s: %s/%s", printf(
$class, "v4%s: %s/%s",
$ipaddr, $class,
$subnet $ipaddr,
); $subnet
} else { );
$v6first = true; } else {
} $v6first = true;
if (!empty($ipaddr6) && !empty($subnet6)) { }
if (!$v6first) { if (!empty($ipaddr6) && !empty($subnet6)) {
printf("\n%s", str_repeat(" ", 20)); if (!$v6first) {
} printf("\n%s", str_repeat(" ", 20));
printf("v6%s: %s/%s", }
$class6, printf(
$ipaddr6, "v6%s: %s/%s",
$subnet6 $class6,
); $ipaddr6,
} $subnet6
);
}
} }
printf("\n"); printf("\n");
...@@ -43,7 +43,7 @@ Do you want to proceed {$yes_no_prompt} ...@@ -43,7 +43,7 @@ Do you want to proceed {$yes_no_prompt}
EOD; EOD;
if (strcasecmp(chop(fgets($fp)), 'y') == 0) { if (strcasecmp(chop(fgets($fp)), 'y') == 0) {
reset_factory_defaults(); reset_factory_defaults();
} }
fclose($fp); fclose($fp);
...@@ -38,7 +38,7 @@ echo "This may take a minute, depending on your hardware.\n"; ...@@ -38,7 +38,7 @@ echo "This may take a minute, depending on your hardware.\n";
echo "\nDo you want to proceed [y|n]? "; echo "\nDo you want to proceed [y|n]? ";
if (strcasecmp(chop(fgets($fp)), 'y') == 0) { if (strcasecmp(chop(fgets($fp)), 'y') == 0) {
system_halt(true); system_halt(true);
} }
fclose($fp); fclose($fp);
...@@ -33,49 +33,50 @@ require_once('auth.inc'); ...@@ -33,49 +33,50 @@ require_once('auth.inc');
$fp = fopen('php://stdin', 'r'); $fp = fopen('php://stdin', 'r');
printf( printf(
gettext('The %s password will be reset to the factory default of `%s\'.'), gettext('The %s password will be reset to the factory default of `%s\'.'),
$g['factory_shipped_username'], $g['factory_shipped_username'],
$g['factory_shipped_password'] $g['factory_shipped_password']
); );
printf("\n\n"); printf("\n\n");
printf(gettext('Do you want to proceed [y|n]? ')); printf(gettext('Do you want to proceed [y|n]? '));
if (strcasecmp(chop(fgets($fp)), 'y') == 0) { if (strcasecmp(chop(fgets($fp)), 'y') == 0) {
if (isset($config['system']['webgui']['authmode']) && if (isset($config['system']['webgui']['authmode']) &&
$config['system']['webgui']['authmode'] != 'Local Database') { $config['system']['webgui']['authmode'] != 'Local Database') {
printf("\n\n"); printf("\n\n");
printf(gettext('The User manager authentication server is set to "%s".'), $config['system']['webgui']['authmode']); printf(gettext('The User manager authentication server is set to "%s".'), $config['system']['webgui']['authmode']);
printf("\n"); printf("\n");
printf(gettext('Do you want to set it back to Local Database [y|n]? ')); printf(gettext('Do you want to set it back to Local Database [y|n]? '));
if (strcasecmp(chop(fgets($fp)), 'y') == 0) { if (strcasecmp(chop(fgets($fp)), 'y') == 0) {
$config['system']['webgui']['authmode'] = 'Local Database'; $config['system']['webgui']['authmode'] = 'Local Database';
} }
} }
$admin_user =& getUserEntryByUID(0); $admin_user =& getUserEntryByUID(0);
if (!$admin_user) { if (!$admin_user) {
echo "Failed to locate the admin user account! Attempting to restore access.\n"; echo "Failed to locate the admin user account! Attempting to restore access.\n";
$admin_user = array(); $admin_user = array();
$admin_user['uid'] = 0; $admin_user['uid'] = 0;
if (!isset($config['system']['user'])) if (!isset($config['system']['user'])) {
$config['system']['user'] = array(); $config['system']['user'] = array();
$config['system']['user'][] = $admin_user; }
} $config['system']['user'][] = $admin_user;
}
$admin_user['name'] = $g['factory_shipped_username']; $admin_user['name'] = $g['factory_shipped_username'];
$admin_user['priv'] = array('user-shell-access'); $admin_user['priv'] = array('user-shell-access');
$admin_user['scope'] = 'system'; $admin_user['scope'] = 'system';
if (isset($admin_user['disabled'])) { if (isset($admin_user['disabled'])) {
unset($admin_user['disabled']); unset($admin_user['disabled']);
} }
local_user_set_password($admin_user, $g['factory_shipped_password']); local_user_set_password($admin_user, $g['factory_shipped_password']);
local_user_set($admin_user); local_user_set($admin_user);
write_config($config, gettext("password changed from console menu")); write_config($config, gettext("password changed from console menu"));
printf("\n\n"); printf("\n\n");
printf(gettext("The password has been reset.")); printf(gettext("The password has been reset."));
printf("\n"); printf("\n");
printf(gettext("Please change the password as soon as you log in!")); printf(gettext("Please change the password as soon as you log in!"));
printf("\n\n"); printf("\n\n");
} }
...@@ -37,15 +37,15 @@ echo "\nEnter a host name or IP address: "; ...@@ -37,15 +37,15 @@ echo "\nEnter a host name or IP address: ";
$pinghost = chop(fgets($fp)); $pinghost = chop(fgets($fp));
if (is_ipaddrv4($pinghost) || is_hostname($pinghost)) { if (is_ipaddrv4($pinghost) || is_hostname($pinghost)) {
$command = "ping"; $command = "ping";
} elseif (is_ipaddrv6($pinghost)) { } elseif (is_ipaddrv6($pinghost)) {
$command = "ping6"; $command = "ping6";
} }
if ($command) { if ($command) {
echo "\n"; echo "\n";
passthru("/sbin/{$command} -c 3 -n " . escapeshellarg($pinghost)); passthru("/sbin/{$command} -c 3 -n " . escapeshellarg($pinghost));
echo "\nPress ENTER to continue.\n"; echo "\nPress ENTER to continue.\n";
fgets($fp); fgets($fp);
} }
fclose($fp); fclose($fp);
...@@ -38,7 +38,7 @@ echo "This may take a minute, depending on your hardware.\n"; ...@@ -38,7 +38,7 @@ echo "This may take a minute, depending on your hardware.\n";
echo "\nDo you want to proceed [y|n]? "; echo "\nDo you want to proceed [y|n]? ";
if (strcasecmp(chop(fgets($fp)), 'y') == 0) { if (strcasecmp(chop(fgets($fp)), 'y') == 0) {
system_reboot(true); system_reboot(true);
} }
fclose($fp); fclose($fp);
This diff is collapsed.
...@@ -42,11 +42,11 @@ require_once("pfsense-utils.inc"); ...@@ -42,11 +42,11 @@ require_once("pfsense-utils.inc");
require_once("unbound.inc"); require_once("unbound.inc");
if (set_networking_interfaces_ports()) { if (set_networking_interfaces_ports()) {
echo "Reloading interfaces..."; echo "Reloading interfaces...";
global $config; global $config;
$config = parse_config(); $config = parse_config();
system_routing_enable(); system_routing_enable();
interfaces_configure(); interfaces_configure();
echo "done.\n"; echo "done.\n";
enable_rrd_graphing(); enable_rrd_graphing();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment