Created
December 12, 2012 19:27
-
-
Save michaelespinosa/4270787 to your computer and use it in GitHub Desktop.
Shell script to download and setup a new Laravel project that you can call from a function in your .bashrc file.
This file contains 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 | |
echo '\033[1;30m==========================================' | |
## check for a directory | |
if test -z "$1"; then | |
echo ' \033[0;31m✖ Please provide a directory name' | |
else | |
## check if directory already exist | |
if [ -d $1 ]; then | |
echo ' \033[0;31m✖ The '"$1"' directory already exists' | |
else | |
mkdir $1 | |
## move to directory | |
cd $1 | |
## Download Laravel | |
echo ' \033[0;32m+ \033[0mDownloading Laravel...' | |
curl -s -L https://github.com/laravel/laravel/zipball/master > laravel.zip | |
## Unzip, move, and clean up Laravel | |
echo ' \033[0;32m+ \033[0mUnzipping and cleaning up files...' | |
unzip -q laravel.zip | |
rm laravel.zip | |
cd *-laravel-* | |
mv * .. | |
cd .. | |
rm -R *-laravel-* | |
rm CONTRIBUTING.md | |
rm readme.md | |
## Make the /storage directory writable | |
echo ' \033[0;32m+ \033[0mMaking /storage directory writable...' | |
chmod -R o+w storage | |
## Download and install the Generators | |
echo ' \033[0;32m+ \033[0mInstalling Generators...' | |
curl -s -L https://raw.github.com/JeffreyWay/Laravel-Generator/master/generate.php > application/tasks/generate.php | |
## Update the application key | |
echo ' \033[0;32m+ \033[0mUpdating Application Key...' | |
MD5=`date +”%N” | md5` | |
sed -ie 's/YourSecretKeyGoesHere!/'"$MD5"'/' application/config/application.php | |
rm application/config/application.phpe | |
## Create .gitignore and initial git if -git is passed | |
if [ "$2" == "-git" ]; then | |
echo ' \033[0;32m+ \033[0mInitiating git...' | |
touch .gitignore | |
curl -s -L https://raw.github.com/gist/4223565/be9f8e85f74a92c95e615ad1649c8d773e908036/.gitignore > .gitignore | |
## Create a local git repo | |
git init --quiet | |
git add * .gitignore | |
git commit -m 'Initial commit.' --quiet | |
fi | |
echo '\033[1;30m==========================================' | |
echo ' \033[0;32m✔ Laravel Setup Complete\033[0m' | |
## Open the project in Sublime | |
/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl . | |
fi ## end check if directory already exist | |
fi ## end check for directory | |
############################## | |
# Place this in your .bashrc # | |
############################## | |
# function laravel { | |
# . path_to_file_above | |
# | |
# # Change directory into new project | |
# filepath=`pwd` | |
# cd "$filepath" | |
#} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment