From 479a8099ee2c24a1916269f0350d8f7d5cff3b89 Mon Sep 17 00:00:00 2001 From: Mark Arts Date: Tue, 2 Aug 2022 10:11:10 +0200 Subject: [PATCH] fix: Update ubuntu example to fix /opt/hostedtoolcache Changing USER_NAME to lower case user_name as that is the variable used by the install_runner.sh script to set the permission for /opt/hostedtoolcache: This also changed the user_name to "ubuntu" to match the `runner_run_as ` as defined in the `runner_run_as` option for the runners module --- examples/ubuntu/templates/user-data.sh | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/examples/ubuntu/templates/user-data.sh b/examples/ubuntu/templates/user-data.sh index fcae68423b..f1c79710f0 100644 --- a/examples/ubuntu/templates/user-data.sh +++ b/examples/ubuntu/templates/user-data.sh @@ -15,9 +15,8 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y \ build-essential \ unzip -USER_NAME=runners -useradd -m -s /bin/bash $USER_NAME -USER_ID=$(id -ru $USER_NAME) +user_name=ubuntu +user_id=$(id -ru $user_name) # install and configure cloudwatch logging agent wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb @@ -44,27 +43,27 @@ WantedBy=default.target EOF -echo export XDG_RUNTIME_DIR=/run/user/$USER_ID >>/home/$USER_NAME/.profile +echo export XDG_RUNTIME_DIR=/run/user/$user_id >>/home/$user_name/.profile systemctl daemon-reload systemctl enable user@UID.service systemctl start user@UID.service curl -fsSL https://get.docker.com/rootless >>/opt/rootless.sh && chmod 755 /opt/rootless.sh -su -l $USER_NAME -c /opt/rootless.sh -echo export DOCKER_HOST=unix:///run/user/$USER_ID/docker.sock >>/home/$USER_NAME/.profile -echo export PATH=/home/$USER_NAME/bin:$PATH >>/home/$USER_NAME/.profile +su -l $user_name -c /opt/rootless.sh +echo export DOCKER_HOST=unix:///run/user/$user_id/docker.sock >>/home/$user_name/.profile +echo export PATH=/home/$user_name/bin:$PATH >>/home/$user_name/.profile # Run docker service by default -loginctl enable-linger $USER_NAME -su -l $USER_NAME -c "systemctl --user enable docker" +loginctl enable-linger $user_name +su -l $user_name -c "systemctl --user enable docker" ${install_runner} # config runner for rootless docker cd /opt/actions-runner/ -echo DOCKER_HOST=unix:///run/user/$USER_ID/docker.sock >>.env -echo PATH=/home/$USER_NAME/bin:$PATH >>.env +echo DOCKER_HOST=unix:///run/user/$user_id/docker.sock >>.env +echo PATH=/home/$user_name/bin:$PATH >>.env ${post_install}