Skip to content

Commit 3a36dbb

Browse files
committed
Add support for a RESTART_STAMP environment variable that allows for restarting K3s based on whether this variable is changed
Signed-off-by: Chris Kim <oats87g@gmail.com>
1 parent a857191 commit 3a36dbb

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

package/run.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,20 @@ cp -f ${CATTLE_AGENT_EXECUTION_PWD}/k3s /usr/local/bin/k3s
66
chmod 755 /usr/local/bin/k3s
77
chown root:root /usr/local/bin/k3s
88

9-
env "INSTALL_K3S_SKIP_DOWNLOAD=true" "INSTALL_K3S_SKIP_SELINUX_RPM=true" "INSTALL_K3S_SELINUX_WARN=true" installer.sh $@
9+
mkdir -p /var/lib/rancher/k3s
10+
11+
RESTART_STAMP_FILE=/var/lib/rancher/k3s/restart_stamp
12+
13+
if [ -f "${RESTART_STAMP_FILE}" ]; then
14+
PRIOR_RESTART_STAMP=$(cat "${RESTART_STAMP_FILE}");
15+
fi
16+
17+
if [ "${PRIOR_RESTART_STAMP}" != "${RESTART_STAMP}" ]; then
18+
FORCE_RESTART=true
19+
else
20+
FORCE_RESTART=false
21+
fi
22+
23+
env "INSTALL_K3S_FORCE_RESTART=${FORCE_RESTART}" "INSTALL_K3S_SKIP_DOWNLOAD=true" "INSTALL_K3S_SKIP_SELINUX_RPM=true" "INSTALL_K3S_SELINUX_WARN=true" installer.sh $@
24+
25+
echo "${RESTART_STAMP}" > "${RESTART_STAMP_FILE}"

0 commit comments

Comments
 (0)