Unverified Commit dde2fef0 authored by Reinhard Nägele's avatar Reinhard Nägele Committed by GitHub

Fix K3S_DATA_DIR when running as non-root user (#11378)

When running the generated kill and uninstall scripts, the environment variable `K3S_DATA_DIR` got lost, because `sudo` by default doesn't preserve the environment. This is fixed by adding the `--preserve-env` flag. Signed-off-by: 's avatarReinhard Nägele <unguiculus@gmail.com>
parent 0144d9b7
......@@ -775,7 +775,7 @@ create_killall() {
info "Creating killall script ${KILLALL_K3S_SH}"
$SUDO tee ${KILLALL_K3S_SH} >/dev/null << \EOF
#!/bin/sh
[ $(id -u) -eq 0 ] || exec sudo $0 $@
[ $(id -u) -eq 0 ] || exec sudo --preserve-env=K3S_DATA_DIR $0 $@
K3S_DATA_DIR=${K3S_DATA_DIR:-/var/lib/rancher/k3s}
......@@ -877,7 +877,7 @@ create_uninstall() {
$SUDO tee ${UNINSTALL_K3S_SH} >/dev/null << EOF
#!/bin/sh
set -x
[ \$(id -u) -eq 0 ] || exec sudo \$0 \$@
[ \$(id -u) -eq 0 ] || exec sudo --preserve-env=K3S_DATA_DIR \$0 \$@
K3S_DATA_DIR=\${K3S_DATA_DIR:-/var/lib/rancher/k3s}
......
d75e014f2d2ab5d30a318efa5c326f3b0b7596f194afcff90fa7a7a91166d5f7 install.sh
73ca045f12174c87138d59dd14b23b8ab70d96c9eaead63104109d330daa8a6a install.sh
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment