From a8f684813ecd2ff775d4648f3116a27d6bf7e8d2 Mon Sep 17 00:00:00 2001 From: Jake Hyde Date: Wed, 7 Aug 2024 13:33:46 -0400 Subject: [PATCH] Add CATTLE_AGENT_FALLBACK_PATH --- install.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 11ce6802..ef4e3395 100755 --- a/install.sh +++ b/install.sh @@ -50,6 +50,7 @@ FALLBACK=v0.2.9 CACERTS_PATH=cacerts RETRYCOUNT=4500 APPLYINATOR_ACTIVE_WAIT_COUNT=60 # If the system-agent is unhealthy but had created an interlock file to indicate it was actively applying a plan, after 5 minutes, ignore the interlock. +DEFAULT_BIN_PREFIX=/usr/local # info logs the given argument at info log level. info() { @@ -74,12 +75,12 @@ fatal() { # check_target_mountpoint return success if the target directory is on a dedicated mount point check_target_mountpoint() { - mountpoint -q "${CATTLE_AGENT_BIN_PREFIX}" + mountpoint -q "${DEFAULT_BIN_PREFIX}" } # check_target_ro returns success if the target directory is read-only check_target_ro() { - touch "${CATTLE_AGENT_BIN_PREFIX}"/.r-sa-ro-test && rm -rf "${CATTLE_AGENT_BIN_PREFIX}"/.r-sa-ro-test + touch "${DEFAULT_BIN_PREFIX}"/.r-sa-ro-test && rm -rf "${DEFAULT_BIN_PREFIX}"/.r-sa-ro-test test $? -ne 0 } @@ -856,6 +857,14 @@ create_env_file() { echo "$i=$v" | tee -a ${FILE_SA_ENV} >/dev/null fi done + + # if /usr/local/ is ready only or on a separate partition, we want to add the bin dirs of rke2/k3s to our path + if check_target_mountpoint || check_target_ro; then + if [ -n "${CATTLE_AGENT_FALLBACK_PATH}" ]; then + info "${DEFAULT_BIN_PREFIX} is unsuitable for installation: adding fallback path to systemd unit env file." + echo "PATH=${PATH}:${CATTLE_AGENT_FALLBACK_PATH}" | tee -a ${FILE_SA_ENV} >/dev/null + fi + fi } ensure_applyinator_not_active() {