-
Notifications
You must be signed in to change notification settings - Fork 19
/
start-docker.sh
48 lines (40 loc) · 1.78 KB
/
start-docker.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
#!/bin/bash
if ! test -f ".env"; then
read -p "$(echo -e "\e[1;37;45m You don't have a .env file, we will create it. Please enter a template name : \e[0m")" template_name
if [[ -z "$template_name" ]]; then
echo -e "\e[1;37;41m Invalid template name \e[0m"
exit 0
fi
# first, strip underscores
template_name=${template_name//_/}
# next, replace spaces with underscores
template_name=${template_name// /_}
# now, clean out anything that's not alphanumeric or an underscore
template_name=${template_name//[^a-zA-Z0-9_]/}
# finally, lowercase with TR
template_name="$(echo $template_name | tr '[A-Z]' '[a-z]')"
cp ".env.docker" ".env"
sed -i "s/modern/${template_name}/g" .env > /dev/null
echo -e "\e[1;37;42m .env file created with success with template name \"${template_name}\" \e[0m"
fi
set -o allexport
eval $(cat '.env' | sed -e '/^#/d;/^\s*$/d' -e 's/\(\w*\)[ \t]*=[ \t]*\(.*\)/\1=\2/' -e "s/=['\"]\(.*\)['\"]/=\1/g" -e "s/'/'\\\''/g" -e "s/=\(.*\)/='\1'/g")
set +o allexport
if [ ! -z "$ACTIVE_FRONT_TEMPLATE" ] && [ ! -d "templates/frontOffice/$ACTIVE_FRONT_TEMPLATE" ]; then
echo -e "\e[1;37;46m Copying template files to templates/frontOffice/$ACTIVE_FRONT_TEMPLATE \e[0m"
cp -r "templates/frontOffice/modern" "templates/frontOffice/$ACTIVE_FRONT_TEMPLATE";
else
echo "Template files "$template_name" already exists"
fi
echo -e "\e[1;37;46m Starting docker \e[0m"
docker-compose up -d --build
docker-compose exec php-fpm docker-init
if [[ $1 = "-demo" ]]; then
docker-compose exec php-fpm php local/setup/import.php
fi
docker-compose exec php-fpm php Thelia c:c
docker-compose exec php-fpm php Thelia c:c --env=prod
docker-compose exec php-fpm php Thelia c:c --env=propel
# Not safe but mandatory on linux env
chmod -R 777 var/cache
chmod -R 777 var/log