Created
August 5, 2010 04:05
-
-
Save ryross/509209 to your computer and use it in GitHub Desktop.
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 | |
dir=$(pwd) | |
project='' | |
# Check for Git | |
type -P git || { echo 'Git is not installed. Exiting.'; exit 1; } | |
while [ "$1" != '' ] | |
do | |
case $1 in | |
-d | --dir ) | |
shift | |
dir=$1 | |
;; | |
-n | --name ) | |
shift | |
project=$1 | |
;; | |
-h | --help ) | |
echo 'usage: create_kohana_project [-d|–-dir] [-n|--name] [-h|--help]' | |
exit 0 | |
;; | |
esac | |
shift | |
done | |
# Project name is required | |
if [ "$project" = '' ] | |
then | |
# Get a project name | |
while [ -z "$project" ] | |
do | |
echo -n 'Please enter your project name> ' | |
read project | |
done | |
fi | |
# Move over into the directory | |
cd "$dir" | |
# Check for the project already | |
if [ -d $project ] | |
then | |
echo "$project already exists. Exiting." | |
exit 1 | |
else | |
mkdir "$project" && cd "$project" | |
# Initialize Git Repository | |
git init | |
# Make directories | |
mkdir -p htdocs/{css,images,js} | |
mkdir -p kohana/application/classes/{controller,model} | |
mkdir -p kohana/application/{config,views} | |
mkdir -m 0777 -p kohana/application/{cache,logs} | |
# Add ignore rule for .DS_Store files (only necessary on OS X) | |
echo ".DS_Store" > .gitignore | |
# Make ignore files for the cache and logs directories | |
echo '[^.]*' > kohana/application/{logs,cache}/.gitignore | |
# Add in Kohana modules | |
# Add git repos that you use across all projects below - | |
# This is just the core and database. | |
git submodule add git://github.com/kohana/core.git kohana/system | |
git submodule add git://github.com/kohana/database.git kohana/modules/database | |
git submodule init | |
# Add in the index.php, .htaccess and bootstrap.php files | |
curl -o htdocs/index.php http://github.com/kohana/kohana/raw/master/index.php | |
curl -o htdocs/.htaccess http://github.com/kohana/kohana/raw/master/example.htaccess | |
curl -o kohana/application/bootstrap.php http://github.com/kohana/kohana/raw/master/application/bootstrap.php | |
git add . | |
git commit -m 'Initial Commit.' | |
# Send success message | |
echo "------------" | |
echo "$project created successfully!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment