home · contact · privacy
Minor web server setup improvements.
[config] / all_new_2018 / hardlink_etc.sh
1 #!/bin/sh
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
8 # to non-root.
9 # CAUTION: This removes original files at the affected paths.
10 set -e
11
12 config_tree_prefix="${HOME}/config/all_new_2018/linkable_etc_files/"
13
14 for target in "$@"; do
15     cd "${config_tree_prefix}${target}"
16     for path in $(find . -type f); do
17         linking=$(echo "${path}" | cut -c2-)
18         linked=$(realpath "${path}")
19         dir=$(dirname "${linking}")
20         mkdir -p "${dir}"
21         ln -f "${linked}" "${linking}"
22     done
23 done