diff options
Diffstat (limited to 'usr/local')
-rwxr-xr-x | usr/local/sbin/pfSsh.php | 111 |
1 files changed, 61 insertions, 50 deletions
diff --git a/usr/local/sbin/pfSsh.php b/usr/local/sbin/pfSsh.php index 002da35..f3fe9be 100755 --- a/usr/local/sbin/pfSsh.php +++ b/usr/local/sbin/pfSsh.php @@ -13,62 +13,66 @@ require("config.inc"); echo "."; $g['booting'] = false; +function show_help() { + echo "\nExample commands:\n"; + + echo "\n/* to output a configuration array */\n"; + echo "print_r(\$config);\n"; + + echo "\n/* to output the interfaces configuration portion of the configuration */\n"; + echo "print_r(\$config['interfaces']);\n"; + + echo "\n/* to output the dhcp server configuration */\n"; + echo "print_r(\$config['dhcpd']);\n"; + + echo "\n/* to enable multiline input mode */\n"; + echo "multiline\n"; + + echo "\n/* to exit the php pfSense shell */\n"; + echo "exit\n"; + + echo "\n/* to output supported wireless modes for an interface */\n"; + echo "print_r(get_wireless_modes(\"ath0\"));\n"; + + echo "\n/* to enable SSH */\n"; + echo "\$config['system']['enablesshd'] = true;\n"; + + echo "\n/* change OPTX to the OPT interface name such as BACKHAUL */\n"; + echo "\$config['interfaces']['optx']['wireless']['standard'] = \"11a\";\n"; + echo "\$config['interfaces']['optx']['wireless']['mode'] = \"hostap\";\n"; + echo "\$config['interfaces']['optx']['wireless']['channel'] = \"6\";\n"; + + echo "\n/* to enable dhcp server for an optx interface */\n"; + echo "\$config['dhcpd']['optx']['enable'] = true;\n"; + echo "\$config['dhcpd']['optx']['range']['from'] = \"192.168.31.100\";\n"; + echo "\$config['dhcpd']['optx']['range']['to'] = \"192.168.31.150\";\n"; + + echo "\n/* to disable the firewall filter */\n"; + echo "\$config['system']['disablefilter'] = true;\n"; + + echo "\n/* to enable an interface and set it for dhcp */\n"; + echo "\$config['interfaces']['optx']['disabled'] = false;\n"; + echo "\$config['interfaces']['optx']['ipaddr'] = \"dhcp\";\n"; + + echo "\n/* to enable an interface and set a static ip address */\n"; + echo "\$config['interfaces']['wan']['disabled'] = false;\n"; + echo "\$config['interfaces']['wan']['ipaddr'] = \"192.168.100.1\";\n"; + echo "\$config['interfaces']['wan']['subnet'] = \"24\";\n"; + + echo "\n/* to save out the new configuration (config.xml) */\n"; + echo "write_config();\n"; + + echo "\n/* to reboot the system after saving */\n"; + echo "system_reboot_sync();"; +} + $fp = fopen('php://stdin', 'r'); echo ".\n\n"; $shell_active = true; -echo "\nExample commands:\n"; - -echo "\n/* to output a configuration array */\n"; -echo "print_r(\$config);\n"; - -echo "\n/* to output the interfaces configuration portion of the configuration */\n"; -echo "print_r(\$config['interfaces']);\n"; - -echo "\n/* to output the dhcp server configuration */\n"; -echo "print_r(\$config['dhcpd']);\n"; - -echo "\n/* to enable multiline input mode */\n"; -echo "multiline\n"; - -echo "\n/* to exit the php pfSense shell */\n"; -echo "exit\n"; - -echo "\n/* to output supported wireless modes for an interface */\n"; -echo "print_r(get_wireless_modes(\"ath0\"));\n"; - -echo "\n/* to enable SSH */\n"; -echo "\$config['system']['enablesshd'] = true;\n"; - -echo "\n/* change OPTX to the OPT interface name such as BACKHAUL */\n"; -echo "\$config['interfaces']['optx']['wireless']['standard'] = \"11a\";\n"; -echo "\$config['interfaces']['optx']['wireless']['mode'] = \"hostap\";\n"; -echo "\$config['interfaces']['optx']['wireless']['channel'] = \"6\";\n"; - -echo "\n/* to enable dhcp server for an optx interface */\n"; -echo "\$config['dhcpd']['optx']['enable'] = true;\n"; -echo "\$config['dhcpd']['optx']['range']['from'] = \"192.168.31.100\";\n"; -echo "\$config['dhcpd']['optx']['range']['to'] = \"192.168.31.150\";\n"; - -echo "\n/* to disable the firewall filter */\n"; -echo "\$config['system']['disablefilter'] = true;\n"; - -echo "\n/* to enable an interface and set it for dhcp */\n"; -echo "\$config['interfaces']['optx']['disabled'] = false;\n"; -echo "\$config['interfaces']['optx']['ipaddr'] = \"dhcp\";\n"; - -echo "\n/* to enable an interface and set a static ip address */\n"; -echo "\$config['interfaces']['wan']['disabled'] = false;\n"; -echo "\$config['interfaces']['wan']['ipaddr'] = \"192.168.100.1\";\n"; -echo "\$config['interfaces']['wan']['subnet'] = \"24\";\n"; - -echo "\n/* to save out the new configuration (config.xml) */\n"; -echo "write_config();\n"; - -echo "\n/* to reboot the system after saving */\n"; -echo "system_reboot_sync();"; +echo "Type \"help\" to show common usage scnenarios."; while($shell_active == true) { echo "\n\npfSense shell> "; @@ -78,6 +82,10 @@ while($shell_active == true) { echo "\n"; break; } + if($command == "help") { + show_help(); + $command = ""; + } if($command == "multiline" or $command == "ml") { echo "\nmultiline mode enabled. enter EOF on a blank line to execute.\n\n"; $command = ""; @@ -86,6 +94,8 @@ while($shell_active == true) { while($command <> "EOF") { echo "pfSense multiline shell[$xxxyzyz]> "; $command = chop(fgets($fp)); + if($command == "help") + show_help(); if($command == "exit") die; if($command <> "EOF") @@ -99,3 +109,4 @@ while($shell_active == true) { eval($command); } } + |