mirror of
https://github.com/helm/helm.git
synced 2026-02-20 00:13:02 -05:00
makes sudo an optional dependency in scripts/get
If the execution user is already the root user, this avoids requireing sudo to be installed within the environment. Which might helo in CI environments.
This commit is contained in:
parent
56ed16aeca
commit
f43da7fcfb
1 changed files with 13 additions and 2 deletions
15
scripts/get
15
scripts/get
|
|
@ -46,6 +46,17 @@ initOS() {
|
|||
esac
|
||||
}
|
||||
|
||||
# runs the given command as root (detects if we are root already)
|
||||
runAsRoot() {
|
||||
local CMD="$*"
|
||||
|
||||
if ! whoami | egrep -q '^root$'; then
|
||||
CMD="sudo $*"
|
||||
fi
|
||||
|
||||
$CMD
|
||||
}
|
||||
|
||||
# verifySupported checks that the os/arch combination is supported for
|
||||
# binary builds.
|
||||
verifySupported() {
|
||||
|
|
@ -129,8 +140,8 @@ installFile() {
|
|||
mkdir -p "$HELM_TMP"
|
||||
tar xf "$HELM_TMP_FILE" -C "$HELM_TMP"
|
||||
HELM_TMP_BIN="$HELM_TMP/$OS-$ARCH/$PROJECT_NAME"
|
||||
echo "Preparing to install into ${HELM_INSTALL_DIR} (sudo)"
|
||||
sudo cp "$HELM_TMP_BIN" "$HELM_INSTALL_DIR"
|
||||
echo "Preparing to install into ${HELM_INSTALL_DIR}"
|
||||
runAsRoot cp "$HELM_TMP_BIN" "$HELM_INSTALL_DIR"
|
||||
}
|
||||
|
||||
# fail_trap is executed if an error occurs.
|
||||
|
|
|
|||
Loading…
Reference in a new issue