Revision 46d53988
Added by Scott Ullrich over 18 years ago
usr/local/sbin/pfSsh.php | ||
---|---|---|
13 | 13 |
echo "."; |
14 | 14 |
$g['booting'] = false; |
15 | 15 |
|
16 |
function show_help() { |
|
17 |
echo "\nExample commands:\n"; |
|
18 |
|
|
19 |
echo "\n/* to output a configuration array */\n"; |
|
20 |
echo "print_r(\$config);\n"; |
|
21 |
|
|
22 |
echo "\n/* to output the interfaces configuration portion of the configuration */\n"; |
|
23 |
echo "print_r(\$config['interfaces']);\n"; |
|
24 |
|
|
25 |
echo "\n/* to output the dhcp server configuration */\n"; |
|
26 |
echo "print_r(\$config['dhcpd']);\n"; |
|
27 |
|
|
28 |
echo "\n/* to enable multiline input mode */\n"; |
|
29 |
echo "multiline\n"; |
|
30 |
|
|
31 |
echo "\n/* to exit the php pfSense shell */\n"; |
|
32 |
echo "exit\n"; |
|
33 |
|
|
34 |
echo "\n/* to output supported wireless modes for an interface */\n"; |
|
35 |
echo "print_r(get_wireless_modes(\"ath0\"));\n"; |
|
36 |
|
|
37 |
echo "\n/* to enable SSH */\n"; |
|
38 |
echo "\$config['system']['enablesshd'] = true;\n"; |
|
39 |
|
|
40 |
echo "\n/* change OPTX to the OPT interface name such as BACKHAUL */\n"; |
|
41 |
echo "\$config['interfaces']['optx']['wireless']['standard'] = \"11a\";\n"; |
|
42 |
echo "\$config['interfaces']['optx']['wireless']['mode'] = \"hostap\";\n"; |
|
43 |
echo "\$config['interfaces']['optx']['wireless']['channel'] = \"6\";\n"; |
|
44 |
|
|
45 |
echo "\n/* to enable dhcp server for an optx interface */\n"; |
|
46 |
echo "\$config['dhcpd']['optx']['enable'] = true;\n"; |
|
47 |
echo "\$config['dhcpd']['optx']['range']['from'] = \"192.168.31.100\";\n"; |
|
48 |
echo "\$config['dhcpd']['optx']['range']['to'] = \"192.168.31.150\";\n"; |
|
49 |
|
|
50 |
echo "\n/* to disable the firewall filter */\n"; |
|
51 |
echo "\$config['system']['disablefilter'] = true;\n"; |
|
52 |
|
|
53 |
echo "\n/* to enable an interface and set it for dhcp */\n"; |
|
54 |
echo "\$config['interfaces']['optx']['disabled'] = false;\n"; |
|
55 |
echo "\$config['interfaces']['optx']['ipaddr'] = \"dhcp\";\n"; |
|
56 |
|
|
57 |
echo "\n/* to enable an interface and set a static ip address */\n"; |
|
58 |
echo "\$config['interfaces']['wan']['disabled'] = false;\n"; |
|
59 |
echo "\$config['interfaces']['wan']['ipaddr'] = \"192.168.100.1\";\n"; |
|
60 |
echo "\$config['interfaces']['wan']['subnet'] = \"24\";\n"; |
|
61 |
|
|
62 |
echo "\n/* to save out the new configuration (config.xml) */\n"; |
|
63 |
echo "write_config();\n"; |
|
64 |
|
|
65 |
echo "\n/* to reboot the system after saving */\n"; |
|
66 |
echo "system_reboot_sync();"; |
|
67 |
} |
|
68 |
|
|
16 | 69 |
$fp = fopen('php://stdin', 'r'); |
17 | 70 |
|
18 | 71 |
echo ".\n\n"; |
19 | 72 |
|
20 | 73 |
$shell_active = true; |
21 | 74 |
|
22 |
echo "\nExample commands:\n"; |
|
23 |
|
|
24 |
echo "\n/* to output a configuration array */\n"; |
|
25 |
echo "print_r(\$config);\n"; |
|
26 |
|
|
27 |
echo "\n/* to output the interfaces configuration portion of the configuration */\n"; |
|
28 |
echo "print_r(\$config['interfaces']);\n"; |
|
29 |
|
|
30 |
echo "\n/* to output the dhcp server configuration */\n"; |
|
31 |
echo "print_r(\$config['dhcpd']);\n"; |
|
32 |
|
|
33 |
echo "\n/* to enable multiline input mode */\n"; |
|
34 |
echo "multiline\n"; |
|
35 |
|
|
36 |
echo "\n/* to exit the php pfSense shell */\n"; |
|
37 |
echo "exit\n"; |
|
38 |
|
|
39 |
echo "\n/* to output supported wireless modes for an interface */\n"; |
|
40 |
echo "print_r(get_wireless_modes(\"ath0\"));\n"; |
|
41 |
|
|
42 |
echo "\n/* to enable SSH */\n"; |
|
43 |
echo "\$config['system']['enablesshd'] = true;\n"; |
|
44 |
|
|
45 |
echo "\n/* change OPTX to the OPT interface name such as BACKHAUL */\n"; |
|
46 |
echo "\$config['interfaces']['optx']['wireless']['standard'] = \"11a\";\n"; |
|
47 |
echo "\$config['interfaces']['optx']['wireless']['mode'] = \"hostap\";\n"; |
|
48 |
echo "\$config['interfaces']['optx']['wireless']['channel'] = \"6\";\n"; |
|
49 |
|
|
50 |
echo "\n/* to enable dhcp server for an optx interface */\n"; |
|
51 |
echo "\$config['dhcpd']['optx']['enable'] = true;\n"; |
|
52 |
echo "\$config['dhcpd']['optx']['range']['from'] = \"192.168.31.100\";\n"; |
|
53 |
echo "\$config['dhcpd']['optx']['range']['to'] = \"192.168.31.150\";\n"; |
|
54 |
|
|
55 |
echo "\n/* to disable the firewall filter */\n"; |
|
56 |
echo "\$config['system']['disablefilter'] = true;\n"; |
|
57 |
|
|
58 |
echo "\n/* to enable an interface and set it for dhcp */\n"; |
|
59 |
echo "\$config['interfaces']['optx']['disabled'] = false;\n"; |
|
60 |
echo "\$config['interfaces']['optx']['ipaddr'] = \"dhcp\";\n"; |
|
61 |
|
|
62 |
echo "\n/* to enable an interface and set a static ip address */\n"; |
|
63 |
echo "\$config['interfaces']['wan']['disabled'] = false;\n"; |
|
64 |
echo "\$config['interfaces']['wan']['ipaddr'] = \"192.168.100.1\";\n"; |
|
65 |
echo "\$config['interfaces']['wan']['subnet'] = \"24\";\n"; |
|
66 |
|
|
67 |
echo "\n/* to save out the new configuration (config.xml) */\n"; |
|
68 |
echo "write_config();\n"; |
|
69 |
|
|
70 |
echo "\n/* to reboot the system after saving */\n"; |
|
71 |
echo "system_reboot_sync();"; |
|
75 |
echo "Type \"help\" to show common usage scnenarios."; |
|
72 | 76 |
|
73 | 77 |
while($shell_active == true) { |
74 | 78 |
echo "\n\npfSense shell> "; |
... | ... | |
78 | 82 |
echo "\n"; |
79 | 83 |
break; |
80 | 84 |
} |
85 |
if($command == "help") { |
|
86 |
show_help(); |
|
87 |
$command = ""; |
|
88 |
} |
|
81 | 89 |
if($command == "multiline" or $command == "ml") { |
82 | 90 |
echo "\nmultiline mode enabled. enter EOF on a blank line to execute.\n\n"; |
83 | 91 |
$command = ""; |
... | ... | |
86 | 94 |
while($command <> "EOF") { |
87 | 95 |
echo "pfSense multiline shell[$xxxyzyz]> "; |
88 | 96 |
$command = chop(fgets($fp)); |
97 |
if($command == "help") |
|
98 |
show_help(); |
|
89 | 99 |
if($command == "exit") |
90 | 100 |
die; |
91 | 101 |
if($command <> "EOF") |
... | ... | |
99 | 109 |
eval($command); |
100 | 110 |
} |
101 | 111 |
} |
112 |
|
Also available in: Unified diff
Move help / common usage scenarios to the "help" command.