Skip to content

Commit 41d32d7

Browse files
authored
Merge pull request #188 from jakefhyde/45815-sle-micro-6
[45815] sle micro 6
2 parents ae76dcf + a8f6848 commit 41d32d7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

install.sh

+13-3
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ fi
4444
# - CATTLE_AGENT_UNINSTALL_LOCAL (default: false)
4545
# - CATTLE_AGENT_UNINSTALL_LOCAL_LOCATION (default: )
4646
# - CATTLE_AGENT_STRICT_VERIFY | STRICT_VERIFY (default: false)
47+
# - CATTLE_AGENT_FALLBACK_PATH (default: )
4748

4849
FALLBACK=v0.2.9
4950
CACERTS_PATH=cacerts
5051
RETRYCOUNT=4500
5152
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
5254

5355
# info logs the given argument at info log level.
5456
info() {
@@ -73,12 +75,12 @@ fatal() {
7375

7476
# check_target_mountpoint return success if the target directory is on a dedicated mount point
7577
check_target_mountpoint() {
76-
mountpoint -q "${CATTLE_AGENT_BIN_PREFIX}"
78+
mountpoint -q "${DEFAULT_BIN_PREFIX}"
7779
}
7880

7981
# check_target_ro returns success if the target directory is read-only
8082
check_target_ro() {
81-
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
8284
test $? -ne 0
8385
}
8486

@@ -855,6 +857,14 @@ create_env_file() {
855857
echo "$i=$v" | tee -a ${FILE_SA_ENV} >/dev/null
856858
fi
857859
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
858868
}
859869

860870
ensure_applyinator_not_active() {
@@ -887,7 +897,7 @@ do_install() {
887897
if [ -z "${CATTLE_CA_CHECKSUM}" ] && [ $(echo "${CATTLE_AGENT_STRICT_VERIFY}" | tr '[:upper:]' '[:lower:]') = "true" ]; then
888898
fatal "Aborting system-agent installation due to requested strict CA verification with no CA checksum provided"
889899
fi
890-
if [ -n "${CATTLE_CA_CHECKSUM}" && [ $(echo "${CATTLE_AGENT_STRICT_VERIFY}" | tr '[:upper:]' '[:lower:]') != "true" ]; then
900+
if [ -n "${CATTLE_CA_CHECKSUM}" ] && [ $(echo "${CATTLE_AGENT_STRICT_VERIFY}" | tr '[:upper:]' '[:lower:]') != "true" ]; then
891901
validate_ca_required
892902
fi
893903
validate_ca_checksum

0 commit comments

Comments
 (0)