-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite-install
executable file
·167 lines (143 loc) · 4.89 KB
/
site-install
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/bash
# site-install
#
# Script d'installation complète du site
#
# Pour installer un nouveau site :
# - rm -R src/drupal/
# - ./site-install
# Stop on error
set -e
# Define colors
RED="\e[00;31m"
YELLOW="\e[01;33m"
GREEN="\e[00;32m"
NOCOLOR="\e[00m"
# Get informations to build site
SITE_TO_BUILD=$1
if [ -z "$1" ]; then
echo -e "${RED}You must pass a site to build as first parameter.${NOCOLOR}"
exit 0;
fi
# Display ASCII Cheese
echo ""
echo -e "${YELLOW} _--'-. ${NOCOLOR}"
echo -e "${YELLOW} .-' '-. ${NOCOLOR}"
echo -e "${YELLOW} |''--.. '-. ${NOCOLOR}"
echo -e "${YELLOW} | ''--.. '-. ${NOCOLOR}"
echo -e "${YELLOW} |.-. .-'. ''--..'.${NOCOLOR}"
echo -e "${YELLOW} |'./ -_' .-. |${NOCOLOR}"
echo -e "${YELLOW} | .-. '.-' .-'${NOCOLOR}"
echo -e "${YELLOW} '--.. '.' .- -. ${NOCOLOR}"
echo -e "${YELLOW} ''--.. '_' :${NOCOLOR}"
echo -e "${YELLOW} ''--.. |${NOCOLOR}"
echo -e "${YELLOW} ''-'${NOCOLOR}"
echo ""
echo "======================"
echo "== Fromages =="
echo "======================"
# call default vars
. `pwd`/vars/default
# and override with local vars
FILE=vars/$SITE_TO_BUILD
if [ -f $FILE ]; then
. $WORKSPACE/$FILE
else
echo -e "${YELLOW}File $FILE does not exist, used default values.${NOCOLOR}"
fi
# Prepare drush make/install commands
DRUSH_OPTS="--prepare-install"
DRUSH_SI_LOCALE=""
# Building mode
echo "This command can be used to build the distribution."
echo " [1] Build distribution at $DRUPAL_ROOT (in release mode)"
echo " [2] Build distribution at $DRUPAL_ROOT (in development mode)"
echo "Selection:"
read SELECTION
if [ $SELECTION = "1" ]; then
echo -e "${GREEN}Building distribution in release mode...${NOCOLOR}"
elif [ $SELECTION = "2" ]; then
DRUSH_OPTS="$DRUSH_OPTS --working-copy --no-gitinfofile"
echo -e "${GREEN}Building distribution in development mode...${NOCOLOR}"
else
echo -e "${RED}Invalid selection.${NOCOLOR}"
exit 0
fi
# Cache use (or not)
echo "This command can be used to use drush cache."
echo " [1] Use drush cache to get core, contrib and translations"
echo " [2] Force drush to download from Drupal.org servers"
echo "Selection:"
read CACHE_SELECT
if [ $CACHE_SELECT = "1" ]; then
echo -e "${GREEN}Building distribution using drush cache...${NOCOLOR}"
elif [ $CACHE_SELECT = "2" ]; then
DRUSH_OPTS="$DRUSH_OPTS --no-cache"
echo -e "${GREEN}Building distribution using Drupal.org servers...${NOCOLOR}"
else
echo -e "${RED}Invalid selection.${NOCOLOR}"
exit 0
fi
# French translation (or not)
echo "This command can be used to download and install french translations."
echo " [1] Download and install only english translations"
echo " [2] Download and install english AND french translations"
echo "Selection:"
read TRANSLATION_SELECT
if [ $TRANSLATION_SELECT = "1" ]; then
echo -e "${GREEN}Building only in english...${NOCOLOR}"
elif [ $TRANSLATION_SELECT = "2" ]; then
DRUSH_OPTS="$DRUSH_OPTS --translations=fr"
DRUSH_SI_LOCALE="$DRUSH_SI_LOCALE --locale=fr"
echo -e "${GREEN}Building in english AND french...${NOCOLOR}"
else
echo -e "${RED}Invalid selection.${NOCOLOR}"
exit 0
fi
# Drupal preparation
rm -rf $SITE_PROFILE
git clone $PROFILE_REPO $SITE_PROFILE
drush make $DRUSH_OPTS $SITE_PROFILE/build/$MAKEFILE.make $DRUPAL_ROOT -y || exit 1
# Site installation,
# run as the web server user
cd $DRUPAL_ROOT
sudo -u $APACHE drush si $SITE_PROFILE $DRUSH_SI_LOCALE --db-url=mysql://$DB_USER:$DB_PASS@localhost/$DB_NAME --site-name="$SITE_NAME" --account-name=$SITE_ADMIN_NAME --account-pass=$SITE_ADMIN_PASS --clean-url=1 -y
# # Copy drush aliases
# mkdir $DRUSH_ALIASES
# cd $DRUSH_ALIASES
# ln -s $WORKSPACE/deploy/drushrc.aliases.php .
# echo "Copy drush aliases in "$DRUSH_ALIASES
# # Set default environment if not passed as parameter
# DRUPAL_ENV=$1
# if [ -z "$1" ]; then
# DRUPAL_ENV=$SITE_ENVIRONMENT
# fi
# # Copy environment settings and call it in settings.php
# cp $WORKSPACE/deploy/env/settings.$DRUPAL_ENV.php $DRUPAL_ROOT/sites/default/settings.$DRUPAL_ENV.php
# echo "
# /**
# * Call environment settings file.
# */
# require_once 'settings."$DRUPAL_ENV".php';" >> $DRUPAL_ROOT/sites/default/settings.php
# echo "Copy environment settings file in "$DRUPAL_ROOT"/sites/default/ and call it in settings.php file"
# Secure files directory
sudo chmod 770 $DRUPAL_ROOT/sites/default/files
sudo chmod g+s $DRUPAL_ROOT/sites/default/files
sudo chgrp $APACHE $DRUPAL_ROOT/sites/default/files
echo -e "${GREEN}Secure files directory...${NOCOLOR}"
# Secure settings.php file
chmod 644 $DRUPAL_ROOT/sites/default/settings.php
echo -e "${GREEN}Secure settings.php file...${NOCOLOR}"
# # Apply environment configuration
# drush d-conf
# Enable custom module
if [ $CUSTOM_MODULE != "custom_module" ]; then
drush en $CUSTOM_MODULE -y
fi
# Clear all cache
drush cc all
# Revert features just to be sure
drush fra -y
# Clear all cache
drush cc all
exit 0;