Update 2 files

- /home/.chezmoiscripts/universal/run_onchange_after_11-symlink-ansible-roles.tmpl
- /home/.chezmoiscripts/universal/run_before_01-decrypt-age-key.tmpl
This commit is contained in:
Brian Zalewski 2023-01-25 01:22:20 +00:00
parent 7bfe2ddbf1
commit 46c96c8141
2 changed files with 15 additions and 14 deletions

View file

@ -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 find "$HOME/.local/share/chezmoi" -type f -name "encrypted_*" | while read ENCRYPTED_FILE; do
logg info "Removing $ENCRYPTED_FILE" logg info "Removing $ENCRYPTED_FILE"
rm -f "$ENCRYPTED_FILE" rm -f "$ENCRYPTED_FILE"
FALLBACK_FILENAME="$(echo "$ENCRYPTED_FILE" | sed 's/encrypted_/encrypted-fallback_/')" done
if [ -f "$FALLBACK_FILENAME" ]; then else
logg info 'Substituting encrypted-file fallback for `'"$ENCRYPTED_FILE"'`' logg info 'Removing files used when an encryption key is not configured'
mv -f "$FALLBACK_FILENAME" "$(echo "$ENCRYPTED_FILE" | sed 's/encrypted_//')" find "$HOME/.local/share/chezmoi" -type f -name "encrypted-fallback_*" | while read UNENCRYPTED_FILE; do
fi logg info "Removing $UNENCRYPTED_FILE"
rm -f "$UNENCRYPTED_FILE"
done done
fi fi
fi fi

View file

@ -11,26 +11,26 @@
{{- end }} {{- end }}
logg info 'Ensuring Gas Station roles are symlinked to ~/.local/share/ansible/roles' 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 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/')" ROLE_FOLDER="professormanhattan.$(echo "$ROLE_PATH" | sed 's/.*\/\([^\/]*\)$/\1/')"
ALT_ROLE_FOLDER="$(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"'`' logg info 'Symlinking `'"$ROLE_FOLDER"'`'
rm -f "$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_HOME/ansible/roles/$ROLE_FOLDER" ln -s "$ROLE_PATH" "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ROLE_FOLDER"
fi fi
if [ ! -d "$XDG_DATA_HOME/ansible/roles/$ALT_ROLE_FOLDER" ] || [ "$(readlink -f "$XDG_DATA_HOME/ansible/roles/$ALT_ROLE_FOLDER")" != "$ROLE_PATH" ]; then 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_HOME/ansible/roles/$ALT_ROLE_FOLDER" rm -f "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ALT_ROLE_FOLDER"
ln -s "$ROLE_PATH" "$XDG_DATA_HOME/ansible/roles/$ALT_ROLE_FOLDER" ln -s "$ROLE_PATH" "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ALT_ROLE_FOLDER"
fi fi
done done
if [ -f "$HOME/.local/src/gas-station/requirements.yml" ]; then if [ -f "$HOME/.local/src/gas-station/requirements.yml" ]; then
if command -v ansible-galaxy > /dev/null; then if command -v ansible-galaxy > /dev/null; then
logg info 'Ensuring Ansible Galaxy collections are installed' logg info 'Ensuring Ansible Galaxy collections are installed'
export ANSIBLE_CONFIG="$HOME/.local/share/ansible/ansible.cfg" export ANSIBLE_CONFIG="${XDG_DATA_DIR:-$HOME/.local/share}/ansible/ansible.cfg"
ansible-galaxy install -r "$HOME/.local/share/ansible/requirements.yml" || EXIT_CODE=$? ansible-galaxy install -r "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/requirements.yml" || EXIT_CODE=$?
if [ -n "$EXIT_CODE" ]; then if [ -n "$EXIT_CODE" ]; then
logg error 'Failed to install Ansible requirements from Ansible Galaxy' logg error 'Failed to install Ansible requirements from Ansible Galaxy'
if [ -d "$HOME/.local/src/gas-station/collections" ]; then if [ -d "$HOME/.local/src/gas-station/collections" ]; then