Horde is an open source application framework that supports a number of applications. We use it here and like it. Here is the script I use tod elete users and clean the associated horde database files. This is setup for a regular Mysql environment.
It would be nice to use the actual horde config files to pobulate the information. But this works.
Note : 7/28/2008 Found I wasn’t cleaning out the history table - corrected
Hope it is useful.
thx
Bill
#!/bin/bash
#
# script to delete all records for a given
# user in the horde- framework and main applications of
# imp/kronolith/mnemo/nag/turba
# Exemple usage : /root/hordedel.sh “john-down”
#
USER=”$1″
# horde database
DB=”MY_DATABASE_NAME”
# horde mysql userid
SQLUSER=”MY_HORDE_DATABASE_USER”
# horde mysql passwd
SQLPWD=”MY_HORDE_DATABASE_USERID_PASSWORD”
#
# Count records before delete
#
HP_B=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.horde_prefs WHERE pref_uid=’$USER’”`
HH_B=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.horde_histories WHERE history_who =’$USER’”`
KE_B=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.kronolith_events WHERE calendar_id=’$USER’”`
MM_B=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.mnemo_memos WHERE memo_owner=’$USER’”`
TO_B=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.turba_objects WHERE owner_id=’$USER’”`
NT_B=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.nag_tasks WHERE task_owner=’$USER’”`
HD_B=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.horde_datatree WHERE user_uid=’$USER’”`
HDA_B=0
COUNT=0
mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT datatree_id from $DB.horde_datatree WHERE user_uid=’$USER’” > /tmp/01
while read I
do
COUNT=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.horde_datatree_attributes WHERE datatree_id=’$I’”`
HDA_B=`expr $HDA_B + $COUNT`
done </tmp/01
#
# Delete records (Comments out these lines for testing)
#
mysql -s -u $SQLUSER –password=$SQLPWD -e “DELETE from $DB.horde_prefs WHERE pref_uid=’$USER’”
mysql -s -u $SQLUSER –password=$SQLPWD -e “DELETE from $DB.horde_histories WHERE history_who =’$USER’”
mysql -s -u $SQLUSER –password=$SQLPWD -e “DELETE from $DB.kronolith_events WHERE calendar_id=’$USER’”
mysql -s -u $SQLUSER –password=$SQLPWD -e “DELETE from $DB.mnemo_memos WHERE memo_owner=’$USER’”
mysql -s -u $SQLUSER –password=$SQLPWD -e “DELETE from $DB.turba_objects WHERE owner_id=’$USER’”
mysql -s -u $SQLUSER –password=$SQLPWD -e “DELETE from $DB.nag_tasks WHERE task_owner=’$USER’”
mysql -s -u $SQLUSER –password=$SQLPWD -e “DELETE from $DB.horde_datatree WHERE user_uid=’$USER’”
while read I
do
mysql -s -u $SQLUSER –password=$SQLPWD -e “DELETE from $DB.horde_datatree_attributes WHERE datatree_id=’$I’”
done</tmp/01
#
# Count records after delete (Should always give zero)
#
HP_A=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.horde_prefs WHERE pref_uid=’$USER’”`
HH_A=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.horde_histories WHERE history_who =’$USER’”`
KE_A=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.kronolith_events WHERE calendar_id=’$USER’”`
MM_A=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.mnemo_memos WHERE memo_owner=’$USER’”`
TO_A=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.turba_objects WHERE owner_id=’$USER’”`
NT_A=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.nag_tasks WHERE task_owner=’$USER’”`
HD_A=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.horde_datatree WHERE user_uid=’$USER’”`
HDA_A=0
COUNT=0
mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT datatree_id from $DB.horde_datatree WHERE user_uid=’$USER’” > /tmp/01
while read I
do
COUNT=`mysql -s -u $SQLUSER –password=$SQLPWD -e “SELECT count(*) from $DB.horde_datatree_attributes WHERE datatree_id=’$I’”`
HDA_A=`expr $HDA_A + $COUNT`
done</tmp/01
#
# Display tables record counts after delete operation
#
echo “Before and after records count for user $USER’”
echo “===========================================================================”
echo “horde_prefs: $HP_B / $HP_A”
echo “horde_histories: $HH_B / $HH_A”
echo “kronolith_events: $KE_B / $KE_A”
echo “mnemo_memos: $MM_B / $MM_A”
echo “turba_objects: $TO_B / $TO_A”
echo “nag_tasks: $NT_B / $NT_A”
echo “horde_datatree: $HD_B / $HD_A”
echo “horde_datatree_attributes: $HDA_B / $HDA_A”
exit 0