mirror of
https://github.com/zebrajr/dotfiles.git
synced 2025-12-06 00:20:05 +01:00
renamed all files such that they match they target destination
This commit is contained in:
parent
59991e5b7d
commit
e2d6eb034f
42
deployer.sh
42
deployer.sh
|
|
@ -1,42 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Load the pairs from the JSON file
|
||||
pairs=$(jq -r '.[] | "\(.source)=\(.destination)=\(.type)"' deployment_playbook.json)
|
||||
|
||||
# Loop through the pairs and copy the source to the destination
|
||||
for pair in ${pairs[@]}; do
|
||||
# Split the pair into source and destination
|
||||
IFS='=' read -ra pair_array <<< "$pair"
|
||||
source=$(echo "${pair_array[0]}" | sed 's/\\"/"/g')
|
||||
destination=$(echo "${pair_array[1]}" | sed 's/\\"/"/g')
|
||||
type=$(echo "${pair_array[2]}" | sed 's/\\"/"/g')
|
||||
|
||||
# Expand ~ if used in the destination
|
||||
destination="${destination/#\~/$HOME}"
|
||||
|
||||
# Check if the destination already exists
|
||||
if [ -e "$destination" ]; then
|
||||
# Backup the destination based on the type
|
||||
if [ "$type" == "append" ]; then
|
||||
echo "Backing up $destination to $destination.backup (cp -r)"
|
||||
cp -r "$destination" "$destination.backup"
|
||||
elif [ "$type" == "replace" ]; then
|
||||
echo "Backing up $destination to $destination.backup (mv)"
|
||||
mv "$destination" "$destination.backup"
|
||||
else
|
||||
echo "Invalid type: $type"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create the directory up to the destination path if it doesn't exist
|
||||
destination_dir=$(dirname "$destination")
|
||||
if [ ! -d "$destination_dir" ]; then
|
||||
echo "Creating directory: $destination_dir"
|
||||
mkdir -p "$destination_dir"
|
||||
fi
|
||||
|
||||
# Copy the source to the destination
|
||||
echo "Copying $source to $destination"
|
||||
cp -r "$source" "$destination"
|
||||
done
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
[
|
||||
{
|
||||
"source": "config/nvim",
|
||||
"destination": "~/.config/nvim",
|
||||
"type": "replace"
|
||||
},
|
||||
{
|
||||
"source": "oh-my-zsh/custom",
|
||||
"destination": "~/.oh-my-zsh/custom",
|
||||
"type": "replace"
|
||||
},
|
||||
{
|
||||
"source": "home/tmux.conf",
|
||||
"destination": "~/.tmux.conf",
|
||||
"type": "replace"
|
||||
},
|
||||
{
|
||||
"source": "home/gitconfig",
|
||||
"destination": "~/.gitconfig",
|
||||
"type": "replace"
|
||||
},
|
||||
{
|
||||
"source": "local/scripts",
|
||||
"destination" : "~/.local/scripts",
|
||||
"type": "replace"
|
||||
}
|
||||
]
|
||||
Loading…
Reference in New Issue
Block a user