From: Christian Heller Date: Sun, 11 May 2025 17:27:52 +0000 (+0200) Subject: Fix. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/%7B%7Bdb.prefix%7D%7D/%7B%7Bprefix%7D%7D/static/task?a=commitdiff_plain;h=HEAD;p=config Fix. --- diff --git a/testing/scripts/_setup_secrets_user.sh b/testing/scripts/_setup_secrets_user.sh index aa5babf..b62746b 100644 --- a/testing/scripts/_setup_secrets_user.sh +++ b/testing/scripts/_setup_secrets_user.sh @@ -10,6 +10,7 @@ cd $(dirname "$0") . lib/constants_user # USERNAME . lib/constants_borg # NAME_BORGAPP . lib/copy_and_unmount_secrets +. lib/expect_n_args . lib/mount_secrets . lib/prefixed_msg . lib/retry_until @@ -20,6 +21,7 @@ PATH_REPOS="${HOME}/repos" REPOS_SITE_DOMAIN=plomlompom.com REMOTE_PATH_REPOS=/var/repos +expect_n_args 1 1 "(device name, e.g. 'sda')" $@ abort_if_offline abort_if_not_user "${USERNAME}" abort_if_exists "${PATH_SECRETS}" diff --git a/testing/scripts/diff_tagged_files.sh b/testing/scripts/diff_tagged_files.sh new file mode 100755 index 0000000..0f21e12 --- /dev/null +++ b/testing/scripts/diff_tagged_files.sh @@ -0,0 +1,63 @@ +#!/bin/sh +set -e +cd $(dirname "$0") +. lib/abort_if_not_user +. lib/expect_n_args +. lib/prefixed_msg + +prefixed_msg_init +abort_if_not_user root +expect_n_args 1 99 "TAG.." $@ +TAGS="$@" +for _TAG in ${TAGS}; do + _PATH_TAG="../copy/${_TAG}" + if [ ! -d "${_PATH_TAG}" ]; then + continue + fi + prefixed_msg_init "tag [${_TAG}]" + cd "${_PATH_TAG}" + for _PATH_REL in $(find -L . -type f | cut -c 3-); do + _FILENAME="$(basename ${_PATH_REL})" + _PATH_REL_PARENT=$(dirname "${_PATH_REL}") + if [ "${_FILENAME}" = 'KILL_ME' ]; then + _TYPE='directory' + _PATH_ABS="/${_PATH_REL_PARENT}" + elif [ $(echo "${_FILENAME}" | grep -E '^LINK_ME' | wc -l) -gt 0 ]; then + _TYPE='symbolic link' + _LINK_TARGET=$(cat "${_PATH_REL}" | head -1) + _LINK_NAME=$(cat "${_PATH_REL}" | tail -1) + if [ -z "${_LINK_NAME}" ]; then + _LINK_NAME=$(basename "${_LINK_TARGET}") + fi + _PATH_ABS="/${_PATH_REL_PARENT}/${_LINK_NAME}" + else + _TYPE='regular file' + _PATH_ABS="/${_PATH_REL}" + fi + if [ -h "${_PATH_ABS}" ]; then + if [ "${_TYPE}" = 'symbolic link' ]; then + _LOCAL_TARGET=$(stat "${_PATH_ABS}" | head -1 | sed -E 's/^ File: [[:print:]]+ -> //g') + if [ "$(echo ${_LOCAL_TARGET} | cut -c1)" != "/" ]; then + _LOCAL_TARGET=$(realpath --canonicalize-missing "/${_PATH_REL_PARENT}/${_LOCAL_TARGET}") + fi + if [ "$(echo ${_LINK_TARGET} | cut -c1)" != "/" ]; then + _LINK_TARGET=$(realpath --canonicalize-missing "/${_PATH_REL_PARENT}/${_LINK_TARGET}") + fi + if [ "${_LOCAL_TARGET}" != "${_LINK_TARGET}" ]; then + prefixed_msg "${_TYPE} targeting ${_LOCAL_TARGET} != ${_LINK_TARGET}" + fi + else + prefixed_msg "Not a ${_TYPE}: ${_PATH_ABS}" + fi + elif [ ! -e "${_PATH_ABS}" ]; then + prefixed_msg "Missing ${_TYPE}: ${_PATH_ABS}" + elif [ "${_TYPE}" != "$(stat --format=%F ${_PATH_ABS})" ]; then + prefixed_msg "Not a ${_TYPE}: ${_PATH_ABS}" + elif [ "${_TYPE}" = 'regular file' ]; then + ! diff "${_PATH_ABS}" "${_PATH_REL}" > /dev/null && prefixed_msg "Regular file differs: ${_PATH_ABS}" + fi + done + cd - > /dev/null + prefixed_msg_exit +done +prefixed_msg_exit diff --git a/testing/scripts/lib/mount_secrets b/testing/scripts/lib/mount_secrets index 934b0a6..7012dab 100644 --- a/testing/scripts/lib/mount_secrets +++ b/testing/scripts/lib/mount_secrets @@ -8,7 +8,6 @@ mount_secrets() { prefixed_msg_init mount_secrets -expect_n_args 1 1 "(device name, e.g. 'sda')" $@ SECRETS_DEV=$1 if [ -z "${SECRETS_DEV}" ]; then abort "Aborting due to empty device argument."