Rework permission handling in scripts
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
@@ -22,6 +22,12 @@ set -eu -o pipefail
|
||||
|
||||
script_dir="$(cd -- "$(dirname -- "$0")" > /dev/null 2>&1; pwd -P)"
|
||||
|
||||
# e2e and Cirrus will fail with "sudo: command not found"
|
||||
SUDO=''
|
||||
if (( $EUID != 0 )); then
|
||||
SUDO='sudo'
|
||||
fi
|
||||
|
||||
function install_runc() {
|
||||
# When updating runc-version, consider updating the runc module in go.mod as well
|
||||
: "${RUNC_VERSION:=$(cat "${script_dir}/runc-version")}"
|
||||
@@ -31,15 +37,15 @@ function install_runc() {
|
||||
pushd "${TMPROOT}"/runc
|
||||
git checkout "${RUNC_VERSION}"
|
||||
make BUILDTAGS='seccomp' runc
|
||||
make install
|
||||
$SUDO make install
|
||||
popd
|
||||
rm -fR "${TMPROOT}"
|
||||
}
|
||||
|
||||
function install_crun() {
|
||||
: "${CRUN_VERSION:=$(cat "${script_dir}/crun-version")}"
|
||||
curl -S -o /usr/local/sbin/runc -L https://github.com/containers/crun/releases/download/"${CRUN_VERSION}"/crun-"${CRUN_VERSION}"-linux-"$(go env GOARCH)"
|
||||
chmod +x /usr/local/sbin/runc
|
||||
$SUDO curl -S -o /usr/local/sbin/runc -L https://github.com/containers/crun/releases/download/"${CRUN_VERSION}"/crun-"${CRUN_VERSION}"-linux-"$(go env GOARCH)"
|
||||
$SUDO chmod +x /usr/local/sbin/runc
|
||||
}
|
||||
|
||||
: "${RUNC_FLAVOR:=runc}"
|
||||
|
Reference in New Issue
Block a user