tazbug view web/plugins/debug/debug.cgi @ rev 132
Bettercount of messages and del file + debug empty messages
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue Feb 21 16:39:16 2017 +0100 (2017-02-21) |
parents | 039c90c60494 |
children | f07cd117feed |
line source
1 #!/bin/sh
2 #
3 # TazBug Plugin - Debug Tazbug :-)
4 #
6 if [ "$(GET debug)" ]; then
7 d="Debug"
8 header
9 html_header
10 user_box
11 if check_auth && ! admin_user; then
12 echo "You must be admin to debug" && exit 0
13 fi
14 cat << EOT
15 <div id="tools">
16 <a href="$script?dashboard">Dashboard</a>
17 </div>
18 <h2>Debug interface</h2>
19 <p>
20 Check for corrupted config files and empty messages.
21 </p>
22 EOT
23 # Handle ?debug&del request
24 if [ "$(GET del)" ]; then
25 id="$(GET del)"
26 if [ -d "${bugdir}/${id}" ]; then
27 echo -n "<pre>Removing bug ID: $id... "
28 rm -rf ${bugdir}/${id}
29 echo "Done</pre>"
30 fi
31 fi
33 # Check for bug DB consistency
34 echo "<h3>Checking for bug.conf consistency</h3>"
35 for id in $(ls $bugdir | sort -g)
36 do
37 if [ $(cat ${bugdir}/${id}/bug.conf | wc -l) != 8 ]; then
38 echo "<pre>"
39 echo -n "ERROR: bug ID $id"
40 # Missing bug.conf
41 if [ ! -f "${bugdir}/${id}/bug.conf" ]; then
42 echo -n " - Missing: bug.conf"
43 fi
44 # Empty bug.conf
45 if [ -s "${bugdir}/${id}/bug.conf" ]; then
46 echo -n " - <a href='?editbug=$id'>Edit</a>"
47 else
48 echo -n " - Empty: bug.conf"
49 fi
50 echo " - <a href='?debug&del=$id'>Delete</a>"
51 cat ${bugdir}/${id}/bug.conf
52 echo "</pre>"
53 else
54 # Empty values
55 . ${bugdir}/${id}/bug.conf
56 [ -n "$BUG" ] || miss="1"
57 [ -n "$STATUS" ] || miss="1"
58 [ -n "$PRIORITY" ] || miss="1"
59 [ -n "$CREATOR" ] || miss="1"
60 [ -n "$DATE" ] || miss="1"
61 if [ "$miss" ]; then
62 echo "<pre>"
63 echo "ERROR: bug ID $id - Empty variable(s) - <a href='?debug&del=$id'>Delete</a>"
64 cat ${bugdir}/${id}/bug.conf
65 echo "</pre>"
66 fi
67 fi
68 unset miss
69 done
70 echo "$(ls -1 $bugdir | wc -l) bugs scanned"
72 # Check for messages consistency
73 echo "<h3>Checking for empty messages</h3>"
74 msgs=$(find $bugdir -name msg.* | wc -l)
75 empty=$(find $bugdir -name msg.* -size 0)
76 if [ "$empty" ]; then
77 echo "<pre>"
78 cd ${bugdir}
79 for msg in */msg.*
80 do
81 if [ ! -s "$msg" ]; then
82 # Delete msg ?
83 if [ "$(GET delmsgs)" ]; then
84 echo "Deleting empty message: $(basename $bugdir)/$msg"
85 rm -f ${bugdir}/${msg}
86 else
87 echo "Found empty message: $(basename $bugdir)/$msg"
88 fi
89 fi
90 done
91 if [ ! "$(GET delmsgs)" ]; then
92 echo "--> <a href='?debug&delmsgs'>Delete empty messages</a>"
93 fi
94 echo "</pre>"
95 fi
96 echo "$msgs messages scanned"
98 html_footer & exit 0
99 fi