Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 8eea748

Browse files
authored
fix: Update ubuntu example to fix /opt/hostedtoolcache (#2302)
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
1 parent 24bee35 commit 8eea748

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

examples/ubuntu/templates/user-data.sh

+10-11
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y \
1515
build-essential \
1616
unzip
1717

18-
USER_NAME=runners
19-
useradd -m -s /bin/bash $USER_NAME
20-
USER_ID=$(id -ru $USER_NAME)
18+
user_name=ubuntu
19+
user_id=$(id -ru $user_name)
2120

2221
# install and configure cloudwatch logging agent
2322
wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb
@@ -44,27 +43,27 @@ WantedBy=default.target
4443
4544
EOF
4645

47-
echo export XDG_RUNTIME_DIR=/run/user/$USER_ID >>/home/$USER_NAME/.profile
46+
echo export XDG_RUNTIME_DIR=/run/user/$user_id >>/home/$user_name/.profile
4847

4948
systemctl daemon-reload
5049
systemctl enable [email protected]
5150
systemctl start [email protected]
5251

5352
curl -fsSL https://get.docker.com/rootless >>/opt/rootless.sh && chmod 755 /opt/rootless.sh
54-
su -l $USER_NAME -c /opt/rootless.sh
55-
echo export DOCKER_HOST=unix:///run/user/$USER_ID/docker.sock >>/home/$USER_NAME/.profile
56-
echo export PATH=/home/$USER_NAME/bin:$PATH >>/home/$USER_NAME/.profile
53+
su -l $user_name -c /opt/rootless.sh
54+
echo export DOCKER_HOST=unix:///run/user/$user_id/docker.sock >>/home/$user_name/.profile
55+
echo export PATH=/home/$user_name/bin:$PATH >>/home/$user_name/.profile
5756

5857
# Run docker service by default
59-
loginctl enable-linger $USER_NAME
60-
su -l $USER_NAME -c "systemctl --user enable docker"
58+
loginctl enable-linger $user_name
59+
su -l $user_name -c "systemctl --user enable docker"
6160

6261
${install_runner}
6362

6463
# config runner for rootless docker
6564
cd /opt/actions-runner/
66-
echo DOCKER_HOST=unix:///run/user/$USER_ID/docker.sock >>.env
67-
echo PATH=/home/$USER_NAME/bin:$PATH >>.env
65+
echo DOCKER_HOST=unix:///run/user/$user_id/docker.sock >>.env
66+
echo PATH=/home/$user_name/bin:$PATH >>.env
6867

6968
${post_install}
7069

0 commit comments

Comments
 (0)