Created
May 3, 2011 19:15
-
-
Save apathyboy/954001 to your computer and use it in GitHub Desktop.
Quickly reloads the swganh database on unix environment: ./setup.sh -u mysql_username -p mysql_password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Get the directory this file is in (the project base) | |
| basedir=$(cd $(dirname $0) && pwd) | |
| mysql=mysql # mysql executable | |
| username= # mysql user | |
| passwd= # mysql password | |
| # parse the command line parameters | |
| while getopts 'm:u:p:d:' OPTION | |
| do case "$OPTION" in | |
| m) mysql="$OPTARG" | |
| ;; | |
| u) username="$OPTARG" | |
| ;; | |
| p) passwd="$OPTARG" | |
| ;; | |
| ?) printf "Reloads the MMOServerDB install\n" | |
| printf "" | |
| exit 2 | |
| ;; | |
| esac | |
| done | |
| shift $(($OPTIND - 1)) | |
| for i in $(find . ! -name . -type d -prune) | |
| do | |
| if [ ! -f $i/create.sql ]; then | |
| continue; | |
| fi | |
| if [ -f $i/create_users.sql ]; then | |
| $mysql -u $username -p$passwd --default-character-set=utf8 <$i/create_users.sql | |
| printf "Installing create_users.sql [Done]\n" | |
| fi | |
| $mysql -u $username -p$passwd --default-character-set=utf8 <$i/create.sql | |
| printf "Installing create.sql [Done]\n" | |
| for j in $(find $i/scripts -name *.sql) | |
| do | |
| $mysql -u $username -p$passwd --default-character-set=utf8 <$j | |
| printf "Installing $j [Done]\n" | |
| done | |
| for j in $(find $i/functions -name *.sql) | |
| do | |
| $mysql -u $username -p$passwd --default-character-set=utf8 <$j | |
| printf "Installing $j [Done]\n" | |
| done | |
| for j in $(find $i/procedures -name *.sql) | |
| do | |
| $mysql -u $username -p$passwd --default-character-set=utf8 <$j | |
| printf "Installing $j [Done]\n" | |
| done | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment