From 0221492f62bcc1b766c2a4d5dbe26f6ff2ed8bc2 Mon Sep 17 00:00:00 2001 From: Botond Hende Date: Sun, 14 Apr 2024 06:38:49 +0200 Subject: squashed init --- deploy_configs | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 deploy_configs (limited to 'deploy_configs') diff --git a/deploy_configs b/deploy_configs new file mode 100755 index 0000000..5a8749d --- /dev/null +++ b/deploy_configs @@ -0,0 +1,67 @@ +#!/usr/bin/bash -eu + +echo =============================== +echo Starting deploy. + +deploy_path="$HOME" +dummy_home="./home" + +cd "$(dirname "$0")" +dummy_home_abs=$(pwd)/home +additional_list="" +while read line; do + folder_path=$(dirname "$line") + file=$(basename "$line") + folder_path=${folder_path:6} + if [[ "$folder_path" != "" ]]; then + mkdir -p "$deploy_path""$folder_path" + fi + + config_path="$dummy_home_abs""$folder_path"/"$file" + desired_path="$deploy_path""$folder_path"/"$file" + if [[ "$file" == *".fof" ]]; then + desired_path=${desired_path::-4} + fi + + if [[ "$folder_path" == *"additional.d"* ]]; then + if [[ "$additional_list" != *"$folder_path"* ]]; then + additional_list+='\n\n'"$folder_path" + fi + + already_deployed="-" + if [[ -L "$desired_path" ]]; then + already_deployed="+" + fi + + additional_list+='\n'"$already_deployed""$file" + else + if [[ "$file" != *".fof" && ( -L "$desired_path" || ( ! -f "$desired_path" && ! -d "$desired_path" ) ) ]]; then + ln -sf "$config_path" "$desired_path" + else + if [[ ( -f "$desired_path".deploy_backup || -d "$desired_path".deploy_backup ) ]]; then + rm -r "$desired_path".deploy_backup + fi + + if [[ ( -f "$desired_path" || -d "$desired_path" ) ]]; then + mv -T "$desired_path" "$desired_path".deploy_backup + fi + + if [[ "$file" == *".fof" ]]; then + echo Deploying fire and forget config: "$desired_path" + cp "$config_path" "$desired_path" + else + echo Path exists, moved to filename.deploy_backup: "$desired_path" + ln -sf "$config_path" "$desired_path" + fi + fi + fi +done < <(find "$dummy_home" -type f) + +echo +echo =============================== +echo Deploy finished. +echo +echo =============================== +echo Additional configs to consider: +additional_list=${additional_list:4} +echo -e "$additional_list" -- cgit v1.2.3-70-g09d2