1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nextcloud_ynh.git synced 2024-09-03 19:55:57 +02:00

move the nextcloud logs to /var/log

This commit is contained in:
OniriCorpe 2024-02-27 22:48:32 +01:00
parent 166f3e6546
commit f2d0e3145e
4 changed files with 26 additions and 5 deletions

View file

@ -60,6 +60,12 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
ynh_backup --src_path="/etc/cron.d/$app"
#=================================================
# BACKUP LOGS
#=================================================
ynh_backup --src_path="/var/log/$app"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================

View file

@ -87,6 +87,9 @@ ynh_script_progression --message="Configuring $app..." --weight=8
# Set the mysql.utf8mb4 config to true in config.php
exec_occ config:system:set mysql.utf8mb4 --type boolean --value="true"
# move the logs from the data_dir to the standard /var/log
exec_occ config:system:set logfile --value="/var/log/$app/nextcloud.log"
# Ensure that UpdateNotification app is disabled
exec_occ app:disable updatenotification
@ -240,7 +243,7 @@ chmod 750 $install_dir
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile="$data_dir/data/nextcloud.log"
ynh_use_logrotate
#=================================================
# SETUP FAIL2BAN
@ -248,7 +251,7 @@ ynh_use_logrotate --logfile="$data_dir/data/nextcloud.log"
ynh_script_progression --message="Configuring Fail2Ban..." --weight=8
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$data_dir/data/nextcloud.log" --failregex="^.*Login failed: '.*' \(Remote IP: '<HOST>'.*$" --max_retry=5
ynh_add_fail2ban_config --logpath="/var/log/$app/nextcloud.log" --failregex="^.*Login failed: '.*' \(Remote IP: '<HOST>'.*$" --max_retry=5
#=================================================
# END OF SCRIPT

View file

@ -53,6 +53,12 @@ ynh_script_progression --message="Restoring cron job..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# RESTORE LOGS
#=================================================
ynh_restore_file --origin_path="/var/log/$app"
#=================================================
# BACKUP THE LOGROTATE CONFIGURATION
#=================================================
@ -109,10 +115,10 @@ ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
# Make sure a log file exists (mostly for CI tests)
logfile="$data_dir/data/nextcloud.log"
logfile="/var/log/$app/nextcloud.log"
if [ ! -f "$logfile" ]; then
touch "$logfile"
chown $app: "$logfile"
chown "$app:" "$logfile"
fi
ynh_systemd_action --action=restart --service_name=fail2ban

View file

@ -24,6 +24,12 @@ then
ynh_die --message="Upgrading from Nextcloud < 22.2 is not supported anymore. You should first upgrade to 22.2 using: yunohost app upgrade nextcloud -u https://github.com/YunoHost-Apps/nextcloud_ynh/tree/41f5f902e7c7cd3c30a6793020562ba98b9bf3e9"
fi
# move the logs from the data_dir to the standard /var/log
if [ -f "$data_dir/data/nextcloud.log" ]; then
mv "$data_dir"/data/nextcloud.log* "/var/log/$app"
# adapt the nextcloud config
exec_occ config:system:set logfile --value="/var/log/$app/nextcloud.log"
fi
#=================================================
# SPECIFIC UPGRADE
@ -360,7 +366,7 @@ ynh_use_logrotate --non-append
#-------------------------------------------------
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$data_dir/data/nextcloud.log" --failregex="^.*Login failed: '.*' \(Remote IP: '<HOST>'.*$" --max_retry=5
ynh_add_fail2ban_config --logpath="/var/log/$app/nextcloud.log" --failregex="^.*Login failed: '.*' \(Remote IP: '<HOST>'.*$" --max_retry=5
#=================================================
# END OF SCRIPT