-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinstall
executable file
·448 lines (387 loc) · 13.3 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
#!/bin/bash
# MageSpawner
#
# Copyright 2011-2014 Matthias Zeis
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# System Requirements:
# - bash
# - The following commands must be locatable in your $PATH
# basename command mysql php sed tar wget (or curl)
version="0.6.0"
usage="\
MageSpawner (v$version)
MageSpawner is a tool for quick setup of multiple Magento test installations.
THIS IS NOT MEANT TO BE USED ON PRODUCTION ENVIORNMENTS!
Usage:
./install
Then follow the instructions on the screen.
Consult the README for further information.
Options:
--help , -h, -? display this help message
--magedomain Specify the shop domain (e.g. 1702.magentoshops.vm).
The subdomain has to be the same string as --magename
--magename The shop name which gets used for the URL, directory and database name.
--mageversion Version of Magento to be used. Has to be one of
[ce1501|ce1510|ce1600|ce1610|ce1620|ce1702|ce1800|ce1810|ce1900|ce1901]
--modman Whether you want modman to be initialized.
[y|n]
--usage display this help message
--version display the version of this script
Get more information at
https://github.com/mzeis/MageSpawner"
###########################
## Common options: help, usage and version number
parse_arguments ()
{
while :
do
case $1 in
-h | --help | --usage | -\?)
echo "$usage"
exit 0
;;
--magedomain)
MAGE_SHOPDOMAIN=$2
shift 2
;;
--magename)
MAGE_NAME=$2
shift 2
;;
--mageversion)
MAGE_VERSION=$2
shift 2
;;
--modman)
MODMAN_USE=$2
shift 2
;;
--version)
echo "$version"
exit 0
;;
--) # End of all options
shift
break
;;
-*)
echo "WARN: Unknown option (ignored): $1" >&2
shift
;;
*) # no more options. Stop while loop
break
;;
esac
done
return 0
}
###########################
## Initialise the script: read configuration files, find executables etc.
init_spawner ()
{
if [[ ! -f ${0%/*}/config.conf ]]; then
echo -e >&2 'config.conf not found.\nPlease copy config.conf.sample to config.conf and adjust your settings.'
exit 1
fi
. ${0%/*}/config.conf
if [[ $MAGE_BASE_DIR = "" || $MAGE_BASE_DIR = "/" ]]; then
echo >&2 "Base directory '$MAGE_BASE_DIR' is not allowed. Please change in configuration."
exit 1
fi
MYSQL=$(command -v mysql) || { echo >&2 'MySQL executable not found'; exit 1; }
PHP=$(command -v php) || { echo >&2 'PHP executable not found'; exit 1; }
SED=$(command -v sed) || { echo >&2 'sed command not found'; exit 1; }
WGET=$(command -v wget)
CURL=$(command -v curl)
if [[ $WGET = "" && $CURL = "" ]]; then
echo >&2 'Neither wget nor curl command found. Please install wget or curl and re-run command.';
exit 1;
fi
if [ "$EUID" -ne 0 ] && [ "$LINUX_USE_SUDO" != "false" ]; then
CMDCHMOD="sudo chmod"
CMDCHOWN="sudo chown"
else
CMDCHMOD="chmod"
CMDCHOWN="chown"
fi
echo -e 'Welcome to MageSpawner.\n'
return 0
}
###########################
## Get Magento archive file
get_magento_archive_file ()
{
if [[ ! -f $MAGE_DOWNLOAD_PATH ]]; then
mkdir -p ${MAGE_DOWNLOAD_DIR}
echo -e "Downloading Magento package..."
if [[ $WGET != "" ]]; then
wget -O $MAGE_DOWNLOAD_PATH $MAGE_DOWNLOAD_URL
elif [[ $CURL != "" ]]; then
curl $MAGE_DOWNLOAD_URL -o $MAGE_DOWNLOAD_PATH
fi
echo -e "Package downloaded.\n"
fi
return 0;
}
###########################
## Get Magento download URL
get_magento_download_url ()
{
case "$1" in
ce1501)
MAGE_DOWNLOAD_URL="http://www.magentocommerce.com/downloads/assets/1.5.0.1/magento-1.5.0.1.tar.gz"
return 0;
;;
ce1510)
MAGE_DOWNLOAD_URL="http://www.magentocommerce.com/downloads/assets/1.5.1.0/magento-1.5.1.0.tar.gz"
return 0;
;;
ce1600)
MAGE_DOWNLOAD_URL="http://www.magentocommerce.com/downloads/assets/1.6.0.0/magento-1.6.0.0.tar.gz"
return 0;
;;
ce1610)
MAGE_DOWNLOAD_URL="http://www.magentocommerce.com/downloads/assets/1.6.1.0/magento-1.6.1.0.tar.gz"
return 0;
;;
ce1620)
MAGE_DOWNLOAD_URL="http://www.magentocommerce.com/downloads/assets/1.6.2.0/magento-1.6.2.0.tar.gz"
return 0;
;;
ce1702)
MAGE_DOWNLOAD_URL="http://www.magentocommerce.com/downloads/assets/1.7.0.2/magento-1.7.0.2.tar.gz"
return 0;
;;
ce1800)
MAGE_DOWNLOAD_URL="http://www.magentocommerce.com/downloads/assets/1.8.0.0/magento-1.8.0.0.tar.gz"
return 0;
;;
ce1810)
MAGE_DOWNLOAD_URL="http://www.magentocommerce.com/downloads/assets/1.8.1.0/magento-1.8.1.0.tar.gz"
return 0;
;;
ce1900)
MAGE_DOWNLOAD_URL="http://www.magentocommerce.com/downloads/assets/1.9.0.0/magento-1.9.0.0.tar.gz"
return 0;
;;
ce1901)
MAGE_DOWNLOAD_URL="http://www.magentocommerce.com/downloads/assets/1.9.0.1/magento-1.9.0.1.tar.gz"
return 0;
;;
*)
MAGE_DOWNLOAD_URL=""
return 1;
;;
esac
}
###########################
## Get Magento version
get_magento_version ()
{
MAGE_DOWNLOAD_URL=""
if get_magento_download_url $MAGE_VERSION; then
return 0;
fi
echo "Which version do you want to install?"
echo "1) None, abort installation"
echo "2) CE 1.5.0.1"
echo "3) CE 1.5.1.0"
echo "4) CE 1.6.0.0"
echo "5) CE 1.6.1.0"
echo "6) CE 1.6.2.0"
echo "7) CE 1.7.0.2"
echo "8) CE 1.8.0.0"
echo "9) CE 1.8.1.0"
echo "10) CE 1.9.0.0"
echo "11) CE 1.9.0.1"
while true; do
read -p "Enter the number (e.g. 1): " INPUT_MAGE_VERSION
case "$INPUT_MAGE_VERSION" in
1)
echo "Aborting installation."
exit 0;
;;
2)
echo -e "CE 1.5.0.1 selected.\n"
MAGE_VERSION="ce1501"
break
;;
3)
echo -e "CE 1.5.1.0 selected.\n"
MAGE_VERSION="ce1510"
break
;;
4)
echo -e "CE 1.6.0.0 selected.\n"
MAGE_VERSION="ce1600"
break
;;
5)
echo -e "CE 1.6.1.0 selected.\n"
MAGE_VERSION="ce1610"
break
;;
6)
echo -e "CE 1.6.2.0 selected.\n"
MAGE_VERSION="ce1620"
break
;;
7)
echo -e "CE 1.7.0.2 selected.\n"
MAGE_VERSION="ce1702"
break
;;
8)
echo -e "CE 1.8.0.0 selected.\n"
MAGE_VERSION="ce1800"
break
;;
9)
echo -e "CE 1.8.1.0 selected.\n"
MAGE_VERSION="ce1810"
break
;;
10)
echo -e "CE 1.9.0.0 selected.\n"
MAGE_VERSION="ce1900"
break
;;
11)
echo -e "CE 1.9.0.1 selected.\n"
MAGE_VERSION="ce1901"
break
;;
*)
echo -e "Invalid option, please try again.\n"
;;
esac
done
get_magento_download_url $MAGE_VERSION
return 0
}
###########################
## Get Magento shop (= subdomain) name.
get_mage_name ()
{
if [[ -z "$MAGE_NAME" ]]; then
echo "Specify the shop name. It may be used for the URL, directory and database name, so don't use spaces, special characters or the like."
read -p "Shop name (default: ${MAGE_DEFAULT_NAME}): " MAGE_NAME
MAGE_NAME=${MAGE_NAME:-${MAGE_DEFAULT_NAME}}
fi
return 0
}
###########################
## Get the Magento shop domain.
get_mage_domain ()
{
if [[ -z "$MAGE_SHOPDOMAIN" ]]; then
MAGE_SHOPDOMAIN="${MAGE_NAME}.${MAGE_DOMAIN}"
fi
return 0
}
###########################
## Setup modman
setup_modman ()
{
if [[ -z "$MODMAN_USE" ]]; then
while true; do
read -p "Do you want to use modman? (y/n) " MODMAN_USE
case "$MODMAN_USE" in
y)
MODMAN_USE="y"
break;;
n)
MODMAN_USE="n"
break;
;;
*)
echo -e "Invalid command, please enter 'y' or 'n' (without quotes).\n"
;;
esac
done
fi
if [[ "$MODMAN_USE" != "y" ]]; then
return 0;
fi
MODMAN_BIN=$(command -v modman)
if [[ $MODMAN_BIN != "" ]]; then
modman init
echo ""
else
# if [[ $WGET != "" ]]; then
# bash < <(wget -O - https://raw.github.com/colinmollenhour/modman/master/modman-installer)
# elif [[ $CURL != "" ]]; then
# bash < <(curl -s https://raw.github.com/colinmollenhour/modman/master/modman-installer)
# fi
# source ~/.profile
echo 'Please install modman first: https://github.com/colinmollenhour/modman';
echo 'Then call "modman init" from the Magento root directory as this will not be executed now.';
fi
return 0
}
###########################
## Main script
parse_arguments "$@"
init_spawner
get_magento_version
get_mage_name
get_mage_domain
# Use information for setting variables
MAGE_UNSECURE_URL="http://${MAGE_SHOPDOMAIN}"
MAGE_SECURE_URL="http://${MAGE_SHOPDOMAIN}"
MAGE_DOWNLOAD_FILENAME=$(basename $MAGE_DOWNLOAD_URL)
DB_NAME="${DB_NAMEPREFIX}${MAGE_NAME}"
DB_SQL="CREATE DATABASE IF NOT EXISTS ${DB_NAME} CHARACTER SET utf8 COLLATE utf8_general_ci;"
MAGE_DOWNLOAD_PATH="${MAGE_DOWNLOAD_DIR}${MAGE_DOWNLOAD_FILENAME}"
echo -e "Thanks, the required information was provided. The installation will now begin.\n"
cd $MAGE_BASE_DIR
get_magento_archive_file
echo "Unpacking package and setting permissions."
tar -zxf $MAGE_DOWNLOAD_PATH
mv magento/ "$MAGE_SHOPDOMAIN"/
cd "$MAGE_SHOPDOMAIN"/
$CMDCHMOD $LINUX_PERM_WRITABLE_FOLDERS . app/etc var/ media/
echo -e "Package unpacked and permissions set.\n"
echo "Creating database..."
$MYSQL -u${DB_USER} -p${DB_PASS} -e "${DB_SQL}"
echo -e "Database created.\n"
echo "Executing Magento setup script..."
# Fix bug in CE 1.6 and 1.7
VERSIONS_PDO_BUG=['ce1600','ce1610','ce1620','ce1702']
if [[ ${VERSIONS_PDO_BUG[*]} =~ $MAGE_VERSION ]]
then
$SED -i 's/<pdo_mysql\>/<pdo_mysql>1<\/pdo_mysql>/g' app/code/core/Mage/Install/etc/config.xml
fi
$PHP -f install.php -- --license_agreement_accepted "yes" --locale "de_DE" --timezone "Europe/Berlin" --default_currency "EUR" --db_host "${DB_HOST}" --db_name "${DB_NAME}" --db_user "${DB_USER}" --db_pass "${DB_PASS}" \ db_prefix "${DB_TABLEPREFIX}" --session_save "files" --admin_frontname "${ADMIN_FRONTNAME}" --url "${MAGE_UNSECURE_URL}" --skip_url_validation --use_rewrites "yes" --use_secure "no" --secure_base_url "${MAGE_SECURE_URL}" --use_secure_admin "no" --admin_firstname "${ADMIN_FIRSTNAME}" --admin_lastname "${ADMIN_LASTNAME}" --admin_email "${ADMIN_EMAIL}" --admin_username "${ADMIN_USERNAME}" --admin_password "${ADMIN_PASSWORD}"
echo -e "Setup script executed. Please write down the encryption key provided above.\n"
echo "Reindexing Magento indexes..."
$PHP -f shell/indexer.php reindexall
$CMDCHMOD $LINUX_PERM_WRITABLE_FILES var/locks/*
echo -e "Indexes reindexed.\n"
echo "Editing .htaccess for VirtualDocumentRoot configuration (setting RewriteBase)..."
cp .htaccess .htaccess.backup
$SED "s/#RewriteBase \/magento\//RewriteBase \//" ${MAGE_BASE_DIR}${MAGE_SHOPDOMAIN}/.htaccess.backup >.htaccess
rm .htaccess.backup
echo -e ".htaccess edited.\n"
setup_modman
# Adjust permissions
echo "Final permission settings..."
$CMDCHMOD $LINUX_PERM_READABLE_FILES app/etc/local.xml
$CMDCHMOD $LINUX_PERM_READABLE_FOLDERS .
$CMDCHOWN -R ${LINUX_USER}:${LINUX_GROUP} .
echo -e "Done.\n"
echo "If you didn't see any error messages, everything went fine."
echo "Set up your vhost config and host entries (if needed) and you are ready to go!"
echo "The frontend shop URL is ${MAGE_UNSECURE_URL}."