tazpanel view 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 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 #
15 # Commands
16 #
18 case "$QUERY_STRING" in
19 boot)
20 #
21 # Everything until user login
22 #
23 TITLE="- Network"
24 xhtml_header
25 cat << EOT
26 <div id="wrapper">
27 <h2>`gettext "Boot &amp; startup"`</h2>
28 <p>
29 `gettext "Everything that appends before user login."`
30 </p>
31 </div>
33 <h3>`gettext "Kernel cmdline"`</h3>
34 <pre>
35 `cat /proc/cmdline`
36 </pre>
37 EOT
38 ;;
39 users|user=*)
40 #
41 # Manage system user accounts
42 #
43 TITLE="- Users"
44 xhtml_header
45 cmdline=`echo ${QUERY_STRING#user*=} | sed s'/&/ /g'`
46 # Parse cmdline
47 for opt in $cmdline
48 do
49 case $opt in
50 adduser=*)
51 user=${opt#adduser=}
52 cmd=adduser ;;
53 deluser=*)
54 user=${opt#deluser=}
55 deluser $user ;;
56 passwd=*)
57 pass=${opt#passwd=} ;;
58 esac
59 done
60 case "$cmd" in
61 adduser)
62 echo "$user"
63 echo $pass
64 adduser -D $user
65 echo "$pass" | chpasswd
66 for g in audio cdrom floppy video
67 do
68 addgroup $user $g
69 done ;;
70 *) continue ;;
71 esac
72 cat << EOT
73 <div id="wrapper">
74 <h2>`gettext "Manage users"`</h2>
75 <p>`gettext "Manage human users on your SliTaz system"`</p>
76 </div>
77 <form method="get" action="$SCRIPT_NAME">
78 EOT
79 table_start
80 cat << EOT
81 <tr id="thead">
82 <td>`gettext "Name"`</td>
83 <td>`gettext "User ID"`</td>
84 <td>`gettext "Name"`</td>
85 <td>`gettext "Home"`</td>
86 <td>`gettext "SHell"`</td>
87 </tr>
88 EOT
89 for i in `cat /etc/passwd | cut -d ":" -f 1`
90 do
91 if [ -d /home/$i ]; then
92 login=$i
93 uid=`cat /etc/passwd | grep $i | cut -d ":" -f 3`
94 gid=`cat /etc/passwd | grep $i | cut -d ":" -f 4`
95 name=`cat /etc/passwd | grep $i | cut -d ":" -f 5 | \
96 sed s/,,,//`
97 home=`cat /etc/passwd | grep $i | cut -d ":" -f 6`
98 shell=`cat /etc/passwd | grep $i | cut -d ":" -f 7`
99 echo '<tr>'
100 echo "<td><input type='hidden' name='user' />
101 <input type='checkbox' name='deluser' value='$login' />
102 <img src='$IMAGES/user.png' />$login</td>"
103 echo "<td>$uid:$gid</td>"
104 echo "<td>$name</td>"
105 echo "<td>$home</td>"
106 echo "<td>$shell</td>"
107 echo '</tr>'
108 fi
109 done
110 table_end
111 cat << EOT
112 <div>
113 <input type="submit" value="`gettext "Delete selected user"`" />
114 </div>
115 </form>
117 <h3>`gettext "Add a user"`</h3>
118 <form method="get" action="$SCRIPT_NAME">
119 <input type="hidden" name="user" size="30" />
120 <p>
121 `gettext ""`
122 <input type="text" name="adduser" size="30" />
123 </p>
124 <p>
125 `gettext ""`
126 <input type="password" name="passwd" size="30" />
127 </p>
128 <input type="submit" value="`gettext ""`Create user" />
129 </form
130 EOT
131 ;;
132 network)
133 #
134 # Network configuration
135 #
136 TITLE="- Network"
137 xhtml_header
138 cat << EOT
139 <div id="wrapper">
140 <h2>`gettext "Networking`</h2>
141 <p>`gettext "Manage network connection and services`</p>
142 </div>
144 <h3>Output of: ifconfig -a</h3>
145 <pre>
146 `ifconfig -a`
147 </pre>
148 EOT
149 ;;
150 hardware)
151 #
152 # Hardware drivers, devices, filesystem, screen
153 #
154 TITLE="- Hardware"
155 xhtml_header
156 cat << EOT
157 <div id="wrapper">
158 <h2>`gettext "Drivers &amp; Devices"`</h2>
159 <p>`gettext "Manage your computer hardware`</p>
160 </div>
161 EOT
162 echo '<pre>'
163 fdisk -l | fgrep Disk
164 echo '</pre>'
165 echo '<pre>'
166 df -h | grep ^/dev
167 echo '</pre>'
168 echo '<pre>'
169 lspci
170 echo '</pre>'
171 ;;
172 *)
173 #
174 # Default xHTML content
175 #
176 xhtml_header
177 cat << EOT
178 <div id="wrapper">
179 <h2>`gettext "Host:"` `hostname`</h2>
180 <p>`gettext "SliTaz administration et configuration Panel"`<p>
181 </div>
183 <h3>`gettext "Summary"`</h3>
184 <div id="summary">
186 <p>
187 `gettext "Uptime:"` `uptime`
188 </p>
189 <p>
190 `gettext "Memory in Mb:"`
191 `free -m | grep Mem: | awk \
192 '{print "| Total:", $2, "| Used:", $3, "| Free:", $4}'`
193 </p>
194 <p>
195 `gettext "Filesystem usage statistics:"`
196 </p>
197 <pre>
198 `df -h | grep ^/dev`
199 </pre>
201 <!-- Close summary -->
202 </div>
203 EOT
204 ;;
205 esac
207 xhtml_footer
208 exit 0