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=$?