From 3371d034211a9032008e6d1cc475175c2ea2a9a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Sat, 2 Jul 2022 15:56:34 +0200 Subject: [PATCH] Fix fixing of /var/lib/dotfiles permissions --- playbook.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/playbook.yml b/playbook.yml index a8d58b4..12c1605 100644 --- a/playbook.yml +++ b/playbook.yml @@ -133,15 +133,20 @@ - name: fix permissions for dotfiles directory shell: | - # There is no sane way to specify the global .gitconfig to use, so we - # actually have to override HOME so git looks into ~/.gitconfig - export HOME="$(mktemp -d)" - set -o pipefail - set -o errexit cd /var/lib/dotfiles - git config --global --add safe.directory /var/lib/dotfiles - git ls-tree -z --name-only HEAD | xargs --null chown --changes --recursive dotfiles:dotfiles - git ls-tree -z --name-only HEAD | xargs --null chmod --changes --recursive g+wX /var/lib/dotfiles + if [[ -e .git ]] ; then + # There is no sane way to specify the global .gitconfig to use, so we + # actually have to override HOME so git looks into ~/.gitconfig + export HOME="$(mktemp -d)" + set -o pipefail + set -o errexit + git config --global --add safe.directory /var/lib/dotfiles + git ls-tree -z --name-only HEAD | xargs --null chown --changes --recursive dotfiles:dotfiles + git ls-tree -z --name-only HEAD | xargs --null chmod --changes --recursive g+wX + else + chown --changes --recursive dotfiles:dotfiles . + chmod --changes --recursive g+wX . + fi args: executable: /bin/bash register: dotfiles_permission_change