From bf62bfda98dbdee901489956326da4fe2c086223 Mon Sep 17 00:00:00 2001 From: Alexandre CATTEAU Date: Thu, 18 Aug 2022 15:41:55 +0200 Subject: [PATCH] Set Docker upgrade process as optional --- README.md | 3 ++- install.sh | 26 +++++++++++++++++--------- variables.conf.template | 1 + 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 44ae67e..3c2ab8b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Containers management -These scripts and Systemd units manage the daily snapshoting of our Nspawn containers, and update of Docker containers. +These scripts and Systemd units manage the daily snapshoting of our Nspawn containers, and (optionally) update of Docker +containers. ### Introduction All running Nspawn containers are stopped, snapshoted (using Btrfs subvolumes) and restarted diff --git a/install.sh b/install.sh index 26ee2d0..4578777 100755 --- a/install.sh +++ b/install.sh @@ -16,19 +16,23 @@ if [[ $user != 'root' ]]; then sudo cp systemd-templates/conts-snap.service /etc/systemd/system/ sudo sed -i -e "s:PH_DIRECTORY:$(pwd):g" /etc/systemd/system/conts-snap.service sudo cp systemd-templates/conts-snap.timer /etc/systemd/system/ - sudo cp systemd-templates/docker-upgrade.service /etc/systemd/system/ - sudo sed -i -e "s:PH_DIRECTORY:$(pwd):g" /etc/systemd/system/docker-upgrade.service - sudo cp systemd-templates/docker-upgrade.timer /etc/systemd/system/ sudo cp systemd-templates/machines-start.timer /etc/systemd/system/ + if [ $docker -eq 1 ]; then + sudo cp systemd-templates/docker-upgrade.service /etc/systemd/system/ + sudo sed -i -e "s:PH_DIRECTORY:$(pwd):g" /etc/systemd/system/docker-upgrade.service + sudo cp systemd-templates/docker-upgrade.timer /etc/systemd/system/ + fi else cp systemd-templates/cont-snap@.service /etc/systemd/system/ cp systemd-templates/conts-snap.service /etc/systemd/system/ sed -i -e "s:PH_DIRECTORY:$(pwd):g" /etc/systemd/system/conts-snap.service cp systemd-templates/conts-snap.timer /etc/systemd/system/ - cp systemd-templates/docker-upgrade.service /etc/systemd/system/ - sed -i -e "s:PH_DIRECTORY:$(pwd):g" /etc/systemd/system/docker-upgrade.service - cp systemd-templates/docker-upgrade.timer /etc/systemd/system/ cp systemd-templates/machines-start.timer /etc/systemd/system/ + if [ $docker -eq 1 ]; then + cp systemd-templates/docker-upgrade.service /etc/systemd/system/ + sed -i -e "s:PH_DIRECTORY:$(pwd):g" /etc/systemd/system/docker-upgrade.service + cp systemd-templates/docker-upgrade.timer /etc/systemd/system/ + fi fi echo "Reloading Systemd..." if [[ $user != 'root' ]]; then @@ -36,13 +40,17 @@ if [[ $user != 'root' ]]; then else systemctl daemon-reload fi -echo "Enabling timer (not starting it, either do it manually or reboot)..." +echo "Enabling timer(s) (not starting it, either do it manually or reboot)..." if [[ $user != 'root' ]]; then sudo systemctl enable conts-snap.timer - sudo systemctl enable docker-upgrade.timer + if [ $docker -eq 1 ]; then + sudo systemctl enable docker-upgrade.timer + fi else systemctl enable conts-snap.timer - systemctl enable docker-upgrade.timer + if [ $docker -eq 1 ]; then + systemctl enable docker-upgrade.timer + fi fi echo "Finished install. Exiting..." diff --git a/variables.conf.template b/variables.conf.template index 17962ef..e86e10a 100644 --- a/variables.conf.template +++ b/variables.conf.template @@ -3,3 +3,4 @@ # Copy this file as variables.conf, with the correct values containers_dir="" # Path to containers subvolumes main directory +docker=0 # Boolean (0 or 1); Set to 1 if Docker is running on the server