-
Notifications
You must be signed in to change notification settings - Fork 176
/
docker_run.sh
executable file
路82 lines (68 loc) 路 2.94 KB
/
docker_run.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
#!/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
fi
if [ ! -f ./config/settings.inc.php ]; then
echo "\n* Reapplying PrestaShop files for enabled volumes ...";
# init if empty
cp -n -R -p /tmp/data-ps/prestashop/* /var/www/html
if [ $PS_DEV_MODE -ne 0 ]; then
echo "\n* Enabling DEV mode ...";
sed -ie "s/define('_PS_MODE_DEV_', false);/define('_PS_MODE_DEV_',\ true);/g" /var/www/html/config/defines.inc.php
fi
if [ $PS_HOST_MODE -ne 0 ]; then
echo "\n* Enabling HOST mode ...";
echo "define('_PS_HOST_MODE_', true);" >> /var/www/html/config/defines.inc.php
fi
if [ $PS_FOLDER_INSTALL != "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" ]; 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_AUTO = 1 ]; then
RET=1
while [ $RET -ne 0 ]; do
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* Installing PrestaShop, this may take a while ...";
if [ $PS_ERASE_DB = 1 ]; then
echo "\n* Drop & recreate mysql database...";
if [ $DB_PASSWD = "" ]; then
mysqladmin -h $DB_SERVER -P $DB_PORT -u $DB_USER drop $DB_NAME --force 2> /dev/null;
mysqladmin -h $DB_SERVER -P $DB_PORT -u $DB_USER create $DB_NAME --force 2> /dev/null;
else
mysqladmin -h $DB_SERVER -P $DB_PORT -u $DB_USER -p$DB_PASSWD drop $DB_NAME --force 2> /dev/null;
mysqladmin -h $DB_SERVER -P $DB_PORT -u $DB_USER -p$DB_PASSWD create $DB_NAME --force 2> /dev/null;
fi
fi
if [ "$PS_DOMAIN" = "<to be defined>" ]; then
export PS_DOMAIN=$(hostname -i)
fi
runuser -g www-data -u www-data -- php /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 \
--newsletter=0 --send_email=0
if [ $? -ne 0 ]; then
echo 'warning: PrestaShop installation failed.'
fi
fi
else
echo "\n* Pretashop Core already installed...";
fi
echo "\n* Almost ! Starting web server now\n";
exec apache2-foreground