From 72d89a2f83452a9b2f8d7fbcafd3a6ca09794d73 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 20 Feb 2021 09:53:53 +0100 Subject: [PATCH] Add logrotate --- scripts/backup | 1 + scripts/install | 3 +++ scripts/remove | 3 +++ scripts/restore | 5 ++++- scripts/upgrade | 3 +++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index 473b1b1..b5a73b4 100644 --- a/scripts/backup +++ b/scripts/backup @@ -28,5 +28,6 @@ ynh_backup --src_path="$home_path" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/sudoers.d/$app" ynh_backup --src_path="/etc/systemd/system/$app@$app.service" +ynh_backup --src_path="/etc/logrotate.d/$app" ynh_print_info --message="Backup of $app completed" diff --git a/scripts/install b/scripts/install index 570ec5f..a369a79 100644 --- a/scripts/install +++ b/scripts/install @@ -77,6 +77,9 @@ ynh_store_file_checksum --file="/etc/systemd/system/$app@$app.service" systemctl daemon-reload ynh_systemd_action --service_name="$app@$app" --action=restart +# enable logrotate +ynh_use_logrotate --logfile="$data_path/home-assistant.log" + # create a dedicated nginx config ynh_script_progression --message="Configuring nginx web server..." ynh_add_nginx_config diff --git a/scripts/remove b/scripts/remove index f716782..817e6b4 100644 --- a/scripts/remove +++ b/scripts/remove @@ -36,6 +36,9 @@ ynh_systemd_action --service_name="$app@$app" --action=stop ynh_systemd_action --service_name="$app@$app" --action=disable ynh_secure_remove --file="/etc/systemd/system/$app@$app.service" +# remove logrotate config +ynh_remove_logrotate + # close port ynh_exec_fully_quiet yunohost firewall disallow TCP $port diff --git a/scripts/restore b/scripts/restore index b59f50f..cb7a2ea 100644 --- a/scripts/restore +++ b/scripts/restore @@ -61,7 +61,7 @@ yunohost service add "$app@$app" --log "$data_path/home-assistant.log" --descrip ynh_script_progression --message="Starting the Home Assistant server..." # add --verbose to service sed --in-place "/ExecStart/s/$/ --verbose/" "/etc/systemd/system/$app@$app.service" -# start +# start ynh_systemd_action --service_name="$app@$app" --action=start --line_match="Home Assistant initialized" --log_path="systemd" --timeout=3600 # remove --verbose from service and restart ynh_replace_string --match_string=" --verbose" --replace_string="" --target_file="/etc/systemd/system/$app@$app.service" @@ -70,6 +70,9 @@ ynh_systemd_action --service_name="$app@$app" --action=restart --line_match="Sta ynh_script_progression --message="Restoring nginx web server..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +# restore logrotate +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + # reload nginx ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index fa0c323..97eee49 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -73,6 +73,9 @@ ynh_store_file_checksum --file="/etc/systemd/system/$app@$app.service" systemctl daemon-reload ynh_systemd_action --service_name="$app@$app" --action=restart +# enable logrotate +ynh_use_logrotate --logfile="$data_path/home-assistant.log" --nonappend + # create a dedicated nginx config ynh_script_progression --message="Configuring nginx web server..." ynh_add_nginx_config