Skip to content

Commit

Permalink
Only set environment variables if not already set
Browse files Browse the repository at this point in the history
Currently, the run.sh script will take the environment variables from
rancher-system-agent.env, overwriting any variables that are already
set. This makes changing any environment variables that are in the env
file impossible.

After this change, only the variables that are not set in the
environment are set from the rancher-system-agent.env file.
  • Loading branch information
Donnie Adams committed Sep 24, 2021
1 parent 238ff34 commit 6d7376f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion package/suc/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ fi
export CATTLE_AGENT_BINARY_LOCAL=true
export CATTLE_AGENT_BINARY_LOCAL_LOCATION=${TMPDIR}/rancher-system-agent
if [ -s /host/etc/systemd/system/rancher-system-agent.env ]; then
export $(grep -v '^#' /host/etc/systemd/system/rancher-system-agent.env | xargs)
for line in $(grep -v '^#' /host/etc/systemd/system/rancher-system-agent.env); do
var=${line%%=*}
val=${line##*=}
eval v=\"\$$var\"
if [ -z "$v" ]; then
export "$var=$val"
fi
done
fi
chroot /host ${TMPDIR}/install.sh "$@"

Expand Down

0 comments on commit 6d7376f

Please sign in to comment.