Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: develop
Fetching contributors…

Cannot retrieve contributors at this time

executable file 219 lines (188 sloc) 4.109 kB
#!/bin/bash
#
# Kohana Application Installer
# ============================
#
# This is a small bash script for installing the core files for a Kohana
# application. Will install at the path specified a basic application
# structure, then initialises a git repository for your convenience. The
# core Kohana system files are added as a submodule and you are given
# the option to install Kostache because you just should!
#
#
# Author
# ------
# Luke Morton <lukemorton.designs@gmail.com>
#
#
# Requirements
# ------------
# * git
#
#
# Usage
# -----
# ./koapp install /var/www/my-new-app
#
# Default
DEFAULT_APP_PATH="$HOME/koapp"
set_app_path()
{
if [ -n "$1" ];
then
# Use first arg as application path
app_path="$1"
else
# Request application name
echo "Please provide a path in which to install your new Kohana application: "
read custom_app_path
# Set app path
if [ -n "$custom_app_path" ];
then
app_path="$custom_app_path"
else
app_path="$DEFAULT_APP_PATH"
fi
fi
# Use app name
echo "Using $app_path as application path..."
}
create_app_path()
{
if [ ! -d "$app_path" ];
then
# Create folder in application path
echo "Creating application path..."
mkdir -p $app_path
fi
}
create_folder_structure()
{
# Create application folders with correct perms
echo "Creating application folders..."
mkdir -p {application,modules,public}
mkdir -p application/{config,classes,cache,logs}
echo "Ensuring 777 permissions on application/log and application/cache..."
chmod 0777 application/{cache,logs}
}
init_git()
{
if [ -d ".git" ];
then
# Already a git repo
echo "Application path is already a git repo..."
else
# Init repo
echo "Initialising application folder as git repo..."
git init > /dev/null
fi
}
install_bootstrap()
{
if [ ! -f "application/bootstrap.php" ];
then
# Grab bootstrap and index
echo "Getting bootstrap.php..."
wget https://github.com/kohana/kohana/raw/3.1/master/application/bootstrap.php --output-document=application/bootstrap.php --no-check-certificate > /dev/null 2>&1
fi
}
install_index()
{
if [ ! -f "public/index.php" ];
then
echo "Getting index.php..."
wget https://github.com/DrPheltRight/koapp/raw/develop/resources/index.php --output-document=public/index.php --no-check-certificate > /dev/null 2>&1
fi
}
install_system()
{
if [ ! -d "system" ];
then
# Get system files
echo "Cloning Kohana Core into system..."
git submodule add https://github.com/kohana/core.git system > /dev/null 2>&1
fi
}
install_module()
{
if [ ! -d "modules/$1" ];
then
echo "Would you like to install $1 (y/n)?"
read install
if [ "$install" == "y" ];
then
echo "Installing $1..."
echo "Cloning $1 from $2 into modules/$1..."
git submodule add "$2" "modules/$1" > /dev/null 2>&1
fi
fi
}
install_kostache()
{
install_module kostache https://github.com/zombor/KOstache.git
if [ "$install" == "y" ];
then
mkdir application/templates
fi
}
install_orm()
{
install_module orm https://github.com/kohana/orm.git
if [ "$install" == "y" ];
then
echo ""
echo "[!!] You will need the database module in order to use ORM"
echo ""
install_db
fi
}
install_db()
{
install_module database https://github.com/kohana/database.git
if [ "$install" == "y" ];
then
cp modules/database/config/database.php application/config/database.php
fi
}
update_submodules()
{
# Ensure submodules initialised
echo "Initialising submodules..."
git submodule update --init > /dev/null
}
commit_git()
{
# Add changes
git add . > /dev/null
echo "Please provide a commit message or leave blank to use default: "
read commit
if [ ! -n "$commit" ];
then
commit="Kohana Application Installer run for $app_path"
fi
echo "Commiting original sin...."
git commit -m "$commit" > /dev/null
}
install()
{
echo $1
set_app_path $1
create_app_path
cd $1
create_folder_structure
install_bootstrap
install_index
init_git
install_system
install_kostache
install_orm
install_db
update_submodules
commit_git
echo ""
echo "Installed."
}
if [ "$1" ];
then
$1 $2
fi
Jump to Line
Something went wrong with that request. Please try again.