tazpanel view network.cgi @ rev 463

Add prism.js syntax highlighter; now files can be edited "in place" without page reloading; allow ANY characters in the Wi-Fi password (bug 126); change web-app layout: main window isn't scrollable, with scrollable contents.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Apr 24 16:00:14 2015 +0300 (2015-04-24)
parents 169f1ccfb613
children c23efdafb18d
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 *\ host\ *)
133 get_hostname="$(GET host)"
134 echo $(_ 'Changed hostname: %s' $get_hostname) | log
135 echo "$get_hostname" > /etc/hostname ;;
136 esac
138 case " $(POST) " in
139 *\ connect_wifi\ *)
140 # Connect to a Wi-Fi network
141 /etc/init.d/network.sh stop | log
142 password="$(POST password)"
144 # Escape special characters to use with sed substitutions
145 password="$(echo -n "$password" | sed 's|\\|\\\\|g; s|&|\\\&|g' | sed "s|'|'\"'\"'|g")"
147 sed -i \
148 -e "s|^WIFI_ESSID=.*|WIFI_ESSID=\"$(POST essid)\"|" \
149 -e "s|^WIFI_BSSID=.*|WIFI_BSSID=\"$(POST bssid)\"|" \
150 -e "s|^WIFI_KEY_TYPE=.*|WIFI_KEY_TYPE=\"$(POST keyType)\"|" \
151 -e "s|^WIFI_KEY=.*|WIFI_KEY='$password'|" \
152 -e "s|^WIFI_EAP_METHOD=.*|WIFI_EAP_METHOD=\"$(POST eap)\"|" \
153 -e "s|^WIFI_CA_CERT=.*|WIFI_CA_CERT=\"$(POST caCert)\"|" \
154 -e "s|^WIFI_CLIENT_CERT=.*|WIFI_CLIENT_CERT=\"$(POST clientCert)\"|" \
155 -e "s|^WIFI_IDENTITY=.*|WIFI_IDENTITY=\"$(POST identity)\"|" \
156 -e "s|^WIFI_ANONYMOUS_IDENTITY=.*|WIFI_ANONYMOUS_IDENTITY=\"$(POST anonymousIdentity)\"|" \
157 -e "s|^WIFI_PHASE2=.*|WIFI_PHASE2=\"$(POST phase2)\"|" \
158 /etc/network.conf
159 . /etc/network.conf
160 start_wifi
161 ;;
162 esac
165 # Get values only now since they could have been modified by actions.
167 . /etc/network.conf
173 #
174 # Main Commands for pages
175 #
177 case " $(GET) " in
179 *\ scan\ *)
180 # Scan open ports
181 scan=$(GET scan); back=$(GET back)
182 xhtml_header
183 LOADING_MSG=$(_ 'Scanning open ports...'); loading_msg
185 cat <<EOT
186 <section>
187 <header>
188 $(_ 'Port scanning for %s' $scan)
189 $(back_button "$back" "$(_ 'Network')" "")
190 </header>
191 <pre>$(pscan -b $scan)</pre>
192 </section>
193 EOT
194 ;;
197 *\ eth\ *)
198 # Wired connections settings
199 xhtml_header
201 PAR1="size=\"20\" required"; PAR="$PAR1 pattern=\"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\""
203 case "$STATIC" in
204 yes) use_static='checked';;
205 *) use_static='';;
206 esac
208 stop_disabled=''; start_disabled=''
209 if cat /sys/class/net/eth*/operstate | fgrep -q up; then
210 start_disabled='disabled'
211 else
212 stop_disabled='disabled'
213 fi
215 cat <<EOT
216 <h2>$(_ 'Ethernet connection')</h2>
217 EOT
218 [ -w /etc/network.conf ] && cat <<EOT
219 <p>$(_ "Here you can configure a wired connection using DHCP to \
220 automatically get a random IP or configure a static/fixed IP")</p>
222 <section>
223 <header>$(_ 'Configuration')</header>
224 <form id="conf">
225 <input type="hidden" name="eth"/>
226 <div>
227 <table>
228 <tr><td>$(_ 'Interface')</td>
229 <td><select name="iface" value="$INTERFACE" style="width:100%">
230 $(cd /sys/class/net; ls -1 | awk -viface="$INTERFACE" '{
231 sel = ($0 == iface) ? " selected":""
232 printf "<option value=\"%s\"%s>%s", $0, sel, $0
233 }')
234 </select></td>
235 </tr>
236 <tr><td>$(_ 'Static IP')</td>
237 <td><label><input type="checkbox" name="staticip" id="staticip" $use_static/>
238 $(_ 'Use static IP')</td>
239 </tr>
240 <tr id="st1"><td>$(_ 'IP address')</td>
241 <td><input type="text" name="ip" value="$IP" $PAR/></td>
242 </tr>
243 <tr id="st2"><td>$(_ 'Netmask')</td>
244 <td><input type="text" name="netmask" value="$NETMASK" $PAR/></td>
245 </tr>
246 <tr id="st3"><td>$(_ 'Gateway')</td>
247 <td><input type="text" name="gateway" value="$GATEWAY" $PAR/></td>
248 </tr>
249 <tr id="st4"><td>$(_ 'DNS server')</td>
250 <td><input type="text" name="dns" value="$DNS_SERVER" $PAR/></td>
251 </tr>
252 </table>
253 </div>
254 </form>
255 <footer><!--
256 --><button form="conf" type="submit" name="start_eth" data-icon="start" $start_disabled>$(_ 'Start' )</button><!--
257 --><button form="conf" type="submit" name="stop" data-icon="stop" $stop_disabled >$(_ 'Stop' )</button><!--
258 --></footer>
259 </section>
261 <script type="text/javascript">
262 function static_change() {
263 staticip = document.getElementById('staticip').checked;
264 for (i = 1; i < 5; i++) {
265 document.getElementById('st' + i).style.display = staticip ? '' : 'none';
266 }
267 }
269 document.getElementById('staticip').onchange = static_change;
270 static_change();
271 </script>
272 EOT
273 cat <<EOT
274 <section>
275 <header>
276 $(_ 'Configuration file')
277 EOT
278 [ -w /etc/network.conf ] && cat <<EOT
279 <form action="index.cgi">
280 <input type="hidden" name="file" value="/etc/network.conf"/>
281 <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button>
282 </form>
283 EOT
284 cat <<EOT
285 </header>
286 <div>$(_ "These values are the ethernet settings in the main /etc/network.conf configuration file")</div>
287 <pre>$(awk '{if($1 !~ "WIFI" && $1 !~ "#" && $1 != ""){print $0}}' /etc/network.conf | syntax_highlighter conf)</pre>
288 </section>
289 EOT
290 ;;
294 *\ wifi_list\ *)
295 # Catch ESSIDs and format output.
296 # We get the list of networks by Cell and without spaces.
298 HIDDEN="$(_ '(hidden)')"
300 cat <<EOT
301 <table class="wide center zebra">
302 <thead>
303 <tr>
304 <td>$(_ 'Name')</td>
305 <td>$(_ 'Signal level')</td>
306 <td>$(_ 'Channel')</td>
307 <td>$(_ 'Encryption')</td>
308 <td>$(_ 'Status')</td>
309 </tr>
310 </thead>
311 <tbody>
312 EOT
313 if [ -d /sys/class/net/$WIFI_INTERFACE/wireless ]; then
314 ifconfig $WIFI_INTERFACE up
315 for i in $(iwlist $WIFI_INTERFACE scan | sed '/Cell /!d;s/.*Cell \([^ ]*\).*/Cell.\1/')
316 do
317 SCAN=$(iwlist $WIFI_INTERFACE scan last | sed "/$i/,/Cell/!d" | sed '$d')
319 BSSID=$(echo "$SCAN" | sed -n 's|.*Address: \([^ ]*\).*|\1|p')
321 CHANNEL=$(echo "$SCAN" | sed -n 's|.*Channel[:=]\([^ ]*\).*|\1|p')
323 QUALITY=$(echo "$SCAN" | sed -n 's|.*Quality[:=]\([^ ]*\).*|\1|p')
324 QUALITY_ICON="lvl$(( 5*${QUALITY:-0} ))" # lvl0 .. lvl4, lvl5
325 LEVEL=$(echo "$SCAN" | sed -n 's|.*Signal level[:=]\([^ ]*\).*|\1|p; s|-|−|')
327 ENCRYPTION=$(echo "$SCAN" | sed -n 's|.*Encryption key[:=]\([^ ]*\).*|\1|p') # on/off
329 ESSID=$(echo "$SCAN" | sed -n 's|.*ESSID:"\([^"]*\).*|\1|p')
331 # WPA Type - Group Cipher - Pairwise Ciphers - Authentication Suites
332 # {WPA|WPA2}-{TKIP|CCMP}-{TKIP|CCMP|TKIP CCMP}-{PSK|802.1x}
333 #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|-$||')"
335 # Authentication type
336 AUTH="$(echo "$SCAN" | sed -n 's|.*Authentication Suites[^:]*: *\(.*\)|\1|p')"
337 if [ -n "$(echo -n $AUTH | fgrep PSK)" ]; then
338 # WPA-Personal. Authentication using password (PSK = pre-shared key)
339 WIFI_KEY_TYPE='WPA'
340 elif [ -n "$(echo -n $AUTH | fgrep 802.1x)" ]; then
341 # WPA-Enterprise. Authentication using username, password, certificates...
342 WIFI_KEY_TYPE='EAP'
343 else
344 WIFI_KEY_TYPE='NONE'
345 fi
347 # Check encryption type
348 if [ "$ENCRYPTION" == 'on' ]; then
349 # "WPA" or "WPA2" or "WPA/WPA2" (maybe also "WPA2/WPA")
350 ENC_SIMPLE=$(echo "$SCAN" | sed -n '/.*WPA.*/ s|.*\(WPA[^ ]*\).*|\1|p')
351 ENC_SIMPLE=$(echo $ENC_SIMPLE | sed 's| |/|')
352 ENC_ICON='sechi' # high
353 if [ -z "$ENC_SIMPLE" ]; then
354 WIFI_KEY_TYPE='WEP'
355 ENC_SIMPLE='WEP'; ENC_ICON='secmi' # middle
356 fi
357 else
358 WIFI_KEY_TYPE='NONE'
359 ENC_SIMPLE="$(_ 'None')"; ENC_ICON='seclo' # low
360 fi
362 #
363 #if echo $SCAN | grep -q 'Mode:Managed'; then
364 # AP="&amp;ap=$(echo $SCAN | sed 's/.*Address: \([^ ]*\).*/\1/')"
365 #else
366 # AP=''
367 #fi
369 # Connected or not connected...
370 if ifconfig $WIFI_INTERFACE | fgrep -q inet && \
371 iwconfig $WIFI_INTERFACE | fgrep -q "ESSID:\"$ESSID\""; then
372 status="$(_ 'Connected')"
373 else
374 status='---'
375 fi
377 cat <<EOT
378 <tr>
379 <td><a data-icon="wifi" onclick="loadcfg('$ESSID', '$BSSID', '$WIFI_KEY_TYPE')">${ESSID:-$HIDDEN}</a></td>
380 <td><span data-icon="$QUALITY_ICON" title="Quality: $QUALITY"> $LEVEL dBm</span></td>
381 <td>$CHANNEL</td>
382 <td><span data-icon="$ENC_ICON">$ENC_SIMPLE</span></td>
383 <td>$status</td>
384 </tr>
385 EOT
386 done
387 fi
388 cat <<EOT
389 </tbody>
390 </table>
391 EOT
392 exit 0
393 ;;
396 *\ wifi\ *)
397 # Wireless connections settings
398 xhtml_header
400 . /etc/network.conf
401 cat <<EOT
402 <h2>$(_ 'Wireless connection')</h2>
403 EOT
405 start_disabled=''; stop_disabled=''
406 if iwconfig 2>/dev/null | grep -q 'Tx-Power=off'; then
407 stop_disabled='disabled'
408 else
409 start_disabled='disabled'
410 fi
412 [ -w /etc/network.conf ] && cat <<EOT
413 <form>
414 <input type="hidden" name="wifi"/>
415 <button name="start_wifi" data-icon="start" $start_disabled>$(_ 'Start')</button><!--
416 --><button name="stop" data-icon="stop" $stop_disabled >$(_ 'Stop' )</button><!--
417 --><button type="submit" data-icon="refresh" $stop_disabled >$(_ 'Scan' )</button>
418 </form>
419 EOT
421 [ -w /etc/network.conf ] &&
422 if [ -n "$start_disabled" ]; then
423 cat <<EOT
424 <section id="wifiList">
425 <div style="text-align: center;"><span id="ajaxStatus"></span>$(_ 'Scanning wireless interface...')</div>
426 </section>
428 <script type="text/javascript">
429 ajax('network.cgi?wifi_list', '1', 'wifiList');
430 $(parse_wpa_conf)
431 </script>
432 EOT
434 # Escape html characters in the WIFI_KEY
435 WIFI_KEY_ESCAPED="$(echo -n "$WIFI_KEY" | sed 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g; s|"|\&quot;|g')"
437 cat <<EOT
438 <section>
439 <header>$(_ 'Connection')</header>
440 <div>
441 <form method="post" action="?wifi" id="connection">
442 <input type="hidden" name="connect_wifi"/>
443 <input type="hidden" name="bssid" id="bssid"/>
444 <table>
445 <tr><td>$(_ 'Network SSID')</td>
446 <td><input type="text" name="essid" value="$WIFI_ESSID" id="essid"/></td>
447 </tr>
449 <tr><td>$(_ 'Security')</td>
450 <td><select name="keyType" id="keyType">
451 <option value="NONE">$(_ 'None')</option>
452 <option value="WEP" >WEP</option>
453 <option value="WPA" >WPA/WPA2 PSK</option>
454 <option value="EAP" >802.1x EAP</option>
455 </select>
456 </td>
457 </tr>
459 <tr class="eap">
460 <td><div>$(_ 'EAP method')</div></td>
461 <td><div><select name="eap" id="eap">
462 <option value="PEAP">PEAP</option>
463 <option value="TLS" >TLS</option>
464 <option value="TTLS">TTLS</option>
465 <option value="PWD" >PWD</option>
466 </select>
467 </div></td>
468 </tr>
470 <tr class="eap1">
471 <td><div>$(_ 'Phase 2 authentication')</div></td>
472 <td><div><select name="phase2" id="phase2">
473 <option value="none" >$(_ 'None')</option>
474 <option value="pap" >PAP</option>
475 <option value="mschap" >MSCHAP</option>
476 <option value="mschapv2">MSCHAPV2</option>
477 <option value="gtc" >GTC</option>
478 </select>
479 </div></td>
480 </tr>
482 <tr class="eap1">
483 <td><div>$(_ 'CA certificate')</div></td>
484 <td><div><input type="text" name="caCert" id="caCert"></div></td>
485 </tr>
487 <tr class="eap1">
488 <td><div>$(_ 'User certificate')</div></td>
489 <td><div><input type="text" name="clientCert" id="clientCert"></div></td>
490 </tr>
492 <tr class="eap">
493 <td><div>$(_ 'Identity')</div></td>
494 <td><div><input type="text" name="identity" id="identity"></div></td>
495 </tr>
497 <tr class="eap1">
498 <td><div>$(_ 'Anonymous identity')</div></td>
499 <td><div><input type="text" name="anonymousIdentity" id="anonymousIdentity"></div></td>
500 </tr>
502 <tr class="wep wpa eap">
503 <td><div>$(_ 'Password')</div></td>
504 <td><div>
505 <input type="password" name="password" value="$WIFI_KEY_ESCAPED" id="password"/>
506 <span data-img="view" title="$(_ 'Show password')"
507 onmousedown="document.getElementById('password').type='text'; return false"
508 onmouseup="document.getElementById('password').type='password'"
509 onmouseout="document.getElementById('password').type='password'"
510 ></span>
511 </div></td>
512 </tr>
514 <script type="text/javascript">
515 function wifiSettingsChange() {
516 document.getElementById('connection').className =
517 document.getElementById('keyType').value.toLowerCase() + ' ' +
518 document.getElementById('eap').value.toLowerCase();
519 }
520 document.getElementById('keyType').onchange = wifiSettingsChange;
521 document.getElementById('eap').onchange = wifiSettingsChange;
523 document.getElementById('keyType').value = "$WIFI_KEY_TYPE"; wifiSettingsChange();
524 </script>
526 <style type="text/css">
527 #connection input[type="text"], #connection input[type="password"] { width: 14rem; }
528 #connection select { width: 14.4rem; }
530 #connection td { padding: 0; margin: 0; }
531 #connection [class] div {
532 max-height: 0; overflow: hidden; padding: 0; margin: 0;
533 -webkit-transition: all 0.5s ease-in-out;
534 -moz-transition: all 0.5s ease-in-out;
535 transition: all 0.5s ease-in-out;
536 }
537 .wep .wep div, .wpa .wpa div, .eap .eap div,
538 .eap.peap .eap1 div, .eap.tls .eap1 div, .eap.ttls .eap1 div {
539 max-height: 2em !important;
540 }
541 </style>
543 </table>
544 </form>
545 </div>
546 <footer>
547 <button form="connection" type="submit" name="wifi" data-icon="ok">$(_ 'Configure')</button>
548 </footer>
549 </section>
550 EOT
551 fi
553 cat <<EOT
554 <section>
555 <header>
556 $(_ 'Configuration file')
557 EOT
558 [ -w /etc/network.conf ] && cat <<EOT
559 <form action="index.cgi">
560 <input type="hidden" name="file" value="/etc/network.conf"/>
561 <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button>
562 </form>
563 EOT
564 cat <<EOT
565 </header>
566 <div>$(_ "These values are the wifi settings in the main /etc/network.conf configuration file")</div>
567 <pre>$(grep ^WIFI /etc/network.conf | sed 's|WIFI_KEY=.*|WIFI_KEY="********"|' | syntax_highlighter conf)</pre>
568 </section>
571 <section>
572 <header>$(_ 'Output of iwconfig')</header>
573 <pre>$(iwconfig)</pre>
574 </section>
575 EOT
576 ;;
579 *)
580 # Main Network page starting with a summary
581 xhtml_header
583 stop_disabled=''; start_disabled=''
584 if cat /sys/class/net/*/operstate | fgrep -q up; then
585 start_disabled='disabled'
586 else
587 stop_disabled='disabled'
588 fi
590 if [ ! -w /etc/network.conf ]; then
591 start_disabled='disabled'; stop_disabled='disabled'
592 fi
594 cat <<EOT
595 <h2>$(_ 'Networking')</h2>
597 <p>$(_ 'Manage network connections and services')</p>
599 <form action="index.cgi" id="indexform"></form>
601 <form id="mainform"><!--
602 --><button name="start" data-icon="start" $start_disabled>$(_ 'Start' )</button><!--
603 --><button name="stop" data-icon="stop" $stop_disabled >$(_ 'Stop' )</button><!--
604 --><button name="restart" data-icon="restart" $stop_disabled >$(_ 'Restart')</button>
605 </form>
607 <div class="float-right"><!--
608 -->$(_ 'Configuration:')<!--
609 --><button form="indexform" name="file" value="/etc/network.conf" data-icon="conf">network.conf</button><!--
610 --><button form="mainform" name="eth" data-icon="eth">Ethernet</button><!--
611 --><button form="mainform" name="wifi" data-icon="wifi">Wireless</button>
612 </div>
615 <section>
616 <header>$(_ 'Network interfaces')</header>
617 $(list_network_interfaces)
618 </section>
621 <section>
622 <header id="hosts">$(_ 'Hosts')</header>
623 <pre>$(cat /etc/hosts)</pre>
624 EOT
625 [ -w /etc/hosts ] && cat <<EOT
626 <footer>
627 <form action="index.cgi">
628 <input type="hidden" name="file" value="/etc/hosts"/>
629 <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button>
630 </form>
631 </footer>
632 EOT
633 cat <<EOT
634 </section>
637 <section>
638 <header>$(_ 'Hostname')</header>
639 <footer>
640 EOT
641 if [ -w /etc/hostname ]; then
642 cat <<EOT
643 <form>
644 <!-- was: name="hostname"; please don't use 'name' in name: unwanted webkit styling -->
645 <input type="text" name="host" value="$(cat /etc/hostname)"/><!--
646 --><button type="submit" data-icon="ok">$(_ 'Change')</button>
647 </form>
648 EOT
649 else
650 cat /etc/hostname
651 fi
652 cat <<EOT
653 </footer>
654 </section>
657 <section>
658 <header id="ifconfig">$(_ 'Output of ifconfig')</header>
659 <pre>$(ifconfig)</pre>
660 </section>
663 <section>
664 <header id="routing">$(_ 'Routing table')</header>
665 <pre>$(route -n)</pre>
666 </section>
669 <section>
670 <header id="dns">$(_ 'Domain name resolution')</header>
671 <pre>$(cat /etc/resolv.conf)</pre>
672 </section>
675 <section>
676 <header id="arp">$(_ 'ARP table')</header>
677 <pre>$(arp)</pre>
678 </section>
681 <section>
682 <header id="connections">$(_ 'IP Connections')</header>
683 <pre>$(netstat -anp 2>/dev/null | sed -e '/UNIX domain sockets/,$d' \
684 -e 's#\([0-9]*\)/#<a href="boot.cgi?daemons=pid=\1">\1</a>/#')</pre>
685 </section>
686 EOT
687 ;;
688 esac
690 xhtml_footer
691 exit 0