Skip to content

Instantly share code, notes, and snippets.

@ryross
Created August 5, 2010 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryross/509209 to your computer and use it in GitHub Desktop.
Save ryross/509209 to your computer and use it in GitHub Desktop.
#!/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