From 02bb39d5f8618919f7503bc001c10502cb574c72 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Mon, 19 Nov 2018 16:39:52 +0100 Subject: [PATCH] Use hard links instead of symbolic links for /etc/. --- all_new_2018/{symlink_etc.sh => hardlink_etc.sh} | 11 +++++++---- all_new_2018/setup_server.sh | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) rename all_new_2018/{symlink_etc.sh => hardlink_etc.sh} (55%) diff --git a/all_new_2018/symlink_etc.sh b/all_new_2018/hardlink_etc.sh similarity index 55% rename from all_new_2018/symlink_etc.sh rename to all_new_2018/hardlink_etc.sh index 90cb20a..a6f3b68 100755 --- a/all_new_2018/symlink_etc.sh +++ b/all_new_2018/hardlink_etc.sh @@ -1,8 +1,11 @@ #!/bin/sh -# Symbolically link files to those in argument-selected subdirectories -# of linkable_etc_files//, e.g. link /etc/foo/bar to +# Hard 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. +# necessary. We do the hard linking so files that should be readable to +# non-root in /etc/ remain so despite having a path below /root/, as +# symbolic links point into /root/ without making the targets readable +# to non-root. # CAUTION: This removes original files at the affected paths. set -e @@ -15,6 +18,6 @@ for target in "$@"; do linked=$(realpath "${path}") dir=$(dirname "${linking}") mkdir -p "${dir}" - ln -fs "${linked}" "${linking}" + ln -f "${linked}" "${linking}" done done diff --git a/all_new_2018/setup_server.sh b/all_new_2018/setup_server.sh index 55650aa..a4f8599 100755 --- a/all_new_2018/setup_server.sh +++ b/all_new_2018/setup_server.sh @@ -4,7 +4,7 @@ set -e # Provide maximum input for set_hostname_and_fqdn.sh. -if "$#" -ne 2 ]; then +if [ "$#" -ne 2 ]; then echo "Need exactly two arguments (hostname, FQDN)." false fi @@ -14,7 +14,7 @@ fqdn="$2" # Adapt /etc/ to our needs by symlinking into ./linkable_etc_files. This # will set basic configurations affecting following steps, such as setup # of APT and the locale selection, so needs to be right at the beginning. -./symlink_etc.sh all server +./hardlink_etc.sh all server # Set hostname and FQDN. ./set_hostname_and_fqdn.sh "${hostname}" "${fqdn}" -- 2.30.2