Skip to content

Commit

Permalink
add ubuntu-24.04 (#133)
Browse files Browse the repository at this point in the history
* add ubuntu-24.04

* Different workaround for default user/group in 24.04 (#137)

---------

Co-authored-by: Bob Vandevliet <info@bvandevliet.nl>
  • Loading branch information
catthehacker and bvandevliet authored Nov 20, 2024
1 parent 5a185c9 commit 844d480
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ env:
IMAGE_LABEL_REPO: ${{ github.repository }}
SLUG: ${{ github.repository_owner }}/ubuntu
DISTRO: ubuntu
NODE: '16 18'
NODE: '16 18 20'
BUILD_REF: ${{ github.sha }}
SKIP_TEST: false
PUSH_GHCR: ${{ github.repository == (github.event.pull_request.head.repo.full_name || github.repository) && '1' || '' }}
Expand All @@ -48,6 +48,7 @@ jobs:
PLATFORMS:
- linux/amd64,linux/arm64,linux/arm/v7
TAG:
- 24.04
- 22.04
- 20.04
steps:
Expand Down Expand Up @@ -235,6 +236,7 @@ jobs:
max-parallel: 8
matrix:
TAG:
- 24.04
- 22.04
- 20.04
TYPE:
Expand Down
27 changes: 19 additions & 8 deletions linux/ubuntu/scripts/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,38 @@

set -Eeuxo pipefail

. /etc/os-release

printf "\n\tπŸ‹ Creating runner users πŸ‹\t\n"

# Default admin user/group
RUNNERADMIN="${RUNNER}admin"

groupadd -g 1001 "${RUNNER}"
groupadd -g 1000 "${RUNNER}admin"
groupadd -g 1000 "${RUNNERADMIN}" || RUNNERADMIN="$(id -gn 1000)" # 24.04 has default user 'ubuntu' with id=1000

useradd -u 1001 -g "${RUNNER}" -G sudo -m -s /bin/bash "${RUNNER}"
useradd -u 1000 -g "${RUNNER}admin" -G sudo -m -s /bin/bash "${RUNNER}admin"
usermod -aG docker "runner"
usermod -aG docker "runneradmin"
useradd -u 1000 -g "${RUNNERADMIN}" -G sudo -m -s /bin/bash "${RUNNERADMIN}" || true

usermod -aG docker "${RUNNER}"
usermod -aG docker "${RUNNERADMIN}"

{
echo "${RUNNER} ALL=(ALL) NOPASSWD: ALL"
echo "${RUNNER}admin ALL=(ALL) NOPASSWD: ALL"
echo "${RUNNERADMIN} ALL=(ALL) NOPASSWD: ALL"
} | tee -a /etc/sudoers

printf "\n\tπŸ‹ Runner user πŸ‹\t\n"
su - "${RUNNER}" -c id

printf "\n\tπŸ‹ Runner admin πŸ‹\t\n"
su - "${RUNNER}admin" -c id
su - "${RUNNERADMIN}" -c id

printf "\n\tπŸ‹ Created non-root user πŸ‹\t\n"
grep "${RUNNER}" /etc/passwd

printf "\n\tπŸ‹ Created non-root admin πŸ‹\t\n"
grep "${RUNNER}admin" /etc/passwd
grep "${RUNNERADMIN}" /etc/passwd

sed -i /etc/environment -e "s/USER=root/USER=${RUNNER}/g"

Expand All @@ -33,6 +43,7 @@ mkdir -p "/home/${RUNNER}/work/_temp"
chown -R "${RUNNER}":"${RUNNER}" "/home/${RUNNER}/work"

mkdir -m 0700 -p "/home/${RUNNER}/.ssh"

{
ssh-keyscan -t rsa github.com
ssh-keyscan -t rsa ssh.dev.azure.com
Expand All @@ -45,6 +56,6 @@ chown -R "${RUNNER}":"${RUNNER}" "/home/${RUNNER}/.ssh"

# Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"?shellcheck(SC2140)
# shellcheck disable=SC2140
chown -R "${RUNNER}":"${RUNNER}admin" "$AGENT_TOOLSDIRECTORY"
chown -R "${RUNNER}":"${RUNNERADMIN}" "$AGENT_TOOLSDIRECTORY"

printf "\n\tπŸ‹ Finished building πŸ‹\t\n"

0 comments on commit 844d480

Please sign in to comment.