#!/bin/bash
#
# gabriel 2010/06/03

export PATH="/bin:/usr/bin:/usr/lib/biblehal"


bibfile=$1; shift

search=$(basename ${bibfile} .bib | cut -f 2-10 -d '-')

CONFIG_FILE=/srv/refbase/initialize/db.inc.php

CONNECT_NAME=$(grep '$username =' ${CONFIG_FILE} | cut -f 2 -d '"')
CONNECT_PASS=$(grep '$password =' ${CONFIG_FILE} | cut -f 2 -d '"')

cat <<END_SQL | mysql --user=${CONNECT_NAME} --password=${CONNECT_PASS}
DELETE FROM refbaselegi.refs WHERE url RLIKE '/$search/';
quit
END_SQL

rm /var/cache/biblehal/upload/${bibfile}
