Skip to content

Commit a8f6848

Browse files
committed
Add CATTLE_AGENT_FALLBACK_PATH
1 parent 355b129 commit a8f6848

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

install.sh

+11-2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ FALLBACK=v0.2.9
5050
CACERTS_PATH=cacerts
5151
RETRYCOUNT=4500
5252
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.
53+
DEFAULT_BIN_PREFIX=/usr/local
5354

5455
# info logs the given argument at info log level.
5556
info() {
@@ -74,12 +75,12 @@ fatal() {
7475

7576
# check_target_mountpoint return success if the target directory is on a dedicated mount point
7677
check_target_mountpoint() {
77-
mountpoint -q "${CATTLE_AGENT_BIN_PREFIX}"
78+
mountpoint -q "${DEFAULT_BIN_PREFIX}"
7879
}
7980

8081
# check_target_ro returns success if the target directory is read-only
8182
check_target_ro() {
82-
touch "${CATTLE_AGENT_BIN_PREFIX}"/.r-sa-ro-test && rm -rf "${CATTLE_AGENT_BIN_PREFIX}"/.r-sa-ro-test
83+
touch "${DEFAULT_BIN_PREFIX}"/.r-sa-ro-test && rm -rf "${DEFAULT_BIN_PREFIX}"/.r-sa-ro-test
8384
test $? -ne 0
8485
}
8586

@@ -856,6 +857,14 @@ create_env_file() {
856857
echo "$i=$v" | tee -a ${FILE_SA_ENV} >/dev/null
857858
fi
858859
done
860+
861+
# if /usr/local/ is ready only or on a separate partition, we want to add the bin dirs of rke2/k3s to our path
862+
if check_target_mountpoint || check_target_ro; then
863+
if [ -n "${CATTLE_AGENT_FALLBACK_PATH}" ]; then
864+
info "${DEFAULT_BIN_PREFIX} is unsuitable for installation: adding fallback path to systemd unit env file."
865+
echo "PATH=${PATH}:${CATTLE_AGENT_FALLBACK_PATH}" | tee -a ${FILE_SA_ENV} >/dev/null
866+
fi
867+
fi
859868
}
860869

861870
ensure_applyinator_not_active() {

0 commit comments

Comments
 (0)