@@ -10,6 +10,7 @@ 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 `echo "${ config . input . preRunnerScript } " > pre-runner-script.sh` ,
1516 'source pre-runner-script.sh' ,
@@ -19,6 +20,7 @@ function buildUserDataScript(githubRegistrationToken, label) {
1920 } else {
2021 userData = [
2122 '#!/bin/bash' ,
23+ 'exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1' ,
2224 'mkdir actions-runner && cd actions-runner' ,
2325 `echo "${ config . input . preRunnerScript } " > pre-runner-script.sh` ,
2426 'source pre-runner-script.sh' ,
@@ -29,11 +31,14 @@ function buildUserDataScript(githubRegistrationToken, label) {
2931 `./config.sh --url https://github.com/${ config . githubContext . owner } /${ config . githubContext . repo } --token ${ githubRegistrationToken } --labels ${ label } ` ,
3032 ] ;
3133 }
34+ if ( config . input . runAsUser ) {
35+ userData . push ( `chown -R ${ config . input . runAsUser } ${ config . input . runnerHomeDir } ` ) ;
36+ }
3237 if ( config . input . runAsService ) {
33- userData . push ( ' ./svc.sh install' ) ;
38+ userData . push ( ` ./svc.sh install ${ config . input . runAsUser || '' } ` ) ;
3439 userData . push ( './svc.sh start' ) ;
3540 } else {
36- userData . push ( ' ./run.sh' ) ;
41+ userData . push ( ` ${ config . input . runAsUser ? `su ${ config . input . runAsUser } -c` : '' } ./run.sh` ) ;
3742 }
3843 return userData ;
3944}
0 commit comments