tazpanel view index.cgi @ rev 81

Use httpd_helper parser (GET)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Apr 13 16:41:02 2011 +0200 (2011-04-13)
parents 7ac8e561d0a5
children b5df231d1010
line source
1 #!/bin/sh
2 #
3 # Main CGI interface for TazPanel. In on word: KISS. Use the main css form
4 # command so we are faster and do not load unneeded functions. If necessary
5 # you can use the lib/ dir to handle external resources.
6 #
7 # Copyright (C) 2011 SliTaz GNU/Linux - GNU gpl v3
8 #
10 # Common functions from libtazpanel
11 . lib/libtazpanel
12 get_config
13 header
15 # Include gettext helper script.
16 . /usr/bin/gettext.sh
18 # Export package name for gettext.
19 TEXTDOMAIN='tazpanel'
20 export TEXTDOMAIN
22 #
23 # Things to do before displaying the page
24 #
26 [ -n "$(GET panel_pass)" ] &&
27 sed -i s@/:root:.*@/:root:$(GET panel_pass)@ $HTTPD_CONF
29 #
30 # Commands
31 #
33 case " $(GET) " in
34 *\ file\ *)
35 #
36 # Handle files (may have an edit function, we will see)
37 #
38 TITLE="- File"
39 xhtml_header
40 file="$(GET file)"
41 echo "<h2>$file</h2>"
42 echo '<pre>'
43 # Handle file type by extension as a Web Server does it.
44 case "$file" in
45 *.conf|*.lst)
46 syntax_highlighter conf ;;
47 *.sh|*.cgi)
48 syntax_highlighter sh ;;
49 *)
50 cat ;;
51 esac < $file
52 echo '</pre>' ;;
53 *\ debug\ *)
54 TITLE="- Debug"
55 xhtml_header
56 echo '<h2>HTTP Environment</h2>'
57 echo '<pre>'
58 httpinfo
59 echo '</pre>' ;;
60 *)
61 #
62 # Default xHTML content
63 #
64 xhtml_header
65 [ -n "$(GET gen_locale)" ] && new_locale=$(GET gen_locale)
66 [ -n "$(GET rdate)" ] && echo ""
67 cat << EOT
68 <div id="wrapper">
69 <h2>`gettext "Host:"` `hostname`</h2>
70 <p>`gettext "SliTaz administration and configuration Panel"`<p>
71 </div>
73 <h3>`gettext "Summary"`</h3>
74 <div id="summary">
75 <p>
76 `gettext "Uptime:"` `uptime`
77 </p>
78 <p>
79 `gettext "Memory in Mb"`
80 `free -m | grep Mem: | awk \
81 '{print "| Total:", $2, "| Used:", $3, "| Free:", $4}'`
82 </p>
83 <!-- Close summary -->
84 </div>
86 <h4>`gettext "Network status"`</h4>
87 `list_network_interfaces`
89 <h4>`gettext "Filesystem usage statistics"`</h4>
90 <pre>
91 `df -h | grep ^/dev`
92 </pre>
94 <h3>`gettext "Panel Activity"`</h3>
95 <pre>
96 $(cat $LOG_FILE | tail -n 6)
97 </pre>
99 <h3>`gettext "Panel settings"`</h3>
100 <form method="get" action="$SCRIPT_NAME">
101 <div>
102 `gettext "Panel password:"`
103 <input type="password" name="panel_pass"/>
104 <input type="submit" value="`gettext "Change"`" />
105 </div>
106 </form>
107 <p>
108 $(gettext "TazPanel provides a debuging mode and page:")
109 <a href='$SCRIPT_NAME?debug'>debug</a>
110 </p>
112 EOT
113 ;;
114 esac
116 xhtml_footer
117 exit 0