From ee34de93ea25871f7548b0a3191a05b45f1632e3 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 21 May 2022 18:49:06 +0200 Subject: [PATCH] build image/machine every night --- .../base/manual/install/install_host | 2 ++ .../base/manual/install/install_image | 18 ++++++++---------- .../templates/risotto-images.service | 12 ++++++++++++ .../templates/risotto-images.timer | 9 +++++++++ 4 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 seed/applicationservice/2022.03.08/host-systemd-machined/templates/risotto-images.service create mode 100644 seed/applicationservice/2022.03.08/host-systemd-machined/templates/risotto-images.timer diff --git a/seed/applicationservice/2022.03.08/base/manual/install/install_host b/seed/applicationservice/2022.03.08/base/manual/install/install_host index 03ab9aa1..eb3b610a 100755 --- a/seed/applicationservice/2022.03.08/base/manual/install/install_host +++ b/seed/applicationservice/2022.03.08/base/manual/install/install_host @@ -15,6 +15,8 @@ systemctl restart systemd-networkd systemctl enable systemd-resolved systemctl restart systemd-resolved # systemctl mask dev-hugepages.mount +systemctl enable risotto-images.timer +systemctl restart risotto-images.timer #nft add table nat #nft flush table nat; diff --git a/seed/applicationservice/2022.03.08/base/manual/install/install_image b/seed/applicationservice/2022.03.08/base/manual/install/install_image index b412782c..35b584b7 100755 --- a/seed/applicationservice/2022.03.08/base/manual/install/install_image +++ b/seed/applicationservice/2022.03.08/base/manual/install/install_image @@ -105,25 +105,23 @@ if [ -n "$COPR" ]; then cd - > /dev/null fi if [ "$FUSION" = true ]; then - dnf -y install "https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$RELEASEVER.noarch.rpm" --installroot="$IMAGE_NAME_RISOTTO_IMAGE_DIR" + dnf -y install "https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$RELEASEVER.noarch.rpm" --installroot="$IMAGE_NAME_RISOTTO_IMAGE_DIR" > /dev/null fi # FIXME verifier s'il y a des modifs sur pre/post if [ -f "$IMAGE_NAME_RISOTTO_IMAGE_DIR".base.pkgs ] && [ -f "$IMAGE_NAME_RISOTTO_IMAGE_DIR".pkgs ]; then echo " - différence(s) avec les paquets de base" - diff -u "$IMAGE_NAME_RISOTTO_IMAGE_DIR".base.pkgs "$BASE_PKGS_FILE" && NEW_BASE=false || NEW_BASE=true -else - NEW_BASE=true -fi -new_package -if [ "$NEW_BASE" = false ]; then - echo " - différence(s) avec les paquets de l'image" - diff -u "$IMAGE_NAME_RISOTTO_IMAGE_DIR".pkgs "$IMAGE_NAME_RISOTTO_IMAGE_DIR".pkgs.new && INSTALL=false || INSTALL=true + diff -u "$IMAGE_NAME_RISOTTO_IMAGE_DIR".base.pkgs "$BASE_PKGS_FILE" && INSTALL=false || INSTALL=true else INSTALL=true fi +new_package +if [ "$INSTALL" = false ]; then + echo " - différence(s) avec les paquets de l'image" + diff -u "$IMAGE_NAME_RISOTTO_IMAGE_DIR".pkgs "$IMAGE_NAME_RISOTTO_IMAGE_DIR".pkgs.new && INSTALL=false || INSTALL=true +fi find $IMAGE_NAME/manual -type f -exec md5sum '{}' \; > "$IMAGE_NAME_RISOTTO_IMAGE_DIR".md5sum.new -if [ "$NEW_BASE" = false ]; then +if [ "$INSTALL" = false ]; then diff -u "$IMAGE_NAME_RISOTTO_IMAGE_DIR".md5sum "$IMAGE_NAME_RISOTTO_IMAGE_DIR".md5sum.new && INSTALL=false || INSTALL=true fi if [ "$INSTALL" = true ]; then diff --git a/seed/applicationservice/2022.03.08/host-systemd-machined/templates/risotto-images.service b/seed/applicationservice/2022.03.08/host-systemd-machined/templates/risotto-images.service new file mode 100644 index 00000000..6b066d87 --- /dev/null +++ b/seed/applicationservice/2022.03.08/host-systemd-machined/templates/risotto-images.service @@ -0,0 +1,12 @@ +[Unit] +Description=Daily images update activities +After=network.target local-fs.target systemd-logind.service + +[Service] +Type=oneshot +WorkingDirectory=%%host_install_dir +ExecStart=%%host_install_dir/install_images %%host_name +ExecStart=%%host_install_dir/install_machines %%host_name + +[Install] +WantedBy=multi-user.target diff --git a/seed/applicationservice/2022.03.08/host-systemd-machined/templates/risotto-images.timer b/seed/applicationservice/2022.03.08/host-systemd-machined/templates/risotto-images.timer new file mode 100644 index 00000000..ba81b3d8 --- /dev/null +++ b/seed/applicationservice/2022.03.08/host-systemd-machined/templates/risotto-images.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Daily images update activities + +[Timer] +OnCalendar=*-*-* 5:00 +Persistent=true + +[Install] +WantedBy=timers.target