Skip to content

Instantly share code, notes, and snippets.

@n00bsys0p
Created June 24, 2013 16:07
Show Gist options
  • Save n00bsys0p/5851213 to your computer and use it in GitHub Desktop.
Save n00bsys0p/5851213 to your computer and use it in GitHub Desktop.
This script will grab a copy of Laravel 4, install all packages, and configure Git. Run the script with no parameters for usage information.
#!/bin/bash
GIT=$(which git)
PHP=$(which php)
CURL=$(which curl)
COMPOSERURL="https://getcomposer.org/installer"
THIS="$0"
MODE="$1"
DIR="$2"
error() {
echo "$1"
exit 1
}
usage() {
echo "This program is used as follows:
$THIS {install|update} {installdir}
The first parameter is the operation mode, and the second
is the folder (relative or absolute) on which the operation
should be run. You will need write permission on the folder
you state." >&2
exit 1
}
# Sanity checks
[[ $# -lt 2 ]] && { usage; }
[[ -z $2 ]] && { error "You must supply a writable folder in which you wish to install Laravel 4."; }
[[ -z $GIT || -z $PHP || -z $CURL ]] && { error "Could not find all dependencies (which, git, php, curl)"; }
function get_composer() {
[[ ! -r ./composer.phar ]] && $CURL -sS $COMPOSERURL | $PHP
}
function install_l4() {
# Grab Laravel 4
$GIT clone -b develop git://github.com/laravel/laravel.git $DIR
cd $DIR
get_composer
$PHP composer.phar install
$GIT remote rename origin upstream
}
function update_l4 {
cd $DIR
$GIT fetch upstream
$GIT merge upstream/develop
get_composer
$PHP composer.phar update
cd - &>/dev/null
}
case $MODE in
"install")
echo "Installing Laravel 4 to $DIR"
install_l4 $DIR
;;
"update")
echo "Updating Laravel 4 install in $DIR"
update_l4 $DIR
;;
*)
usage
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment