From c06da82ccdebd4fdd36bbf1a59f8a6266289490f Mon Sep 17 00:00:00 2001 From: Nikola Jokic <97525037+nikola-jokic@users.noreply.github.com> Date: Fri, 11 Feb 2022 15:29:48 +0100 Subject: [PATCH] updated systemd svc.sh to accept custom service file (#1612) * updated systemd svc.sh to accept custom service file * updated systemd and darwin svc templates to accept TEMPLATE_PATH env --- src/Misc/layoutbin/darwin.svc.sh.template | 14 ++++++++++++-- src/Misc/layoutbin/systemd.svc.sh.template | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Misc/layoutbin/darwin.svc.sh.template b/src/Misc/layoutbin/darwin.svc.sh.template index 8d2f96512..8657c9dda 100644 --- a/src/Misc/layoutbin/darwin.svc.sh.template +++ b/src/Misc/layoutbin/darwin.svc.sh.template @@ -17,7 +17,13 @@ RUNNER_ROOT=`pwd` LAUNCH_PATH="${HOME}/Library/LaunchAgents" PLIST_PATH="${LAUNCH_PATH}/${SVC_NAME}.plist" -TEMPLATE_PATH=./bin/actions.runner.plist.template +TEMPLATE_PATH=$GITHUB_ACTIONS_RUNNER_SERVICE_TEMPLATE +IS_CUSTOM_TEMPLATE=0 +if [[ -z $TEMPLATE_PATH ]]; then + TEMPLATE_PATH=./bin/actions.runner.plist.template +else + IS_CUSTOM_TEMPLATE=1 +fi TEMP_PATH=./bin/actions.runner.plist.temp CONFIG_PATH=.service @@ -29,7 +35,11 @@ function failed() } if [ ! -f "${TEMPLATE_PATH}" ]; then - failed "Must run from runner root or install is corrupt" + if [[ $IS_CUSTOM_TEMPLATE = 0 ]]; then + failed "Must run from runner root or install is corrupt" + else + failed "Service file at '$GITHUB_ACTIONS_RUNNER_SERVICE_TEMPLATE' using GITHUB_ACTIONS_RUNNER_SERVICE_TEMPLATE env variable is not found" + fi fi function install() diff --git a/src/Misc/layoutbin/systemd.svc.sh.template b/src/Misc/layoutbin/systemd.svc.sh.template index 4361a1a1e..842985429 100644 --- a/src/Misc/layoutbin/systemd.svc.sh.template +++ b/src/Misc/layoutbin/systemd.svc.sh.template @@ -10,7 +10,13 @@ arg_2=${2} RUNNER_ROOT=`pwd` UNIT_PATH=/etc/systemd/system/${SVC_NAME} -TEMPLATE_PATH=./bin/actions.runner.service.template +TEMPLATE_PATH=$GITHUB_ACTIONS_RUNNER_SERVICE_TEMPLATE +IS_CUSTOM_TEMPLATE=0 +if [[ -z $TEMPLATE_PATH ]]; then + TEMPLATE_PATH=./bin/actions.runner.service.template +else + IS_CUSTOM_TEMPLATE=1 +fi TEMP_PATH=./bin/actions.runner.service.temp CONFIG_PATH=.service @@ -31,7 +37,11 @@ function failed() } if [ ! -f "${TEMPLATE_PATH}" ]; then - failed "Must run from runner root or install is corrupt" + if [[ $IS_CUSTOM_TEMPLATE = 0 ]]; then + failed "Must run from runner root or install is corrupt" + else + failed "Service file at '$GITHUB_ACTIONS_RUNNER_SERVICE_TEMPLATE' using GITHUB_ACTIONS_RUNNER_SERVICE_TEMPLATE env variable is not found" + fi fi #check if we run as root