tazpanel view hardware.cgi @ rev 183

Fix Makefile
author Christophe Lincoln <pankso@slitaz.org>
date Fri Jun 10 15:19:16 2011 +0200 (2011-06-10)
parents ed55f0e369b3
children dbb91ac456b7
line source
1 #!/bin/sh
2 #
3 # Hardware part of TazPanel - Devices, drivers, printing
4 #
5 # Copyright (C) 2011 SliTaz GNU/Linux - BSD License
6 #
8 # Common functions from libtazpanel
9 . lib/libtazpanel
10 get_config
11 header
13 # Include gettext helper script.
14 . /usr/bin/gettext.sh
16 # Export package name for gettext.
17 TEXTDOMAIN='tazpanel'
18 export TEXTDOMAIN
20 TITLE="- Hardware"
22 #
23 # Commands
24 #
26 case " $(GET) " in
27 *\ print\ *)
28 echo "TODO" ;;
29 *\ modules\ *|*\ modinfo\ *)
30 xhtml_header
31 cat << EOT
32 <div id="wrapper">
33 <h2>`gettext "Kernel modules"`</h2>
34 <div class="float-right">
35 <form method="get" action="$SCRIPT_NAME">
36 <input type="hidden" name="modules" />
37 <input type="text" name="search" />
38 </form>
39 </div>
40 <p>`gettext "Manage, search or get information about the Linux kernel modules`</p>
41 </div>
42 EOT
43 # Request may be modinfo output that we want in the page itself
44 if [ -n "$(GET modinfo)" ]; then
45 echo '<strong>'
46 gettext "Detailed information for module: "; echo "$(GET modinfo)"
47 echo '</strong>'
48 echo '<pre>'
49 modinfo $(GET modinfo)
50 echo '</pre>'
51 fi
52 if [ -n "$(GET modprobe)" ]; then
53 echo '<pre>'
54 modprobe -v $(GET modprobe)
55 echo '</pre>'
56 fi
57 if [ -n "$(GET rmmod)" ]; then
58 echo "Removing"
59 rmmod -w $(GET rmmod)
60 fi
61 if [ -n "$(GET search)" ]; then
62 gettext "Matching result(s) for: "; echo "$(GET search)"
63 echo '<pre>'
64 modprobe -l | grep "$(GET search)" | while read line
65 do
66 name=$(basename $line)
67 mod=${name%.ko.gz}
68 echo "Module : <a href='$SCRIPT_NAME?modinfo=$mod'>$mod</a> "
69 done
70 echo '</pre>'
71 fi
72 cat << EOT
73 `table_start`
74 <tr class="thead">
75 <td>`gettext "Module"`</td>
76 <td>`gettext "Size"`</td>
77 <td>`gettext "Used"`</td>
78 <td>`gettext "by"`</td>
79 </tr>
80 EOT
81 # Get the list of modules and link to modinfo
82 lsmod | grep ^[a-z] | while read MOD SIZE USED BY
83 do
84 cat << EOT
85 <tr>
86 <td><a href="$SCRIPT_NAME?modinfo=$MOD">$MOD</a></td>
87 <td>$SIZE</td>
88 <td>$USED</td>
89 <td>`echo $BY | sed s/","/" "/g`</td>
90 </tr>
91 EOT
92 done
93 table_end ;;
94 *)
95 #
96 # Default to summary with mounted filesystem, loaded modules
97 #
98 xhtml_header
99 cat << EOT
100 <div id="wrapper">
101 <h2>`gettext "Drivers &amp; Devices"`</h2>
102 <p>`gettext "Manage your computer hardware`</p>
103 </div>
104 <div>
105 <a class="button" href="$SCRIPT_NAME?modules">
106 <img src="$IMAGES/tux.png" />Kernel modules</a>
107 </div>
109 <h3>$(gettext "Filesystem usage statistics")</h3>
110 <pre>
111 EOT
112 fdisk -l | fgrep Disk
113 echo '</pre>'
114 #
115 # Disk stats and management (mount, umount, heck)
116 #
117 table_start
118 df_thead
119 df -h | grep ^/dev | while read fs size used av pct mp
120 do
121 cat << EOT
122 <tr>
123 <td><img src="$IMAGES/harddisk.png" />$fs</td>
124 <td>$size</td>
125 <td>$av</td>
126 <td class="pct"><div class="pct"
127 style="width: $pct;">$used - $pct</div></td>
128 <td>$mp</td>
129 </tr>
130 EOT
131 done
132 table_end
133 echo "<h3>$(gettext "System memory")</h3>"
134 echo '<pre>'
135 free -m | sed \
136 -e s"#total.*\([^']\)#<span class='top'>\0</span>#"g \
137 -e s"#^[A-Z-].*:\([^']\)#<span class='sh-comment'>\0</span>#"g
138 echo '</pre>'
139 echo '<h3>lspci</h3>'
140 echo '<pre>'
141 lspci -k | sed \
142 -e s"#^[0-9].*\([^']\)#<span class='diff-at'>\0</span>#" \
143 -e s"#use: \(.*\)#use: <span class='diff-rm'>\1</span>#"
144 echo '</pre>'
145 echo '<h3>lsusb</h3>'
146 echo '<pre>'
147 lsusb
148 echo '</pre>'
149 ;;
150 esac
152 xhtml_footer
153 exit 0