tazpanel view network.cgi @ rev 475

network.cgi: add ether-wake support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri May 01 23:56:00 2015 +0200 (2015-05-01)
parents c23efdafb18d
children a15936aa1275
line source
1 #!/bin/sh
2 #
3 # Network configuration CGI interface
4 #
5 # Copyright (C) 2012-2015 SliTaz GNU/Linux - BSD License
6 #
9 # Common functions from libtazpanel
11 . lib/libtazpanel
12 get_config
13 header
15 TITLE=$(_ 'TazPanel - Network')
18 # Start a Wi-Fi connection
20 start_wifi() {
21 sed -i \
22 -e 's|^WIFI=.*|WIFI="yes"|' \
23 -e 's|^DHCP=.*|DHCP="yes"|' \
24 -e 's|^STATIC=.*|STATIC="no"|' /etc/network.conf
25 ifconfig $WIFI_INTERFACE up
26 iwconfig $WIFI_INTERFACE txpower auto
27 /etc/init.d/network.sh restart | log
29 # Sleep until connection established (max 5 seconds)
30 for i in $(seq 5); do
31 [ -n "$(iwconfig 2>/dev/null | fgrep Link)" ] && break
32 sleep 1
33 done
34 }
37 # Start an Ethernet connection
39 start_eth() {
40 case "$(GET staticip)" in
41 on) DHCP='no'; STATIC='yes';;
42 *) DHCP='yes'; STATIC='no';;
43 esac
45 /etc/init.d/network.sh stop | log
46 sleep 2
47 sed -i \
48 -e "s|^INTERFACE=.*|INTERFACE=\"$(GET iface)\"|" \
49 -e 's|^WIFI=.*|WIFI="no"|' \
50 -e "s|^DHCP=.*|DHCP=\"$DHCP\"|" \
51 -e "s|^STATIC=.*|STATIC=\"$STATIC\"|" \
52 -e "s|^IP=.*|IP=\"$(GET ip)\"|" \
53 -e "s|^NETMASK=.*|NETMASK=\"$(GET netmask)\"|" \
54 -e "s|^GATEWAY=.*|GATEWAY=\"$(GET gateway)\"|" \
55 -e "s|^DNS_SERVER=.*|DNS_SERVER=\"$(GET dns)\"|" \
56 /etc/network.conf
57 /etc/init.d/network.sh start | log
58 . /etc/network.conf
59 }
62 # Use /etc/wpa/wpa.conf as single database for known networks, passwords, etc.
63 # Translate this data to use in javascript.
65 parse_wpa_conf() {
66 awk '
67 BEGIN { print "networks = ["; begin_list = 1; network = 0; }
68 {
69 if ($0 == "network={") {
70 if (begin_list == 0) print ",";
71 begin_list = 0;
72 printf "{"; begin_obj = 1;
73 network = 1; next;
74 }
75 if (network == 1) {
76 if ($0 ~ "=") {
77 if (begin_obj == 0) printf ", ";
78 begin_obj = 0;
80 # split line into variable and value (note "=" can appear in the value)
81 split($0, a, "="); variable = a[1];
82 value = gensub(variable "=", "", "");
84 # escape html entities
85 value = gensub("\\\\", "\\\\", "g", value);
86 value = gensub("&", "\\&amp;", "g", value);
87 value = gensub("<", "\\&lt;", "g", value);
88 value = gensub(">", "\\&gt;", "g", value);
89 value = gensub("\"", "\\\"", "g", value);
91 # if value was already quoted - remove \" from begin and end
92 if (substr(value, 1, 2) == "\\\"")
93 value = substr(value, 3, length(value) - 4);
95 # output in form: variable:"escaped value"
96 printf "%s:\"%s\"", variable, value;
97 }
98 }
99 if (network == 1 && $0 ~ "}") { printf "}"; network = 0; next; }
100 }
101 END {print "\n];"}
102 ' /etc/wpa/wpa.conf | sed 's|\t||g;'
103 }
106 # Waiting for network link up
108 wait_up() {
109 for i in $(seq 5); do
110 [ -z "$(cat /sys/class/net/*/operstate | fgrep up)"] && sleep 1
111 done
112 }
115 # Actions commands before page is displayed
117 case " $(GET) " in
118 *\ start\ *)
119 /etc/init.d/network.sh start | log
120 # Here we sleep a bit to let udhcp get the lease before reloading
121 # the page with status
122 wait_up ;;
123 *\ stop\ *)
124 /etc/init.d/network.sh stop | log ;;
125 *\ restart\ *)
126 /etc/init.d/network.sh restart | log
127 wait_up ;;
128 *\ start_wifi\ *)
129 start_wifi ;;
130 *\ start_eth\ *)
131 start_eth ;;
132 *\ dowakeup\ *)
133 mac="$(GET macwakup)"
134 unset pass
135 [ "$(GET pass)" ] && pass="-p $(GET pass)"
136 if [ "$mac" ]; then
137 ether-wake $(GET iface) $mac $pass
138 else
139 ether-wake -b $(GET iface) $pass
140 fi
141 ;;
142 *\ host\ *)
143 get_hostname="$(GET host)"
144 echo $(_ 'Changed hostname: %s' $get_hostname) | log
145 echo "$get_hostname" > /etc/hostname ;;
146 esac
148 case " $(POST) " in
149 *\ connect_wifi\ *)
150 # Connect to a Wi-Fi network
151 /etc/init.d/network.sh stop | log
152 password="$(POST password)"
154 # Escape special characters to use with sed substitutions
155 password="$(echo -n "$password" | sed 's|\\|\\\\|g; s|&|\\\&|g' | sed "s|'|'\"'\"'|g")"
157 sed -i \
158 -e "s|^WIFI_ESSID=.*|WIFI_ESSID=\"$(POST essid)\"|" \
159 -e "s|^WIFI_BSSID=.*|WIFI_BSSID=\"$(POST bssid)\"|" \
160 -e "s|^WIFI_KEY_TYPE=.*|WIFI_KEY_TYPE=\"$(POST keyType)\"|" \
161 -e "s|^WIFI_KEY=.*|WIFI_KEY='$password'|" \
162 -e "s|^WIFI_EAP_METHOD=.*|WIFI_EAP_METHOD=\"$(POST eap)\"|" \
163 -e "s|^WIFI_CA_CERT=.*|WIFI_CA_CERT=\"$(POST caCert)\"|" \
164 -e "s|^WIFI_CLIENT_CERT=.*|WIFI_CLIENT_CERT=\"$(POST clientCert)\"|" \
165 -e "s|^WIFI_IDENTITY=.*|WIFI_IDENTITY=\"$(POST identity)\"|" \
166 -e "s|^WIFI_ANONYMOUS_IDENTITY=.*|WIFI_ANONYMOUS_IDENTITY=\"$(POST anonymousIdentity)\"|" \
167 -e "s|^WIFI_PHASE2=.*|WIFI_PHASE2=\"$(POST phase2)\"|" \
168 /etc/network.conf
169 . /etc/network.conf
170 start_wifi
171 ;;
172 esac
175 # Get values only now since they could have been modified by actions.
177 . /etc/network.conf
183 #
184 # Main Commands for pages
185 #
187 case " $(GET) " in
189 *\ scan\ *)
190 # Scan open ports
191 scan=$(GET scan); back=$(GET back)
192 xhtml_header
193 LOADING_MSG=$(_ 'Scanning open ports...'); loading_msg
195 cat <<EOT
196 <section>
197 <header>
198 $(_ 'Port scanning for %s' $scan)
199 $(back_button "$back" "$(_ 'Network')" "")
200 </header>
201 <pre>$(pscan -b $scan)</pre>
202 </section>
203 EOT
204 ;;
207 *\ eth\ *)
208 # Wired connections settings
209 xhtml_header
211 PAR1="size=\"20\" required"; PAR="$PAR1 pattern=\"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\""
213 case "$STATIC" in
214 yes) use_static='checked';;
215 *) use_static='';;
216 esac
218 stop_disabled=''; start_disabled=''
219 if cat /sys/class/net/eth*/operstate | fgrep -q up; then
220 start_disabled='disabled'
221 else
222 stop_disabled='disabled'
223 fi
225 cat <<EOT
226 <h2>$(_ 'Ethernet connection')</h2>
227 EOT
228 [ -w /etc/network.conf ] && cat <<EOT
229 <p>$(_ "Here you can configure a wired connection using DHCP to \
230 automatically get a random IP or configure a static/fixed IP")</p>
232 <section>
233 <header>$(_ 'Configuration')</header>
234 <form id="conf">
235 <input type="hidden" name="eth"/>
236 <div>
237 <table>
238 <tr><td>$(_ 'Interface')</td>
239 <td><select name="iface" value="$INTERFACE" style="width:100%">
240 $(cd /sys/class/net; ls -1 | awk -viface="$INTERFACE" '{
241 sel = ($0 == iface) ? " selected":""
242 printf "<option value=\"%s\"%s>%s", $0, sel, $0
243 }')
244 </select></td>
245 </tr>
246 <tr><td>$(_ 'Static IP')</td>
247 <td><label><input type="checkbox" name="staticip" id="staticip" $use_static/>
248 $(_ 'Use static IP')</td>
249 </tr>
250 <tr id="st1"><td>$(_ 'IP address')</td>
251 <td><input type="text" name="ip" value="$IP" $PAR/></td>
252 </tr>
253 <tr id="st2"><td>$(_ 'Netmask')</td>
254 <td><input type="text" name="netmask" value="$NETMASK" $PAR/></td>
255 </tr>
256 <tr id="st3"><td>$(_ 'Gateway')</td>
257 <td><input type="text" name="gateway" value="$GATEWAY" $PAR/></td>
258 </tr>
259 <tr id="st4"><td>$(_ 'DNS server')</td>
260 <td><input type="text" name="dns" value="$DNS_SERVER" $PAR/></td>
261 </tr>
262 <tr><td>$(_ 'Wake up')</td>
263 <td><label><input type="checkbox" name="wakeup" id="wakeup" />
264 $(_ 'Wake up machines by network')</td>
265 </tr>
266 <tr id="wk1"><td>$(_ 'MAC address to wake up')</td>
267 <td><input type="text" name="macwakup" title="$(_ 'Leave empty for a general wakeup')" $PAR/><!--
268 <button name="ethers" value="/etc/ethers" data-icon="view">$(_ 'View')</button -->
269 </td>
270 </tr>
271 </table>
272 </div>
273 </form>
274 <footer><!--
275 --><button form="conf" type="submit" name="start_eth" data-icon="start" $start_disabled>$(_ 'Start' )</button><!--
276 --><button form="conf" type="submit" name="stop" data-icon="stop" $stop_disabled >$(_ 'Stop' )</button><!--
277 --><button form="conf" type="submit" name="dowakeup" data-icon="clock" $stop_disabled >$(_ 'Wake up')</button><!--
278 --></footer>
279 </section>
281 <script type="text/javascript">
282 function check_change() {
283 enabled = document.getElementById('staticip').checked;
284 for (i = 1; i < 5; i++) {
285 document.getElementById('st' + i).style.display = enabled ? '' : 'none';
286 }
287 enabled = document.getElementById('wakeup').checked;
288 for (i = 1; i < 2; i++) {
289 document.getElementById('wk' + i).style.display = enabled ? '' : 'none';
290 }
291 }
293 document.getElementById('staticip').onchange = check_change;
294 document.getElementById('wakeup').onchange = check_change;
295 check_change();
296 </script>
297 EOT
298 cat <<EOT
299 <section>
300 <header>
301 $(_ 'Configuration file')
302 EOT
303 [ -w /etc/network.conf ] && cat <<EOT
304 <form action="index.cgi">
305 <input type="hidden" name="file" value="/etc/network.conf"/>
306 <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button>
307 </form>
308 EOT
309 cat <<EOT
310 </header>
311 <div>$(_ "These values are the ethernet settings in the main /etc/network.conf configuration file")</div>
312 <pre>$(awk '{if($1 !~ "WIFI" && $1 !~ "#" && $1 != ""){print $0}}' /etc/network.conf | syntax_highlighter conf)</pre>
313 </section>
314 EOT
315 ;;
319 *\ wifi_list\ *)
320 # Catch ESSIDs and format output.
321 # We get the list of networks by Cell and without spaces.
323 HIDDEN="$(_ '(hidden)')"
325 cat <<EOT
326 <table class="wide center zebra">
327 <thead>
328 <tr>
329 <td>$(_ 'Name')</td>
330 <td>$(_ 'Signal level')</td>
331 <td>$(_ 'Channel')</td>
332 <td>$(_ 'Encryption')</td>
333 <td>$(_ 'Status')</td>
334 </tr>
335 </thead>
336 <tbody>
337 EOT
338 if [ -d /sys/class/net/$WIFI_INTERFACE/wireless ]; then
339 ifconfig $WIFI_INTERFACE up
340 for i in $(iwlist $WIFI_INTERFACE scan | sed '/Cell /!d;s/.*Cell \([^ ]*\).*/Cell.\1/')
341 do
342 SCAN=$(iwlist $WIFI_INTERFACE scan last | sed "/$i/,/Cell/!d" | sed '$d')
344 BSSID=$(echo "$SCAN" | sed -n 's|.*Address: \([^ ]*\).*|\1|p')
346 CHANNEL=$(echo "$SCAN" | sed -n 's|.*Channel[:=]\([^ ]*\).*|\1|p')
348 QUALITY=$(echo "$SCAN" | sed -n 's|.*Quality[:=]\([^ ]*\).*|\1|p')
349 QUALITY_ICON="lvl$(( 5*${QUALITY:-0} ))" # lvl0 .. lvl4, lvl5
350 LEVEL=$(echo "$SCAN" | sed -n 's|.*Signal level[:=]\([^ ]*\).*|\1|p; s|-|−|')
352 ENCRYPTION=$(echo "$SCAN" | sed -n 's|.*Encryption key[:=]\([^ ]*\).*|\1|p') # on/off
354 ESSID=$(echo "$SCAN" | sed -n 's|.*ESSID:"\([^"]*\).*|\1|p')
356 # WPA Type - Group Cipher - Pairwise Ciphers - Authentication Suites
357 # {WPA|WPA2}-{TKIP|CCMP}-{TKIP|CCMP|TKIP CCMP}-{PSK|802.1x}
358 #CAPABILITIES="$(echo "$SCAN" | grep -e 'IE: .*WPA*' -A3 | cut -d: -f2 | sed -e 's|^ ||' -e '/WPA2/s|.*|=WPA2|' -e '/WPA /s|.*|=WPA|' -e '/--/d' | tr '\n' '-' | tr '=' '\n' | sed -e '/^$/d' -e 's|-$||')"
360 # Authentication type
361 AUTH="$(echo "$SCAN" | sed -n 's|.*Authentication Suites[^:]*: *\(.*\)|\1|p')"
362 if [ -n "$(echo -n $AUTH | fgrep PSK)" ]; then
363 # WPA-Personal. Authentication using password (PSK = pre-shared key)
364 WIFI_KEY_TYPE='WPA'
365 elif [ -n "$(echo -n $AUTH | fgrep 802.1x)" ]; then
366 # WPA-Enterprise. Authentication using username, password, certificates...
367 WIFI_KEY_TYPE='EAP'
368 else
369 WIFI_KEY_TYPE='NONE'
370 fi
372 # Check encryption type
373 if [ "$ENCRYPTION" == 'on' ]; then
374 # "WPA" or "WPA2" or "WPA/WPA2" (maybe also "WPA2/WPA")
375 ENC_SIMPLE=$(echo "$SCAN" | sed -n '/.*WPA.*/ s|.*\(WPA[^ ]*\).*|\1|p')
376 ENC_SIMPLE=$(echo $ENC_SIMPLE | sed 's| |/|')
377 ENC_ICON='sechi' # high
378 if [ -z "$ENC_SIMPLE" ]; then
379 WIFI_KEY_TYPE='WEP'
380 ENC_SIMPLE='WEP'; ENC_ICON='secmi' # middle
381 fi
382 else
383 WIFI_KEY_TYPE='NONE'
384 ENC_SIMPLE="$(_ 'None')"; ENC_ICON='seclo' # low
385 fi
387 # Connected or not connected...
388 if ifconfig $WIFI_INTERFACE | fgrep -q inet && \
389 iwconfig $WIFI_INTERFACE | fgrep -q "ESSID:\"$ESSID\""; then
390 status="$(_ 'Connected')"
391 else
392 status='---'
393 fi
395 cat <<EOT
396 <tr>
397 <td><a data-icon="wifi" onclick="loadcfg('$ESSID', '$BSSID', '$WIFI_KEY_TYPE')">${ESSID:-$HIDDEN}</a></td>
398 <td><span data-icon="$QUALITY_ICON" title="Quality: $QUALITY"> $LEVEL dBm</span></td>
399 <td>$CHANNEL</td>
400 <td><span data-icon="$ENC_ICON">$ENC_SIMPLE</span></td>
401 <td>$status</td>
402 </tr>
403 EOT
404 done
405 fi
406 cat <<EOT
407 </tbody>
408 </table>
409 EOT
410 exit 0
411 ;;
414 *\ wifi\ *)
415 # Wireless connections settings
416 xhtml_header
418 . /etc/network.conf
419 cat <<EOT
420 <h2>$(_ 'Wireless connection')</h2>
421 EOT
423 start_disabled=''; stop_disabled=''
424 if iwconfig 2>/dev/null | grep -q 'Tx-Power=off'; then
425 stop_disabled='disabled'
426 else
427 start_disabled='disabled'
428 fi
430 [ -w /etc/network.conf ] && cat <<EOT
431 <form>
432 <input type="hidden" name="wifi"/>
433 <button name="start_wifi" data-icon="start" $start_disabled>$(_ 'Start')</button><!--
434 --><button name="stop" data-icon="stop" $stop_disabled >$(_ 'Stop' )</button><!--
435 --><button type="submit" data-icon="refresh" $stop_disabled >$(_ 'Scan' )</button>
436 </form>
437 EOT
439 [ -w /etc/network.conf ] &&
440 if [ -n "$start_disabled" ]; then
441 cat <<EOT
442 <section id="wifiList">
443 <div style="text-align: center;"><span id="ajaxStatus"></span>$(_ 'Scanning wireless interface...')</div>
444 </section>
446 <script type="text/javascript">
447 ajax('network.cgi?wifi_list', '1', 'wifiList');
448 $(parse_wpa_conf)
449 </script>
450 EOT
452 # Escape html characters in the WIFI_KEY
453 WIFI_KEY_ESCAPED="$(echo -n "$WIFI_KEY" | sed 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g; s|"|\&quot;|g')"
455 cat <<EOT
456 <section>
457 <header>$(_ 'Connection')</header>
458 <div>
459 <form method="post" action="?wifi" id="connection">
460 <input type="hidden" name="connect_wifi"/>
461 <input type="hidden" name="bssid" id="bssid"/>
462 <table>
463 <tr><td>$(_ 'Network SSID')</td>
464 <td><input type="text" name="essid" value="$WIFI_ESSID" id="essid"/></td>
465 </tr>
467 <tr><td>$(_ 'Security')</td>
468 <td><select name="keyType" id="keyType">
469 <option value="NONE">$(_ 'None')</option>
470 <option value="WEP" >WEP</option>
471 <option value="WPA" >WPA/WPA2 PSK</option>
472 <option value="EAP" >802.1x EAP</option>
473 </select>
474 </td>
475 </tr>
477 <tr class="eap">
478 <td><div>$(_ 'EAP method')</div></td>
479 <td><div><select name="eap" id="eap">
480 <option value="PEAP">PEAP</option>
481 <option value="TLS" >TLS</option>
482 <option value="TTLS">TTLS</option>
483 <option value="PWD" >PWD</option>
484 </select>
485 </div></td>
486 </tr>
488 <tr class="eap1">
489 <td><div>$(_ 'Phase 2 authentication')</div></td>
490 <td><div><select name="phase2" id="phase2">
491 <option value="none" >$(_ 'None')</option>
492 <option value="pap" >PAP</option>
493 <option value="mschap" >MSCHAP</option>
494 <option value="mschapv2">MSCHAPV2</option>
495 <option value="gtc" >GTC</option>
496 </select>
497 </div></td>
498 </tr>
500 <tr class="eap1">
501 <td><div>$(_ 'CA certificate')</div></td>
502 <td><div><input type="text" name="caCert" id="caCert"></div></td>
503 </tr>
505 <tr class="eap1">
506 <td><div>$(_ 'User certificate')</div></td>
507 <td><div><input type="text" name="clientCert" id="clientCert"></div></td>
508 </tr>
510 <tr class="eap">
511 <td><div>$(_ 'Identity')</div></td>
512 <td><div><input type="text" name="identity" id="identity"></div></td>
513 </tr>
515 <tr class="eap1">
516 <td><div>$(_ 'Anonymous identity')</div></td>
517 <td><div><input type="text" name="anonymousIdentity" id="anonymousIdentity"></div></td>
518 </tr>
520 <tr class="wep wpa eap">
521 <td><div>$(_ 'Password')</div></td>
522 <td><div>
523 <input type="password" name="password" value="$WIFI_KEY_ESCAPED" id="password"/>
524 <span data-img="view" title="$(_ 'Show password')"
525 onmousedown="document.getElementById('password').type='text'; return false"
526 onmouseup="document.getElementById('password').type='password'"
527 onmouseout="document.getElementById('password').type='password'"
528 ></span>
529 </div></td>
530 </tr>
532 <script type="text/javascript">
533 function wifiSettingsChange() {
534 document.getElementById('connection').className =
535 document.getElementById('keyType').value.toLowerCase() + ' ' +
536 document.getElementById('eap').value.toLowerCase();
537 }
538 document.getElementById('keyType').onchange = wifiSettingsChange;
539 document.getElementById('eap').onchange = wifiSettingsChange;
541 document.getElementById('keyType').value = "$WIFI_KEY_TYPE"; wifiSettingsChange();
542 </script>
544 <style type="text/css">
545 #connection input[type="text"], #connection input[type="password"] { width: 14rem; }
546 #connection select { width: 14.4rem; }
548 #connection td { padding: 0; margin: 0; }
549 #connection [class] div {
550 max-height: 0; overflow: hidden; padding: 0; margin: 0;
551 -webkit-transition: all 0.5s ease-in-out;
552 -moz-transition: all 0.5s ease-in-out;
553 transition: all 0.5s ease-in-out;
554 }
555 .wep .wep div, .wpa .wpa div, .eap .eap div,
556 .eap.peap .eap1 div, .eap.tls .eap1 div, .eap.ttls .eap1 div {
557 max-height: 2em !important;
558 }
559 </style>
561 </table>
562 </form>
563 </div>
564 <footer>
565 <button form="connection" type="submit" name="wifi" data-icon="ok">$(_ 'Configure')</button>
566 </footer>
567 </section>
568 EOT
569 fi
571 cat <<EOT
572 <section>
573 <header>
574 $(_ 'Configuration file')
575 EOT
576 [ -w /etc/network.conf ] && cat <<EOT
577 <form action="index.cgi">
578 <input type="hidden" name="file" value="/etc/network.conf"/>
579 <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button>
580 </form>
581 EOT
582 cat <<EOT
583 </header>
584 <div>$(_ "These values are the wifi settings in the main /etc/network.conf configuration file")</div>
585 <pre>$(grep ^WIFI /etc/network.conf | sed 's|WIFI_KEY=.*|WIFI_KEY="********"|' | syntax_highlighter conf)</pre>
586 </section>
589 <section>
590 <header>$(_ 'Output of iwconfig')</header>
591 <pre>$(iwconfig)</pre>
592 </section>
593 EOT
594 ;;
597 *)
598 # Main Network page starting with a summary
599 xhtml_header
601 stop_disabled=''; start_disabled=''
602 if cat /sys/class/net/*/operstate | fgrep -q up; then
603 start_disabled='disabled'
604 else
605 stop_disabled='disabled'
606 fi
608 if [ ! -w /etc/network.conf ]; then
609 start_disabled='disabled'; stop_disabled='disabled'
610 fi
612 cat <<EOT
613 <h2>$(_ 'Networking')</h2>
615 <p>$(_ 'Manage network connections and services')</p>
617 <form action="index.cgi" id="indexform"></form>
619 <form id="mainform"><!--
620 --><button name="start" data-icon="start" $start_disabled>$(_ 'Start' )</button><!--
621 --><button name="stop" data-icon="stop" $stop_disabled >$(_ 'Stop' )</button><!--
622 --><button name="restart" data-icon="restart" $stop_disabled >$(_ 'Restart')</button>
623 </form>
625 <div class="float-right"><!--
626 -->$(_ 'Configuration:')<!--
627 --><button form="indexform" name="file" value="/etc/network.conf" data-icon="conf">network.conf</button><!--
628 --><button form="mainform" name="eth" data-icon="eth">Ethernet</button><!--
629 --><button form="mainform" name="wifi" data-icon="wifi">Wireless</button>
630 </div>
633 <section>
634 <header>$(_ 'Network interfaces')</header>
635 $(list_network_interfaces)
636 </section>
639 <section>
640 <header id="hosts">$(_ 'Hosts')</header>
641 <pre>$(cat /etc/hosts)</pre>
642 EOT
643 [ -w /etc/hosts ] && cat <<EOT
644 <footer>
645 <form action="index.cgi">
646 <input type="hidden" name="file" value="/etc/hosts"/>
647 <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button>
648 </form>
649 </footer>
650 EOT
651 cat <<EOT
652 </section>
655 <section>
656 <header>$(_ 'Hostname')</header>
657 <footer>
658 EOT
659 if [ -w /etc/hostname ]; then
660 cat <<EOT
661 <form>
662 <!-- was: name="hostname"; please don't use 'name' in name: unwanted webkit styling -->
663 <input type="text" name="host" value="$(cat /etc/hostname)"/><!--
664 --><button type="submit" data-icon="ok">$(_ 'Change')</button>
665 </form>
666 EOT
667 else
668 cat /etc/hostname
669 fi
670 cat <<EOT
671 </footer>
672 </section>
675 <section>
676 <header id="ifconfig">$(_ 'Output of ifconfig')</header>
677 <pre>$(ifconfig)</pre>
678 </section>
681 <section>
682 <header id="routing">$(_ 'Routing table')</header>
683 <pre>$(route -n)</pre>
684 </section>
687 <section>
688 <header id="dns">$(_ 'Domain name resolution')</header>
689 <pre>$(cat /etc/resolv.conf)</pre>
690 </section>
693 <section>
694 <header id="arp">$(_ 'ARP table')</header>
695 <pre>$(arp)</pre>
696 </section>
699 <section>
700 <header id="connections">$(_ 'IP Connections')</header>
701 <pre>$(netstat -anp 2>/dev/null | sed -e '/UNIX domain sockets/,$d' \
702 -e 's#\([0-9]*\)/#<a href="boot.cgi?daemons=pid=\1">\1</a>/#')</pre>
703 </section>
704 EOT
705 ;;
706 esac
708 xhtml_footer
709 exit 0