Commit b4a0c4bc authored by Franco Fichtner's avatar Franco Fichtner

rc.initial: apply PSR2 style

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