Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add update certificates to ./run.sh if RUNNER_UPDATE_CA_CERTS env is set #2471

Merged
merged 10 commits into from
Mar 8, 2023
27 changes: 27 additions & 0 deletions src/Misc/layoutroot/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,33 @@ runWithManualTrap() {
done
}

function updateCerts() {
local sudo_prefix=""
local user_id=`id -u`

if [ $user_id -ne 0 ]; then
if [[ ! -x "$(command -v sudo)" ]]; then
echo "Warning: failed to update certificate store: sudo is required but not found"
return 1
TingluoHuang marked this conversation as resolved.
Show resolved Hide resolved
else
sudo_prefix="sudo"
fi
fi

if [[ -x "$(command -v update-ca-certificates)" ]]; then
eval $sudo_prefix "update-ca-certificates"
elif [[ -x "$(command -v update-ca-trust)" ]]; then
eval $sudo_prefix "update-ca-trust"
else
echo "Warning: failed to update certificate store: update-ca-certificates or update-ca-trust not found. This can happen if you're using a different runner base image."
return 1
TingluoHuang marked this conversation as resolved.
Show resolved Hide resolved
fi
}

if [[ ! -z "$RUNNER_UPDATE_CA_CERTS" ]]; then
updateCerts
fi

if [[ -z "$RUNNER_MANUALLY_TRAP_SIG" ]]; then
run $*
else
Expand Down