tazbug view web/plugins/debug/debug.cgi @ rev 137

Update all plugins to use new storage paths
author Christophe Lincoln <pankso@slitaz.org>
date Wed Feb 22 14:59:49 2017 +0100 (2017-02-22)
parents 2499947037cf
children
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 <a href="$script?debug">Recheck</a>
18 </div>
19 <h2>Debug interface</h2>
20 <p>
21 Check for corrupted config files and empty messages.
22 </p>
23 EOT
24 # Handle ?debug&del request
25 if [ "$(GET del)" ]; then
26 id="$(GET del)"
27 set_bugdir "$id"
28 if [ -d "${bugdir}/${id}" ]; then
29 echo -n "<pre>Removing bug ID: $id... "
30 rm -rf ${bugdir}/${id}
31 echo "Done</pre>"
32 fi
33 fi
35 # Check for bug DB consistency
36 echo "<h3>Checking for bug.conf consistency</h3>"
37 for id in $(ls_bugs | sort -g)
38 do
39 set_bugdir "$id"
40 if [ $(cat ${bugdir}/${id}/bug.conf | wc -l) != 8 ]; then
41 echo "<pre>"
42 echo -n "ERROR: bug ID $id"
43 # Missing bug.conf
44 if [ ! -f "${bugdir}/${id}/bug.conf" ]; then
45 echo -n " - Missing: bug.conf"
46 fi
47 # Empty bug.conf
48 if [ -s "${bugdir}/${id}/bug.conf" ]; then
49 echo -n " - <a href='?editbug=$id'>Edit</a>"
50 else
51 echo -n " - Empty: bug.conf"
52 fi
53 echo " - <a href='?debug&amp;del=$id'>Delete</a>"
54 cat ${bugdir}/${id}/bug.conf
55 echo "</pre>"
56 else
57 # Empty values
58 . ${bugdir}/${id}/bug.conf
59 [ -n "$BUG" ] || miss="1"
60 [ -n "$STATUS" ] || miss="1"
61 [ -n "$PRIORITY" ] || miss="1"
62 [ -n "$CREATOR" ] || miss="1"
63 [ -n "$DATE" ] || miss="1"
64 if [ "$miss" ]; then
65 echo "<pre>"
66 echo "ERROR: bug ID $id - Empty variable(s) - <a href='?debug&amp;del=$id'>Delete</a>"
67 cat ${bugdir}/${id}/bug.conf
68 echo "</pre>"
69 fi
70 fi
71 bugdir=$(dirname $bugdir)
72 unset miss
73 done
74 echo "$(ls_bugs | wc -l) bugs scanned"
76 # Check for messages consistency
77 echo "<h3>Checking for empty messages</h3>"
78 msgs=$(find $bugdir -name msg.* | wc -l)
79 empty=$(find $bugdir -name msg.* -size 0)
80 if [ "$empty" ]; then
81 echo "<pre>"
82 cd ${bugdir}
83 for msg in */*/msg.*
84 do
85 if [ ! -s "$msg" ]; then
86 # Delete msg ?
87 if [ "$(GET delmsgs)" ]; then
88 echo "Deleting empty message: $(basename $bugdir)/$msg"
89 rm -f ${bugdir}/${msg}
90 else
91 echo "Found empty message: $(basename $bugdir)/$msg"
92 fi
93 fi
94 done
95 if [ ! "$(GET delmsgs)" ]; then
96 echo "--&gt; <a href='?debug&amp;delmsgs'>Delete empty messages</a>"
97 fi
98 echo "</pre>"
99 fi
100 echo "$msgs messages scanned"
102 html_footer & exit 0
103 fi