Change machines-start functionning

This commit is contained in:
Alexandre CATTEAU 2024-02-24 11:14:42 +01:00
parent fb819b7b9e
commit 5e2e981cba
4 changed files with 10 additions and 2 deletions

View File

@ -12,7 +12,8 @@ All running Nspawn containers are stopped, snapshoted (using Btrfs subvolumes) a
* `variables.conf.template` contains examples variables definitions, and should be copied locally to `variables.conf` * `variables.conf.template` contains examples variables definitions, and should be copied locally to `variables.conf`
(with any required modifications). (with any required modifications).
* `systemd-templates/` contains Systemd units templates for running the scripts unattended. * `systemd-templates/` contains Systemd units templates for running the scripts unattended.
* specifically, `machines-start.timer` is a daily permanent trigger to start all enabled containers. * specifically, `machines-start.timer` and `machines-start.service` form a daily permanent trigger to start all
enabled containers.
#### Installation #### Installation
* `install.sh` script copies Systemd templates to their destination, and enables conts-snap and docker-upgrade timer. * `install.sh` script copies Systemd templates to their destination, and enables conts-snap and docker-upgrade timer.

View File

@ -21,6 +21,7 @@ $sudo cp systemd-templates/cont-snap@.service /etc/systemd/system/
$sudo cp systemd-templates/conts-snap.service /etc/systemd/system/ $sudo cp systemd-templates/conts-snap.service /etc/systemd/system/
$sudo sed -i -e "s:PH_DIRECTORY:$run_directory:g" /etc/systemd/system/conts-snap.service $sudo sed -i -e "s:PH_DIRECTORY:$run_directory:g" /etc/systemd/system/conts-snap.service
$sudo cp systemd-templates/conts-snap.timer /etc/systemd/system/ $sudo cp systemd-templates/conts-snap.timer /etc/systemd/system/
$sudo cp systemd-templates/machines-start.service /etc/systemd/system/
$sudo cp systemd-templates/machines-start.timer /etc/systemd/system/ $sudo cp systemd-templates/machines-start.timer /etc/systemd/system/
if [ $docker -eq 1 ]; then if [ $docker -eq 1 ]; then
$sudo cp systemd-templates/docker-upgrade.service /etc/systemd/system/ $sudo cp systemd-templates/docker-upgrade.service /etc/systemd/system/

View File

@ -0,0 +1,6 @@
[Unit]
Description=Force start machines.target
[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl start machines.target

View File

@ -2,7 +2,7 @@
Description=Make sure containers are started after snapshoting Description=Make sure containers are started after snapshoting
[Timer] [Timer]
Unit=machines.target Unit=machines-start.service
OnCalendar=*-*-* 04:15:00 OnCalendar=*-*-* 04:15:00
Persistent=true Persistent=true