tazpanel view network.cgi @ rev 481

Tiny edits
author Paul Issott <paul@slitaz.org>
date Sun May 10 11:51:03 2015 +0100 (2015-05-10)
parents de34ca9d1417
children 62d49bf26410
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 macpass)" ] && pass="-p $(GET macpass)"
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 [ -s /etc/ethers ] || echo "#01:02:03:04:05:06 mystation" > /etc/ethers
226 cat <<EOT
227 <h2>$(_ 'Ethernet connection')</h2>
228 EOT
229 [ -w /etc/network.conf ] && cat <<EOT
230 <p>$(_ "Here you can configure a wired connection using DHCP to \
231 automatically get a random IP or configure a static/fixed IP")</p>
233 <section>
234 <header>$(_ 'Configuration')</header>
235 <form action="index.cgi" id="indexform"></form>
236 <form id="conf">
237 <input type="hidden" name="eth"/>
238 <div>
239 <table>
240 <tr><td>$(_ 'Interface')</td>
241 <td><select name="iface" value="$INTERFACE" style="width:100%">
242 $(cd /sys/class/net; ls -1 | awk -viface="$INTERFACE" '{
243 sel = ($0 == iface) ? " selected":""
244 printf "<option value=\"%s\"%s>%s", $0, sel, $0
245 }')
246 </select></td>
247 </tr>
248 <tr><td>$(_ 'Static IP')</td>
249 <td><label><input type="checkbox" name="staticip" id="staticip" $use_static/>
250 $(_ 'Use static IP')</td>
251 </tr>
252 <tr id="st1"><td>$(_ 'IP address')</td>
253 <td><input type="text" name="ip" value="$IP" $PAR/></td>
254 </tr>
255 <tr id="st2"><td>$(_ 'Netmask')</td>
256 <td><input type="text" name="netmask" value="$NETMASK" $PAR/></td>
257 </tr>
258 <tr id="st3"><td>$(_ 'Gateway')</td>
259 <td><input type="text" name="gateway" value="$GATEWAY" $PAR/></td>
260 </tr>
261 <tr id="st4"><td>$(_ 'DNS server')</td>
262 <td><input type="text" name="dns" value="$DNS_SERVER" $PAR/></td>
263 </tr>
264 <tr><td>$(_ 'Wake up')</td>
265 <td><label><input type="checkbox" name="wakeup" id="wakeup" />
266 $(_ 'Wake up machines by network')</td>
267 </tr>
268 <tr id="wk1"><td>$(_ 'MAC address to wake up')</td>
269 <td><input type="text" name="macwakup" title="$(_ 'Leave empty for a general wakeup')" $PAR/><!--
270 --><button form="indexform" name="file" value="/etc/ethers" data-icon="view">$(_ 'List')</button>
271 </td>
272 </tr>
273 <tr id="wk2"><td>$(_ 'MAC/IP address password')</td>
274 <td><input type="text" name="macpass" title="$(_ 'Leave empty for a general wakeup')" $PAR/><!--
275 --><button form="indexform" name="exec" value="ether-wake --help" data-icon="help">$(_ 'Help')</button>
276 </td>
277 </tr>
278 </table>
279 </div>
280 </form>
281 <footer><!--
282 --><button form="conf" type="submit" name="start_eth" data-icon="start" $start_disabled>$(_ 'Start' )</button><!--
283 --><button form="conf" type="submit" name="stop" data-icon="stop" $stop_disabled >$(_ 'Stop' )</button><!--
284 --><button form="conf" type="submit" name="dowakeup" data-icon="clock" $stop_disabled >$(_ 'Wake up')</button><!--
285 --></footer>
286 </section>
288 <script type="text/javascript">
289 function check_change() {
290 enabled = document.getElementById('staticip').checked;
291 for (i = 1; i < 5; i++) {
292 document.getElementById('st' + i).style.display = enabled ? '' : 'none';
293 }
294 enabled = document.getElementById('wakeup').checked;
295 for (i = 1; i < 3; i++) {
296 document.getElementById('wk' + i).style.display = enabled ? '' : 'none';
297 }
298 }
300 document.getElementById('staticip').onchange = check_change;
301 document.getElementById('wakeup').onchange = check_change;
302 check_change();
303 </script>
304 EOT
305 cat <<EOT
306 <section>
307 <header>
308 $(_ 'Configuration file')
309 EOT
310 [ -w /etc/network.conf ] && cat <<EOT
311 <form action="index.cgi">
312 <input type="hidden" name="file" value="/etc/network.conf"/>
313 <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button>
314 </form>
315 EOT
316 cat <<EOT
317 </header>
318 <div>$(_ "These values are the ethernet settings in the main /etc/network.conf configuration file")</div>
319 <pre>$(awk '{if($1 !~ "WIFI" && $1 !~ "#" && $1 != ""){print $0}}' /etc/network.conf | syntax_highlighter conf)</pre>
320 </section>
321 EOT
322 ;;
326 *\ wifi_list\ *)
327 # Catch ESSIDs and format output.
328 # We get the list of networks by Cell and without spaces.
330 HIDDEN="$(_ '(hidden)')"
332 cat <<EOT
333 <table class="wide center zebra">
334 <thead>
335 <tr>
336 <td>$(_ 'Name')</td>
337 <td>$(_ 'Signal level')</td>
338 <td>$(_ 'Channel')</td>
339 <td>$(_ 'Encryption')</td>
340 <td>$(_ 'Status')</td>
341 </tr>
342 </thead>
343 <tbody>
344 EOT
345 if [ -d /sys/class/net/$WIFI_INTERFACE/wireless ]; then
346 ifconfig $WIFI_INTERFACE up
347 for i in $(iwlist $WIFI_INTERFACE scan | sed '/Cell /!d;s/.*Cell \([^ ]*\).*/Cell.\1/')
348 do
349 SCAN=$(iwlist $WIFI_INTERFACE scan last | sed "/$i/,/Cell/!d" | sed '$d')
351 BSSID=$(echo "$SCAN" | sed -n 's|.*Address: \([^ ]*\).*|\1|p')
353 CHANNEL=$(echo "$SCAN" | sed -n 's|.*Channel[:=]\([^ ]*\).*|\1|p')
355 QUALITY=$(echo "$SCAN" | sed -n 's|.*Quality[:=]\([^ ]*\).*|\1|p')
356 QUALITY_ICON="lvl$(( 5*${QUALITY:-0} ))" # lvl0 .. lvl4, lvl5
357 LEVEL=$(echo "$SCAN" | sed -n 's|.*Signal level[:=]\([^ ]*\).*|\1|p; s|-|−|')
359 ENCRYPTION=$(echo "$SCAN" | sed -n 's|.*Encryption key[:=]\([^ ]*\).*|\1|p') # on/off
361 ESSID=$(echo "$SCAN" | sed -n 's|.*ESSID:"\([^"]*\).*|\1|p')
363 # WPA Type - Group Cipher - Pairwise Ciphers - Authentication Suites
364 # {WPA|WPA2}-{TKIP|CCMP}-{TKIP|CCMP|TKIP CCMP}-{PSK|802.1x}
365 #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|-$||')"
367 # Authentication type
368 AUTH="$(echo "$SCAN" | sed -n 's|.*Authentication Suites[^:]*: *\(.*\)|\1|p')"
369 if [ -n "$(echo -n $AUTH | fgrep PSK)" ]; then
370 # WPA-Personal. Authentication using password (PSK = pre-shared key)
371 WIFI_KEY_TYPE='WPA'
372 elif [ -n "$(echo -n $AUTH | fgrep 802.1x)" ]; then
373 # WPA-Enterprise. Authentication using username, password, certificates...
374 WIFI_KEY_TYPE='EAP'
375 else
376 WIFI_KEY_TYPE='NONE'
377 fi
379 # Check encryption type
380 if [ "$ENCRYPTION" == 'on' ]; then
381 # "WPA" or "WPA2" or "WPA/WPA2" (maybe also "WPA2/WPA")
382 ENC_SIMPLE=$(echo "$SCAN" | sed -n '/.*WPA.*/ s|.*\(WPA[^ ]*\).*|\1|p')
383 ENC_SIMPLE=$(echo $ENC_SIMPLE | sed 's| |/|')
384 ENC_ICON='sechi' # high
385 if [ -z "$ENC_SIMPLE" ]; then
386 WIFI_KEY_TYPE='WEP'
387 ENC_SIMPLE='WEP'; ENC_ICON='secmi' # middle
388 fi
389 else
390 WIFI_KEY_TYPE='NONE'
391 ENC_SIMPLE="$(_ 'None')"; ENC_ICON='seclo' # low
392 fi
394 # Connected or not connected...
395 if ifconfig $WIFI_INTERFACE | fgrep -q inet && \
396 iwconfig $WIFI_INTERFACE | fgrep -q "ESSID:\"$ESSID\""; then
397 status="$(_ 'Connected')"
398 else
399 status='---'
400 fi
402 cat <<EOT
403 <tr>
404 <td><a data-icon="wifi" onclick="loadcfg('$ESSID', '$BSSID', '$WIFI_KEY_TYPE')">${ESSID:-$HIDDEN}</a></td>
405 <td><span data-icon="$QUALITY_ICON" title="Quality: $QUALITY"> $LEVEL dBm</span></td>
406 <td>$CHANNEL</td>
407 <td><span data-icon="$ENC_ICON">$ENC_SIMPLE</span></td>
408 <td>$status</td>
409 </tr>
410 EOT
411 done
412 fi
413 cat <<EOT
414 </tbody>
415 </table>
416 EOT
417 exit 0
418 ;;
421 *\ wifi\ *)
422 # Wireless connections settings
423 xhtml_header
425 . /etc/network.conf
426 cat <<EOT
427 <h2>$(_ 'Wireless connection')</h2>
428 EOT
430 start_disabled=''; stop_disabled=''
431 if iwconfig 2>/dev/null | grep -q 'Tx-Power=off'; then
432 stop_disabled='disabled'
433 else
434 start_disabled='disabled'
435 fi
437 [ -w /etc/network.conf ] && cat <<EOT
438 <form>
439 <input type="hidden" name="wifi"/>
440 <button name="start_wifi" data-icon="start" $start_disabled>$(_ 'Start')</button><!--
441 --><button name="stop" data-icon="stop" $stop_disabled >$(_ 'Stop' )</button><!--
442 --><button type="submit" data-icon="refresh" $stop_disabled >$(_ 'Scan' )</button>
443 </form>
444 EOT
446 [ -w /etc/network.conf ] &&
447 if [ -n "$start_disabled" ]; then
448 cat <<EOT
449 <section id="wifiList">
450 <div style="text-align: center;"><span id="ajaxStatus"></span>$(_ 'Scanning wireless interface...')</div>
451 </section>
453 <script type="text/javascript">
454 ajax('network.cgi?wifi_list', '1', 'wifiList');
455 $(parse_wpa_conf)
456 </script>
457 EOT
459 # Escape html characters in the WIFI_KEY
460 WIFI_KEY_ESCAPED="$(echo -n "$WIFI_KEY" | sed 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g; s|"|\&quot;|g')"
462 cat <<EOT
463 <section>
464 <header>$(_ 'Connection')</header>
465 <div>
466 <form method="post" action="?wifi" id="connection">
467 <input type="hidden" name="connect_wifi"/>
468 <input type="hidden" name="bssid" id="bssid"/>
469 <table>
470 <tr><td>$(_ 'Network SSID')</td>
471 <td><input type="text" name="essid" value="$WIFI_ESSID" id="essid"/></td>
472 </tr>
474 <tr><td>$(_ 'Security')</td>
475 <td><select name="keyType" id="keyType">
476 <option value="NONE">$(_ 'None')</option>
477 <option value="WEP" >WEP</option>
478 <option value="WPA" >WPA/WPA2 PSK</option>
479 <option value="EAP" >802.1x EAP</option>
480 </select>
481 </td>
482 </tr>
484 <tr class="eap">
485 <td><div>$(_ 'EAP method')</div></td>
486 <td><div><select name="eap" id="eap">
487 <option value="PEAP">PEAP</option>
488 <option value="TLS" >TLS</option>
489 <option value="TTLS">TTLS</option>
490 <option value="PWD" >PWD</option>
491 </select>
492 </div></td>
493 </tr>
495 <tr class="eap1">
496 <td><div>$(_ 'Phase 2 authentication')</div></td>
497 <td><div><select name="phase2" id="phase2">
498 <option value="none" >$(_ 'None')</option>
499 <option value="pap" >PAP</option>
500 <option value="mschap" >MSCHAP</option>
501 <option value="mschapv2">MSCHAPV2</option>
502 <option value="gtc" >GTC</option>
503 </select>
504 </div></td>
505 </tr>
507 <tr class="eap1">
508 <td><div>$(_ 'CA certificate')</div></td>
509 <td><div><input type="text" name="caCert" id="caCert"></div></td>
510 </tr>
512 <tr class="eap1">
513 <td><div>$(_ 'User certificate')</div></td>
514 <td><div><input type="text" name="clientCert" id="clientCert"></div></td>
515 </tr>
517 <tr class="eap">
518 <td><div>$(_ 'Identity')</div></td>
519 <td><div><input type="text" name="identity" id="identity"></div></td>
520 </tr>
522 <tr class="eap1">
523 <td><div>$(_ 'Anonymous identity')</div></td>
524 <td><div><input type="text" name="anonymousIdentity" id="anonymousIdentity"></div></td>
525 </tr>
527 <tr class="wep wpa eap">
528 <td><div>$(_ 'Password')</div></td>
529 <td><div>
530 <input type="password" name="password" value="$WIFI_KEY_ESCAPED" id="password"/>
531 <span data-img="view" title="$(_ 'Show password')"
532 onmousedown="document.getElementById('password').type='text'; return false"
533 onmouseup="document.getElementById('password').type='password'"
534 onmouseout="document.getElementById('password').type='password'"
535 ></span>
536 </div></td>
537 </tr>
539 <script type="text/javascript">
540 function wifiSettingsChange() {
541 document.getElementById('connection').className =
542 document.getElementById('keyType').value.toLowerCase() + ' ' +
543 document.getElementById('eap').value.toLowerCase();
544 }
545 document.getElementById('keyType').onchange = wifiSettingsChange;
546 document.getElementById('eap').onchange = wifiSettingsChange;
548 document.getElementById('keyType').value = "$WIFI_KEY_TYPE"; wifiSettingsChange();
549 </script>
551 <style type="text/css">
552 #connection input[type="text"], #connection input[type="password"] { width: 14rem; }
553 #connection select { width: 14.4rem; }
555 #connection td { padding: 0; margin: 0; }
556 #connection [class] div {
557 max-height: 0; overflow: hidden; padding: 0; margin: 0;
558 -webkit-transition: all 0.5s ease-in-out;
559 -moz-transition: all 0.5s ease-in-out;
560 transition: all 0.5s ease-in-out;
561 }
562 .wep .wep div, .wpa .wpa div, .eap .eap div,
563 .eap.peap .eap1 div, .eap.tls .eap1 div, .eap.ttls .eap1 div {
564 max-height: 2em !important;
565 }
566 </style>
568 </table>
569 </form>
570 </div>
571 <footer>
572 <button form="connection" type="submit" name="wifi" data-icon="ok">$(_ 'Configure')</button>
573 </footer>
574 </section>
575 EOT
576 fi
578 cat <<EOT
579 <section>
580 <header>
581 $(_ 'Configuration file')
582 EOT
583 [ -w /etc/network.conf ] && cat <<EOT
584 <form action="index.cgi">
585 <input type="hidden" name="file" value="/etc/network.conf"/>
586 <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button>
587 </form>
588 EOT
589 cat <<EOT
590 </header>
591 <div>$(_ "These values are the wifi settings in the main /etc/network.conf configuration file")</div>
592 <pre>$(grep ^WIFI /etc/network.conf | sed 's|WIFI_KEY=.*|WIFI_KEY="********"|' | syntax_highlighter conf)</pre>
593 </section>
596 <section>
597 <header>$(_ 'Output of iwconfig')</header>
598 <pre>$(iwconfig)</pre>
599 </section>
600 EOT
601 ;;
604 *)
605 # Main Network page starting with a summary
606 xhtml_header
608 stop_disabled=''; start_disabled=''
609 if cat /sys/class/net/*/operstate | fgrep -q up; then
610 start_disabled='disabled'
611 else
612 stop_disabled='disabled'
613 fi
615 if [ ! -w /etc/network.conf ]; then
616 start_disabled='disabled'; stop_disabled='disabled'
617 fi
619 cat <<EOT
620 <h2>$(_ 'Networking')</h2>
622 <p>$(_ 'Manage network connections and services')</p>
624 <form action="index.cgi" id="indexform"></form>
626 <form id="mainform"><!--
627 --><button name="start" data-icon="start" $start_disabled>$(_ 'Start' )</button><!--
628 --><button name="stop" data-icon="stop" $stop_disabled >$(_ 'Stop' )</button><!--
629 --><button name="restart" data-icon="restart" $stop_disabled >$(_ 'Restart')</button>
630 </form>
632 <div class="float-right"><!--
633 -->$(_ 'Configuration:')<!--
634 --><button form="indexform" name="file" value="/etc/network.conf" data-icon="conf">network.conf</button><!--
635 --><button form="mainform" name="eth" data-icon="eth">Ethernet</button><!--
636 --><button form="mainform" name="wifi" data-icon="wifi">Wireless</button>
637 </div>
640 <section>
641 <header>$(_ 'Network interfaces')</header>
642 $(list_network_interfaces)
643 </section>
646 <section>
647 <header id="hosts">$(_ 'Hosts')</header>
648 <pre>$(cat /etc/hosts)</pre>
649 EOT
650 [ -w /etc/hosts ] && cat <<EOT
651 <footer>
652 <form action="index.cgi">
653 <input type="hidden" name="file" value="/etc/hosts"/>
654 <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button>
655 </form>
656 </footer>
657 EOT
658 cat <<EOT
659 </section>
662 <section>
663 <header>$(_ 'Hostname')</header>
664 <footer>
665 EOT
666 if [ -w /etc/hostname ]; then
667 cat <<EOT
668 <form>
669 <!-- was: name="hostname"; please don't use 'name' in name: unwanted webkit styling -->
670 <input type="text" name="host" value="$(cat /etc/hostname)"/><!--
671 --><button type="submit" data-icon="ok">$(_ 'Change')</button>
672 </form>
673 EOT
674 else
675 cat /etc/hostname
676 fi
677 cat <<EOT
678 </footer>
679 </section>
682 <section>
683 <header id="ifconfig">$(_ 'Output of ifconfig')</header>
684 <pre>$(ifconfig)</pre>
685 </section>
688 <section>
689 <header id="routing">$(_ 'Routing table')</header>
690 <pre>$(route -n)</pre>
691 </section>
694 <section>
695 <header id="dns">$(_ 'Domain name resolution')</header>
696 <pre>$(cat /etc/resolv.conf)</pre>
697 </section>
700 <section>
701 <header id="arp">$(_ 'ARP table')</header>
702 <pre>$(arp)</pre>
703 </section>
706 <section>
707 <header id="connections">$(_ 'IP Connections')</header>
708 <pre>$(netstat -anp 2>/dev/null | sed -e '/UNIX domain sockets/,$d' \
709 -e 's#\([0-9]*\)/#<a href="boot.cgi?daemons=pid=\1">\1</a>/#')</pre>
710 </section>
711 EOT
712 ;;
713 esac
715 xhtml_footer
716 exit 0