summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid T. Sadler <davidtsadler@googlemail.com>2023-12-29 21:07:33 +0000
committerDavid T. Sadler <davidtsadler@googlemail.com>2023-12-29 21:07:33 +0000
commit3f2389b90ed8199f8c7798103fafeef6dd189620 (patch)
tree3b061c7f99e1fd466715cc25cd98a52b13311fce
parent74e0098575119410c26ea7a3fe697555df52e932 (diff)
Install yay
-rwxr-xr-xgohan.sh54
1 files 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 <david@davidtsadler.com>
# 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