dotfiles/scripts/sync.sh

25 lines
528 B
Bash
Raw Normal View History

2024-01-26 21:38:51 +01:00
#!/bin/bash
src_dir="../root"
dst_dir="/"
2024-01-26 23:49:54 +01:00
amount=0
2024-01-26 21:38:51 +01:00
function create_hard_links() {
local src_path="$1"
local dst_path="$2"
2024-01-26 23:49:54 +01:00
for item in "$src_path"/* "$src_path"/.[^.]*; do
2024-01-26 21:38:51 +01:00
if [ -d "$item" ]; then
mkdir -p "${dst_path}${item#$src_path}/"
create_hard_links "$item" "${dst_path}${item#$src_path}/"
elif [ -f "$item" ] && [[ ! "$item" =~ \.enc$ ]]; then
2024-01-26 23:49:54 +01:00
ln -f "$item" "${dst_path}${item#$src_path}"
amount=$((amount+1))
2024-01-26 21:38:51 +01:00
fi
done
}
2024-01-26 23:49:54 +01:00
create_hard_links "$src_dir" "$dst_dir"
echo "Hard links created: $amount"