tazpanel view pkgs.cgi @ rev 155

hardware.cgi: highlight kernel module in lspci
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Apr 18 10:52:59 2011 +0200 (2011-04-18)
parents e5e08e734226
children 2b919224c683
line source
1 #!/bin/sh
2 #
3 # TazPKG CGI interface - Manage packages via a browser
4 #
5 # This CGI interface intensively uses tazpkg to manage packages and have
6 # its own code for some tasks. Please KISS, it is important and keep speed
7 # in mind. Thanks, Pankso.
8 #
9 # (C) 2011 SliTaz GNU/Linux - BSD License
10 #
12 . lib/libtazpanel
13 get_config
14 header
16 # xHTML 5 header with special side bar fo categories.
17 TITLE="- Packages"
18 xhtml_header | sed 's/id="content"/id="content-sidebar"/'
21 # We need packages information for list and search
22 parse_packages_desc() {
23 IFS="|"
24 cut -f 1,2,3,5 -d "|" | while read PACKAGE VERSION SHORT_DESC WEB_SITE
25 do
26 echo '<tr>'
27 if [ -d $INSTALLED/${PACKAGE% } ]; then
28 echo -e "<td><input type='checkbox' name='pkg' value='$PACKAGE'>\n
29 <a href='$SCRIPT_NAME?info=$PACKAGE'>
30 <img src='$IMAGES/tazpkg-installed.png'/>$PACKAGE</a></td>"
31 else
32 echo -e "<td><input type='checkbox' name='pkg' value='$PACKAGE'>\n
33 <a href='$SCRIPT_NAME?info=$PACKAGE'>
34 <img src='$IMAGES/tazpkg.png'/>$PACKAGE</a></td>"
35 fi
36 echo "<td>$VERSION</td>"
37 echo "<td class='desc'>$SHORT_DESC</td>"
38 echo "<td><a href='$WEB_SITE'><img src='$IMAGES/browser.png'/></a></td>"
39 echo '</tr>'
40 done
41 unset IFS
42 }
44 # Display a full summary of packages stats
45 packages_summary() {
46 gettext "Last recharge : "
47 stat=`stat -c %y $LOCALSTATE/packages.list | \
48 sed 's/\(:..\):.*/\1/' | awk '{print $1}'`
49 mtime=`find $LOCALSTATE/packages.list -mtime +10`
50 echo -n "$stat "
51 if [ "$mtime" ]; then
52 echo "(Older than 10 days)"
53 else
54 echo "(Not older than 10 days)"
55 fi
56 gettext "Installed packages : "
57 ls $INSTALLED | wc -l
58 gettext "Mirrored packages : "
59 cat $LOCALSTATE/packages.list | wc -l
60 gettext "Upgradeable packages : "
61 cat $LOCALSTATE/packages.up | wc -l
62 #gettext "Installed files : "
63 #cat $INSTALLED/*/files.list | wc -l
64 gettext "Blocked packages : "
65 cat $LOCALSTATE/blocked-packages.list | wc -l
66 }
68 # Parse mirrors list to be able to have an icon and remove link
69 list_mirrors() {
70 while read line
71 do
72 cat << EOT
73 <li><a href="$SCRIPT_NAME?admin=rm-mirror=$line&amp;file=$(httpd -e $1)"><img
74 src="$IMAGES/clear.png" /></a><a href="$line">$line</a></li>
75 EOT
76 done < $1
77 }
79 # Parse repositories list to be able to have an icon and remove link
80 list_repos() {
81 ls $LOCALSTATE/undigest 2> /dev/null | while read repo ; do
82 cat <<EOT
83 <li><a href="$SCRIPT_NAME?admin=rm-repo=$repo">
84 <img src="$IMAGES/clear.png">$repo</a></li>
85 EOT
86 done
87 }
89 #
90 # xHTML functions
91 #
93 # ENTER will search but user may search for a button, so put one.
94 search_form() {
95 [ -n "$repo" ] || repo="$(GET repo)"
96 [ -n "$repo" ] || repo=Any
97 cat << EOT
98 <div class="search">
99 <form method="get" action="$SCRIPT_NAME">
100 <p>
101 <input type="text" name="search" size="20">
102 <input type="submit" value="`gettext "Search"`">
103 <input class="radius" type="submit" name="files"
104 value="`gettext "Files"`">
105 <input type="hidden" name="repo" value="$repo" />
106 </p>
107 </form>
108 </div>
109 EOT
110 }
112 table_head() {
113 cat << EOT
114 <tr id="thead">
115 <td>`gettext "Name"`</td>
116 <td>`gettext "Version"`</td>
117 <td>`gettext "Description"`</td>
118 <td>`gettext "Web"`</td>
119 </tr>
120 EOT
121 }
123 sidebar() {
124 [ -n "$repo" ] || repo=Public
125 cat << EOT
126 <div id="sidebar">
127 <h4>Categories</h4>
128 <a class="active_base-system" href="$SCRIPT_NAME?cat=base-system&repo=$repo">Base-system</a>
129 <a class="active_x-window" href="$SCRIPT_NAME?cat=x-window&repo=$repo">X window</a>
130 <a class="active_utilities" href="$SCRIPT_NAME?cat=utilities&repo=$repo">Utilities</a>
131 <a class="active_network" href="$SCRIPT_NAME?cat=network&repo=$repo">Network</a>
132 <a class="active_games" href="$SCRIPT_NAME?cat=games&repo=$repo">Games</a>
133 <a class="active_graphics" href="$SCRIPT_NAME?cat=graphics&repo=$repo">Graphics</a>
134 <a class="active_office" href="$SCRIPT_NAME?cat=office&repo=$repo">Office</a>
135 <a class="active_multimedia" href="$SCRIPT_NAME?cat=multimedia&repo=$repo">Multimedia</a>
136 <a class="active_development" href="$SCRIPT_NAME?cat=development&repo=$repo">Development</a>
137 <a class="active_system-tools" href="$SCRIPT_NAME?cat=system-tools&repo=$repo">System tools</a>
138 <a class="active_security" href="$SCRIPT_NAME?cat=security&repo=$repo">Security</a>
139 <a class="active_misc" href="$SCRIPT_NAME?cat=misc&repo=$repo">Misc</a>
140 <a class="active_meta" href="$SCRIPT_NAME?cat=meta&repo=$repo">Meta</a>
141 <a class="active_non-free" href="$SCRIPT_NAME?cat=non-free&repo=$repo">Non free</a>
142 <a class="active_all" href="$SCRIPT_NAME?cat=all&repo=$repo">All</a>
143 EOT
145 if [ -d $LOCALSTATE/undigest ]; then
146 [ -n "$category" ] || category="base-system"
147 cat << EOT
148 <p></p>
149 <h4>Repositories</h4>
150 <a class="repo_Public" href="$SCRIPT_NAME?repo=Public&cat=$category">Public</a>
151 EOT
152 for i in $(ls $LOCALSTATE/undigest); do
153 cat << EOT
154 <a class="repo_$i" href="$SCRIPT_NAME?repo=$i&cat=$category">$i</a>
155 EOT
156 done
157 cat << EOT
158 <a class="repo_Any" href="$SCRIPT_NAME?repo=Any&cat=$category">Any</a>
159 EOT
160 fi
161 echo "</div>"
162 }
164 repo_list() {
165 if [ -n "$(ls $LOCALSTATE/undigest/ 2> /dev/null)" ]; then
166 case "$repo" in
167 Public) ;;
168 ""|Any) for i in $LOCALSTATE/undigest/* ; do
169 [ -d "$i" ] && echo "$i$1"
170 done ;;
171 *) echo "$LOCALSTATE/undigest/$repo$1"
172 return ;;
173 esac
174 fi
175 echo "$LOCALSTATE$1"
176 }
178 repo_name() {
179 case "$1" in
180 $LOCALSTATE) echo "Public" ;;
181 $LOCALSTATE/undigest/*) echo ${1#$LOCALSTATE/undigest/} ;;
182 esac
183 }
185 #
186 # Commands
187 #
189 case " $(GET) " in
190 *\ list\ *)
191 #
192 # List installed packages. This is the default because parsing
193 # the full packages.desc can be long and take up some resources
194 #
195 cd $INSTALLED
196 search_form
197 sidebar
198 LOADING_MSG="Listing packages..."
199 loading_msg
200 cat << EOT
201 <h2>`gettext "My packages"`</h2>
202 <form method='get' action='$SCRIPT_NAME'>
203 <div id="actions">
204 <div class="float-left">
205 `gettext "Selection:"`
206 <input type="submit" name="do" value="Remove" />
207 </div>
208 <div class="float-right">
209 `gettext "List:"`
210 <input type="submit" name="recharge" value="Recharge" />
211 <input type="submit" name="up" value="Upgrade" />
212 </div>
213 </div>
214 EOT
215 table_start
216 table_head
217 for pkg in *
218 do
219 . $pkg/receipt
220 echo '<tr>'
221 # Use default tazpkg icon since all packages displayed are
222 # installed
223 colorpkg=$pkg
224 grep -qs "^$pkg$" $LOCALSTATE/blocked-packages.list &&
225 colorpkg="<span style='color: red;'>$pkg</span>"
226 echo "<td class='pkg'>
227 <input type='checkbox' name='pkg' value=\"$pkg\" />
228 <a href='$SCRIPT_NAME?info=$pkg'><img
229 src='$IMAGES/tazpkg-installed.png'/>$colorpkg</a></td>"
230 echo "<td>$VERSION</td>"
231 echo "<td class='desc'>$SHORT_DESC</td>"
232 echo "<td><a href='$WEB_SITE'><img src='$IMAGES/browser.png'/></a></td>"
233 echo '</tr>'
234 done
235 table_end
236 echo '</form>' ;;
237 *\ linkable\ *)
238 #
239 # List linkable packages.
240 #
241 cd $INSTALLED
242 search_form
243 sidebar
244 LOADING_MSG="Listing linkable packages..."
245 loading_msg
246 cat << EOT
247 <h2>`gettext "Linkable packages"`</h2>
248 <form method='get' action='$SCRIPT_NAME'>
249 <div id="actions">
250 <div class="float-left">
251 `gettext "Selection:"`
252 <input type="submit" name="do" value="Link" />
253 </div>
254 <div class="float-right">
255 `gettext "List:"`
256 <input type="submit" name="recharge" value="Recharge" />
257 <input type="submit" name="up" value="Upgrade" />
258 </div>
259 </div>
260 EOT
261 table_start
262 table_head
263 target=$(readlink $LOCALSTATE/fslink)
264 for pkg in $(ls $target/$INSTALLED)
265 do
266 [ -s $pkg/receipt ] && continue
267 . $target/$INSTALLED/$pkg/receipt
268 echo '<tr>'
269 echo "<td class='pkg'>
270 <input type='checkbox' name='pkg' value=\"$pkg\" />
271 <a href='$SCRIPT_NAME?info=$pkg'><img
272 src='$IMAGES/tazpkg.png'/>$pkg</a></td>"
273 echo "<td>$VERSION</td>"
274 echo "<td class='desc'>$SHORT_DESC</td>"
275 echo "<td><a href='$WEB_SITE'><img src='$IMAGES/browser.png'/></a></td>"
276 echo '</tr>'
277 done
278 table_end
279 echo '</form>' ;;
280 *\ cat\ *)
281 #
282 # List all available packages by category on mirror. Listing all
283 # packages is too resource intensive and not useful.
284 #
285 cd $LOCALSTATE
286 repo=$(GET repo)
287 category=$(GET cat)
288 [ "$category" == "cat" ] && category="base-system"
289 grep_category=$category
290 [ "$grep_category" == "all" ] && grep_category=".*"
291 search_form
292 sidebar | sed "s/active_$category/active/;s/repo_$repo/active/"
293 LOADING_MSG="Listing packages..."
294 loading_msg
295 cat << EOT
296 <h2>`gettext "Category:"` $category</h2>
297 <form method='get' action='$SCRIPT_NAME'>
298 <div id="actions">
299 <div class="float-left">
300 `gettext "Selection:"`
301 <input type="submit" name="do" value="Install" />
302 <input type="submit" name="do" value="Remove" />
303 <input type="hidden" name="repo" value="$repo" />
304 </div>
305 <div class="float-right">
306 `gettext "List:"`
307 <input type="submit" name="recharge" value="Recharge" />
308 <input type="submit" name="up" value="Upgrade" />
309 <a class="button" href='$SCRIPT_NAME?list'>
310 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
311 </div>
312 </div>
313 EOT
314 for i in $(repo_list ""); do
315 [ "$repo" != "Public" ] &&
316 echo "<h3>Repository: $(repo_name $i)</h3>"
317 table_start
318 table_head
319 grep "| $grep_category |" $i/packages.desc | \
320 parse_packages_desc
321 table_end
322 done
323 echo '</form>' ;;
324 *\ search\ *)
325 #
326 # Search for packages. Here default is to search in packages.desc
327 # and so get result including packages names and descriptions
328 #
329 pkg=$(GET search)
330 repo=$(GET repo)
331 cd $LOCALSTATE
332 search_form
333 sidebar | sed "s/repo_$repo/active/"
334 LOADING_MSG="Searching packages..."
335 loading_msg
336 cat << EOT
337 <h2>`gettext "Search packages"`</h2>
338 <form method="get" action="$SCRIPT_NAME">
339 <div id="actions">
340 <div class="float-left">
341 `gettext "Selection:"`
342 <input type="submit" name="do" value="Install" />
343 <input type="submit" name="do" value="Remove" />
344 <a href="`cat $PANEL/lib/checkbox.js`">`gettext "Toogle all"`</a>
345 </div>
346 <div class="float-right">
347 `gettext "List:"`
348 <input type="submit" name="recharge" value="Recharge" />
349 <input type="submit" name="up" value="Upgrade" />
350 <a class="button" href='$SCRIPT_NAME?list'>
351 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
352 </div>
353 </div>
354 <input type="hidden" name="repo" value="$repo" />
355 EOT
356 table_start
357 if [ "$(GET files)" ]; then
358 cat <<EOT
359 <tr id="thead">
360 <td>`gettext "Package"`</td>
361 <td>`gettext "File"`</td>
362 </tr>
363 $(unlzma -c $(repo_list /files.list.lzma) \
364 | grep -Ei ": .*$(GET search)" | \
365 while read PACKAGE FILE; do
366 PACKAGE=${PACKAGE%:}
367 image=tazpkg-installed.png
368 [ -d $INSTALLED/$PACKAGE ] || image=tazpkg.png
369 echo "<tr>
370 <td><input type='checkbox' name='pkg' value='$PACKAGE'>
371 <a href='$SCRIPT_NAME?info=$PACKAGE'><img src='$IMAGES/$image' />$PACKAGE</a></td>
372 <td>$FILE</td>
373 </tr>"
374 done)
375 EOT
376 else
377 table_head
378 grep -ih $pkg $(repo_list /packages.desc) | \
379 parse_packages_desc
380 fi
381 table_end
382 echo '</form>' ;;
383 *\ recharge\ *)
384 #
385 # Lets recharge the packages list
386 #
387 search_form
388 sidebar
389 LOADING_MSG="Recharging lists..."
390 loading_msg
391 cat << EOT
392 <h2>`gettext "Recharge"`</h2>
393 <form method='get' action='$SCRIPT_NAME'>
394 <div id="actions">
395 <div class="float-left">
396 <p>
397 `gettext "Recharge checks for new or updated packages"`
398 </p>
399 </div>
400 <div class="float-right">
401 <p>
402 <a class="button" href='$SCRIPT_NAME?up'>
403 <img src="$IMAGES/update.png" />`gettext "Check upgrades"`</a>
404 <a class="button" href='$SCRIPT_NAME?list'>
405 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
406 </p>
407 </div>
408 </div>
409 <pre>
410 EOT
411 gettext "Recharging packages list" | log
412 tazpkg recharge | filter_taztools_msgs
413 cat << EOT
414 </pre>
415 <p>
416 `gettext "Packages lists are up-to-date. You should check for upgrades now."`
417 </p>
418 EOT
419 ;;
420 *\ up\ *)
421 #
422 # Upgrade packages
423 #
424 cd $LOCALSTATE
425 search_form
426 sidebar
427 LOADING_MSG="Checking for upgrades..."
428 loading_msg
429 cat << EOT
430 <h2>`gettext "Up packages"`</h2>
431 <form method="get" action="$SCRIPT_NAME">
432 <div id="actions">
433 <div class="float-left">
434 `gettext "Selection:"`
435 <input type="submit" name="do" value="Install" />
436 <input type="submit" name="do" value="Remove" />
437 <a href="`cat $PANEL/lib/checkbox.js`">`gettext "Toogle all"`</a>
438 </div>
439 <div class="float-right">
440 `gettext "List:"`
441 <input type="submit" name="recharge" value="Recharge" />
442 <a class="button" href='$SCRIPT_NAME?list'>
443 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
444 </div>
445 </div>
446 EOT
447 tazpkg up --check >/dev/null
448 table_start
449 table_head
450 for pkg in `cat packages.up`
451 do
452 grep -s "^$pkg |" $LOCALSTATE/packages.desc \
453 $LOCALSTATE/undisgest/*/packages.desc | \
454 parse_packages_desc
455 done
456 table_end
457 echo '</form>' ;;
458 *\ do\ *)
459 #
460 # Do an action on one or some packages
461 #
462 opt=""
463 pkgs=""
464 cmdline=`echo ${QUERY_STRING#do=} | sed s'/&/ /g'`
465 cmd=`echo ${cmdline} | awk '{print $1}'`
466 pkgs=`echo $cmdline | sed -e s'/+/ /g' -e s'/pkg=//g' -e s/$cmd//`
467 cmd=`echo $cmd | tr [A-Z] [a-z]`
468 case $cmd in
469 install)
470 cmd=get-install opt=--forced ;;
471 link)
472 opt=$(readlink $LOCALSTATE/fslink) ;;
473 esac
474 search_form
475 sidebar
476 LOADING_MSG="${cmd}ing packages..."
477 loading_msg
478 cat << EOT
479 <h2>Tazpkg: $cmd</h2>
480 <form method="get" action="$SCRIPT_NAME">
481 <div id="actions">
482 <div class="float-left">
483 <p>
484 `gettext "Performing tasks on packages"`
485 </p>
486 </div>
487 <div class="float-right">
488 <p>
489 <a class="button" href='$SCRIPT_NAME?list'>
490 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
491 </p>
492 </div>
493 </div>
494 EOT
495 echo '<div class="box">'
496 gettext "Executing $cmd for:$pkgs"
497 echo '</div>'
498 for pkg in $pkgs
499 do
500 echo '<pre>'
501 echo 'y' | tazpkg $cmd $pkg $opt 2>/dev/null | filter_taztools_msgs
502 echo '</pre>'
503 done ;;
504 *\ info\ *)
505 #
506 # Packages info
507 #
508 pkg=$(GET info)
509 search_form
510 sidebar
511 if [ -d $INSTALLED/$pkg ]; then
512 . $INSTALLED/$pkg/receipt
513 files=`cat $INSTALLED/$pkg/files.list | wc -l`
514 action=$(gettext "Remove")
515 else
516 cd $LOCALSTATE
517 LOADING_MSG=$(gettext "Getting package info...")
518 loading_msg
519 IFS='|'
520 set -- $(grep -hs "^$pkg |" packages.desc \
521 undigest/*/packages.desc)
522 unset IFS
523 PACKAGE=$1
524 VERSION="$(echo $2)"
525 SHORT_DESC="$(echo $3)"
526 CATEGORY="$(echo $4)"
527 WEB_SITE="$(echo $5)"
528 action=$(gettext "Install")
529 fi
530 cat << EOT
531 <h2>`gettext "Package"` $PACKAGE</h2>
532 <div id="actions">
533 <div class="float-left">
534 <p>
535 <a class="button" href='$SCRIPT_NAME?do=$action&$pkg'>$action</a>
536 EOT
537 if [ -d $INSTALLED/$pkg ]; then
538 if grep -qs "^$pkg$" $LOCALSTATE/blocked-packages.list; then
539 block=$(gettext "Unblock")
540 else
541 block=$(gettext "Block")
542 fi
543 cat << EOT
544 <a class="button" href='$SCRIPT_NAME?do=$block&$pkg'>$block</a>
545 <a class="button" href='$SCRIPT_NAME?do=Repack&$pkg'>Repack</a>
546 EOT
547 fi
548 cat << EOT
549 </p>
550 </div>
551 <div class="float-right">
552 <p>
553 <a class="button" href='$SCRIPT_NAME?list'>
554 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
555 </p>
556 </div>
557 </div>
558 <pre>
559 Name : $PACKAGE
560 Version : $VERSION
561 Description : $SHORT_DESC
562 Category : $CATEGORY
563 EOT
564 if [ -d $INSTALLED/$pkg ]; then
565 cat << EOT
566 Maintainer : $MAINTAINER
567 Website : <a href="$WEB_SITE">$WEB_SITE</a>
568 Sizes : $PACKED_SIZE/$UNPACKED_SIZE
569 EOT
570 if [ -n "$DEPENDS" ]; then
571 echo -n "Depends : "
572 for i in $DEPENDS; do
573 echo -n "<a href="$SCRIPT_NAME?info=$i">$i</a> "
574 done
575 echo ""
576 fi
577 if [ -n "$SUGGESTED" ]; then
578 echo -n "Suggested : "
579 for i in $SUGGESTED; do
580 echo -n "<a href="$SCRIPT_NAME?info=$i">$i</a> "
581 done
582 echo ""
583 fi
584 [ -n "$TAGS" ] && echo "Tags : $TAGS"
585 cat << EOT
586 </pre>
588 <p>`gettext "Installed files:"` `cat $INSTALLED/$pkg/files.list | wc -l`</p>
589 <pre>
590 `cat $INSTALLED/$pkg/files.list`
591 </pre>
592 EOT
593 else
594 cat << EOT
595 Website : <a href="$WEB_SITE">$WEB_SITE</a>
596 Sizes : `grep -hsA 3 ^$pkg$ packages.txt undigest/*/packages.txt | \
597 tail -n 1 | sed 's/ *//'`
598 </pre>
600 <p>`gettext "Installed files:"`</p>
601 <pre>
602 `unlzma -c files.list.lzma undigest/*/files.list.lzma 2> /dev/null | \
603 sed "/^$pkg: /!d;s/^$pkg: //"`
604 </pre>
605 EOT
606 fi
607 ;;
608 *\ admin\ * )
609 #
610 # Tazpkg configuration page
611 #
612 cmd=$(GET admin)
613 case "$cmd" in
614 clean)
615 rm -rf /var/cache/tazpkg/* ;;
616 add-mirror)
617 # Decode url
618 mirror=$(GET mirror)
619 case "$mirror" in
620 http://*|ftp://*)
621 echo "$mirror" >> $(GET file) ;;
622 esac ;;
623 rm-mirror=http://*|rm-mirror=ftp://*)
624 mirror=${cmd#rm-mirror=}
625 sed -i -e "s@$mirror@@" -e '/^$/d' $(GET file) ;;
626 add-repo)
627 # Decode url
628 mirror=$(GET mirror)
629 repository=$LOCALSTATE/undigest/$(GET repository)
630 case "$mirror" in
631 http://*|ftp://*)
632 mkdir -p $repository
633 echo "$mirror" > $repository/mirror
634 echo "$mirror" > $repository/mirrors ;;
635 esac ;;
636 rm-repo=*)
637 repository=${cmd#rm-repo=}
638 rm -rf $LOCALSTATE/undigest/$repository ;;
639 esac
640 [ "$cmd" == "$(gettext "Set link")" ] &&
641 [ -d "$(GET link)/$INSTALLED" ] &&
642 ln -fs $(GET link) $LOCALSTATE/fslink
643 [ "$cmd" == "$(gettext "Remove link")" ] &&
644 rm -f $LOCALSTATE/fslink
645 cache_files=`find /var/cache/tazpkg -name *.tazpkg | wc -l`
646 cache_size=`du -sh /var/cache/tazpkg`
647 sidebar
648 cat << EOT
649 <h2>$(gettext "Administration")</h2>
650 <div>
651 <p>$(gettext "Tazpkg administration and settings")</p>
652 </div>
653 <div id="actions">
654 <a class="button" href='$SCRIPT_NAME?admin=&action=saveconf'>
655 <img src="$IMAGES/tazpkg.png" />`gettext "Save configuration"`</a>
656 <a class="button" href='$SCRIPT_NAME?admin=&action=listconf'>
657 <img src="$IMAGES/edit.png" />`gettext "List configuration files"`</a>
658 <a class="button" href='$SCRIPT_NAME?admin=&action=quickcheck'>
659 <img src="$IMAGES/recharge.png" />`gettext "Quick check"`</a>
660 <a class="button" href='$SCRIPT_NAME?admin=&action=fullcheck'>
661 <img src="$IMAGES/recharge.png" />`gettext "Full check"`</a>
662 </div>
663 EOT
664 case "$(GET action)" in
665 saveconf)
666 LOADING_MSG=$(gettext "Creating the package...")
667 loading_msg
668 echo "<pre>"
669 cd $HOME
670 tazpkg repack-config | filter_taztools_msgs
671 gettext "Path : " && ls $HOME/config-*.tazpkg
672 echo "</pre>" ;;
673 listconf)
674 echo "<h4>`gettext "Configuration files"`</h4>"
675 echo "<ul>"
676 tazpkg list-config | while read file; do
677 [ "${file:0:1}" == "/" ] || continue
678 if [ -e $file ]; then
679 echo "<li><a href=\"index.cgi?file=$file\">$file</a></li>"
680 else
681 echo "<li>$file</li>"
682 fi
683 done
684 echo "</ul>"
685 echo "</pre>" ;;
686 quickcheck)
687 LOADING_MSG=$(gettext "Checking packages consistency...")
688 loading_msg
689 echo "<pre>"
690 tazpkg check
691 echo "</pre>" ;;
692 fullcheck)
693 LOADING_MSG=$(gettext "Full packages check...")
694 loading_msg
695 echo "<pre>"
696 tazpkg check --full
697 echo "</pre>" ;;
698 esac
699 cat << EOT
700 <h3>$(gettext "Packages cache")</h3>
701 <div>
702 <form method="get" action="$SCRIPT_NAME">
703 <p>
704 `gettext "Packages in the cache:"` $cache_files ($cache_size)
705 <input type="hidden" name="admin" value="clean" />
706 <input type="submit" value="Clean" />
707 </p>
708 </form>
709 </div>
711 <h3>`gettext "Current mirror list"`</h3>
712 EOT
713 for i in $LOCALSTATE/mirrors $LOCALSTATE/undigest/*/mirrors; do
714 [ -s $i ] || continue
715 echo '<div class="box">'
716 [ $i != $LOCALSTATE/mirrors ] &&
717 echo "<h4>Repository: $(repo_name $(dirname $i))</h4>"
718 echo "<ul>"
719 list_mirrors $i
720 echo "</ul>"
721 cat << EOT
722 </div>
723 <form method="get" action="$SCRIPT_NAME">
724 <p>
725 <input type="hidden" name="admin" value="add-mirror" />
726 <input type="hidden" name="file" value="$i" />
727 <input type="text" name="mirror" size="60">
728 <input type="submit" value="Add mirror" />
729 </p>
730 </form>
731 EOT
732 done
733 echo "<h3>"
734 gettext "Private repositories"
735 echo "</h3>"
736 [ -n "$(ls $LOCALSTATE/undigest 2> /dev/null)" ] && cat << EOT
737 <div class="box">
738 <ul>
739 $(list_repos)
740 </ul>
741 </div>
742 EOT
743 cat << EOT
744 <form method="get" action="$SCRIPT_NAME">
745 <p>
746 <input type="hidden" name="admin" value="add-repo" />
747 Name <input type="text" name="repository" size="10">
748 mirror
749 <input type="text" name="mirror" value="http://" size="50">
750 <input type="submit" value="Add repository" />
751 </p>
752 </form>
753 <h3>`gettext "Link to another SliTaz installation"`</h3>
754 <p>
755 $(gettext "This link point to the root of another SliTaz installation. \
756 You will be able to install packages using soft links to it.")
757 </p>
758 <form method="get" action="$SCRIPT_NAME">
759 <p>
760 <input type="hidden" name="admin" value="add-link" />
761 <input type="text" name="link"
762 value="$(readlink $LOCALSTATE/fslink 2> /dev/null)" size="50">
763 <input type="submit" name="admin" value="$(gettext "Set link")" />
764 <input type="submit" name="admin" value="$(gettext "Remove link")" />
765 </p>
766 </form>
767 EOT
768 version=$(cat /etc/slitaz-release)
769 cat << EOT
771 <a name="dvd"></a>
772 <h3>`gettext "SliTaz packages DVD"`</h3>
773 <p>
774 $(gettext "A bootable DVD image of all available packages for \
775 the $version version is generated every day. It also contains a copy of \
776 the website and can be used without an internet connection. This image can be \
777 installed on a DVD or an USB key.")
778 </p>
779 <div>
780 <form method="post" action='$SCRIPT_NAME?admin&action=dvdimage#dvd'>
781 <p>
782 <a class="button"
783 href='http://mirror.slitaz.org/iso/$version/packages-$version.iso'>
784 <img src="$IMAGES/tazpkg.png" />$(gettext "Download DVD image")</a>
785 <a class="button" href='$SCRIPT_NAME?admin&action=dvdusbkey#dvd'>
786 <img src="$IMAGES/tazpkg.png" />$(gettext "Install from DVD/USB key")</a>
787 </p>
788 <div class="box">
789 $(gettext "Install from ISO image: ")
790 <input type="text" name="dvdimage" size="40" value="/root/packages-$version.iso">
791 </div>
792 </form>
793 </div>
794 EOT
795 if [ "$(GET action)" == "dvdimage" ]; then
796 dev=$(POST dvdimage)
797 mkdir -p /mnt/packages 2> /dev/null
798 echo "<pre>"
799 mount -t iso9660 -o loop,ro $dev /mnt/packages &&
800 /mnt/packages/install.sh &&
801 echo "$dev is installed on /mnt/packages"
802 echo "</pre>"
803 fi
804 if [ "$(GET action)" == "dvdusbkey" ]; then
805 mkdir -p /mnt/packages 2> /dev/null
806 for tag in "LABEL=\"packages-$version\" TYPE=\"iso9660\"" \
807 "LABEL=\"sources-$version\" TYPE=\"iso9660\"" ; do
808 dev=$(blkid | grep "$tag" | cut -d: -f1)
809 [ -n "$dev" ] || continue
810 echo "<pre>"
811 mount -t iso9660 -o ro $dev /mnt/packages &&
812 /mnt/packages/install.sh &&
813 echo "$dev is installed on /mnt/packages"
814 echo "</pre>"
815 break
816 done
817 fi
818 ;;
819 *)
820 #
821 # Default to summary
822 #
823 search_form
824 sidebar
825 [ -n "$(GET block)" ] && tazpkg block $(GET block)
826 [ -n "$(GET unblock)" ] && tazpkg unblock $(GET unblock)
827 cat << EOT
828 <h2>`gettext "Summary"`</h2>
829 <div id="actions">
830 <a class="button" href='$SCRIPT_NAME?list'>
831 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
832 EOT
833 fslink=$(readlink $LOCALSTATE/fslink)
834 [ -n "$fslink" -a -d "$fslink/$INSTALLED" ] &&
835 cat << EOT
836 <a class="button" href='$SCRIPT_NAME?linkable'>
837 <img src="$IMAGES/tazpkg.png" />`gettext "Linkable packages"`</a>
838 EOT
839 cat << EOT
840 <a class="button" href='$SCRIPT_NAME?recharge'>
841 <img src="$IMAGES/recharge.png" />`gettext "Recharge list"`</a>
842 <a class="button" href='$SCRIPT_NAME?up'>
843 <img src="$IMAGES/update.png" />`gettext "Check upgrades"`</a>
844 <a class="button" href='$SCRIPT_NAME?admin'>
845 <img src="$IMAGES/edit.png" />`gettext "Administration"`</a>
846 </div>
847 <pre class="pre-main">
848 `packages_summary`
849 </pre>
851 <h3>`gettext "Latest log entries"`</h3>
852 <pre>
853 `tail -n 5 /var/log/tazpkg.log | fgrep "-" | \
854 awk '{print $1, $2, $3, $4, $5, $6, $7}'`
855 </pre>
856 EOT
857 ;;
858 esac
860 # xHTML 5 footer
861 xhtml_footer
862 exit 0