@@ -10,13 +10,15 @@ function buildUserDataScript(githubRegistrationToken, label) {
1010 // to be pre-installed in the AMI, so we simply cd into that directory and then start the runner
1111 userData = [
1212 '#!/bin/bash' ,
13+ 'exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1' ,
1314 `cd "${ config . input . runnerHomeDir } "` ,
1415 'export RUNNER_ALLOW_RUNASROOT=1' ,
1516 `./config.sh --url https://github.com/${ config . githubContext . owner } /${ config . githubContext . repo } --token ${ githubRegistrationToken } --labels ${ label } ` ,
1617 ] ;
1718 } else {
1819 userData = [
1920 '#!/bin/bash' ,
21+ 'exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1' ,
2022 'mkdir actions-runner && cd actions-runner' ,
2123 'case $(uname -m) in aarch64) ARCH="arm64" ;; amd64|x86_64) ARCH="x64" ;; esac && export RUNNER_ARCH=${ARCH}' ,
2224 'curl -O -L https://github.com/actions/runner/releases/download/v2.299.1/actions-runner-linux-${RUNNER_ARCH}-2.299.1.tar.gz' ,
@@ -25,11 +27,14 @@ function buildUserDataScript(githubRegistrationToken, label) {
2527 `./config.sh --url https://github.com/${ config . githubContext . owner } /${ config . githubContext . repo } --token ${ githubRegistrationToken } --labels ${ label } ` ,
2628 ] ;
2729 }
30+ if ( config . input . runAsUser ) {
31+ userData . push ( `chown -R ${ config . input . runAsUser } ${ config . input . runnerHomeDir } ` ) ;
32+ }
2833 if ( config . input . runAsService ) {
29- userData . push ( ' ./svc.sh install' ) ;
34+ userData . push ( ` ./svc.sh install ${ config . input . runAsUser || '' } ` ) ;
3035 userData . push ( './svc.sh start' ) ;
3136 } else {
32- userData . push ( ' ./run.sh' ) ;
37+ userData . push ( ` ${ config . input . runAsUser ? `su ${ config . input . runAsUser } -c` : '' } ./run.sh` ) ;
3338 }
3439 return userData ;
3540}
0 commit comments