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