From e97991ef78ea821681b6d826d069aea94627d296 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 4 Apr 2023 18:24:21 +0200 Subject: [PATCH] do not try to install the runner if it already available --- forgejo-runner.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/forgejo-runner.sh b/forgejo-runner.sh index 16b8236..b52575b 100755 --- a/forgejo-runner.sh +++ b/forgejo-runner.sh @@ -13,18 +13,21 @@ function download() { local runner_repository="$1" local version="$2" - curl -L --fail -sS $runner_repository/releases/download/$version/forgejo-runner-amd64 > /bin/forgejo-runner - chmod 755 /bin/forgejo-runner + if ! which forgejo-runner > /dev/null; then + curl -L --fail -sS $runner_repository/releases/download/$version/forgejo-runner-amd64 > /bin/forgejo-runner + chmod 755 /bin/forgejo-runner + fi } function register() { local forgejo="$1" docker exec --user 1000 forgejo forgejo actions --registration-token-admin > forgejo-runner-token - timeout --signal=KILL 30 forgejo-runner register --no-interactive --instance "$forgejo" --name runner --token $(cat forgejo-runner-token) --labels ubuntu-latest:docker://node:16-buster,self-hosted + timeout --signal=KILL 30 forgejo-runner register --no-interactive --instance "$forgejo" --name runner --token $(cat forgejo-runner-token) --labels ubuntu-latest:docker://node:16-buster,self-hosted } function run() { - daemon --chdir=$(pwd) --unsafe --pidfile=$(pwd)/forgejo-runner-pid --errlog=$(pwd)/forgejo-runner.log --output=$(pwd)/forgejo-runner.log /bin/forgejo-runner daemon + rm -f forgejo-runner.log + daemon --chdir=$(pwd) --unsafe --pidfile=$(pwd)/forgejo-runner-pid --errlog=$(pwd)/forgejo-runner.log --output=$(pwd)/forgejo-runner.log forgejo-runner daemon sleep 1 cat forgejo-runner.log }