forked from docksal/boilerplate-magento
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit
executable file
·92 lines (73 loc) · 2.54 KB
/
init
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
#!/usr/bin/env bash
## Initialize a Docksal powered Magento site
##
## Usage: fin init
# Abort if anything fails
set -e
#-------------------------- Settings --------------------------------
# PROJECT_ROOT is passed from fin.
# The following variables are configured in the '.env' file: DOCROOT, VIRTUAL_HOST.
DOCROOT_PATH="${PROJECT_ROOT}/${DOCROOT}"
BIN_PATH="${DOCROOT_PATH}/bin"
#-------------------------- END: Settings --------------------------------
#-------------------------- Helper functions --------------------------------
# Console colors
red='\033[0;31m'
green='\033[0;32m'
green_bg='\033[42m'
yellow='\033[1;33m'
NC='\033[0m'
echo-red () { echo -e "${red}$1${NC}"; }
echo-green () { echo -e "${green}$1${NC}"; }
echo-green-bg () { echo -e "${green_bg}$1${NC}"; }
echo-yellow () { echo -e "${yellow}$1${NC}"; }
#-------------------------- END: Helper functions --------------------------------
#-------------------------- Functions --------------------------------
# Install site
site_install ()
{
cd $BIN_PATH
fin exec "php ./magento setup:install \
--base-url=http://${VIRTUAL_HOST} \
--db-host=${MAGENTO_DB_HOST} \
--db-name=${MYSQL_DATABASE} \
--db-user=${MYSQL_USER} \
--db-password=${MYSQL_PASSWORD} \
--admin-firstname=${MAGENTO_ADMIN_FIRSTNAME} \
--admin-lastname=${MAGENTO_ADMIN_LASTNAME} \
--admin-email=${MAGENTO_ADMIN_EMAIL} \
--admin-user=${MAGENTO_ADMIN_USER} \
--admin-password=${MAGENTO_ADMIN_PASS} \
--language=${MAGENTO_LANGUAGE} \
--currency=${MAGENTO_CURRENCY} \
--timezone=${MAGENTO_TIMEZONE} \
--use-rewrites=${MAGENTO_USE_REWRITES}"
}
# Fix permissions for security.
fix_permissions ()
{
cd $DOCROOT_PATH
chmod 777 ./app/etc
chmod -R 644 ./app/etc/*
}
if [[ "$PROJECT_ROOT" == "" ]]; then
echo-red "\$PROJECT_ROOT is not set"
exit 1
fi
if [[ $DOCKER_RUNNING == "true" ]]; then
echo -e "${green_bg} Step 1 ${NC}${green} Recreating services...${NC}"
fin reset -f
else
echo -e "${green_bg} Step 1 ${NC}${green} Creating services...${NC}"
fin up
fi
echo "Waiting 10s for MySQL to initialize...";
sleep 10
echo -e "${green_bg} Step 2 ${NC}${green} Installing site...${NC}"
time site_install
echo -e "${green_bg} Step 3 ${NC}${green} Fix folder permissions...${NC}"
time fix_permissions
echo -en "${green_bg} DONE! ${NC} "
echo -e "Open ${yellow}http://${VIRTUAL_HOST}${NC} in your browser to verify the setup."
echo -e "Magento Admin URL is in the output above."
echo -e "Admin username: ${yellow}${MAGENTO_ADMIN_USER}${NC}; password: ${yellow}${MAGENTO_ADMIN_PASS}${NC}."