From 3260425a17292ab92829f9738fcbcac12552b0fb Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 17 Aug 2020 20:27:08 +0200 Subject: [PATCH] Add logs --- scripts/install | 16 ++++++++++++++-- scripts/remove | 9 +++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 7f09e5c..4e44932 100644 --- a/scripts/install +++ b/scripts/install @@ -148,12 +148,24 @@ chown -R $app:$app "$config_path" chown -R $app:www-data /home/yunohost.$app/ chmod -R 764 /home/yunohost.$app +#================================================= +# HANDLE LOG FILES AND SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Configuring log rotation..." --weight=1 + +# FIXME Currently, the log is only redirected to syslog. +mkdir -p /var/log/$app +touch /var/log/$app/$app.log +chown $app -R /var/log/$app + +ynh_use_logrotate + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description "Web-based music collection server and streamer" +yunohost service add $app --description "Web-based music collection server and streamer" --log "/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE @@ -161,7 +173,7 @@ yunohost service add $app --description "Web-based music collection server and s ynh_script_progression --message="Starting a systemd service..." --weight=2 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Version:" +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Version:" #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index c1a3d15..8891e11 100644 --- a/scripts/remove +++ b/scripts/remove @@ -73,6 +73,15 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated nginx config ynh_remove_nginx_config +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 + +ynh_secure_remove --file="/var/log/$app" + +ynh_remove_logrotate + #================================================= # GENERIC FINALIZATION #=================================================