Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 219 lines (188 sloc) 4.109 kb
425f813 @DrPheltRight
authored
1 #!/bin/bash
9d0916e @DrPheltRight
authored
2 #
8d7a4d9 @DrPheltRight
authored
3 # Kohana Application Installer
9a5b1c4 @DrPheltRight
authored
4 # ============================
5219500 @DrPheltRight
authored
5 #
1451383 @DrPheltRight
authored
6 # This is a small bash script for installing the core files for a Kohana
7 # application. Will install at the path specified a basic application
8 # structure, then initialises a git repository for your convenience. The
9 # core Kohana system files are added as a submodule and you are given
10 # the option to install Kostache because you just should!
0fcd576 @DrPheltRight
authored
11 #
efce5d6 @DrPheltRight
authored
12 #
9a5b1c4 @DrPheltRight
authored
13 # Author
14 # ------
15 # Luke Morton <lukemorton.designs@gmail.com>
ae062ea @DrPheltRight
authored
16 #
efce5d6 @DrPheltRight
authored
17 #
9a5b1c4 @DrPheltRight
authored
18 # Requirements
19 # ------------
20 # * git
0fcd576 @DrPheltRight
authored
21 #
efce5d6 @DrPheltRight
authored
22 #
9a5b1c4 @DrPheltRight
authored
23 # Usage
24 # -----
443dc89 @DrPheltRight Updated comments.
authored
25 # ./koapp install /var/www/my-new-app
5219500 @DrPheltRight
authored
26 #
0fcd576 @DrPheltRight
authored
27
9d8287a @DrPheltRight
authored
28 # Default
e823b93 @DrPheltRight
authored
29 DEFAULT_APP_PATH="$HOME/koapp"
9d8287a @DrPheltRight
authored
30
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
31 set_app_path()
32 {
33 if [ -n "$1" ];
5219500 @DrPheltRight
authored
34 then
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
35 # Use first arg as application path
36 app_path="$1"
5219500 @DrPheltRight
authored
37 else
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
38 # Request application name
39 echo "Please provide a path in which to install your new Kohana application: "
40 read custom_app_path
41
42 # Set app path
43 if [ -n "$custom_app_path" ];
44 then
45 app_path="$custom_app_path"
46 else
47 app_path="$DEFAULT_APP_PATH"
48 fi
5219500 @DrPheltRight
authored
49 fi
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
50
51 # Use app name
3cfb5a5 @DrPheltRight koapp should be functional now...
authored
52 echo "Using $app_path as application path..."
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
53 }
6f5b468 @DrPheltRight
authored
54
9d8287a @DrPheltRight
authored
55
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
56 create_app_path()
57 {
3cfb5a5 @DrPheltRight koapp should be functional now...
authored
58 if [ ! -d "$app_path" ];
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
59 then
60 # Create folder in application path
61 echo "Creating application path..."
3cfb5a5 @DrPheltRight koapp should be functional now...
authored
62 mkdir -p $app_path
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
63 fi
64 }
5219500 @DrPheltRight
authored
65
0fcd576 @DrPheltRight
authored
66
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
67 create_folder_structure()
68 {
69 # Create application folders with correct perms
70 echo "Creating application folders..."
71 mkdir -p {application,modules,public}
72 mkdir -p application/{config,classes,cache,logs}
0fcd576 @DrPheltRight
authored
73
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
74 echo "Ensuring 777 permissions on application/log and application/cache..."
75 chmod 0777 application/{cache,logs}
76 }
e726cb8 @DrPheltRight
authored
77
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
78 init_git()
79 {
80 if [ -d ".git" ];
81 then
82 # Already a git repo
83 echo "Application path is already a git repo..."
84 else
85 # Init repo
86 echo "Initialising application folder as git repo..."
87 git init > /dev/null
88 fi
89 }
8d7a4d9 @DrPheltRight
authored
90
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
91 install_bootstrap()
92 {
93 if [ ! -f "application/bootstrap.php" ];
94 then
95 # Grab bootstrap and index
96 echo "Getting bootstrap.php..."
97 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
98 fi
99 }
e2ab254 @DrPheltRight
authored
100
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
101 install_index()
102 {
103 if [ ! -f "public/index.php" ];
104 then
105 echo "Getting index.php..."
d9d5548 @DrPheltRight Move index.php into resources.
authored
106 wget https://github.com/DrPheltRight/koapp/raw/develop/resources/index.php --output-document=public/index.php --no-check-certificate > /dev/null 2>&1
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
107 fi
108 }
0fcd576 @DrPheltRight
authored
109
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
110 install_system()
111 {
112 if [ ! -d "system" ];
113 then
114 # Get system files
115 echo "Cloning Kohana Core into system..."
116 git submodule add https://github.com/kohana/core.git system > /dev/null 2>&1
117 fi
118 }
57890f3 @DrPheltRight
authored
119
d7e8448 @DrPheltRight
authored
120 install_module()
20ec549 @DrPheltRight
authored
121 {
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
122 if [ ! -d "modules/$1" ];
5219500 @DrPheltRight
authored
123 then
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
124 echo "Would you like to install $1 (y/n)?"
84c08cc @DrPheltRight Remove unwanted files.
authored
125 read install
5219500 @DrPheltRight
authored
126
84c08cc @DrPheltRight Remove unwanted files.
authored
127 if [ "$install" == "y" ];
5219500 @DrPheltRight
authored
128 then
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
129 echo "Installing $1..."
130 echo "Cloning $1 from $2 into modules/$1..."
131 git submodule add "$2" "modules/$1" > /dev/null 2>&1
5219500 @DrPheltRight
authored
132 fi
133 fi
20ec549 @DrPheltRight
authored
134 }
8d7a4d9 @DrPheltRight
authored
135
d7e8448 @DrPheltRight
authored
136 install_kostache()
20ec549 @DrPheltRight
authored
137 {
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
138 install_module kostache https://github.com/zombor/KOstache.git
f8327dc @DrPheltRight
authored
139
84c08cc @DrPheltRight Remove unwanted files.
authored
140 if [ "$install" == "y" ];
5219500 @DrPheltRight
authored
141 then
142 mkdir application/templates
143 fi
d7e8448 @DrPheltRight
authored
144 }
20ec549 @DrPheltRight
authored
145
d7e8448 @DrPheltRight
authored
146
147 install_orm()
148 {
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
149 install_module orm https://github.com/kohana/orm.git
f8327dc @DrPheltRight
authored
150
84c08cc @DrPheltRight Remove unwanted files.
authored
151 if [ "$install" == "y" ];
5219500 @DrPheltRight
authored
152 then
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
153 echo ""
5219500 @DrPheltRight
authored
154 echo "[!!] You will need the database module in order to use ORM"
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
155 echo ""
5219500 @DrPheltRight
authored
156 install_db
157 fi
20ec549 @DrPheltRight
authored
158 }
159
160 install_db()
161 {
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
162 install_module database https://github.com/kohana/database.git
f8327dc @DrPheltRight
authored
163
84c08cc @DrPheltRight Remove unwanted files.
authored
164 if [ "$install" == "y" ];
5219500 @DrPheltRight
authored
165 then
166 cp modules/database/config/database.php application/config/database.php
167 fi
20ec549 @DrPheltRight
authored
168 }
c630cf2 @DrPheltRight
authored
169
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
170 update_submodules()
171 {
172 # Ensure submodules initialised
173 echo "Initialising submodules..."
174 git submodule update --init > /dev/null
175 }
57890f3 @DrPheltRight
authored
176
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
177 commit_git()
178 {
179 # Add changes
180 git add . > /dev/null
57890f3 @DrPheltRight
authored
181
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
182 echo "Please provide a commit message or leave blank to use default: "
84c08cc @DrPheltRight Remove unwanted files.
authored
183 read commit
20ec549 @DrPheltRight
authored
184
84c08cc @DrPheltRight Remove unwanted files.
authored
185 if [ ! -n "$commit" ];
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
186 then
84c08cc @DrPheltRight Remove unwanted files.
authored
187 commit="Kohana Application Installer run for $app_path"
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
188 fi
20ec549 @DrPheltRight
authored
189
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
190 echo "Commiting original sin...."
84c08cc @DrPheltRight Remove unwanted files.
authored
191 git commit -m "$commit" > /dev/null
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
192 }
20ec549 @DrPheltRight
authored
193
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
194 install()
195 {
3cfb5a5 @DrPheltRight koapp should be functional now...
authored
196 echo $1
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
197 set_app_path $1
198 create_app_path
3cfb5a5 @DrPheltRight koapp should be functional now...
authored
199 cd $1
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
200 create_folder_structure
201 install_bootstrap
202 install_index
203 init_git
204 install_system
205 install_kostache
206 install_orm
207 install_db
208 update_submodules
3cfb5a5 @DrPheltRight koapp should be functional now...
authored
209 commit_git
210
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
211 echo ""
212 echo "Installed."
213 }
e726cb8 @DrPheltRight
authored
214
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
215 if [ "$1" ];
216 then
3cfb5a5 @DrPheltRight koapp should be functional now...
authored
217 $1 $2
5a2ba22 @DrPheltRight Put functionality into functions to make koapp more modular.
authored
218 fi
Something went wrong with that request. Please try again.