Skip to content

Commit

Permalink
fix: Update ubuntu example to fix /opt/hostedtoolcache
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MarkArts committed Aug 2, 2022
1 parent 24bee35 commit 479a809
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions examples/ubuntu/templates/user-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}

Expand Down

0 comments on commit 479a809

Please sign in to comment.