forked from srsolutionsag/docker-ilias-base
-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-ilias-entrypoint
executable file
·238 lines (203 loc) · 6.6 KB
/
docker-ilias-entrypoint
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
#!/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_SKIP_UPDATE="${ILIAS_SKIP_UPDATE:=0}"
ILIAS_DEVMODE="${ILIAS_DEVMODE:=0}"
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:=200M}"
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_DEFAULT_SKIN="${ILIAS_DEFAULT_SKIN:=default}"
ILIAS_DEFAULT_STYLE="${ILIAS_DEFAULT_STYLE:=delos}"
# 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
"
echo "${PHP_INI}" > ${PHP_INI_DIR}/conf.d/ilias.ini
echo "${CRON}" > /etc/cron.d/ilias
if [ "${ILIAS_AUTO_SETUP}" -eq "1" ]; then
if [ ! -d "${ILIAS_DATA_PATH}/${ILIAS_CLIENT_NAME}" ]; then
echo "Preparing data directories"
# Create data directories
mkdir -p "${ILIAS_ILIASDATA_PATH}/${ILIAS_CLIENT_NAME}/files"
mkdir -p "${ILIAS_ILIASDATA_PATH}/${ILIAS_CLIENT_NAME}/forum"
mkdir -p "${ILIAS_ILIASDATA_PATH}/${ILIAS_CLIENT_NAME}/lm_data"
mkdir -p "${ILIAS_ILIASDATA_PATH}/${ILIAS_CLIENT_NAME}/mail"
mkdir -p "${ILIAS_DATA_PATH}/${ILIAS_CLIENT_NAME}/css"
mkdir -p "${ILIAS_DATA_PATH}/${ILIAS_CLIENT_NAME}/lm_data"
mkdir -p "${ILIAS_DATA_PATH}/${ILIAS_CLIENT_NAME}/mobs"
mkdir -p "${ILIAS_DATA_PATH}/${ILIAS_CLIENT_NAME}/usr_images"
# Fix permissions
chown -R www-data:www-data ${ILIAS_ILIASDATA_PATH} || true
chown -R www-data:www-data ${ILIAS_DATA_PATH} || true
fi
# Add ini files
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"
echo "${ILIAS_INI}" > "${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
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=10
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 3
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"
install-ilias ${ILIAS_CLIENT_NAME} > /dev/null
# 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"
fi
fi
else
echo "ILIAS setup skipped"
fi
exec "$@"