-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodern-init.sh
executable file
·141 lines (109 loc) · 3.81 KB
/
modern-init.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
139
140
141
#!/bin/sh
set -e
#COLORS
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
reset=`tput sgr0`
NEWLINE=$'\n'
TEMPLATE_NAME=modern
DB_FILE=./local/config/database.yml
echo "Checking node is installed"
if command -v node > /dev/null 2>&1
then
echo "${green}Node: OK${reset}"
else
echo "${red}Node is not installed nor in your PATH${reset}"
exit 1
fi
echo "Checking yarn is installed"
if command -v yarn > /dev/null 2>&1
then
echo "${green}Yarn: OK${reset}"
else
echo "${red}Yarn is not installed or nor in your PATH${reset}"
exit 1
fi
echo "Checking composer is installed"
if command -v composer > /dev/null 2>&1
then
echo "${green}Composer: OK${reset}"
else
echo "${red}Composer is not installed nor in your PATH${reset}"
exit 1
fi
if test -f "$DB_FILE"; then
read -p "$(echo "Would you like to erase the current database.yml file [y/n] ?")" erase
if [ "$erase" != "${erase#[Yy]}" ] ;then
echo "Removing current database.yml"
rm $DB_FILE
rm -rf ./cache
fi
fi
echo "Installing composer dependencies"
composer install
read -p "$(echo "Enter a template folder name, (default: modern) it's recommended to change it : ")" TEMPLATE_NAME
TEMPLATE_NAME=${TEMPLATE_NAME:-modern}
if [ "$TEMPLATE_NAME" != "modern" ] ;then
echo "Copying template files to templates/frontOffice/$TEMPLATE_NAME"
cp -r "templates/frontOffice/modern" "templates/frontOffice/$TEMPLATE_NAME";
fi
echo "Creating session and media folder"
[ -d local/session ] || mkdir -p local/session
[ -d local/media ] || mkdir -p local/media
chmod -R +w local/session && chmod -R +w local/media
read -p "$(echo "Would you like to install Thelia [y/n] ?")" install
if [ "$install" != "${install#[Yy]}" ] ;then
echo "Installing Thelia"
php Thelia thelia:install
echo "Activating modules"
php Thelia module:refresh
php Thelia module:activate OpenApi
php Thelia module:activate ChoiceFilter
php Thelia module:activate StoreSeo
php Thelia module:activate SmartyRedirection
php Thelia module:deactivate HookAnalytics
php Thelia module:deactivate HookCart
php Thelia module:deactivate HookCustomer
php Thelia module:deactivate HookSearch
php Thelia module:deactivate HookLang
php Thelia module:deactivate HookCurrency
php Thelia module:deactivate HookNavigation
php Thelia module:deactivate HookProductsNew
php Thelia module:deactivate HookSocial
php Thelia module:deactivate HookNewsletter
php Thelia module:deactivate HookContact
php Thelia module:deactivate HookLinks
php Thelia module:deactivate HookProductsOffer
php Thelia module:refresh
fi
echo "Changing active template"
php Thelia template:set frontOffice modern # THELIA 2.5
read -p "$(echo "Would you like to create an administrator (y/n)?")" withAdmin
if [ "$withAdmin" != "${withAdmin#[Yy]}" ] ;then
echo "Creating an admin account${NEWLINE} login:${yellow}thelia2${reset}${NEWLINE}password ${yellow}thelia2${reset}"
php Thelia admin:create --login_name thelia2 --password thelia2 --last_name thelia2 --first_name thelia2 --email thelia2@example.com
fi
if test -f "$DB_FILE"; then
read -p "$(echo "Would you like to install a sample database (y/n)?")" sample
if [ "$sample" != "${sample#[Yy]}" ] ;then
if test -f local/setup/import.php; then
php local/setup/import.php
elif test -f setup/import.php; then
php setup/import.php
else
echo "${red}Import script not found${reset}"
exit
fi
echo "${green}Sample data imported${reset}"
fi
fi
rm -rf ./cache || exit
cd "templates/frontOffice/$TEMPLATE_NAME"
echo "Installing dependencies with yarn"
yarn install || exit
echo "Building template"
yarn build || exit
cd ../../..
echo "${green}Everything is ok, you can now use your Thelia !${reset}"
exit 1