home · contact · privacy
Improve new setup.
[config] / all_new_2018 / symlink_etc.sh
1 #!/bin/sh
2 # Symbolically link files to those in argument-selected subdirectories
3 # of linkable_etc_files//, e.g. link /etc/foo/bar to
4 # linkable_etc_files/$1/etc/foo/bar and so on. Create directories as
5 # necessary.
6 # CAUTION: This removes original files at the affected paths.
7 set -e
8
9 for target in "$@"; do
10     cd "${config_tree_prefix}${target}"
11     for path in $(find . -type f); do
12         linking=$(echo "${path}" | cut -c2-)
13         linked=$(realpath "${path}")
14         dir=$(dirname "${linking}")
15         mkdir -p "${dir}"
16         ln -fs "${linked}" "${linking}"
17     done
18 done