From 3f2389b90ed8199f8c7798103fafeef6dd189620 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Fri, 29 Dec 2023 21:07:33 +0000 Subject: Install yay --- gohan.sh | 54 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/gohan.sh b/gohan.sh index 9793155..d60099d 100755 --- a/gohan.sh +++ b/gohan.sh @@ -1,5 +1,7 @@ #!/bin/sh +# GOHAN +# # My Arch Linux installation script # by David T. Sadler # License: GNU GPLv3 @@ -8,6 +10,26 @@ ### FUNCTIONS ### +install_from_pacman() { + pacman --noconfirm --needed -S "$1" >/dev/null 2>&1 +} + +# Install packages required by GOHAN. +install_dependancies() { + install_from_pacman base-devel + install_from_pacman git +} + +add_user() { + get_username_and_password + [ -d "/home/$name" ] && echo "Skipping adding of user as $name already exists." && return + + useradd -m -s /bin/zsh "$name" >/dev/null 2>&1 || mkdir -p /home/"$name" && chown "$name":"$name" /home/"$name" + usermod -aG wheel "$name" + echo "$name:$pass1" | chpasswd + unset pass1 pass2 +} + read_password() { PASSWORD="$( # always read from the tty even when redirected: @@ -61,14 +83,9 @@ get_username_and_password() { done } -add_user() { - get_username_and_password - [ -d "/home/$name" ] && echo "Skipping adding of user as $name already exists" && return - - useradd -m -s /bin/zsh "$name" >/dev/null 2>&1 || mkdir -p /home/"$name" && chown "$name":"$name" /home/"$name" - usermod -aG wheel "$name" - echo "$name:$pass1" | chpasswd - unset pass1 pass2 +# Sets up the home directory for the user account. +setup_user_home_directory() { + clean_user_home_directory } # Remove un-needed files and directories from the home directory. @@ -79,13 +96,28 @@ clean_user_home_directory() { [ -f "/home/$name/.bashrc" ] && rm /home/$name/.bashrc } -# Sets up the home directory for the user account. -setup_user_home_directory() { - clean_user_home_directory + +install_yay() { + [ -f "/usr/bin/yay" ] || ( + echo "Installing yay." + # Use all cores for compilation. + sed -i "s/-j2/-j$(nproc)/;s/^#MAKEFLAGS/MAKEFLAGS/" /etc/makepkg.conf + cd /tmp + rm -rf /tmp/yay + git clone https://aur.archlinux.org/yay.git + cd yay + sudo -u "$name" makepkg --noconfirm -si >/dev/null 2>&1 + cd /tmp + rm -rf /tmp/yay + ); } ### THE ACTUAL SCRIPT ### +install_dependancies + add_user setup_user_home_directory + +install_yay -- cgit v1.2.3-13-gbd6f