From 46c96c8141a8dfb6897883b075951bd05d2ef4b1 Mon Sep 17 00:00:00 2001 From: Brian Zalewski Date: Wed, 25 Jan 2023 01:22:20 +0000 Subject: [PATCH] Update 2 files - /home/.chezmoiscripts/universal/run_onchange_after_11-symlink-ansible-roles.tmpl - /home/.chezmoiscripts/universal/run_before_01-decrypt-age-key.tmpl --- .../run_before_01-decrypt-age-key.tmpl | 11 ++++++----- ...nchange_after_11-symlink-ansible-roles.tmpl | 18 +++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/home/.chezmoiscripts/universal/run_before_01-decrypt-age-key.tmpl b/home/.chezmoiscripts/universal/run_before_01-decrypt-age-key.tmpl index f80c1112..b22366bb 100644 --- a/home/.chezmoiscripts/universal/run_before_01-decrypt-age-key.tmpl +++ b/home/.chezmoiscripts/universal/run_before_01-decrypt-age-key.tmpl @@ -16,11 +16,12 @@ if [ ! -f "${XDG_CONFIG_HOME}/age/chezmoi.txt" ]; then find "$HOME/.local/share/chezmoi" -type f -name "encrypted_*" | while read ENCRYPTED_FILE; do logg info "Removing $ENCRYPTED_FILE" rm -f "$ENCRYPTED_FILE" - FALLBACK_FILENAME="$(echo "$ENCRYPTED_FILE" | sed 's/encrypted_/encrypted-fallback_/')" - if [ -f "$FALLBACK_FILENAME" ]; then - logg info 'Substituting encrypted-file fallback for `'"$ENCRYPTED_FILE"'`' - mv -f "$FALLBACK_FILENAME" "$(echo "$ENCRYPTED_FILE" | sed 's/encrypted_//')" - fi + done + else + logg info 'Removing files used when an encryption key is not configured' + find "$HOME/.local/share/chezmoi" -type f -name "encrypted-fallback_*" | while read UNENCRYPTED_FILE; do + logg info "Removing $UNENCRYPTED_FILE" + rm -f "$UNENCRYPTED_FILE" done fi fi diff --git a/home/.chezmoiscripts/universal/run_onchange_after_11-symlink-ansible-roles.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_11-symlink-ansible-roles.tmpl index ed6c0a1e..1d3c31ca 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_11-symlink-ansible-roles.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_11-symlink-ansible-roles.tmpl @@ -11,26 +11,26 @@ {{- end }} logg info 'Ensuring Gas Station roles are symlinked to ~/.local/share/ansible/roles' -mkdir -p "$XDG_DATA_HOME/ansible/roles" +mkdir -p "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles" find "$HOME/.local/src/gas-station/roles" -mindepth 2 -maxdepth 2 -type d | while read ROLE_PATH; do ROLE_FOLDER="professormanhattan.$(echo "$ROLE_PATH" | sed 's/.*\/\([^\/]*\)$/\1/')" ALT_ROLE_FOLDER="$(echo "$ROLE_PATH" | sed 's/.*\/\([^\/]*\)$/\1/')" - if [ ! -d "$XDG_DATA_HOME/ansible/roles/$ROLE_FOLDER" ] || [ "$(readlink -f "$XDG_DATA_HOME/ansible/roles/$ROLE_FOLDER")" != "$ROLE_PATH" ]; then + if [ ! -d "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ROLE_FOLDER" ] || [ "$(readlink -f "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ROLE_FOLDER")" != "$ROLE_PATH" ]; then logg info 'Symlinking `'"$ROLE_FOLDER"'`' - rm -f "$XDG_DATA_HOME/ansible/roles/$ROLE_FOLDER" - ln -s "$ROLE_PATH" "$XDG_DATA_HOME/ansible/roles/$ROLE_FOLDER" + rm -f "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ROLE_FOLDER" + ln -s "$ROLE_PATH" "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ROLE_FOLDER" fi - if [ ! -d "$XDG_DATA_HOME/ansible/roles/$ALT_ROLE_FOLDER" ] || [ "$(readlink -f "$XDG_DATA_HOME/ansible/roles/$ALT_ROLE_FOLDER")" != "$ROLE_PATH" ]; then - rm -f "$XDG_DATA_HOME/ansible/roles/$ALT_ROLE_FOLDER" - ln -s "$ROLE_PATH" "$XDG_DATA_HOME/ansible/roles/$ALT_ROLE_FOLDER" + if [ ! -d "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ALT_ROLE_FOLDER" ] || [ "$(readlink -f "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ALT_ROLE_FOLDER")" != "$ROLE_PATH" ]; then + rm -f "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ALT_ROLE_FOLDER" + ln -s "$ROLE_PATH" "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ALT_ROLE_FOLDER" fi done if [ -f "$HOME/.local/src/gas-station/requirements.yml" ]; then if command -v ansible-galaxy > /dev/null; then logg info 'Ensuring Ansible Galaxy collections are installed' - export ANSIBLE_CONFIG="$HOME/.local/share/ansible/ansible.cfg" - ansible-galaxy install -r "$HOME/.local/share/ansible/requirements.yml" || EXIT_CODE=$? + export ANSIBLE_CONFIG="${XDG_DATA_DIR:-$HOME/.local/share}/ansible/ansible.cfg" + ansible-galaxy install -r "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/requirements.yml" || EXIT_CODE=$? if [ -n "$EXIT_CODE" ]; then logg error 'Failed to install Ansible requirements from Ansible Galaxy' if [ -d "$HOME/.local/src/gas-station/collections" ]; then