tazpanel view index.cgi @ rev 75

Add SHell script colored sytax as seen in boot for /etc/init.d/local.sh
author Christophe Lincoln <pankso@slitaz.org>
date Tue Apr 12 03:52:19 2011 +0200 (2011-04-12)
parents e4a7503f7efd
children 7ac8e561d0a5
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 #
9 echo "Content-Type: text/html"
10 echo ""
12 # Common functions from libtazpanel
13 . lib/libtazpanel
14 get_config
15 query_string_parser
17 # Include gettext helper script.
18 . /usr/bin/gettext.sh
20 # Export package name for gettext.
21 TEXTDOMAIN='tazpanel'
22 export TEXTDOMAIN
24 #
25 # Things to do before displaying the page
26 #
28 case "$QUERY_STRING" in
29 panel-pass=*)
30 new=${QUERY_STRING#*=}
31 sed -i s@/:root:.*@/:root:$new@ $HTTPD_CONF ;;
32 *) continue ;;
33 esac
35 #
36 # Commands
37 #
39 case "$QUERY_STRING" in
40 file=*)
41 #
42 # Handle files (may have an edit function, we will see)
43 #
44 TITLE="- File"
45 xhtml_header
46 echo "<h2>$WANT</h2>"
47 echo '<pre>'
48 # Handle file type by extension as a Web Server does it.
49 # HTML entities: -e 's|&|\&amp;|g' -e 's|<|\&lt;|g' -e 's|>|\&gt;|g'
50 case "$WANT" in
51 *.conf|*.lst)
52 cat $WANT | syntax_highlighter conf ;;
53 *.sh|*.cgi)
54 cat $WANT | syntax_highlighter sh ;;
55 *)
56 cat $WANT ;;
57 esac
58 echo '</pre>' ;;
59 debug*)
60 TITLE="- Debug"
61 xhtml_header
62 cat << EOT
63 <h2>QUERY_STRING</h2>
64 <pre>
65 QUERY_STRING="$QUERY_STRING"
67 Fuction: query_string_parser (<a href="?debug=test=var1=var2">test</a>)
69 CASE="$CASE"
70 WANT="$WANT"
71 VAR_1="$VAR_1"
72 VAR_2="$VAR_2"
73 </pre>
74 EOT
75 echo '<h2>HTTP Environment</h2>'
76 local var
77 local info
78 echo '<pre>'
79 for var in SERVER_SOFTWARE SERVER_NAME SERVER_PORT GATEWAY_INTERFACE \
80 AUTH_TYPE REMOTE_ADDR REMOTE_PORT HTTP_HOST HTTP_USER_AGENT \
81 HTTP_ACCEPT_LANGUAGE REQUEST_METHOD REQUEST_URI QUERY_STRING \
82 CONTENT_LENGTH CONTENT_TYPE SCRIPT_NAME SCRIPT_FILENAME PWD
83 do
84 eval info=\$$var
85 echo "$var=\"$info\""
86 done
87 echo '</pre>' ;;
88 *)
89 #
90 # Default xHTML content
91 #
92 xhtml_header
93 case "$QUERY_STRING" in
94 gen-locale=*)
95 new_locale=${QUERY_STRING#gen-locale=} ;;
96 rdate)
97 echo "" ;;
98 esac
99 cat << EOT
100 <div id="wrapper">
101 <h2>`gettext "Host:"` `hostname`</h2>
102 <p>`gettext "SliTaz administration and configuration Panel"`<p>
103 </div>
105 <h3>`gettext "Summary"`</h3>
106 <div id="summary">
107 <p>
108 `gettext "Uptime:"` `uptime`
109 </p>
110 <p>
111 `gettext "Memory in Mb"`
112 `free -m | grep Mem: | awk \
113 '{print "| Total:", $2, "| Used:", $3, "| Free:", $4}'`
114 </p>
115 <!-- Close summary -->
116 </div>
118 <h4>`gettext "Network status"`</h4>
119 `list_network_interfaces`
121 <h4>`gettext "Filesystem usage statistics"`</h4>
122 <pre>
123 `df -h | grep ^/dev`
124 </pre>
126 <h3>`gettext "Panel settings"`</h3>
127 <form method="get" action="$SCRIPT_NAME">
128 <div>
129 `gettext "Panel password:"`
130 <input type="password" name="panel-pass"/>
131 <input type="submit" value="`gettext "Change"`" />
132 </div>
133 </form>
134 <p>
135 $(gettext "TazPanel provides a debuging mode and page:")
136 <a href='$SCRIPT_NAME?debug'>debug</a>
137 </p>
139 EOT
140 ;;
141 esac
143 xhtml_footer
144 exit 0