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