diff options
author | Dan McGee <dan@archlinux.org> | 2011-03-01 16:59:03 +0100 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2011-03-04 10:29:14 +0100 |
commit | abd41bbb51ea2340bd06648cc0cd5b9144cce91e (patch) | |
tree | afbaae2fb8cc2bbdc71ccbe9b87419fc47cee270 /support/schema/reloadtestdb.sh | |
parent | b9690972d084c09f5cc080322db29c54be872045 (diff) | |
download | aur-abd41bbb51ea2340bd06648cc0cd5b9144cce91e.tar.gz aur-abd41bbb51ea2340bd06648cc0cd5b9144cce91e.tar.xz |
Allow DB connection values to come from the environment
Stop hardcoding everything everywhere for those of us that don't use the
localhost/aur/aur/AUR setup. Also allow for the dummy data to be created
in the reload script if it does not exist. Finally, remove two
assumptions that the AUR database already exists.
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'support/schema/reloadtestdb.sh')
-rwxr-xr-x | support/schema/reloadtestdb.sh | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/support/schema/reloadtestdb.sh b/support/schema/reloadtestdb.sh index 1cf392a2..5f26023c 100755 --- a/support/schema/reloadtestdb.sh +++ b/support/schema/reloadtestdb.sh @@ -1,17 +1,29 @@ -#!/bin/sh +#!/bin/bash -e -mydir=`pwd` -if [ `basename $mydir` != "schema" ]; then +DB_NAME=${DB_NAME:-AUR} +DB_USER=${DB_USER:-aur} +# Password should allow empty definition +DB_PASS=${DB_PASS-aur} +DB_HOST=${DB_HOST:-localhost} +DATA_FILE=${DATA_FILE:-dummy-data.sql} + +echo "Using database $DB_NAME, user $DB_USER, host $DB_HOST" + +mydir=$(pwd) +if [ $(basename $mydir) != "schema" ]; then echo "you must be in the aur/support/schema directory to run this script" - exit + exit 1 fi echo "recreating database..." -mysql -uaur -paur AUR < ./aur-schema.sql +mysql -h $DB_HOST -u $DB_USER -p$DB_PASS < aur-schema.sql + +if [ ! -f $DATA_FILE ]; then + echo "creating dumy-data..." + python2 gendummydata.py $DATA_FILE +fi echo "loading dummy-data..." -bzcat ./dummy-data.sql.bz2 | mysql -uaur -paur AUR +mysql -h $DB_HOST -u $DB_USER -p$DB_PASS $DB_NAME < $DATA_FILE echo "done." -exit - |