-
Notifications
You must be signed in to change notification settings - Fork 190
Expand file tree
/
Copy pathdocker_run.sh
More file actions
executable file
·147 lines (115 loc) · 5.05 KB
/
Copy pathdocker_run.sh
File metadata and controls
executable file
·147 lines (115 loc) · 5.05 KB
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
#!/bin/sh
if [ "$DB_SERVER" = "<to be defined>" -a $PS_INSTALL_AUTO = 1 ]; then
echo >&2 'error: You requested automatic PrestaShop installation but MySQL server address is not provided '
echo >&2 ' You need to specify DB_SERVER in order to proceed'
exit 1
elif [ "$DB_SERVER" != "<to be defined>" -a $PS_INSTALL_AUTO = 1 ]; then
RET=1
while [ $RET -ne 0 ]; do
echo "\n* Checking if $DB_SERVER is available..."
mysql -h $DB_SERVER -P $DB_PORT -u $DB_USER -p$DB_PASSWD -e "status" > /dev/null 2>&1
RET=$?
if [ $RET -ne 0 ]; then
echo "\n* Waiting for confirmation of MySQL service startup";
sleep 5
fi
done
echo "\n* DB server $DB_SERVER is available, let's continue !"
fi
# From now, stop at error
set -e
if [ ! -f ./config/settings.inc.php ] && [ ! -f ./app/config/parameters.php ] && [ ! -f ./install.lock ]; then
echo "\n* Setting up install lock file..."
touch ./install.lock
echo "\n* Reapplying PrestaShop files for enabled volumes ...";
if [ -d /tmp/data-ps/prestashop ]; then
# init if empty
echo "\n* Copying files from tmp directory ...";
cp -n -R -T -p /tmp/data-ps/prestashop/ /var/www/html
else
echo "\n* No files to copy from tmp directory ...";
fi
if [ -f /tmp/defines_custom.inc.php ]; then
cp -n -p /tmp/defines_custom.inc.php /var/www/html/config/defines_custom.inc.php
fi
if [ -d /tmp/pre-install-scripts/ ]; then
echo "\n* Running pre-install script(s)..."
for i in `ls /tmp/pre-install-scripts/`;do
/tmp/pre-install-scripts/$i
done
else
echo "\n* No pre-install script found, let's continue..."
fi
if [ $PS_FOLDER_INSTALL != "install" ] && [ -d /var/www/html/install ]; then
echo "\n* Renaming install folder as $PS_FOLDER_INSTALL ...";
mv /var/www/html/install /var/www/html/$PS_FOLDER_INSTALL/
fi
if [ $PS_FOLDER_ADMIN != "admin" ] && [ -d /var/www/html/admin ]; then
echo "\n* Renaming admin folder as $PS_FOLDER_ADMIN ...";
mv /var/www/html/admin /var/www/html/$PS_FOLDER_ADMIN/
fi
if [ $PS_HANDLE_DYNAMIC_DOMAIN = 1 ]; then
cp /tmp/docker_updt_ps_domains.php /var/www/html
sed -ie "s/DirectoryIndex\ index.php\ index.html/DirectoryIndex\ docker_updt_ps_domains.php\ index.php\ index.html/g" $APACHE_CONFDIR/conf-available/docker-php.conf
fi
if [ $PS_INSTALL_DB = 1 ]; then
echo "\n* Create mysql database...";
echo "\n* Creating database $DB_NAME..."
mysqladmin -h $DB_SERVER -P $DB_PORT -u $DB_USER create $DB_NAME -p$DB_PASSWD --force;
fi
if [ $PS_INSTALL_AUTO = 1 ]; then
echo "\n* Installing PrestaShop, this may take a while ...";
if [ "$PS_DOMAIN" = "<to be defined>" ]; then
export PS_DOMAIN=$(hostname -i)
fi
echo "\n* Launching the installer script..."
if [ $PS_ERASE_DB = 1 ]; then
echo "\n* Existing database $DB_NAME will be dropped"
fi
runuser -g www-data -u www-data -- php -d memory_limit=-1 /var/www/html/$PS_FOLDER_INSTALL/index_cli.php \
--domain="$PS_DOMAIN" --db_server=$DB_SERVER:$DB_PORT --db_name="$DB_NAME" --db_user=$DB_USER \
--db_password=$DB_PASSWD --prefix="$DB_PREFIX" --firstname="John" --lastname="Doe" \
--password="$ADMIN_PASSWD" --email="$ADMIN_MAIL" --language=$PS_LANGUAGE --country=$PS_COUNTRY \
--all_languages=$PS_ALL_LANGUAGES --newsletter=0 --send_email=0 --ssl=$PS_ENABLE_SSL --db_clear=$PS_ERASE_DB
if [ $? -ne 0 ]; then
echo 'warning: PrestaShop installation failed.'
else
echo "\n* Removing install folder..."
rm -r /var/www/html/$PS_FOLDER_INSTALL/
fi
fi
if [ -d /tmp/post-install-scripts/ ]; then
echo "\n* Running post-install script(s)..."
for i in `ls /tmp/post-install-scripts/`;do
/tmp/post-install-scripts/$i
done
else
echo "\n* No post-install script found, let's continue..."
fi
echo "\n* Setup completed, removing lock file..."
rm ./install.lock
elif [ ! -f ./config/settings.inc.php ] && [ ! -f ./app/config/parameters.php ] && [ -f ./install.lock ]; then
echo "\n* Another setup is currently running..."
sleep 10
exit 42
elif [ -f ./config/settings.inc.php ] && [ ! -f ./app/config/parameters.php ] && [ -f ./install.lock ]; then
echo "\n* Shop seems setup but remaining install lock still present..."
sleep 10
exit 42
else
echo "\n* PrestaShop Core already installed...";
fi
if [ $PS_DEMO_MODE -ne 0 ]; then
echo "\n* Enabling DEMO mode ...";
sed -ie "s/define('_PS_MODE_DEMO_', false);/define('_PS_MODE_DEMO_',\ true);/g" /var/www/html/config/defines.inc.php
fi
echo "\n* Almost ! Starting web server now\n";
if [ -d /tmp/init-scripts/ ]; then
echo "\n* Running init script(s)..."
for i in `ls /tmp/init-scripts/`;do
/tmp/init-scripts/$i
done
else
echo "\n* No init script found, let's continue..."
fi
exec {PHP_CMD}