tazpanel view index.cgi @ rev 22

*.cgi clean up and update for last CSS style
author Christophe Lincoln <pankso@slitaz.org>
date Tue Apr 05 01:34:37 2011 +0200 (2011-04-05)
parents 2ea20065417a
children 79c49d85215d
line source
1 #!/bin/sh
2 #
3 # Main CGI interface for TazPanel. In on word: KISS. Use the main cas form
4 # command so we are faster and dont load unneeded function. If nececarry
5 # you can use the lib/ dir to handle external resources.
6 #
7 echo "Content-Type: text/html"
8 echo ""
10 # Common functions from libtazpanel
11 . lib/libtazpanel
12 get_config
14 # Include gettext helper script.
15 . /usr/bin/gettext.sh
17 # Export package name for gettext.
18 TEXTDOMAIN='tazpanel-cgi'
19 export TEXTDOMAIN
21 #
22 # Commands
23 #
25 case "$QUERY_STRING" in
26 boot)
27 #
28 # Everything until user login
29 #
30 TITLE="- Network"
31 xhtml_header
32 cat << EOT
33 <div id="wrapper">
34 <h2>`gettext "Boot &amp; startup"`</h2>
35 <p>
36 `gettext "Everything that appends before user login."`
37 </p>
38 </div>
40 <h3>`gettext "Kernel cmdline"`</h3>
41 <pre>
42 `cat /proc/cmdline`
43 </pre>
44 EOT
45 ;;
46 users|user=*)
47 #
48 # Manage system user accounts
49 #
50 TITLE="- Users"
51 xhtml_header
52 cmdline=`echo ${QUERY_STRING#user*=} | sed s'/&/ /g'`
53 # Parse cmdline
54 for opt in $cmdline
55 do
56 case $opt in
57 adduser=*)
58 user=${opt#adduser=}
59 cmd=adduser ;;
60 deluser=*)
61 user=${opt#deluser=}
62 deluser $user ;;
63 passwd=*)
64 pass=${opt#passwd=} ;;
65 esac
66 done
67 case "$cmd" in
68 adduser)
69 echo "$user"
70 echo $pass
71 adduser -D $user
72 echo "$pass" | chpasswd
73 for g in audio cdrom floppy video
74 do
75 addgroup $user $g
76 done ;;
77 *) continue ;;
78 esac
79 cat << EOT
80 <div id="wrapper">
81 <h2>`gettext "Manage users"`</h2>
82 <p>`gettext "Manage human users on your SliTaz system"`</p>
83 </div>
84 <form method="get" action="$SCRIPT_NAME">
85 EOT
86 table_start
87 cat << EOT
88 <tr id="thead">
89 <td>`gettext "Name"`</td>
90 <td>`gettext "User ID"`</td>
91 <td>`gettext "Name"`</td>
92 <td>`gettext "Home"`</td>
93 <td>`gettext "SHell"`</td>
94 </tr>
95 EOT
96 for i in `cat /etc/passwd | cut -d ":" -f 1`
97 do
98 if [ -d /home/$i ]; then
99 login=$i
100 uid=`cat /etc/passwd | grep $i | cut -d ":" -f 3`
101 gid=`cat /etc/passwd | grep $i | cut -d ":" -f 4`
102 name=`cat /etc/passwd | grep $i | cut -d ":" -f 5 | \
103 sed s/,,,//`
104 home=`cat /etc/passwd | grep $i | cut -d ":" -f 6`
105 shell=`cat /etc/passwd | grep $i | cut -d ":" -f 7`
106 echo '<tr>'
107 echo "<td><input type='hidden' name='user' />
108 <input type='checkbox' name='deluser' value='$login' />
109 <img src='$IMAGES/user.png' />$login</td>"
110 echo "<td>$uid:$gid</td>"
111 echo "<td>$name</td>"
112 echo "<td>$home</td>"
113 echo "<td>$shell</td>"
114 echo '</tr>'
115 fi
116 done
117 table_end
118 cat << EOT
119 <div>
120 <input type="submit" value="`gettext "Delete selected user"`" />
121 </div>
122 </form>
124 <h3>`gettext "Add a user"`</h3>
125 <form method="get" action="$SCRIPT_NAME">
126 <input type="hidden" name="user" size="30" />
127 <p>
128 `gettext ""`
129 <input type="text" name="adduser" size="30" />
130 </p>
131 <p>
132 `gettext ""`
133 <input type="password" name="passwd" size="30" />
134 </p>
135 <input type="submit" value="`gettext ""`Create user" />
136 </form
137 EOT
138 ;;
139 network)
140 #
141 # Network configuration
142 #
143 TITLE="- Network"
144 xhtml_header
145 cat << EOT
146 <div id="wrapper">
147 <h2>`gettext "Networking`</h2>
148 <p>`gettext "Manage network connection and services`</p>
149 </div>
151 <h3>Output of: ifconfig -a</h3>
152 <pre>
153 `ifconfig -a`
154 </pre>
155 EOT
156 ;;
157 hardware)
158 #
159 # Hardware drivers, devices, filesystem, screen
160 #
161 TITLE="- Hardware"
162 xhtml_header
163 cat << EOT
164 <div id="wrapper">
165 <h2>`gettext "Drivers &amp; Devices"`</h2>
166 <p>`gettext "Manage your computer hardware`</p>
167 </div>
168 EOT
169 echo '<pre>'
170 fdisk -l | fgrep Disk
171 echo '</pre>'
172 echo '<pre>'
173 df -h | grep ^/dev
174 echo '</pre>'
175 echo '<pre>'
176 lspci
177 echo '</pre>'
178 ;;
179 *)
180 #
181 # Default xHTML content
182 #
183 xhtml_header
184 cat << EOT
185 <div id="wrapper">
186 <h2>`gettext "Host:"` `hostname`</h2>
187 <p>`gettext "SliTaz administration et configuration Panel"`<p>
188 </div>
190 <h3>`gettext "Summary"`</h3>
191 <div id="summary">
193 <p>
194 `gettext "Uptime:"` `uptime`
195 </p>
196 <p>
197 `gettext "Memory in Mb:"`
198 `free -m | grep Mem: | awk \
199 '{print "| Total:", $2, "| Used:", $3, "| Free:", $4}'`
200 </p>
201 <p>
202 `gettext "Filesystem usage statistics:"`
203 </p>
204 <pre>
205 `df -h | grep ^/dev`
206 </pre>
208 <!-- Close summary -->
209 </div>
210 EOT
211 ;;
212 esac
214 xhtml_footer
215 exit 0