bkctld-sync: don't init jail if it already exists

This commit is contained in:
Jérémy Lecour 2020-05-01 10:31:20 +02:00 committed by Jérémy Lecour
parent 9cd94dabc2
commit 8ed06511d9
1 changed files with 6 additions and 2 deletions

View File

@ -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/*