forked from srsolutionsag/docker-ilias-base
-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-ilias-entrypoint-setup-cli
executable file
·281 lines (244 loc) · 7.95 KB
/
docker-ilias-entrypoint-setup-cli
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
#!/bin/bash
set -e
function mkpass () {
pass="$1"
echo -n ${pass} | md5sum | awk '{print $1}'
}
# Set defaults
ILIAS_AUTO_SETUP="${ILIAS_AUTO_SETUP:=0}"
ILIAS_AUTO_UPDATE="${ILIAS_AUTO_UPDATE:=$ILIAS_AUTO_SETUP}"
ILIAS_DEVMODE="${ILIAS_DEVMODE:=0}"
ILIAS_INSTALL_ARGUMENTS=${ILIAS_INSTALL_ARGUMENTS:=}
ILIAS_UPDATE_ARGUMENTS=${ILIAS_UPDATE_ARGUMENTS:=$ILIAS_INSTALL_ARGUMENTS}
ILIAS_CLIENT_NAME="${ILIAS_CLIENT_NAME:=default}"
ILIAS_HOST_NAME="${ILIAS_HOST_NAME:=$(hostname)}"
ILIAS_TIMEZONE="${ILIAS_TIMEZONE:=Europe/Berlin}"
ILIAS_MEMORY_LIMIT="${ILIAS_MEMORY_LIMIT:=300M}"
ILIAS_MAX_UPLOAD_SIZE="${ILIAS_MAX_UPLOAD_SIZE:=200M}"
ILIAS_SESSION_LIFETIME="${ILIAS_SESSION_LIFETIME:=1800}"
ILIAS_ERRORS_PATH="${ILIAS_ERRORS_PATH:=${ILIAS_ILIASDATA_PATH}/errors}"
ILIAS_ROOT_PASSWORD="${ILIAS_ROOT_PASSWORD:=$(pwgen -1 16)}"
ILIAS_SETUP_PASSWORD="${ILIAS_SETUP_PASSWORD:=$(pwgen -1 16)}"
ILIAS_DB_TYPE="${ILIAS_DB_TYPE:=innodb}"
ILIAS_DB_HOST="${ILIAS_DB_HOST:=mysql}"
ILIAS_DB_USER="${ILIAS_DB_USER:=ilias}"
ILIAS_DB_NAME="${ILIAS_DB_NAME:=ilias}"
ILIAS_DB_PORT="${ILIAS_DB_PORT:=3306}"
ILIAS_DB_DUMP="${ILIAS_DB_DUMP:=setup/sql/ilias3.sql}"
ILIAS_SOAP_ACTIVATED=${ILIAS_SOAP_ACTIVATED:=1}
ILIAS_SOAP_WSDL="${ILIAS_SOAP_WSDL:=https://test7.ilias.de/webservice/soap/server.php?wsdl}"
ILIAS_MANAGE_STYTEM_STYLE=${ILIAS_MANAGE_STYTEM_STYLE:=1}
ILIAS_DEFAULT_SKIN="${ILIAS_DEFAULT_SKIN:=default}"
ILIAS_DEFAULT_STYLE="${ILIAS_DEFAULT_STYLE:=delos}"
ILIAS_INSTALL_CONFIG_PATH="${ILIAS_INSTALL_CONFIG_PATH:=/tmp/install.json}"
# Define Templates
ILIAS_INI="
; <?php exit; ?>
[server]
http_path = http://${ILIAS_HOST_NAME}
absolute_path = ${ILIAS_WWW_PATH}
presetting =
timezone = ${ILIAS_TIMEZONE}
[clients]
path = data
inifile = client.ini.php
datadir = ${ILIAS_ILIASDATA_PATH}
default = ${ILIAS_CLIENT_NAME}
list = 0
[setup]
pass = $(mkpass ${ILIAS_SETUP_PASSWORD})
[tools]
convert = /usr/bin/convert
zip = /usr/bin/zip
unzip = /usr/bin/unzip
java =
htmldoc =
ffmpeg = /usr/bin/ffmpeg
ghostscript = /usr/bin/gs
latex =
phantomjs = /usr/local/bin/phantomjs
vscantype =
scancommand =
cleancommand =
[log]
; log to php://stdout (missing slash is added during concat by ilias itself)
path = php:/
file = stdout
enabled = 1
level = WARNING
error_path = ${ILIAS_ERRORS_PATH}
[https]
auto_https_detect_enabled = 1
auto_https_detect_header_name = X_FORWARDED_PROTO
auto_https_detect_header_value = https
"
ILIAS_CLIENT_INI="
; <?php exit; ?>
[server]
start = ./login.php
[client]
name = ${ILIAS_CLIENT_NAME}
description =
access = 1
[db]
type = ${ILIAS_DB_TYPE}
host = ${ILIAS_DB_HOST}
user = ${ILIAS_DB_USER}
pass = ${ILIAS_DB_PASSWORD}
name = ${ILIAS_DB_NAME}
port = ${ILIAS_DB_PORT}
[auth]
table = usr_data
usercol = login
passcol = passwd
[language]
default = en
path = ./lang
[layout]
skin = ${ILIAS_DEFAULT_SKIN}
style = ${ILIAS_DEFAULT_STYLE}
[session]
expire = ${ILIAS_SESSION_LIFETIME}
[system]
ROOT_FOLDER_ID = 1
SYSTEM_FOLDER_ID = 9
ROLE_FOLDER_ID = 8
MAIL_SETTINGS_ID = 12
MAXLENGTH_OBJ_TITLE = 65
MAXLENGTH_OBJ_DESC = 123
DEBUG = 0
DEVMODE = ${ILIAS_DEVMODE}
[cache]
activate_global_cache = 0
global_cache_service_type = 0
"
PHP_INI="
memory_limit = ${ILIAS_MEMORY_LIMIT}
error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT
log_errors = On
max_execution_time = 900
max_input_time = 900
max_input_vars = 10000
upload_max_filesize = ${ILIAS_MAX_UPLOAD_SIZE}
post_max_size = ${ILIAS_MAX_UPLOAD_SIZE}
session.gc_maxlifetime = ${ILIAS_SESSION_LIFETIME}
"
CRON="
*/10 * * * * root su www-data -s /bin/sh -c \"/usr/local/bin/php ${ILIAS_WWW_PATH}/cron/cron.php root ${ILIAS_ROOT_PASSWORD} ${ILIAS_CLIENT_NAME}\" 1>/proc/1/fd/1 2>/proc/1/fd/2
"
INSTALL_JSON="
{
\"common\" : {
\"client_id\" : \"${ILIAS_CLIENT_NAME}\",
\"master_password\" : \"${ILIAS_SETUP_PASSWORD}\"
},
\"database\" : {
\"type\" : \"${ILIAS_DB_TYPE}\",
\"host\" : \"${ILIAS_DB_HOST}\",
\"database\" : \"${ILIAS_DB_NAME}\",
\"user\" : \"${ILIAS_DB_USER}\",
\"password\" : \"${ILIAS_DB_PASSWORD}\",
\"create_database\": false
},
\"filesystem\" : {
\"data_dir\" : \"${ILIAS_ILIASDATA_PATH}\"
},
\"http\" : {
\"path\" : \"http://${ILIAS_HOST_NAME}\"
},
\"style\" : {
\"manage_system_styles\" : $ILIAS_MANAGE_STYTEM_STYLE
},
\"webservices\" : {
\"soap_user_administration\" : $ILIAS_SOAP_ACTIVATED,
\"soap_wsdl_path\" : \"https://test7.ilias.de/webservice/soap/server.php?wsdl\",
\"soap_connect_timeout\" : 30
},
\"systemfolder\" : {
\"contact\" : {
\"firstname\" : \"Systemadministrator\",
\"lastname\" : \"ILIAS\",
\"email\" : \"[email protected]\"
}
}
}
"
echo "${PHP_INI}" > ${PHP_INI_DIR}/conf.d/ilias.ini
echo "${CRON}" > /etc/cron.d/ilias
if [ "${ILIAS_AUTO_SETUP}" -eq "1" ]; then
# Dump install config
echo "${INSTALL_JSON}" > "${ILIAS_INSTALL_CONFIG_PATH}"
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
mysql="mysql
--host=${ILIAS_DB_HOST}
--user=${ILIAS_DB_USER}
--password=${ILIAS_DB_PASSWORD}
${ILIAS_DB_NAME}"
# Wait for database
tries=0
maxTries=6
until ${mysql} -e "SELECT VERSION();" &> /dev/null; do
tries=$((tries + 1))
if [ $tries -gt $maxTries ]; then
# give up
echo "Could not connect to database, aborting"
exit 1
fi
echo "Cannot connect to database, waiting"
sleep 10
done
echo "Database connection established"
if ! $(${mysql} -e "SELECT COUNT(*) FROM settings" &> /dev/null); then
# Import database
echo "Installing database"
${mysql} < ${ILIAS_DB_DUMP}
# Run setup
echo "Running setup"
su www-data -s /bin/sh -c "php setup/cli.php install -y \
${ILIAS_INSTALL_ARGUMENTS} ${ILIAS_INSTALL_CONFIG_PATH}"
# Customize ilias
echo "Setting root password"
${mysql} -e "UPDATE usr_data SET
passwd = '$(mkpass ${ILIAS_ROOT_PASSWORD})',
passwd_enc_type = 'md5'
WHERE usr_id = 6"
echo "Setting skin/style"
${mysql} -e "UPDATE usr_pref SET value = '${ILIAS_DEFAULT_SKIN}'
WHERE keyword = 'skin'"
${mysql} -e "UPDATE usr_pref SET value = '${ILIAS_DEFAULT_STYLE}'
WHERE keyword = 'style'"
echo "======================================================="
echo "ILIAS installed successfully!"
echo "Log in using the following credentials:"
echo
echo "User: root"
echo "Password: ${ILIAS_ROOT_PASSWORD}"
echo "Setup Password: ${ILIAS_SETUP_PASSWORD}"
echo "======================================================="
else
echo "ILIAS already installed"
if [ "${ILIAS_AUTO_UPDATE}" -eq "1" ]; then
if php setup/cli.php status | egrep '(update|hotfix|custom_update)_required: true' &> /dev/null; then
echo "Update required, running setup"
su www-data -s /bin/sh -c "php setup/cli.php update -y \
${ILIAS_UPDATE_ARGUMENTS}"
else
echo "No update required"
fi
fi
fi
fi
# Add ini files
if [ -d "${ILIAS_DATA_PATH}/${ILIAS_CLIENT_NAME}" ]; then
echo "${ILIAS_CLIENT_INI}" > "${ILIAS_DATA_PATH}/${ILIAS_CLIENT_NAME}/client.ini.php"
chown www-data:www-data "${ILIAS_DATA_PATH}/${ILIAS_CLIENT_NAME}/client.ini.php"
fi
echo "${ILIAS_INI}" > "${ILIAS_WWW_PATH}/ilias.ini.php"
chown www-data:www-data "${ILIAS_WWW_PATH}/ilias.ini.php"
# Touch ilias log
touch ${ILIAS_ILIASDATA_PATH}/ilias.log
chown www-data:www-data ${ILIAS_ILIASDATA_PATH}/ilias.log
else
echo "ILIAS setup skipped"
fi
exec "$@"