X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/balance2?a=blobdiff_plain;f=all_new_2018%2Fsymlink_etc.sh;h=90cb20ab51cfdb6d07c9d8e295d3c361eea89f24;hb=8bbfcc3c6a262a74d66ac84a25c7775029f4e53f;hp=9a7a162f07c28b137fe1186ffe189b34af7904d2;hpb=c5917948ea2b6f1114aaf239567298c3cd20d017;p=config diff --git a/all_new_2018/symlink_etc.sh b/all_new_2018/symlink_etc.sh index 9a7a162..90cb20a 100755 --- a/all_new_2018/symlink_etc.sh +++ b/all_new_2018/symlink_etc.sh @@ -1,20 +1,20 @@ #!/bin/sh -# Symbolically link files to those under linkable_etc_files/$1/, e.g. -# link /etc/foo/bar to linkable_etc_files/$1/etc/foo/bar. Create -# directories as necessary. +# Symbolically link files to those in argument-selected subdirectories +# of linkable_etc_files//, e.g. link /etc/foo/bar to +# linkable_etc_files/$1/etc/foo/bar and so on. Create directories as +# necessary. # CAUTION: This removes original files at the affected paths. set -e -target="$1" -if [ ! "${target}" = "all" ] && [ ! "${target}" = "server" ]; then - echo "Need proper target." - false -fi - config_tree_prefix="${HOME}/config/all_new_2018/linkable_etc_files/" -cd "${config_tree_prefix}""${target}" -for path in $(find . -type f); do - src=$(echo "${path}" | cut -c2-) - dest=$(realpath "${path}") - ln -fs "${dest}" "${src}" + +for target in "$@"; do + cd "${config_tree_prefix}${target}" + for path in $(find . -type f); do + linking=$(echo "${path}" | cut -c2-) + linked=$(realpath "${path}") + dir=$(dirname "${linking}") + mkdir -p "${dir}" + ln -fs "${linked}" "${linking}" + done done