mirror of
https://github.com/dockersrc/archlinux
synced 2024-12-03 23:23:12 -05:00
🗃️ Committing everything that changed 🗃️
rootfs/root/docker/setup/04-users.sh
This commit is contained in:
parent
d9611337d4
commit
fe7ae5e735
@ -24,28 +24,41 @@ set -o pipefail
|
|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set env variables
|
# Set env variables
|
||||||
exitCode=0
|
exitCode=0
|
||||||
|
AUR_UID="9000"
|
||||||
AUR_USER="${AUR_USER:-aur}"
|
AUR_USER="${AUR_USER:-aur}"
|
||||||
|
AUR_GROUP="${AUR_GROUP:-$AUR_USER}"
|
||||||
AUR_HOME="${AUR_HOME:-/var/lib/aur}"
|
AUR_HOME="${AUR_HOME:-/var/lib/aur}"
|
||||||
AUR_BUILD_DIR="${AUR_BUILD_DIR:-${AUR_HOME}/build}"
|
AUR_BUILD_DIR="${AUR_BUILD_DIR:-${AUR_HOME}/build}"
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Main script
|
# Main script
|
||||||
chmod 777 -f "${AUR_HOME}/build"
|
if ! grep -sq "^$AUR_GROUP:" /etc/group; then
|
||||||
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
|
echo "Creating group: $AUR_GROUP"
|
||||||
mkdir -p "${AUR_BUILD_DIR}"
|
groupadd -r -g $AUR_UID $AUR_GROUP
|
||||||
mkdir -p "${AUR_HOME}/.gnupg"
|
fi
|
||||||
[ -d "/etc/sudoers.d" ] || mkdir -p "/etc/sudoers.d"
|
if ! grep -sq "^$AUR_USER:" /etc/passwd; then
|
||||||
echo ''${AUR_USER}' ALL=(ALL) ALL' >"/etc/sudoers.d/${AUR_USER}" &&
|
echo "Creating user: $AUR_USER"
|
||||||
echo 'standard-resolver' >"${AUR_HOME}/.gnupg/dirmngr.conf" &&
|
useradd -m -r -s /bin/bash -d "${AUR_HOME}" -u $AUR_UID -g $AUR_UID "$AUR_USER" && passwd -d "$AUR_USER"
|
||||||
chown -Rf "${AUR_USER}":"${AUR_USER}" "${AUR_HOME}"
|
fi
|
||||||
|
grep -sq "^$AUR_USER:" /etc/passwd && grep -sq "^$AUR_GROUP:" /etc/group && chown -Rf $AUR_USER:$AUR_GROUP "$AUR_HOME" || exit 1
|
||||||
|
if [ -n "$(type -P sudo)" ] && grep -sq "^$AUR_USER:" /etc/passwd; then
|
||||||
|
mkdir -p "/etc/sudoers.d"
|
||||||
|
echo ''$AUR_USER' ALL=(ALL) ALL' >"/etc/sudoers.d/$AUR_USER"
|
||||||
|
fi
|
||||||
|
mkdir -p "$AUR_BUILD_DIR/yay"
|
||||||
|
if ! grep -qs "standard-resolver" "$AUR_HOME/.gnupg/dirmngr.conf"; then
|
||||||
|
mkdir -p "$AUR_HOME.gnupg"
|
||||||
|
echo 'standard-resolver' >"$AUR_HOME/.gnupg/dirmngr.conf"
|
||||||
|
fi
|
||||||
if [ -z "$(command -v yay 2>/dev/null)" ]; then
|
if [ -z "$(command -v yay 2>/dev/null)" ]; then
|
||||||
if cd "$AUR_BUILD_DIR"; then
|
if cd "$AUR_BUILD_DIR/yay"; then
|
||||||
[ -n "$(type -P git)" ] && git config --global init.defaultBranch main
|
[ -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
|
chmod -Rf 777 "$AUR_BUILD_DIR"
|
||||||
|
git clone --depth 1 "https://aur.archlinux.org/yay" "." && sudo -u "$AUR_USER" makepkg --noconfirm -si
|
||||||
|
sudo -u "${AUR_USER}" yay --afterclean --removemake --save && pacman -Qtdq | xargs -r pacman --noconfirm -Rcns
|
||||||
else
|
else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
sudo -u "${AUR_USER}" yay --afterclean --removemake --save && pacman -Qtdq | xargs -r pacman --noconfirm -Rcns
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Set the exit code
|
# Set the exit code
|
||||||
exitCode=$?
|
exitCode=$?
|
||||||
|
Loading…
Reference in New Issue
Block a user