home · contact · privacy
Add /etc/hosts and hostname and FQDN setting.
[config] / all_new_2018 / symlink_etc.sh
index f1f97af1a557a27b5a5d51fdce500cda02c7cd23..90cb20ab51cfdb6d07c9d8e295d3c361eea89f24 100755 (executable)
@@ -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