diff options
| author | dane dane@31f1291d-b8d6-0310-a050-a5561fc1590b <dane dane@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2004-04-17 15:42:25 +0000 |
|---|---|---|
| committer | dane dane@31f1291d-b8d6-0310-a050-a5561fc1590b <dane dane@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2004-04-17 15:42:25 +0000 |
| commit | 0731a633f8735b08ef92b5111663bb2960382cef (patch) | |
| tree | c3d85530163fcab0585ec789e3b8f615556b21ab /bin | |
| parent | a7f2245085fee869e6eb24f1d5b682d0cf8398f5 (diff) | |
BUILD : 1.7.1 (59) BUGS : 10 NOTES : Fixed the second part of bug 10. The mydbgen script should behave much better now.
git-svn-id: svn://svn.anope.org/anope/trunk@59 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@40 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/mydbgen | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/bin/mydbgen b/bin/mydbgen index 717e5b29b..5dc9e562a 100755 --- a/bin/mydbgen +++ b/bin/mydbgen @@ -86,24 +86,28 @@ while [ -z "$SQLDB" ] ; do fi done +MYSQLDUMP="mysqldump -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB" MYSQLSHOW="mysqlshow -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB" MYSQL="mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB" echo "" -$MYSQLHOW >/dev/null 2>&1 +$MYSQLSHOW | grep -q $SQLDB if test "$?" = "1" ; then - echo "It appears that database does not exist. Or that you don't have the" - echo "correct credentials to access it. Please verify that you have entered" - echo "the correct values." - exit + echo -n "Unable to find databse, creating... " + mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS -Bs -e "create database $SQLDB" >/dev/null 2>&1 + if test "$?" = "0" ; then + echo "done!" + else + echo "failed!" + FAILED="$FAILED 'database creation'" + fi fi - -res="$($MYSQL -Bs -e "show tables like 'anope_os_core'" | wc -l)" -if test "$res" = "0" ; then +$MYSQL -Bs -e "show tables like 'anope_os_core'" | grep -q anope_os_core +if test "$?" = "1" ; then echo -n "Unable to find Anope schema, creating... " - mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB < $DBFILE + $MYSQL < $DBFILE if test "$?" = "0" ; then echo "done!" else @@ -112,8 +116,8 @@ if test "$res" = "0" ; then fi else # Introduced on Anope 1.6.0 -> Table anope_info - res="$($MYSQL -Bs -e "show tables like 'anope_info'" | wc -l)" - if test "$res" = "0" ; then + $MYSQL -Bs -e "show tables like 'anope_info'" | grep -q anope_info + if test "$?" = "1" ; then echo -n "Unable to find Anope info table, creating... " echo "CREATE TABLE anope_info (version int, date datetime) TYPE=MyISAM" > $TFILE mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB < $TFILE >/dev/null 2>&1 @@ -132,8 +136,8 @@ else fi # Introduced on Anope 1.5.14.5 -> anope_cs_info.memomax - res="$($MYSQL -Bs -e "describe anope_cs_info memomax" 2> /dev/null | wc -l)" - if test "$res" = "0" ; then + $MYSQL -Bs -e "describe anope_cs_info memomax" 2> /dev/null | grep -q memomax + if test "$?" = "1" ; then echo -n "Unable to find anope_cs_info.memomax, altering... " echo "ALTER TABLE anope_cs_info ADD memomax smallint unsigned NOT NULL default 0" > $TFILE mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB < $TFILE >/dev/null 2>&1 @@ -147,8 +151,8 @@ else fi # Introduced on Anope 1.5.14.5 -> anope_cs_info.ttb - res="$($MYSQL -Bs -e "describe anope_cs_info ttb" | wc -l)" - if test "$res" = "0" ; then + $MYSQL -Bs -e "describe anope_cs_info ttb" 2> /dev/null | grep -q ttb + if test "$?" = "1" ; then echo -n "Unable to find anope_cs_info.ttb, altering... " echo "ALTER TABLE anope_cs_info ADD ttb smallint NOT NULL default 0" > $TFILE mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB < $TFILE >/dev/null 2>&1 |
