tazpanel diff index.cgi @ rev 14
Massive improvement to inedx.cgi, up Makefile, smatter tazpanel cmdline
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Apr 03 17:43:32 2011 +0200 (2011-04-03) |
parents | 64f564036b88 |
children | c630f623ac7c |
line diff
1.1 --- a/index.cgi Sun Apr 03 03:21:00 2011 +0200 1.2 +++ b/index.cgi Sun Apr 03 17:43:32 2011 +0200 1.3 @@ -1,34 +1,15 @@ 1.4 #!/bin/sh 1.5 # 1.6 -# Main CGI interface for TazPanel. In on word: KISS 1.7 +# Main CGI interface for TazPanel. In on word: KISS. Use the main cas form 1.8 +# command so we are faster and dont load unneeded function. If nececarry 1.9 +# you can use the lib/ dir to handle external resources. 1.10 # 1.11 echo "Content-Type: text/html" 1.12 echo "" 1.13 1.14 -# We need a config file first 1.15 -CONFIG="/etc/slitaz/tazpanel.conf" 1.16 -[ -f $CONFIG ] && . $CONFIG 1.17 -[ -f tazpanel.conf ] && . tazpanel.conf 1.18 -[ -z $PANEL ] && echo "No config file found" && exit 1 1.19 - 1.20 -# xHTML 5 header 1.21 -xhtml_header() { 1.22 - cat $HEADER | sed s/'- %TITLE%'/"$TITLE"/ 1.23 -} 1.24 - 1.25 -table_start() { 1.26 - cat << EOT 1.27 -<table> 1.28 - <tbody> 1.29 -EOT 1.30 -} 1.31 - 1.32 -table_end () { 1.33 - cat << EOT 1.34 - </tbody> 1.35 -</table> 1.36 -EOT 1.37 -} 1.38 +# Common functions from libtazpanel 1.39 +. lib/libtazpanel 1.40 +get_config 1.41 1.42 # 1.43 # Commands 1.44 @@ -36,34 +17,32 @@ 1.45 1.46 case "$QUERY_STRING" in 1.47 boot) 1.48 + # 1.49 # Everything until user login 1.50 + # 1.51 TITLE="- Network" 1.52 xhtml_header 1.53 cat << EOT 1.54 <div id="wrapper"> 1.55 -<h2>`gettext "Boot & startup"`</h2> 1.56 -<p> 1.57 - `gettext "Everything that appends before user login."` 1.58 -</p> 1.59 + <h2>`gettext "Boot & startup"`</h2> 1.60 + <p> 1.61 + `gettext "Everything that appends before user login."` 1.62 + </p> 1.63 +</div> 1.64 1.65 <h3>`gettext "Kernel cmdline"`</h3> 1.66 <pre> 1.67 `cat /proc/cmdline` 1.68 </pre> 1.69 EOT 1.70 - echo '</div>' ;; 1.71 + ;; 1.72 users|user=*) 1.73 + # 1.74 # Manage system user accounts 1.75 + # 1.76 TITLE="- Users" 1.77 xhtml_header 1.78 - 1.79 cmdline=`echo ${QUERY_STRING#user*=} | sed s'/&/ /g'` 1.80 - #user=`echo ${cmdline} | sed s'/=/ /' | awk '{print $1}'` 1.81 - #cmd=`echo ${cmdline} | sed s'/=/ /' |awk '{print $2}'` 1.82 - 1.83 - [ $DEBUG == "1" ] && echo \ 1.84 - "<p class='debug'>$cmdline</p>" 1.85 - #$REQUEST_METHOD $QUERY_STRING 1.86 # Parse cmdline 1.87 for opt in $cmdline 1.88 do 1.89 @@ -92,8 +71,9 @@ 1.90 esac 1.91 cat << EOT 1.92 <div id="wrapper"> 1.93 -<h2>`gettext "Manage users"`</h2> 1.94 -<div>`gettext "Manage human users on your SliTaz system"`</div> 1.95 + <h2>`gettext "Manage users"`</h2> 1.96 + <p>`gettext "Manage human users on your SliTaz system"`</p> 1.97 +</div> 1.98 <form method="get" action="$SCRIPT_NAME"> 1.99 EOT 1.100 table_start 1.101 @@ -128,66 +108,101 @@ 1.102 fi 1.103 done 1.104 table_end 1.105 - #`gettext "Selection:"` 1.106 cat << EOT 1.107 -<div> 1.108 - <input type="submit" value="`gettext "Delete selected user"`" /> 1.109 -</div> 1.110 - 1.111 + <div> 1.112 + <input type="submit" value="`gettext "Delete selected user"`" /> 1.113 + </div> 1.114 </form> 1.115 -</div> 1.116 1.117 <h3>`gettext "Add a user"`</h3> 1.118 <form method="get" action="$SCRIPT_NAME"> 1.119 -<input type="hidden" name="user" size="30" /> 1.120 -<p> 1.121 - `gettext ""` 1.122 - <input type="text" name="adduser" size="30" /> 1.123 -</p> 1.124 -<p> 1.125 - `gettext ""` 1.126 - <input type="password" name="passwd" size="30" /> 1.127 -</p> 1.128 -<input type="submit" value="`gettext ""`Create user" /> 1.129 + <input type="hidden" name="user" size="30" /> 1.130 + <p> 1.131 + `gettext ""` 1.132 + <input type="text" name="adduser" size="30" /> 1.133 + </p> 1.134 + <p> 1.135 + `gettext ""` 1.136 + <input type="password" name="passwd" size="30" /> 1.137 + </p> 1.138 + <input type="submit" value="`gettext ""`Create user" /> 1.139 </form 1.140 EOT 1.141 ;; 1.142 network) 1.143 + # 1.144 # Network configuration 1.145 + # 1.146 TITLE="- Network" 1.147 xhtml_header 1.148 cat << EOT 1.149 <div id="wrapper"> 1.150 -<h2>`gettext "Connections`</h2> 1.151 + <h2>`gettext "Networking`</h2> 1.152 + <p>`gettext "Manage network connection and services`</p> 1.153 +</div> 1.154 + 1.155 +<h3>Output of: ifconfig -a</h3> 1.156 +<pre> 1.157 +`ifconfig -a` 1.158 +</pre> 1.159 EOT 1.160 - echo '<pre>' 1.161 - ifconfig 1.162 - echo '</pre>' 1.163 - echo '</div>' ;; 1.164 + ;; 1.165 hardware) 1.166 + # 1.167 + # Hardware drivers, devices, filesystem, screen 1.168 + # 1.169 TITLE="- Hardware" 1.170 xhtml_header 1.171 cat << EOT 1.172 <div id="wrapper"> 1.173 -<h2>`gettext "Drivers & Devices"`</h2> 1.174 + <h2>`gettext "Drivers & Devices"`</h2> 1.175 + <p>`gettext "Manage your computer hardware`</p> 1.176 +</div> 1.177 EOT 1.178 echo '<pre>' 1.179 - lspci 1.180 + fdisk -l | fgrep Disk 1.181 echo '</pre>' 1.182 - echo '</div>' ;; 1.183 + echo '<pre>' 1.184 + df -h | grep ^/dev 1.185 + echo '</pre>' 1.186 + echo '<pre>' 1.187 + lspci 1.188 + echo '</pre>' 1.189 + ;; 1.190 *) 1.191 + # 1.192 # Default xHTML content 1.193 + # 1.194 xhtml_header 1.195 cat << EOT 1.196 <div id="wrapper"> 1.197 -<h2>`gettext "Host:"` `hostname`</h2> 1.198 + <h2>`gettext "Host:"` `hostname`</h2> 1.199 + <p>`gettext "SliTaz administration et configuration Panel"`<p> 1.200 +</div> 1.201 + 1.202 +<h3>`gettext "Summary"`</h3> 1.203 +<div id="summary"> 1.204 + 1.205 <p> 1.206 - Uptime: `uptime` 1.207 + `gettext "Uptime:"` `uptime` 1.208 </p> 1.209 +<p> 1.210 + `gettext "Memory in Mb:"` 1.211 + `free -m | grep Mem: | awk \ 1.212 + '{print "| Total:", $2, "| Used:", $3, "| Free:", $4}'` 1.213 +</p> 1.214 +<p> 1.215 + `gettext "Filesystem usage statistics:"` 1.216 +</p> 1.217 +<pre> 1.218 +`df -h | grep ^/dev` 1.219 +</pre> 1.220 + 1.221 +<!-- Close summary --> 1.222 +</div> 1.223 EOT 1.224 - echo '</div>' 1.225 ;; 1.226 esac 1.227 1.228 -# xHTML 5 footer 1.229 -cat $FOOTER 1.230 +xhtml_footer 1.231 +exit 0