From 494008532d80642e52d3d72ed9a7ce0ac3633b56 Mon Sep 17 00:00:00 2001 From: casjay Date: Wed, 4 Sep 2024 12:51:12 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Committing=20everything?= =?UTF-8?q?=20that=20changed=20=F0=9F=97=83=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dockerfile rootfs/root/docker/setup/03-files.sh rootfs/root/docker/setup/04-users.sh --- Dockerfile | 11 ----------- rootfs/root/docker/setup/03-files.sh | 5 +---- rootfs/root/docker/setup/04-users.sh | 22 ++++++++++++++++++++-- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0d8c33d..2a59003 100644 --- a/Dockerfile +++ b/Dockerfile @@ -153,17 +153,6 @@ RUN echo "Custom Settings"; \ RUN echo "Setting up users and scripts "; \ $SHELL_OPTS; \ - if ! grep -s -q "${AUR_HOME}" /etc/passwd;then useradd -m -r -s /bin/bash -d "${AUR_HOME}" "${AUR_USER}";fi; \ - passwd -d "${AUR_USER}"; \ - [ -d "/etc/sudoers.d" ] || mkdir -p "/etc/sudoers.d"; \ - echo ''${AUR_USER}' ALL=(ALL) ALL' >"/etc/sudoers.d/${AUR_USER}" && \ - echo 'standard-resolver' >"${AUR_HOME}/.gnupg/dirmngr.conf" && \ - chown -Rf "${AUR_USER}":"${AUR_USER}" "${AUR_HOME}"; \ - if [ -z "$(command -v yay 2>/dev/null)" ];then cd "${AUR_HOME}/build" && \ - git clone --depth 1 "https://aur.archlinux.org/yay.git" && cd yay && \ - sudo -u "${AUR_USER}" makepkg --noconfirm -si; \ - fi; \ - sudo -u "${AUR_USER}" yay --afterclean --removemake --save && pacman -Qtdq | xargs -r pacman --noconfirm -Rcns; \ if [ -f "/root/docker/setup/04-users.sh" ];then echo "Running the users script";/root/docker/setup/04-users.sh||{ echo "Failed to execute /root/docker/setup/04-users.sh" >&2 && exit 10; };echo "Done running the users script";fi; \ echo "" diff --git a/rootfs/root/docker/setup/03-files.sh b/rootfs/root/docker/setup/03-files.sh index 52929cf..a1e2a0a 100755 --- a/rootfs/root/docker/setup/03-files.sh +++ b/rootfs/root/docker/setup/03-files.sh @@ -24,12 +24,9 @@ set -o pipefail # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set env variables exitCode=0 -AUR_USER="${AUR_USER:-aur}" -AUR_HOME="${AUR_HOME:-/var/lib/aur}" + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Main script -mkdir -p "${AUR_HOME}/build" -mkdir -p "${AUR_HOME}/.gnupg" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set the exit code exitCode=$? diff --git a/rootfs/root/docker/setup/04-users.sh b/rootfs/root/docker/setup/04-users.sh index 7044417..19e4660 100755 --- a/rootfs/root/docker/setup/04-users.sh +++ b/rootfs/root/docker/setup/04-users.sh @@ -24,10 +24,28 @@ set -o pipefail # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set env variables exitCode=0 - +AUR_USER="${AUR_USER:-aur}" +AUR_HOME="${AUR_HOME:-/var/lib/aur}" +AUR_BUILD_DIR="${AUR_BUILD_DIR:-${AUR_HOME}/build}" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Main script - +chmod 777 -f "${AUR_HOME}/build" +if ! grep -s -q "${AUR_HOME}" /etc/passwd; then useradd -m -r -s /bin/bash -d "${AUR_HOME}" "${AUR_USER}" && passwd -d "${AUR_USER}" || exit 1; fi +mkdir -p "${AUR_BUILD_DIR}" +mkdir -p "${AUR_HOME}/.gnupg" +[ -d "/etc/sudoers.d" ] || mkdir -p "/etc/sudoers.d" +echo ''${AUR_USER}' ALL=(ALL) ALL' >"/etc/sudoers.d/${AUR_USER}" && + echo 'standard-resolver' >"${AUR_HOME}/.gnupg/dirmngr.conf" && + chown -Rf "${AUR_USER}":"${AUR_USER}" "${AUR_HOME}" +if [ -z "$(command -v yay 2>/dev/null)" ]; then + if cd "$AUR_BUILD_DIR"; then + [ -n "$(type -P git)" ] && git config --global init.defaultBranch main + git clone --depth 1 "https://aur.archlinux.org/yay" "$AUR_BUILD_DIR/yay" && cd "$AUR_BUILD_DIR/yay" && sudo -u "${AUR_USER}" makepkg --noconfirm -si + else + exit 1 + fi +fi +sudo -u "${AUR_USER}" yay --afterclean --removemake --save && pacman -Qtdq | xargs -r pacman --noconfirm -Rcns # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set the exit code exitCode=$?