forked from andreaskoch/dockerized-magento
-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
138 lines (114 loc) · 3.32 KB
/
install.sh
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
#!/bin/bash
#####################################
# Update the Magento Installation
# Arguments:
# None
# Returns:
# None
#####################################
function updateMagento() {
cd /var/www/html
composer update
}
#####################################
# Print URLs and Logon Information
# Arguments:
# None
# Returns:
# None
#####################################
function printLogonInformation() {
baseUrl="http://$DOMAIN"
frontendUrl="$baseUrl/"
backendUrl="$baseUrl/admin"
echo "Frontend: $frontendUrl"
echo "Backend: $backendUrl"
echo " - Username: ${ADMIN_USERNAME}"
echo " - Password: ${ADMIN_PASSWORD}"
}
#####################################
# Fix the filesystem permissions for the magento root.
# Arguments:
# None
# Returns:
# None
#####################################
function fixFilesystemPermissions() {
chmod -R go+rw $MAGENTO_ROOT
}
#####################################
# A never-ending while loop (which keeps the installer container alive)
# Arguments:
# None
# Returns:
# None
#####################################
function runForever() {
while :
do
sleep 1
done
}
# Check if the MAGENTO_ROOT direcotry has been specified
if [ -z "$MAGENTO_ROOT" ]
then
echo "Please specify the root directory of Magento via the environment variable: MAGENTO_ROOT"
exit 1
fi
# Check if the specified MAGENTO_ROOT direcotry exists
if [ ! -d "$MAGENTO_ROOT" ]
then
mkdir -p $MAGENTO_ROOT
fi
# Check if there is alreay an index.php. If yes, abort the installation process.
if [ -e "$MAGENTO_ROOT/index.php" ]
then
echo "Magento is already installed."
echo "Updating Magento"
updateMagento
echo "Fixing filesystem permissions"
fixFilesystemPermissions
echo "Update fininished"
printLogonInformation
runForever
exit 0
fi
echo "Preparing the Magerun Configuration"
substitute-env-vars.sh /etc /etc/n98-magerun.yaml.tmpl
echo "Installing Magento"
updateMagento
echo "Preparing the Magento Configuration"
substitute-env-vars.sh /etc /etc/local.xml.tmpl
substitute-env-vars.sh /etc /etc/fpc.xml.tmpl
echo "Overriding Magento Configuration"
cp -v /etc/local.xml /var/www/html/web/app/etc/local.xml
cp -v /etc/fpc.xml /var/www/html/web/app/etc/fpc.xml
echo "Installing Sample Data: Media"
curl -s -L https://raw.githubusercontent.com/Vinai/compressed-magento-sample-data/1.9.1.0/compressed-no-mp3-magento-sample-data-1.9.1.0.tgz | tar xz -C /tmp
cp -av /tmp/magento-sample-data-*/* $MAGENTO_ROOT
rm -rf /tmp/magento-sample-data-*
echo "Installing Sample Data: Database"
magerun --skip-root-check --root-dir="$MAGENTO_ROOT" db:create
databaseFilePath="$MAGENTO_ROOT/*.sql"
magerun --skip-root-check --root-dir="$MAGENTO_ROOT" db:import $databaseFilePath
rm $databaseFilePath
echo "Installing Sample Data: Reindex"
magerun --skip-root-check --root-dir="$MAGENTO_ROOT" cache:clean
magerun --skip-root-check --root-dir="$MAGENTO_ROOT" index:reindex:all
echo "Installing Sample Data: Admin User"
magerun --skip-root-check --root-dir="$MAGENTO_ROOT" \
admin:user:create \
"${ADMIN_USERNAME}" \
"${ADMIN_EMAIL}" \
"${ADMIN_PASSWORD}" \
"${ADMIN_FIRSTNAME}" \
"${ADMIN_LASTNAME}" \
"Administrators"
echo "Enable Fullpage Cache"
magerun --skip-root-check --root-dir="$MAGENTO_ROOT" cache:enable fpc
echo "Fixing filesystem permissions"
fixFilesystemPermissions
echo "Installation fininished"
printLogonInformation
runForever
exit 0