summaryrefslogtreecommitdiff
path: root/deploy_configs
diff options
context:
space:
mode:
authorBotond Hende <nettingman@gmail.com>2024-04-14 06:38:49 +0200
committerBotond Hende <nettingman@gmail.com>2024-04-14 06:38:49 +0200
commit0221492f62bcc1b766c2a4d5dbe26f6ff2ed8bc2 (patch)
treef91b7ada571a4dab7ae99c8f3ee252616baff2db /deploy_configs
squashed init
Diffstat (limited to 'deploy_configs')
-rwxr-xr-xdeploy_configs67
1 files changed, 67 insertions, 0 deletions
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"