tazbug view web/plugins/textmode/textmode.cgi @ rev 159

Remove ashism ==
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Feb 26 08:28:10 2019 +0100 (2019-02-26)
parents 2a172aca8228
children
line source
1 #!/bin/sh
2 #
3 # TazBug Plugin - Textmode will output plain data to be used by remote client
4 #
6 if [ "$(GET textmode)" ]; then
7 header "Content-type: text/plain; charset=UTF-8"
9 separator() {
10 echo "-------------------------------------------------------------------------------"
11 }
13 case " $(GET) " in
15 *\ stats\ *)
16 echo "Bugs count : $(ls_bugs | wc -l)"
17 echo "Messages count : $(find $bugdir -name msg.* | wc -l)"
18 echo "Database size : $(du -sh $bugdir | awk '{print $1}')" ;;
20 *\ search\ *)
21 for bug in $(ls_bugs)
22 do
23 set_bugdir "$bug"
24 result=$(fgrep -i -h "$(GET search)" $bugdir/$bug/*)
25 if [ "$result" ]; then
26 found=$(($found + 1))
27 . ${bugdir}/${bug}/bug.conf
28 echo "Bug: $bug - $BUG"
29 fi
30 bugdir=$(dirname $bugdir)
31 done
32 if [ "$found" = "" ]; then
33 echo "No result found for: $(GET search)"
34 else
35 separator && echo "$found result(s) found"
36 fi ;;
38 *\ id\ *)
39 # Show bug information and description
40 id=$(GET id)
41 set_bugdir "$id"
42 if [ -f "$bugdir/$id/bug.conf" ]; then
43 . ${bugdir}/${id}/bug.conf
44 cat << EOT
45 Bug : $id - $STATUS - $PRIORITY
46 Title : $BUG
47 Info : $DATE - Creator: $CREATOR
48 $(separator)
49 $(cat $bugdir/$id/desc.txt)
50 EOT
51 else
52 echo "Can't find bug ID: $id" && exit 0
53 fi ;;
55 *)
56 cat << EOT
57 Tazbug Textmode plugin
58 $(separator)
59 $(date)
61 Functions:
62 &stats Display bug tracker stats
63 &search= Search for bugs by pattern
64 &id= Show bug info and description
65 EOT
66 ;;
67 esac
68 exit 0
69 fi