Skip to content

Instantly share code, notes, and snippets.

@richardsweeney
Created March 7, 2013 19:49
Show Gist options
  • Save richardsweeney/5111175 to your computer and use it in GitHub Desktop.
Save richardsweeney/5111175 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Create a folder + download latest WordPress.
# Create a database with the same name + add the whole
# shebang to gitlab.
# For this to work the directory contining the repo has
# to have the same name as the gitlab repo
basedir="/Users/richardsweeney/s/"
MYSQL=`which mysql`
SQLCREATE="CREATE DATABASE IF NOT EXISTS $1;"
# See if the database exists
RESULT=`mysqlshow --user=root --password=root $1| grep -v Wildcard | grep -o $1`
if [ "$RESULT" == $1 ]; then
echo "A database with that name already exists"
else
$MYSQL -uroot --password=root -e "$SQLCREATE"
echo "The database $1 has been successfully created"
fi
# Create a directory if it doesn't exist
if [ -d "$basedir$1" ]; then
echo "A directory named $1 already exists"
exit 0
else
mkdir $basedir$1 && cd $basedir$1 && curl http://wordpress.org/latest.tar.gz | tar xvz && mv wordpress/* . && rm -R wordpress
fi
# Do that git thang...
git init;
git add .;
git commit -m 'initial commit';
git remote add origin [email protected]:richard.sweeney/$1.git;
git push -u origin master;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment