40 lines
653 B
Bash
Executable File
40 lines
653 B
Bash
Executable File
#!/bin/sh -e
|
|
|
|
install_dotfiles() {
|
|
local target_dir="$1"
|
|
for d in dotfiles/*; do
|
|
cp -v "$d" "${target_dir}/$(basename "$d")"
|
|
done
|
|
}
|
|
|
|
install_files() {
|
|
local target_dir="$1"
|
|
local source_dir="${2:-.}"
|
|
if [ ! -d "${source_dir}" ]; then
|
|
echo "Source directory ${source_dir} does not exist, skipping."
|
|
return
|
|
fi
|
|
(
|
|
cd "${source_dir}"
|
|
for f in *; do
|
|
case "$f" in
|
|
^dotfiles)
|
|
install_dotfiles "${target_dir}"
|
|
;;
|
|
*)
|
|
if [ -d "$f" ]; then
|
|
(cd "$d" && install_files "${target_dir}/$f")
|
|
else
|
|
cp -v "$f" "${target_dir}"
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
)
|
|
}
|
|
|
|
###
|
|
|
|
install_files "${HOME}" home
|
|
install_files "/etc" etc
|