From 08858249467860785846b99b387993b5ea0765d5 Mon Sep 17 00:00:00 2001 From: Christoph Date: Fri, 15 Nov 2019 14:36:04 +0100 Subject: [PATCH] install_roundcube.sh: fix error creating logrotae definitions. --- install_roundcube.sh | 45 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/install_roundcube.sh b/install_roundcube.sh index 76329ab..207b0b9 100755 --- a/install_roundcube.sh +++ b/install_roundcube.sh @@ -186,6 +186,7 @@ DEFAULT_MYSQL_CREDENTIALS="--defaults-file=/usr/local/mysql/sys-maint.cnf" TLD=${WEBSITE_NAME##*.} _tmp_string=${WEBSITE_NAME%.*} MAIN_DOMAIN=${_tmp_string##*.} +HOSTNAME_SHORT=${_tmp_string%%.*} [[ -n "$WEBMASTER_EMAIL" ]] || WEBMASTER_EMAIL="admin@${MAIN_DOMAIN}.$TLD" @@ -1540,11 +1541,7 @@ fi # - Logrotate logfiles from webmailer, locatet at $WEBSITE_BASEDIR/logs # - echononl "\tCreate logrotate entry.." -if [[ "$PHP_TYPE" = "fcgid" ]] ; then - cat < /etc/logrotate.d/roundcube 2> $log_file -$WEBSITE_BASEDIR/logs/errors -$WEBSITE_BASEDIR/logs/sql -$WEBSITE_BASEDIR/logs/sendmail +cat < /etc/logrotate.d/roundcube-${HOSTNAME_SHORT} 2> $log_file $WEBSITE_BASEDIR/logs/*.log { daily start 0 @@ -1555,36 +1552,20 @@ $WEBSITE_BASEDIR/logs/*.log { delaycompress create 640 www-data www-data copytruncate + postrotate + # Maybe apache2 logrotating sets wron file permissions.. + # + if ls /var/www/${WEBSITE_BASEDIR}/logs/*.log > /dev/null 2>&1 ; then + chown www-data:www-data /var/www/${WEBSITE_BASEDIR}/logs/*.log + fi + endscript } EOF - if [[ $? -eq 0 ]]; then - echo_ok - else - echo_failed - error "$(cat $log_file)" - fi -elif [[ "$APACHE_LOG_DIR" =~ ${WEBSITE_BASEDIR} ]] ; then - cat < /etc/logrotate.d/roundcube 2> $log_file -$APACHE_LOG_DIR/*.log { - daily - start 0 - rotate 7 - missingok - notifempty - compress - delaycompress - create 640 www-data www-data - copytruncate -} -EOF - if [[ $? -eq 0 ]]; then - echo_ok - else - echo_failed - error "$(cat $log_file)" - fi +if [[ $? -eq 0 ]]; then + echo_ok else - echo_skipped + echo_failed + error "$(cat $log_file)" fi