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