-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
4,116 additions
and
1,480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| #!/bin/bash | ||
|
|
||
| user_id=`id -u` | ||
|
|
||
| # we want to snapshot the environment of the config user | ||
| if [ $user_id -eq 0 -a -z "$RUNNER_ALLOW_RUNASROOT" ]; then | ||
| echo "Must not run with sudo" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Check dotnet Core 6.0 dependencies for Linux | ||
| if [[ (`uname` == "Linux") ]] | ||
| then | ||
| command -v ldd > /dev/null | ||
| if [ $? -ne 0 ] | ||
| then | ||
| echo "Can not find 'ldd'. Please install 'ldd' and try again." | ||
| exit 1 | ||
| fi | ||
|
|
||
| message="Execute sudo ./bin/installdependencies.sh to install any missing Dotnet Core 6.0 dependencies." | ||
|
|
||
| ldd ./bin/libcoreclr.so | grep 'not found' | ||
| if [ $? -eq 0 ]; then | ||
| echo "Dependencies is missing for Dotnet Core 6.0" | ||
| echo $message | ||
| exit 1 | ||
| fi | ||
|
|
||
| ldd ./bin/libSystem.Security.Cryptography.Native.OpenSsl.so | grep 'not found' | ||
| if [ $? -eq 0 ]; then | ||
| echo "Dependencies is missing for Dotnet Core 6.0" | ||
| echo $message | ||
| exit 1 | ||
| fi | ||
|
|
||
| ldd ./bin/libSystem.IO.Compression.Native.so | grep 'not found' | ||
| if [ $? -eq 0 ]; then | ||
| echo "Dependencies is missing for Dotnet Core 6.0" | ||
| echo $message | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! [ -x "$(command -v ldconfig)" ]; then | ||
| LDCONFIG_COMMAND="/sbin/ldconfig" | ||
| if ! [ -x "$LDCONFIG_COMMAND" ]; then | ||
| echo "Can not find 'ldconfig' in PATH and '/sbin/ldconfig' doesn't exists either. Please install 'ldconfig' and try again." | ||
| exit 1 | ||
| fi | ||
| else | ||
| LDCONFIG_COMMAND="ldconfig" | ||
| fi | ||
|
|
||
| libpath=${LD_LIBRARY_PATH:-} | ||
| $LDCONFIG_COMMAND -NXv ${libpath//:/ } 2>&1 | grep libicu >/dev/null 2>&1 | ||
| if [ $? -ne 0 ]; then | ||
| echo "Libicu's dependencies is missing for Dotnet Core 6.0" | ||
| echo $message | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| # Change directory to the script root directory | ||
| # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within | ||
| SOURCE="${BASH_SOURCE[0]}" | ||
| while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
| DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
| SOURCE="$(readlink "$SOURCE")" | ||
| [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
| done | ||
| DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
| cd "$DIR" | ||
|
|
||
| source ./env.sh | ||
|
|
||
| shopt -s nocasematch | ||
| if [[ "$1" == "remove" ]]; then | ||
| ./bin/Runner.Listener "$@" | ||
| else | ||
| ./bin/Runner.Listener configure "$@" | ||
| fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #!/bin/bash | ||
|
|
||
| varCheckList=( | ||
| 'LANG' | ||
| 'JAVA_HOME' | ||
| 'ANT_HOME' | ||
| 'M2_HOME' | ||
| 'ANDROID_HOME' | ||
| 'ANDROID_SDK_ROOT' | ||
| 'GRADLE_HOME' | ||
| 'NVM_BIN' | ||
| 'NVM_PATH' | ||
| 'LD_LIBRARY_PATH' | ||
| 'PERL5LIB' | ||
| ) | ||
|
|
||
| envContents="" | ||
|
|
||
| if [ -f ".env" ]; then | ||
| envContents=`cat .env` | ||
| else | ||
| touch .env | ||
| fi | ||
|
|
||
| function writeVar() | ||
| { | ||
| checkVar="$1" | ||
| checkDelim="${1}=" | ||
| if test "${envContents#*$checkDelim}" = "$envContents" | ||
| then | ||
| if [ ! -z "${!checkVar}" ]; then | ||
| echo "${checkVar}=${!checkVar}">>.env | ||
| fi | ||
| fi | ||
| } | ||
|
|
||
| echo $PATH>.path | ||
|
|
||
| for var_name in ${varCheckList[@]} | ||
| do | ||
| writeVar "${var_name}" | ||
| done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| @echo off | ||
| SET UPDATEFILE=update.finished | ||
| "%~dp0\bin\Runner.Listener.exe" run %* | ||
|
|
||
| rem using `if %ERRORLEVEL% EQU N` insterad of `if ERRORLEVEL N` | ||
| rem `if ERRORLEVEL N` means: error level is N or MORE | ||
|
|
||
| if %ERRORLEVEL% EQU 0 ( | ||
| echo "Runner listener exit with 0 return code, stop the service, no retry needed." | ||
| exit /b 0 | ||
| ) | ||
|
|
||
| if %ERRORLEVEL% EQU 1 ( | ||
| echo "Runner listener exit with terminated error, stop the service, no retry needed." | ||
| exit /b 0 | ||
| ) | ||
|
|
||
| if %ERRORLEVEL% EQU 2 ( | ||
| echo "Runner listener exit with retryable error, re-launch runner in 5 seconds." | ||
| ping 127.0.0.1 -n 6 -w 1000 >NUL | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| if %ERRORLEVEL% EQU 3 ( | ||
| rem Wait for 30 seconds or for flag file to exists for the ephemeral runner update process finish | ||
| echo "Runner listener exit because of updating, re-launch runner after successful update" | ||
| FOR /L %%G IN (1,1,30) DO ( | ||
| IF EXIST %UPDATEFILE% ( | ||
| echo "Update finished successfully." | ||
| del %FILE% | ||
| exit /b 1 | ||
| ) | ||
| ping 127.0.0.1 -n 2 -w 1000 >NUL | ||
| ) | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| if %ERRORLEVEL% EQU 4 ( | ||
| rem Wait for 30 seconds or for flag file to exists for the runner update process finish | ||
| echo "Runner listener exit because of updating, re-launch runner after successful update" | ||
| FOR /L %%G IN (1,1,30) DO ( | ||
| IF EXIST %UPDATEFILE% ( | ||
| echo "Update finished successfully." | ||
| del %FILE% | ||
| exit /b 1 | ||
| ) | ||
| ping 127.0.0.1 -n 2 -w 1000 >NUL | ||
| ) | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| echo "Exiting after unknown error code: %ERRORLEVEL%" | ||
| exit /b 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Validate not sudo | ||
| user_id=`id -u` | ||
| if [ $user_id -eq 0 -a -z "$RUNNER_ALLOW_RUNASROOT" ]; then | ||
| echo "Must not run interactively with sudo" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Run | ||
| shopt -s nocasematch | ||
|
|
||
| SOURCE="${BASH_SOURCE[0]}" | ||
| while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
| DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
| SOURCE="$(readlink "$SOURCE")" | ||
| [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
| done | ||
| DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
|
||
| # Wait for docker to start | ||
| if [ ! -z "$RUNNER_WAIT_FOR_DOCKER_IN_SECONDS" ]; then | ||
| if [ "$RUNNER_WAIT_FOR_DOCKER_IN_SECONDS" -gt 0 ]; then | ||
| echo "Waiting for docker to be ready." | ||
| for i in $(seq "$RUNNER_WAIT_FOR_DOCKER_IN_SECONDS"); do | ||
| if docker ps > /dev/null 2>&1; then | ||
| echo "Docker is ready." | ||
| break | ||
| fi | ||
| "$DIR"/safe_sleep.sh 1 | ||
| done | ||
| fi | ||
| fi | ||
|
|
||
| updateFile="update.finished" | ||
| "$DIR"/bin/Runner.Listener run $* | ||
|
|
||
| returnCode=$? | ||
| if [[ $returnCode == 0 ]]; then | ||
| echo "Runner listener exit with 0 return code, stop the service, no retry needed." | ||
| exit 0 | ||
| elif [[ $returnCode == 1 ]]; then | ||
| echo "Runner listener exit with terminated error, stop the service, no retry needed." | ||
| exit 0 | ||
| elif [[ $returnCode == 2 ]]; then | ||
| echo "Runner listener exit with retryable error, re-launch runner in 5 seconds." | ||
| "$DIR"/safe_sleep.sh 5 | ||
| exit 2 | ||
| elif [[ $returnCode == 3 ]]; then | ||
| # Wait for 30 seconds or for flag file to exists for the runner update process finish | ||
| echo "Runner listener exit because of updating, re-launch runner after successful update" | ||
| for i in {0..30}; do | ||
| if test -f "$updateFile"; then | ||
| echo "Update finished successfully." | ||
| rm "$updateFile" | ||
| break | ||
| fi | ||
| "$DIR"/safe_sleep.sh 1 | ||
| done | ||
| exit 2 | ||
| elif [[ $returnCode == 4 ]]; then | ||
| # Wait for 30 seconds or for flag file to exists for the ephemeral runner update process finish | ||
| echo "Runner listener exit because of updating, re-launch runner after successful update" | ||
| for i in {0..30}; do | ||
| if test -f "$updateFile"; then | ||
| echo "Update finished successfully." | ||
| rm "$updateFile" | ||
| break | ||
| fi | ||
| "$DIR"/safe_sleep.sh 1 | ||
| done | ||
| exit 2 | ||
| else | ||
| echo "Exiting with unknown error code: ${returnCode}" | ||
| exit 0 | ||
| fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Validate not sudo | ||
| user_id=`id -u` | ||
| if [ $user_id -eq 0 -a -z "$RUNNER_ALLOW_RUNASROOT" ]; then | ||
| echo "Must not run interactively with sudo" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Run | ||
| shopt -s nocasematch | ||
|
|
||
| SOURCE="${BASH_SOURCE[0]}" | ||
| while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
| DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
| SOURCE="$(readlink "$SOURCE")" | ||
| [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
| done | ||
| DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
|
||
| # Wait for docker to start | ||
| if [ ! -z "$RUNNER_WAIT_FOR_DOCKER_IN_SECONDS" ]; then | ||
| if [ "$RUNNER_WAIT_FOR_DOCKER_IN_SECONDS" -gt 0 ]; then | ||
| echo "Waiting for docker to be ready." | ||
| for i in $(seq "$RUNNER_WAIT_FOR_DOCKER_IN_SECONDS"); do | ||
| if docker ps > /dev/null 2>&1; then | ||
| echo "Docker is ready." | ||
| break | ||
| fi | ||
| "$DIR"/safe_sleep.sh 1 | ||
| done | ||
| fi | ||
| fi | ||
|
|
||
| updateFile="update.finished" | ||
| "$DIR"/bin/Runner.Listener run $* | ||
|
|
||
| returnCode=$? | ||
| if [[ $returnCode == 0 ]]; then | ||
| echo "Runner listener exit with 0 return code, stop the service, no retry needed." | ||
| exit 0 | ||
| elif [[ $returnCode == 1 ]]; then | ||
| echo "Runner listener exit with terminated error, stop the service, no retry needed." | ||
| exit 0 | ||
| elif [[ $returnCode == 2 ]]; then | ||
| echo "Runner listener exit with retryable error, re-launch runner in 5 seconds." | ||
| "$DIR"/safe_sleep.sh 5 | ||
| exit 2 | ||
| elif [[ $returnCode == 3 ]]; then | ||
| # Wait for 30 seconds or for flag file to exists for the runner update process finish | ||
| echo "Runner listener exit because of updating, re-launch runner after successful update" | ||
| for i in {0..30}; do | ||
| if test -f "$updateFile"; then | ||
| echo "Update finished successfully." | ||
| rm "$updateFile" | ||
| break | ||
| fi | ||
| "$DIR"/safe_sleep.sh 1 | ||
| done | ||
| exit 2 | ||
| elif [[ $returnCode == 4 ]]; then | ||
| # Wait for 30 seconds or for flag file to exists for the ephemeral runner update process finish | ||
| echo "Runner listener exit because of updating, re-launch runner after successful update" | ||
| for i in {0..30}; do | ||
| if test -f "$updateFile"; then | ||
| echo "Update finished successfully." | ||
| rm "$updateFile" | ||
| break | ||
| fi | ||
| "$DIR"/safe_sleep.sh 1 | ||
| done | ||
| exit 2 | ||
| else | ||
| echo "Exiting with unknown error code: ${returnCode}" | ||
| exit 0 | ||
| fi |
Oops, something went wrong.