Commit dfb296ad authored by Taylor Thomas's avatar Taylor Thomas Committed by GitHub

Merge pull request #2626 from twolfy/master

[scripts/get] makes sudo an optional dependency
parents 24238bbe 8eace382
...@@ -46,6 +46,17 @@ initOS() { ...@@ -46,6 +46,17 @@ initOS() {
esac esac
} }
# runs the given command as root (detects if we are root already)
runAsRoot() {
local CMD="$*"
if [ $EUID -ne 0 ]; then
CMD="sudo $CMD"
fi
$CMD
}
# verifySupported checks that the os/arch combination is supported for # verifySupported checks that the os/arch combination is supported for
# binary builds. # binary builds.
verifySupported() { verifySupported() {
...@@ -129,8 +140,8 @@ installFile() { ...@@ -129,8 +140,8 @@ installFile() {
mkdir -p "$HELM_TMP" mkdir -p "$HELM_TMP"
tar xf "$HELM_TMP_FILE" -C "$HELM_TMP" tar xf "$HELM_TMP_FILE" -C "$HELM_TMP"
HELM_TMP_BIN="$HELM_TMP/$OS-$ARCH/$PROJECT_NAME" HELM_TMP_BIN="$HELM_TMP/$OS-$ARCH/$PROJECT_NAME"
echo "Preparing to install into ${HELM_INSTALL_DIR} (sudo)" echo "Preparing to install into ${HELM_INSTALL_DIR}"
sudo cp "$HELM_TMP_BIN" "$HELM_INSTALL_DIR" runAsRoot cp "$HELM_TMP_BIN" "$HELM_INSTALL_DIR"
} }
# fail_trap is executed if an error occurs. # fail_trap is executed if an error occurs.
......
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