From 9574fa9902471d628ab7e813c1fab711818d1103 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 22 Jun 2021 10:06:39 +0200 Subject: [PATCH] Add systemd timer --- conf/invidious.timer | 10 ++++++++++ conf/systemd.service | 4 ++-- scripts/backup | 1 + scripts/install | 2 ++ scripts/remove | 6 ++++++ scripts/restore | 1 + scripts/upgrade | 2 +- 7 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 conf/invidious.timer diff --git a/conf/invidious.timer b/conf/invidious.timer new file mode 100644 index 0000000..42f65fa --- /dev/null +++ b/conf/invidious.timer @@ -0,0 +1,10 @@ +# /etc/systemd/system/invidious.timer + +[Unit] +Description=Lance Invidious toutes les heures + +[Timer] +OnCalendar=hourly + +[Install] +WantedBy=timers.target \ No newline at end of file diff --git a/conf/systemd.service b/conf/systemd.service index aeb78f0..cc96b15 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -4,11 +4,11 @@ After=syslog.target After=network.target [Service] -Type=simple +Type=oneshot User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__ -ExecStart=__FINALPATH__/invidious -o invidious.log +ExecStart=__FINALPATH__/invidious -o invidious.log -p __PORT__ RestartSec=2s Restart=always diff --git a/scripts/backup b/scripts/backup index 42b66cd..274fa1b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -60,6 +60,7 @@ ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup --src_path="/etc/systemd/system/invidious.timer" #================================================= # BACKUP VARIOUS FILES diff --git a/scripts/install b/scripts/install index 24c23d9..c479af7 100644 --- a/scripts/install +++ b/scripts/install @@ -145,6 +145,8 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=1 ynh_add_systemd_config +ynh_add_config --template="../conf/invidious.timer" --destination="/etc/systemd/system/invidious.timer" + #================================================= # SETUP CRON #================================================= diff --git a/scripts/remove b/scripts/remove index 8566bf5..076edc8 100644 --- a/scripts/remove +++ b/scripts/remove @@ -69,6 +69,12 @@ ynh_script_progression --message="Removing Invidious main directory..." --weight # Remove the app directory securely ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE SYSTEMD TIMER +#================================================= + +ynh_secure_remove --file="/etc/systemd/system/invidious.timer" + #================================================= # REMOVE NGINX CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 3c08df3..c3bb0f5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -100,6 +100,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name ynh_script_progression --message="Restoring the systemd configuration..." --weight=5 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +ynh_restore_file --origin_path="/etc/systemd/system/invidious.timer" systemctl enable $app.service --quiet #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 142261c..f4abc49 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -82,7 +82,6 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=8 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - tempdir="$(mktemp -d)" ynh_setup_source --dest_dir=$tempdir --source_id=crystal ynh_exec_warn_less dpkg -i $tempdir/crystal_1.0.0-1_amd64.deb @@ -137,6 +136,7 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=2 # Create a dedicated systemd config ynh_add_systemd_config +ynh_add_config --template="../conf/invidious.timer" --destination="/etc/systemd/system/invidious.timer" #================================================= # GENERIC FINALIZATION