Created
October 14, 2013 12:45
-
-
Save drymek/6975023 to your computer and use it in GitHub Desktop.
Open database manager (mysql is the only one supported right now) based on parameters.yml file.
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 | |
## Usage | |
## database.sh /path/parameters.yml | |
## or if you are in symfony root directory | |
## database.sh | |
if [ -z $1 ] | |
then | |
if [ -f "app/config/parameters.yml" ] | |
then | |
PARAMETERS="app/config/parameters.yml" | |
else | |
echo "Can not locate parameters.yml file" | |
fi | |
else | |
if [ -f $1 ] | |
then | |
PARAMETERS=$1 | |
else | |
echo "Given parameters.yml path does not exists" | |
fi | |
fi | |
DRIVER=`cat $PARAMETERS | grep database_driver | awk '{print $2}'` | |
PASSWORD=`cat $PARAMETERS | grep database_password | awk '{print $2}'` | |
USER=`cat $PARAMETERS | grep database_user | awk '{print $2}'` | |
HOST=`cat $PARAMETERS | grep database_host | awk '{print $2}'` | |
PORT=`cat $PARAMETERS | grep database_port | awk '{print $2}'` | |
NAME=`cat $PARAMETERS | grep database_name | awk '{print $2}'` | |
if [ 'pdo_mysql' = $DRIVER ] | |
then | |
if [ 'null' = $PORT ] | |
then | |
PORT='3306' | |
fi | |
mysql -u$USER -p$PASSWORD -h$HOST -P$PORT $NAME | |
else | |
echo -e "Unknown driver $DRIVER" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment