From 73ad8e1d70709017975d9e3f4a31b5295da95b8b Mon Sep 17 00:00:00 2001
From: Adam Thorn <alt36@cam.ac.uk>
Date: Wed, 25 May 2022 09:11:03 +0100
Subject: [PATCH] Ignore non-zero exit from systemd-detect-virt in prepare
 script

As of b4b89ed we need the prepare script to exit zero on success.

We only use the stdout from this command, not the return code, for
determining if the target is a xen VM.
---
 ROOT/DEBIAN/control                                 | 2 +-
 ROOT/etc/chem-zfs-backup-server/zfs-rsync.d/prepare | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/ROOT/DEBIAN/control b/ROOT/DEBIAN/control
index fdfe0fc..eda3c3d 100644
--- a/ROOT/DEBIAN/control
+++ b/ROOT/DEBIAN/control
@@ -3,6 +3,6 @@ Priority: optional
 Section: otherosfs
 Maintainer: Chemistry COs <support@ch.cam.ac.uk>
 Architecture: all
-Version: 0.9-ch94
+Version: 0.9-ch95
 Depends: zfs-dkms, postgresql-13 | postgresql-9.5 | postgresql-9.4 , liblockfile-simple-perl, libdbi-perl, libjson-perl, libzfs-perl-chem, libnet-openssh-perl, libdbd-pg-perl, mbuffer, rsync, nfs-kernel-server, pv, libwww-curl-perl
 Description: a backup system using ZFS (repository 'backup-scheduler')
diff --git a/ROOT/etc/chem-zfs-backup-server/zfs-rsync.d/prepare b/ROOT/etc/chem-zfs-backup-server/zfs-rsync.d/prepare
index 342d939..1a420ac 100755
--- a/ROOT/etc/chem-zfs-backup-server/zfs-rsync.d/prepare
+++ b/ROOT/etc/chem-zfs-backup-server/zfs-rsync.d/prepare
@@ -54,7 +54,11 @@ fi
 # provided by it.
 # systemd-detect-virt is present on all our Ubuntu VMs so is hopefully a 
 # reliable method to use
+# NB this returns non-zero on a non-virtual machine so we don't mind
+# the return value
+set +e
 VIRT_TYPE=$(ssh root@$SERVER systemd-detect-virt 2>/dev/null)
+set -e
 if [ "$VIRT_TYPE" == "xen" ] ; then
 cat<<EOF >> $CONFDIR/$SERVER/exclude
 /lib/modules
-- 
GitLab