2019-07-19 10:07:43 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2020-06-14 14:11:29 +02:00
|
|
|
VERSION=${VERSION:-dev-master}
|
|
|
|
PHP_VERSION=${PHP_VERSION:-7.3}
|
|
|
|
|
2020-02-10 14:32:27 +01:00
|
|
|
# if EGW_APC_SHM_SIZE is set in environment, propagate value to apcu.ini
|
|
|
|
test -n "$EGW_APC_SHM_SIZE" && {
|
2020-06-14 14:11:29 +02:00
|
|
|
grep "apc.shm_size" /etc/php/$PHP_VERSION/fpm/conf.d/20-apcu.ini >/dev/null && \
|
2020-02-10 14:32:27 +01:00
|
|
|
sed -e "s/^;\?apc.shm_size.*/apc.shm_size=$EGW_APC_SHM_SIZE/g" \
|
2020-06-14 14:11:29 +02:00
|
|
|
-i /etc/php/$PHP_VERSION/fpm/conf.d/20-apcu.ini || \
|
|
|
|
echo "apc.shm_size=$EGW_APC_SHM_SIZE" >> /etc/php/$PHP_VERSION/fpm/conf.d/20-apcu.ini
|
2020-02-10 14:32:27 +01:00
|
|
|
}
|
|
|
|
|
2019-10-31 13:02:49 +01:00
|
|
|
# if EGW_SESSION_TIMEOUT is set in environment, propagate value to php.ini
|
2020-02-10 14:32:27 +01:00
|
|
|
test -n "$EGW_SESSION_TIMEOUT" && test "$EGW_SESSION_TIMEOUT" -ge 1440 && \
|
2019-11-19 14:15:18 +01:00
|
|
|
sed -e "s/^;\?session.gc_maxlifetime.*/session.gc_maxlifetime=$EGW_SESSION_TIMEOUT/g" \
|
2020-06-14 14:11:29 +02:00
|
|
|
-i /etc/php/$PHP_VERSION/fpm/php.ini
|
2019-10-31 13:02:49 +01:00
|
|
|
|
2020-06-28 09:14:32 +02:00
|
|
|
# if EGW_MEMORY_LIMIT is set in environment, propagate value to pool.d/www.conf, which has higher precedence then php.ini
|
2020-06-05 11:45:17 +02:00
|
|
|
test -n "$EGW_MEMORY_LIMIT" && \
|
2020-06-28 09:14:32 +02:00
|
|
|
sed -e "s/^;\?php_admin_value\[memory_limit\].*/php_admin_value[memory_limit]=$EGW_MEMORY_LIMIT/g" \
|
|
|
|
-i /etc/php/$PHP_VERSION/fpm/pool.d/www.conf
|
2020-06-05 11:45:17 +02:00
|
|
|
|
2019-07-19 10:07:43 +02:00
|
|
|
# ToDo check version before copy
|
|
|
|
rsync -a --delete /usr/share/egroupware-sources/ /usr/share/egroupware/
|
|
|
|
|
|
|
|
# sources of extra apps merged into our sources (--ignore-existing to NOT overwrite any regular sources!)
|
|
|
|
test -d /usr/share/egroupware-extra && \
|
|
|
|
rsync -a --ignore-existing /usr/share/egroupware-extra/ /usr/share/egroupware/
|
|
|
|
|
|
|
|
# check and if necessary change ownership of /var/lib/egroupware
|
|
|
|
test $(stat -c '%U' /var/lib/egroupware) = "www-data" || \
|
|
|
|
chown -R www-data:www-data /var/lib/egroupware
|
|
|
|
|
2019-08-06 12:20:21 +02:00
|
|
|
# add private CA so egroupware can validate your certificate to talk to Collabora or Rocket.Chat
|
|
|
|
test -f /usr/local/share/ca-certificates/private-ca.crt &&
|
|
|
|
update-ca-certificates
|
|
|
|
|
2019-07-19 10:07:43 +02:00
|
|
|
# write install-log in /var/lib/egroupware (only readable by root!)
|
|
|
|
LOG=/var/lib/egroupware/egroupware-docker-install.log
|
|
|
|
touch $LOG
|
|
|
|
chmod 600 $LOG
|
|
|
|
|
|
|
|
max_retries=10
|
2019-07-23 19:49:18 +02:00
|
|
|
export try=0
|
|
|
|
# EGW_SKIP_INSTALL=true skips initial installation (no header.inc.php yet)
|
|
|
|
until [ -n "$EGW_SKIP_INSTALL" -a ! -f /var/lib/egroupware/header.inc.php ] || \
|
|
|
|
php /usr/share/egroupware/doc/rpm-build/post_install.php \
|
2019-07-19 10:07:43 +02:00
|
|
|
--start_webserver "" --autostart_webserver "" \
|
|
|
|
--start_db "" --autostart_db "" \
|
|
|
|
--db_type "${EGW_DB_TYPE:-mysqli}" \
|
|
|
|
--db_host "${EGW_DB_HOST:-localhost}" \
|
2019-08-07 21:53:31 +02:00
|
|
|
--db_grant_host "${EGW_DB_GRANT_HOST:-localhost}" \
|
2019-07-19 10:07:43 +02:00
|
|
|
--db_root "${EGW_DB_ROOT:-root}" \
|
|
|
|
--db_root_pw "${EGW_DB_ROOT_PW:-}" \
|
|
|
|
--db_name "${EGW_DB_NAME:-egroupware}" \
|
|
|
|
--db_user "${EGW_DB_USER:-egroupware}" \
|
2019-07-23 19:49:18 +02:00
|
|
|
--db_pass "${EGW_DB_PASS:-}"
|
2019-07-19 10:07:43 +02:00
|
|
|
do
|
2019-07-23 19:49:18 +02:00
|
|
|
if [ "$try" -gt "$max_retries" ]; then
|
|
|
|
echo "Installing of EGroupware failed!"
|
|
|
|
break
|
|
|
|
fi
|
2019-07-19 10:07:43 +02:00
|
|
|
echo "Retrying EGroupware installation in 3 seconds ..."
|
|
|
|
try=$((try+1))
|
|
|
|
sleep 3s
|
|
|
|
done 2>&1 | tee -a $LOG
|
|
|
|
|
2019-07-23 19:49:18 +02:00
|
|
|
# as we can NOT exit from until (runs a subshell), we need to check and do it here
|
|
|
|
[ "$(tail -1 $LOG)" = "Installing of EGroupware failed!" ] && exit 1
|
2019-07-19 10:07:43 +02:00
|
|
|
|
2020-08-17 14:34:00 +02:00
|
|
|
# fix cron entries in case docker uses "overlay" storage driver (eg. Univention 4.4)
|
|
|
|
# cron does NOT executing scripts with "NUMBER OF HARD LINKS > 1"
|
|
|
|
for f in /etc/crontab /etc/cron.*/*; do
|
|
|
|
[ $(ls -l $f | cut -d' ' -f2) -gt 1 ] && {
|
|
|
|
mv $f /tmp
|
|
|
|
cat /tmp/$(basename $f) > $f
|
|
|
|
}
|
|
|
|
done
|
2019-07-19 10:07:43 +02:00
|
|
|
# to run async jobs
|
|
|
|
service cron start
|
|
|
|
|
|
|
|
exec "$@"
|