From f181b5ddb4386a179fddd8b7e1dc509614d84003 Mon Sep 17 00:00:00 2001 From: Joachim Desroches Date: Wed, 21 Apr 2021 15:27:52 +0200 Subject: [PATCH] Pull updates to __borg_repo from recycled.cloud types. --- type/__borg_repo/gencode-remote | 11 ++++++++--- type/__borg_repo/man.rst | 3 +++ type/__borg_repo/manifest | 5 +++++ type/__borg_repo/parameter/optional | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/type/__borg_repo/gencode-remote b/type/__borg_repo/gencode-remote index 542bf5f..f4580ef 100644 --- a/type/__borg_repo/gencode-remote +++ b/type/__borg_repo/gencode-remote @@ -27,10 +27,15 @@ then appendonly='--append-only' fi +if [ -f "${__object:?}/parameter/owner" ]; +then + doas="sudo -u '$(cat "${__object:?}/parameter/owner")'" +fi + cat <<- EOF - if ! borg check --repository-only 1>&2 2>/dev/null "/${__object_id:?}"; - then - BORG_NEW_PASSPHRASE=$passphrase borg init -e ${enc:?} $appendonly /${__object_id:?} + set -x + if [ ! -d "/${__object_id:?}" ]; then + $doas BORG_NEW_PASSPHRASE=$passphrase borg init -e ${enc:?} $appendonly /${__object_id:?} fi EOF diff --git a/type/__borg_repo/man.rst b/type/__borg_repo/man.rst index 38ab0c9..dce3660 100644 --- a/type/__borg_repo/man.rst +++ b/type/__borg_repo/man.rst @@ -26,6 +26,9 @@ OPTIONAL PARAMETERS passphrase The passphrase to encrypt the keyfile with. +owner + Remote user owning the repository. + BOOLEAN PARAMETERS ------------------ append-only diff --git a/type/__borg_repo/manifest b/type/__borg_repo/manifest index fe18c9c..968066d 100644 --- a/type/__borg_repo/manifest +++ b/type/__borg_repo/manifest @@ -12,3 +12,8 @@ case "$os" in esac __package "$borg_package" + +if [ -f "${__object:?}/parameter/owner" ]; +then + __package sudo +fi diff --git a/type/__borg_repo/parameter/optional b/type/__borg_repo/parameter/optional index f63b25b..8e1ddfd 100644 --- a/type/__borg_repo/parameter/optional +++ b/type/__borg_repo/parameter/optional @@ -1 +1,2 @@ passphrase +owner