-
Notifications
You must be signed in to change notification settings - Fork 0
/
oituolia_ddev_installer.sh
executable file
·244 lines (208 loc) · 7.31 KB
/
oituolia_ddev_installer.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
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/usr/bin/env bash
################################################################################
#
# Questo è uno script che installa Ouitoulìa CMS
#
# Author: Pietro Arturo Panetta
# Site: https://www.drupal.org/u/arturopanetta
# Copyright: @arturu 2023
# License: AGPL-3.0-only
#
################################################################################
declare -gr timestamp_start=$(date +%s)
#-[ Impostazioni ]----------------
loggingInFile=0
notificationDisplayLevelNotice=1
notificationDisplayLevelSuccess=1
notificationDisplayLevelWarning=1
notificationDisplayLevelDanger=1
notificationDisplayLevelDebugLiv1=0
notificationDisplayLevelDebugLiv2=0
notificationDisplayLevelDebugLiv3=0
ouitouliaCodebaseInstallVersion="^10.3"
# La cartella base dove si trova questo script
if [[ -L "${BASH_SOURCE[0]}" ]]; then
symlink_path=$(readlink -f "${BASH_SOURCE[0]}")
folderBase=$(dirname "$symlink_path")
else
if [ "$notificationDisplayLevelDebugLiv1" = "1" ]; then
folderBase=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
else
folderBase="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
fi
fi
#-[ Funzioni ]--------------------
function n() { notification "$1" "$2"; } #alias di notification
function notification() {
local message="$1"
local level="$2"
# Evidenziazione del testo
if [ "$loggingInFile" = "1" ]; then
local text_bold=""
local text_color_red=""
local text_color_green=""
local text_color_yellow=""
local text_color_blue=""
local text_color_magenta=""
local text_color_cyan=""
local text_color_white=""
local bg_red=""
local bg_green=""
local bg_yellow=""
local bg_blue=""
local bg_magenta=""
local bg_cyan=""
local text_reset=""
else
local text_bold=`tput bold`
local text_color_red="\e[0;31m"
local text_color_green="\e[0;32m"
local text_color_yellow="\e[0;33m"
local text_color_blue="\e[0;34m"
local text_color_magenta="\e[0;35m"
local text_color_cyan="\e[0;36m"
local text_color_white="\e[0;97m"
local bg_red="\e[1;41m"
local bg_green="\e[1;42m"
local bg_yellow="\e[1;43m"
local bg_blue="\e[1;44m"
local bg_magenta="\e[1;45m"
local bg_cyan="\e[1;46m"
local text_reset=`tput sgr0`
fi
local text_tag_notice=$(echo -e ${text_bold}${text_color_white}${bg_blue}[notice]${text_reset})
local text_tag_success=$(echo -e ${text_bold}${text_color_white}${bg_green}[success]${text_reset})
local text_tag_warning=$(echo -e ${text_bold}${text_color_white}${bg_yellow}[warning]${text_reset})
local text_tag_danger=$(echo -e ${text_bold}${text_color_white}${bg_red}[error]${text_reset})
local text_tag_debugLiv1=$(echo -e ${text_bold}${text_color_white}${bg_cyan}[debug L1]${text_reset})
local text_tag_debugLiv2=$(echo -e ${text_bold}${text_color_white}${bg_cyan}[debug L2]${text_reset})
local text_tag_debugLiv3=$(echo -e ${text_bold}${text_color_white}${bg_cyan}[debug L3]${text_reset})
local text_tag_ask=$(echo -e ${text_bold}${text_color_white}${bg_magenta}[?]${text_reset})
case "$level" in
"notice")
if [ "$notificationDisplayLevelNotice" = "1" ]; then
echo -e "${text_tag_notice} ${message}"
fi
;;
"success")
if [ "$notificationDisplayLevelSuccess" = "1" ]; then
echo -e "${text_tag_success} ${message}"
fi
;;
"warning")
if [ "$notificationDisplayLevelWarning" = "1" ]; then
echo -e "${text_tag_warning} ${message}"
fi
;;
"danger")
if [ "$notificationDisplayLevelDanger" = "1" ]; then
echo -e "${text_tag_danger} ${message}"
fi
;;
"ask")
echo -e "${text_tag_ask} ${message}"
;;
"debug" | "debugLiv1")
if [ "$notificationDisplayLevelDebugLiv1" = "1" ]; then
echo -e "${text_tag_debugLiv1} ${message}"
fi
;;
"debugLiv2")
if [ "$notificationDisplayLevelDebugLiv2" = "1" ]; then
echo -e "${text_tag_debugLiv2} ${message}"
fi
;;
"debugLiv3")
if [ "$notificationDisplayLevelDebugLiv3" = "1" ]; then
echo -e "${text_tag_debugLiv3} ${message}"
fi
;;
*)
echo -e "${text_tag_danger} Function notification: parametro level=\"${2}\" non valido"
;;
esac
}
validate_project_name() {
local input=$1
local fqdn_host_regex='^[a-z][a-z0-9_-]*[a-z0-9]$'
if [[ ! $input =~ $fqdn_host_regex ]]; then
echo "Il nome del progetto non è nel formato corretto."
return 1
fi
}
echo -e "\e[0;97m\e[1;44m"
echo " ###########################"
echo "# #"
echo "# 🏫 #"
echo "# Ouituolìa #"
echo "# installer #"
echo "# #"
echo " ###########################"`tput sgr0`
echo " "
# Nome del progetto
read -r -p "Nome del progetto (fomato FQDN host) [a-z0-9] (mia-scuola): " project_name
project_name=${project_name:-mia-scuola}
while ! validate_project_name "$project_name"; do
read -r -p "Nome del progetto (formato FQDN host) [a-z0-9] (mia-scuola): " project_name
project_name=${project_name:-mia-scuola}
done
if [ -d "$project_name" ]; then
echo "${project_name} already exists! Exit..."
exit
fi
# Search project in ddev
ddev_search=$(ddev list | grep -w "$project_name" | awk '{name = $2}; END {print name}')
if [ "$project_name" == "$ddev_search" ]; then
echo "Error! The project name ${ddev_search} already exists! Exit..."
exit
fi
echo "Make ${project_name}"
mkdir "$project_name"
cd "$project_name" || exit
# Password di admin
read -r -p "Inserisci la password di admin [minimo 12 caratteri] (random): " adminPass
while [[ -z $adminPass || ${#adminPass} -lt 12 ]]; do
adminPass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
done
echo -e "\n\n"
n "Configuro ddev" notice
echo "-----------------------"
ddev config --project-type=drupal10 --docroot=web --create-docroot
echo -e "\n\n"
n "Avvio i container" notice
echo "--------------------------"
ddev start
echo -e "\n\n"
n "Installo Ouitoulía codebase" notice
echo "------------------------------------"
ddev composer clear-cache
ddev composer create ouitoulia/diagraphe:${ouitouliaCodebaseInstallVersion} --no-install --no-cache --no-interaction
echo -e "\n\n"
n "Do i permessi di esecuzione agli script di installazione" notice
echo "-----------------------------------------------------------------"
ddev exec chmod -R +x /var/www/html/scripts/
echo -e "\n\n"
n "Installo le dipendenze della codebase" notice
echo "----------------------------------------------"
ddev exec /var/www/html/scripts/setup_step01__ouitoulia_codebase.sh
echo -e "\n\n"
n "Setup Drupal" notice
echo "---------------------"
ddev exec /var/www/html/scripts/setup_step02__configure_drupal.sh "${adminPass}"
echo -e "\n\n"
n "Setup Ouitoulía" notice
echo "------------------------"
ddev exec /var/www/html/scripts/setup_step03__configure_ouitoulia.sh
echo -e "\n\n"
n "Dati facoltativi" notice
echo "-------------------------"
ddev exec /var/www/html/scripts/setup_step04__import_optional_data.sh
echo -e "\n\n"
n "Pulizia" notice
echo "----------------"
#dev exec drush -y pm:uninstall sunchronizo_lexika lexika migrate dblog bibliotheke
#ddev composer remove ouitoulia/sunchronizo_lexika ouitoulia/lexika ouitoulia/bibliotheke
#ddev ssh
ddev describe
echo "La password di admin è: ${adminPass} oppure clicca su: "
ddev exec drush uli