From 8ed06511d9ffd61a9d8b92821ef8cd6df94a87ea Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Fri, 1 May 2020 10:31:20 +0200 Subject: [PATCH] bkctld-sync: don't init jail if it already exists --- lib/bkctld-sync | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/bkctld-sync b/lib/bkctld-sync index 74dea8c..d521c79 100755 --- a/lib/bkctld-sync +++ b/lib/bkctld-sync @@ -18,8 +18,12 @@ test -d "${jail_path}" || error "${jail_name}: jail not found" 2 [ -n "${NODE}" ] || error "Sync need config of \$NODE in /etc/default/bkctld !" -# Init jail on remote server -ssh "${NODE}" "${LIBDIR}/bkctld-init" "${jail_name}" | debug +ssh "${NODE}" "${LIBDIR}/bkctld-is-on ${jail_name} 2>/dev/null" +# return code 2 is for "missing jail" error +if [ "$?" -eq 2 ]; then + # Init jail on remote server + ssh "${NODE}" "${LIBDIR}/bkctld-init ${jail_name}" | debug +fi # Sync Jail structure and configuration on remote server rsync -a "${jail_path}/" "${NODE}:${jail_path}/" --exclude proc/* --exclude sys/* --exclude dev/* --exclude run --exclude var/backup/*