home · contact · privacy
9a7a162f07c28b137fe1186ffe189b34af7904d2
[config] / all_new_2018 / symlink_etc.sh
1 #!/bin/sh
2 # Symbolically link files to those under linkable_etc_files/$1/, e.g.
3 # link /etc/foo/bar to linkable_etc_files/$1/etc/foo/bar. Create
4 # directories as necessary.
5 # CAUTION: This removes original files at the affected paths.
6 set -e
7
8 target="$1"
9 if [ ! "${target}" = "all" ] && [ ! "${target}" = "server" ]; then
10     echo "Need proper target."
11     false
12 fi
13
14 config_tree_prefix="${HOME}/config/all_new_2018/linkable_etc_files/"
15 cd "${config_tree_prefix}""${target}"
16 for path in $(find . -type f); do
17     src=$(echo "${path}" | cut -c2-)
18     dest=$(realpath "${path}")
19     ln -fs "${dest}" "${src}"
20 done