2 # Hard link files to those in argument-selected subdirectories of
3 # 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. We do the hard linking so files that should be readable to
6 # non-root in /etc/ remain so despite having a path below /root/, as
7 # symbolic links point into /root/ without making the targets readable
9 # CAUTION: This removes original files at the affected paths.
12 config_tree_prefix="${HOME}/config/all_new_2018"
13 linkable_files_dir="${config_tree_prefix}/linkable_etc_files"
15 for target in "$@"; do
16 cd "${linkable_files_dir}/${target}"
17 for path in $(find . -type f); do
18 linking=$(echo "${path}" | cut -c2-)
19 linked=$(realpath "${path}")
20 dir=$(dirname "${linking}")
22 ln -f "${linked}" "${linking}"