commit 1415df19eb9ea1695c8346e0be6fde166a1e05e9 parent 8bc2a9d0adbdbe5775c28f2a8f6bc0da3294b775 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Tue, 4 Dec 2018 11:05:38 +0100 Call script with sudo if not SU and on Linux Diffstat:
M | links/bin/gitlab-ci | | | 10 | ++++++---- |
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/links/bin/gitlab-ci b/links/bin/gitlab-ci @@ -16,14 +16,16 @@ case "$1" in ;; *) if [ "$(uname)" = "Linux" ]; then - runnercmd="sudo gitlab-runner" - else - runnercmd=gitlab-runner + # Run as sudo if not SU already + if [ $EUID != 0 ]; then + sudo "$0" "$@" + exit $? + fi fi ;; esac for jobname in "$@"; do - eval "$runnercmd" exec docker "$jobname" + gitlab-runner exec docker "$jobname" done