diff options
Diffstat (limited to 'static/thesiah.sh')
| -rwxr-xr-x | static/thesiah.sh | 151 |
1 files changed, 107 insertions, 44 deletions
diff --git a/static/thesiah.sh b/static/thesiah.sh index 48b7e2b..3aca943 100755 --- a/static/thesiah.sh +++ b/static/thesiah.sh @@ -7,6 +7,9 @@ ### OPTIONS AND VARIABLES ### dotfilesrepo="https://github.com/TheSiahxyz/.dotfiles.git" +passwordrepo="https://github.com/TheSiahxyz/.password-store.git" +obsidianrepo="https://github.com/TheSiahxyz/Obsidian.git" +webrepo="https://github.com/TheSiahxyz/THESIAH.git" progsfile="https://raw.githubusercontent.com/TheSiahxyz/THESIAH/main/static/progs.csv" aurhelper="yay" repobranch="main" @@ -50,12 +53,19 @@ getuserandpass() { epass1=$(whiptail --nocancel --passwordbox "Enter a password for ecryptfs which will be used to set up an encrypt folder." 10 60 3>&1 1>&2 2>&3 3>&1) epass2=$(whiptail --nocancel --passwordbox "Retype password." 10 60 3>&1 1>&2 2>&3 3>&1) while ! [ "$epass1" = "$epass2" ]; do - unset pass2 + unset epass2 epass1=$(whiptail --nocancel --passwordbox "Passwords do not match.\\n\\nEnter password again." 10 60 3>&1 1>&2 2>&3 3>&1) epass2=$(whiptail --nocancel --passwordbox "Retype password." 10 60 3>&1 1>&2 2>&3 3>&1) done } +repocheck() { + putrepo=$(whiptail --inputbox "Do you want to clone TheSiahxyz's repositories? y/n" 10 60 3>&1 1>&2 2>&3 3>&1) || exit 1 + while [ "$putrepo" != "y" ] && [ "$putrepo" != "n" ]; do + putrepo=$(whiptail --inputbox "Invalid option! Choose 'y' or 'n'.\nDo you want to clone TheSiahxyz's repositories? y/n" 10 60 3>&1 1>&2 2>&3 3>&1) || exit 1 + done +} + usercheck() { ! { id -u "$name" >/dev/null 2>&1; } || whiptail --title "WARNING" --yes-button "CONTINUE" \ @@ -76,7 +86,7 @@ adduserandpass() { # Adds user `$name` with password $pass1. whiptail --infobox "Adding user \"$name\"..." 7 50 useradd -m -g wheel -s /bin/zsh "$name" >/dev/null 2>&1 || - usermod -a -G wheel "$name" && mkdir -p /home/"$name"/{.config.secret,Documents,Downloads,Music,Personal,Pictures,Public,Videos} /home/"$name"/Torrents/{complete,incomplete} /home/"$name"/.local/{bin,share,src,state} /media/{flash,hdd,ssd} /mnt/extra/{backup,videos,win10} && chown "$name":wheel /home/"$name" + usermod -a -G wheel "$name" && mkdir -p /home/"$name"/{.config,.secret,Documents,Downloads,Music,Pictures,Private,Public,Videos} /home/"$name"/Torrents/{complete,incomplete} /home/"$name"/.local/{bin,share,src,state} /media/{flash,hdd,ipdisk,ssd,private} /mnt/extra/{backup,videos,win10} && chown "$name":wheel /home/"$name" export repodir="/home/$name/.local/src" mkdir -p "$repodir" chown -R "$name":wheel "$(dirname "$repodir")" @@ -89,6 +99,7 @@ refreshkeys() { *systemd*) whiptail --infobox "Refreshing Arch Keyring..." 7 40 pacman --noconfirm -S archlinux-keyring >/dev/null 2>&1 + installpkg arch-install-scripts ;; *) whiptail --infobox "Enabling Arch Repositories for more a more extensive software collection..." 7 40 @@ -96,9 +107,12 @@ refreshkeys() { artix-keyring artix-archlinux-support >/dev/null 2>&1 grep -q "^\[extra\]" /etc/pacman.conf || echo "[extra] +Include = /etc/pacman.d/mirrorlist-arch\n +[multilib] Include = /etc/pacman.d/mirrorlist-arch" >>/etc/pacman.conf pacman -Sy --noconfirm >/dev/null 2>&1 pacman-key --populate archlinux >/dev/null 2>&1 + installpkg artools-base ;; esac } @@ -295,19 +309,23 @@ addsudo() { } pamgnupg() { + whiptail --infobox "Setting up pam-gnupg..." 7 50 + $aurhelper -Qq pam-gnupg >/dev/null 2>&1 || aurinstall pam-gnupg echo "auth optional pam_gnupg.so store-only" >>/etc/pam.d/system-login >/dev/null 2>&1 echo "session optional pam_gnupg.so " >>/etc/pam.d/system-login >/dev/null 2>&1 } ecryptfssetup() { - [ -d "/home/$name/.secret" ] && [ -d "/home/$name/Personal" ] || { mkdir -p /home/"$name"/{.secret,Personal} && chown "$name":wheel /home/"$name"/{.secret,Personal} } >/dev/null 2>&1 + whiptail --infobox "Setting up ecryptfs..." 7 50 + [ -x "$(command -v "ecryptfs")" ] || installpkg ecryptfs-utils + [ -d "/home/$name/.secret" ] && [ -d "/home/$name/Private" ] || { mkdir -p /home/"$name"/{.secret,Private} && chown "$name":wheel /home/"$name"/{.secret,Private} } >/dev/null 2>&1 # Ecrypt the folder - printf '\nyes\nyes\n' | mount -t ecryptfs .secret Personal -o ecryptfs_passthrough=n,ecryptfs_enable_filename_crypto=y,passphrase_passwd="$epass1",ecryptfs_cipher=aes,ecryptfs_key_bytes=32 >/dev/null 2>&1 || exit 1 - umount /home/"$name"/Media >/dev/null 2>&1 + printf '\nyes\nyes\n' | mount -t ecryptfs .secret Private -o ecryptfs_passthrough=n,ecryptfs_enable_filename_crypto=y,passphrase_passwd="$epass1",ecryptfs_cipher=aes,ecryptfs_key_bytes=32 >/dev/null 2>&1 || exit 1 + umount /home/"$name"/Private >/dev/null 2>&1 } ufwsetup() { - whiptail --infobox "Setting service ufw..." 7 50 + whiptail --infobox "Setting up ufw..." 7 50 [ -x "$(command -v "ufw")" ] || installpkg ufw pacman -Qq ufw-"$initsys" >/dev/null 2>&1 || install ufw-"$initsys" ufw default deny incoming >/dev/null 2>&1 @@ -343,7 +361,7 @@ ufwsetup() { } sambasetup() { - whiptail --infobox "Setting service samba..." 7 50 + whiptail --infobox "Setting up samba..." 7 50 [ -x "$(command -v "samba")" ] || installpkg samba pacman -Qq samba-"$initsys" >/dev/null 2>&1 || installpkg samba-"$initsys" ufw allow 137/tcp >/dev/null 2>&1 @@ -374,36 +392,16 @@ sambasetup() { esac } -tlpsetup() { - whiptail --infobox "Setting service tlp..." 7 50 - [ -x "$(command -v "tlp")" ] || installpkg tlp - pacman -Qq tlp-"$initsys" >/dev/null 2>&1 || installpkg tlp-"$initsys" - sed -Ei "s/^#(CPU_ENERGY_PERF_POLICY_ON_AC=).*/\1balance_performance/" /etc/tlp.conf >/dev/null 2>&1 - sed -Ei "s/^#(CPU_ENERGY_PERF_POLICY_ON_BAT=).*/\1balance_poewr/" /etc/tlp.conf >/dev/null 2>&1 - sed -Ei "s/^#(START_CHARGE_THRESH_BAT0=).*/\150/" /etc/tlp.conf >/dev/null 2>&1 - sed -Ei "s/^#(STOP_CHARGE_THRESH_BAT0=).*/\175/" /etc/tlp.conf >/dev/null 2>&1 - sed -Ei "s/^#(START_CHARGE_THRESH_BAT1=).*/\150/" /etc/tlp.conf >/dev/null 2>&1 - sed -Ei "s/^#(STOP_CHARGE_THRESH_BAT1=).*/\175/" /etc/tlp.conf >/dev/null 2>&1 - case "$initsys" in - "runit") - ln -s /etc/runit/sv/tlp /run/runit/service/ >/dev/null 2>&1 - sv start tlp >/dev/null 2>&1 - ;; - "openrc") - rc-update add tlp default >/dev/null 2>&1 - rc-service tlp start >/dev/null 2>&1 - ;; - "s6") - ln -s /etc/s6/sv/tlp /run/s6/services/ >/dev/null 2>&1 - s6-svc -u /run/s6/services/tlp >/dev/null 2>&1 - ;; - esac - tlp start >/dev/null 2>&1 +bbswitchsetup() { + whiptail --infobox "Setting up bbswitch..." 7 50 + pacman -Qq bbswitch >/dev/null 2>&1 || installpkg bbswitch + echo "bbswitch" > /etc/modules-load.d/bbswitch.conf >/dev/null 2>&1 + echo "options bbswitch load_state=0 unload_state=1" > /etc/modprobe.d/bbswitch.conf >/dev/null 2>&1 } cronsetup() { - whiptail --infobox "Setting service cronjob..." 7 50 - [ -x "$(command -v "cronie")" ] || installpkg cronie + whiptail --infobox "Setting up cronjob..." 7 50 + pacman -Qq cronie >/dev/null 2>&1 || installpkg cronie pacman -Qq cronie-"$initsys" >/dev/null 2>&1 || installpkg cronie-"$initsys" case "$initsys" in "runit") @@ -421,8 +419,36 @@ cronsetup() { esac } +tlpsetup() { + whiptail --infobox "Setting up tlp..." 7 50 + [ -x "$(command -v "tlp")" ] || installpkg tlp + pacman -Qq tlp-"$initsys" >/dev/null 2>&1 || installpkg tlp-"$initsys" + sed -Ei " + s/^#(PLATFORM_PROFILE_ON_AC=).*/\1performance/g; + s/^#(PLATFORM_PROFILE_ON_BAT=).*/\1balanced/g; + s/^#(START_CHARGE_THRESH_BAT0=).*/\150/g; + s/^#(STOP_CHARGE_THRESH_BAT0=).*/\175/g; + s/^#(START_CHARGE_THRESH_BAT1=).*/\150/g; + s/^#(STOP_CHARGE_THRESH_BAT1=).*/\175/g" >/dev/null 2>&1 + case "$initsys" in + "runit") + ln -s /etc/runit/sv/tlp /run/runit/service/ >/dev/null 2>&1 + sv start tlp >/dev/null 2>&1 + ;; + "openrc") + rc-update add tlp default >/dev/null 2>&1 + rc-service tlp start >/dev/null 2>&1 + ;; + "s6") + ln -s /etc/s6/sv/tlp /run/s6/services/ >/dev/null 2>&1 + s6-svc -u /run/s6/services/tlp >/dev/null 2>&1 + ;; + esac + tlp start >/dev/null 2>&1 +} + vpnsetup() { - whiptail --infobox "Setting service vpn..." 7 50 + whiptail --infobox "Setting up vpn..." 7 50 [ -x "$(command -v "openvpn")" ] || installpkg openvpn pacman -Qq openvpn-"$initsys" >/dev/null 2>&1 || installpkg openvpn-"$initsys" pacman -Qq networkmanager-openvpn >/dev/null 2>&1 || installpkg networkmanager-openvpn @@ -447,6 +473,17 @@ Depends = dash' > /usr/share/libalpm/hooks/relinking-dash.hook ln -sfT dash /usr/bin/sh } +gpusetup() { + gpu_info=$(lspci | grep -E "VGA|Display") + if echo "$gpu_info" | grep -qi "Intel"; then + installpkg xf86-video-intel + installpkg intel-ucode + elif echo "$gpu_info" | grep -qi "AMD"; then + installpkg xf86-video-amdgpu + installpkg amd-ucode + fi +} + finalize() { # Farewell whiptail --title "All done!" \ @@ -467,6 +504,9 @@ welcomemsg || error "User exited." # Get and verify username and password. getuserandpass || error "User exited." +# Decide cloning repositories. +repocheck || error "User exited." + # Give warning if user already exists. usercheck || error "User exited." @@ -608,28 +648,51 @@ pkill -u "$name" librewolf # (like `shutdown` to run without password). addsudo -# Set pam-gnupg +[ ! -f /usr/share/libalpm/hooks/statusbar.hook ] && 'printf [Trigger] +Operation = Upgrade +Type = Package +Target = * + +[Action] +Description = Updating statusbar... +When = PostTransaction +Exec = /usr/bin/pkill -RTMIN+8 dwmblocks' >/usr/share/libalpm/hooks/statusbar.hook + +# Set up pam-gnupg pamgnupg || error "Failed to set up pam-gnupg" -# ecryptfs set up +# Set up ecryptfs ecryptfssetup || error "Failed to set up ecryptfs rules." -# ufw set up +# Set up ufw ufwsetup || error "Failed to set up ufw rules." -# samba set up +# Set up samba sambasetup || error "Failed to set up samba." -# tlp set up -tlpsetup || error "Failed to set up tlp" +# Set up bbswitch +bbswitchsetup || error "Failed to set up bbswitch" -# cronjob set up +# Set up cronjob cronsetup || error "Failed to set up cron" -# vpn set up +# Set up tlp +tlpsetup || error "Failed to set up tlp" + +# Set up vpn vpnsetup || error "Failed to set up vpn" -# dash set up +# Set up gpu +gpusetup || error "Failed to install gpu" + +# Clone TheSiahxyz's repositories +[ "$putrepo" = "y" ] && { + putgitrepo "$passwordrepo" "/home/$name/.local/share" "$repobranch" + putgitrepo "$obsidianrepo" "/home/$name" "$repobranch" + putgitrepo "$webrepo" "/home/$name" "$repobranch" +} + +# Set up dash dashsetup || error "Failed to set up dash" # Last message! Install complete! |
