diff --git a/dotfiles/.local/share/chezmoi/home/dot_local/bin/run_onchange_ensure-executable.tmpl b/dotfiles/.local/share/chezmoi/home/dot_local/bin/run_onchange_ensure-executable.tmpl index d69709b7..b590c53e 100644 --- a/dotfiles/.local/share/chezmoi/home/dot_local/bin/run_onchange_ensure-executable.tmpl +++ b/dotfiles/.local/share/chezmoi/home/dot_local/bin/run_onchange_ensure-executable.tmpl @@ -1,5 +1,8 @@ #!/usr/bin/env bash +{{- includeTemplate "universal/profile" }} +{{- includeTemplate "universal/logg" }} + {{ $exeFiles := (output "find" (joinPath .chezmoi.homeDir ".local" "bin") "-mindepth" "1" "-maxdepth" "1" "-type" "f") -}} {{- range $exeFile := splitList "\n" $exeFiles -}} {{- if ne $exeFile "" -}} @@ -7,7 +10,7 @@ {{ end -}} {{- end }} -### Ensure all files in ~/.local/bin are executable +logg 'Ensuring all files in ~/.local/bin are executable' find "$HOME/.local/bin" -mindepth 1 -maxdepth 1 -type f | while read EXE_FILE; do chmod +x "$EXE_FILE" done diff --git a/dotfiles/.local/share/chezmoi/home/dot_local/share/ansible/roles/run_onchange_after_symlink-ansible-roles b/dotfiles/.local/share/chezmoi/home/dot_local/share/ansible/roles/run_onchange_after_symlink-ansible-roles index 777c8b54..7e683fe8 100644 --- a/dotfiles/.local/share/chezmoi/home/dot_local/share/ansible/roles/run_onchange_after_symlink-ansible-roles +++ b/dotfiles/.local/share/chezmoi/home/dot_local/share/ansible/roles/run_onchange_after_symlink-ansible-roles @@ -1,5 +1,8 @@ #!/usr/bin/env bash +{{- includeTemplate "universal/profile" }} +{{- includeTemplate "universal/logg" }} + {{ $roleDirs := (output "find" (joinPath .chezmoi.homeDir ".local" "src" "gas-station" "roles") "-mindepth" "2" "-maxdepth" "2" "-type" "d") -}} {{- range $roleDir := splitList "\n" $roleDirs -}} {{- if ne $roleDir "" -}} @@ -7,7 +10,11 @@ {{ end -}} {{- end }} +logg 'Ensuring Gas Station roles are symlinked to ~/.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/')" - ln -s "$ROLE_PATH" "$XDG_DATA_HOME/ansible/roles/$ROLE_FOLDER" + if [ ! -d "$XDG_DATA_HOME/ansible/roles/$ROLE_FOLDER" ] || [ "$(readlink -f "$XDG_DATA_HOME/ansible/roles/$ROLE_FOLDER")" != "$ROLE_PATH" ]; then + rm -f "$XDG_DATA_HOME/ansible/roles/$ROLE_FOLDER" + ln -s "$ROLE_PATH" "$XDG_DATA_HOME/ansible/roles/$ROLE_FOLDER" + fi fi diff --git a/dotfiles/.local/share/chezmoi/home/dot_local/share/ansible/run_onchange_after_symlink-ansible-configs b/dotfiles/.local/share/chezmoi/home/dot_local/share/ansible/run_onchange_after_symlink-ansible-configs index 1fec5a76..952ed541 100644 --- a/dotfiles/.local/share/chezmoi/home/dot_local/share/ansible/run_onchange_after_symlink-ansible-configs +++ b/dotfiles/.local/share/chezmoi/home/dot_local/share/ansible/run_onchange_after_symlink-ansible-configs @@ -1,21 +1,25 @@ #!/usr/bin/env bash +{{- includeTemplate "universal/profile" }} +{{- includeTemplate "universal/logg" }} + ### Symlink the variables / files / inventories to ~/.config/ansible folders if they are present ### i.e. Changes to upstream will not impact the play if your configuration files are stored locally for TARGET of "files" "group_vars" "host_vars" "inventories" "templates"; do - if [ -d "$HOME/.config/ansible/$TARGET" ] && [ "$(readlink -f "$HOME/.local/share/ansible/$TARGET")" != "$HOME/.config/ansible/$TARGET" ]; then + if [ -d "$XDG_CONFIG_HOME/ansible/$TARGET" ] && [ "$(readlink -f "$XDG_DATA_HOME/ansible/$TARGET")" != "$XDG_CONFIG_HOME/ansible/$TARGET" ]; then logg 'Symlinking Ansible playbook `'"$TARGET"'` to ~/.config/ansible/$TARGET' - rm -f "$HOME/.local/share/ansible/$TARGET" - ln -s "$HOME/.config/ansible/$TARGET" "$HOME/.local/share/ansible/$TARGET" + rm -f "$XDG_DATA_HOME/ansible/$TARGET" + ln -s "$XDG_CONFIG_HOME/ansible/$TARGET" "$XDG_DATA_HOME/ansible/$TARGET" fi done ### Symlink tasks as well ### Note: Only handles tasks one level deep (i.e. ~/.config/ansible/tasks/my-task.yml will link to the tasks folder ### but ~/.config/ansible/tasks/directory/my-other-task.yml will not) -find "$HOME/.config/ansible/tasks" -type f | while read TASK_FILE; do +find "$XDG_CONFIG_HOME/ansible/tasks" -type f | while read TASK_FILE; do TASK_FILE_NAME="$(echo "$TASK_FILE" | sed 's/.*\/\([^\/]*\)$/\1/')" - if [ "$(readlink -f "$HOME/.local/share/ansible/tasks/$TASK_FILE_NAME")" != "$TASK_FILE" ]; then - ln -s "$TASK_FILE" "$HOME/.local/share/ansible/tasks/$TASK_FILE_NAME" + if [ "$(readlink -f "$XDG_DATA_HOME/ansible/tasks/$TASK_FILE_NAME")" != "$TASK_FILE" ]; then + logg 'Symlinking new task to ~/.local/share/ansible/tasks' + ln -s "$TASK_FILE" "$XDG_DATA_HOME/ansible/tasks/$TASK_FILE_NAME" fi done