cbsh/cbsh_arch.sh
2021-12-09 13:33:33 +00:00

159 lines
7.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# ____ ____ ____ _ _
# / ___|| __ )/ ___| | | | |
# | | | _ \\___ \ | |_| |
# | |___ | |_) |___) || _ |
# \____||____/|____/ |_| |_|
#
# NAME: CBSH -- ARCH
# DESC: An installation and deployment script that installs Cabooshy's Desktop on Arch Linux and Arch based Distro's
# WARNING: Run this script at your own risk.
# DEPENDENCIES: dialog
if [ "$(id -u)" = 0 ]; then
echo "#######################################################################"
echo "This script MUST NOT be run as root user since it makes changes to the"
echo "\$HOME directory of the \$USER executing this script. We dont want"
echo "those to be 'root' and '/root',We don't want to mess around in there"
echo "and potentially break something, So run this script as a normal user."
echo "You will be asked for a sudo password when necessary."
echo "######################################################################"
exit 1
fi
err() { \
clear; printf "ERR:\\n%s\\n" "$1" >&2; exit 1;
}
echo "##########################################################################"
echo "###### Syncing the Repos and installing 'dialog' if not installed ######"
echo "########################################################################"
sudo pacman --noconfirm --needed -Syu dialog || error "Error syncing the repos."
welcome () { \
dialog --colors --title "\Z7\ZbInstalling CBSH!" --msgbox "\Z4This Postinstall Script will install my Qtile Desktop as well as Doom Emacs, Zsh with the Starship Prompt, the Kitty Shell and some other essential programs to make my dotfiles and programs work.\\n\\n-Cabooshy" 16 60
dialog --colors --title "\Z7\ZbStay Near your PC!" --yes-label "Continue" --no-label "Exit" --yesno "\Z4This script cannot be run as root, but when needed you will be asked for your sudo password during the installation. This will give PACMAN the necessary permissions to install the software needed. So stay near the computer" 10 60
}
welcome || err "User choose to exit."
addrepos() { \
echo "####################################################"
echo "## Adding the CBSH repository to /etc/pacman.conf ##"
echo "####################################################"
grep -qxF "[cbsh-arch-repo]" /etc/pacman.conf ||
(echo "[cbsh-arch-repo]"; echo "SigLevel = Optional DatabaseOptional"; \
echo "Server = https://gitlab.com/cabooshyy/\$repo/-/raw/main/\$arch") | sudo tee -a /etc/pacman.conf
}
addrepos || err "Error adding the Repo to /etc/pacman.conf."
addkeyservers() { \
echo "#######################################################"
echo "## Adding Keyservers to /etc/pacman.d/gnupg/gpg.conf ##"
echo "#######################################################"
grep -qxF "keyserver.ubuntu.com:80" /etc/pacman.d/gnupg/gpg.conf || echo "keyserver hkp://keyserver.ubuntu.com:80" | sudo tee -a /etc/pacman.d/gnupg/gpg.conf
grep -qxF "keyserver.ubuntu.com:443" /etc/pacman.d/gnupg/gpg.conf || echo "keyserver hkps://keyserver.ubuntu.com:443" | sudo tee -a /etc/pacman.d/gnupg/gpg.conf
}
addkeyservers || err "Error adding the Keyservers to /etc/pacman.d/gnupg/gpg.conf"
recieve_keys() { \
local _pgpkey="94424B71F1A63D9D"
echo "#############################"
echo "## Adding PGP key $_pgpkey ##"
echo "#############################"
sudo pacman-key --recv-key $_pgpkey
sudo pacman-key --lsign-key $_pgpkey
}
recieve_keys || err "Error Recieving PGP key $_pgpkey"
# Let's install all of the packages listed in the pkglist.txt file.
sudo pacman --needed --ask 4 -Syu - < pkglist.txt
# Now that pikaur is installed, we can sync the AUR and install some needed packages (Nerd Fonts) from there.
pikaur -Syu nerd-fonts-source-code-pro nerd-fonts-fira-code pa-applet-git
echo "#########################################################"
echo "## Copying the config files from /etc/cbsh into \$HOME ##"
echo "#########################################################"
[ ! -d /etc/cbsh ] && sudo mkdir /etc/cbsh
[ -d /etc/cbsh ] && mkdir ~/cbsh-backup-$(date +%Y.%m.%d-%H%M) && cp -Rf /etc/cbsh ~/cbsh-backup-$(date +%Y.%m.%d-%H%M)
[ ! -d ~/.config ] && mkdir ~/.config
[ -d ~/.config ] && mkdir ~/.config-backup-$(date +%Y.%m.%d-%H%M) && cp -Rf ~/.config ~/.config-backup-$(date +%Y.%m.%d-%H%M)
cd /etc/cbsh
sudo mv .config/qtile/qtile/* .config/qtile && sudo rm -r .config/qtile/qtile
sudo mv .config/kitty/kitty/* .config/kitty && sudo rm -r .config/kitty/kitty
sudo mv zsh/.zshrc .zshrc && sudo rm -r .config/zsh
cp -Rf . ~ && cd -
echo "#########################################################"
echo "## Installing Doom Emacs. This may take a few minutes. ##"
echo "#########################################################"
[ -d ~/.emacs.d ] && mv ~/.emacs.d ~/.emacs.d.bak.$(date +"%Y%m%d_%H%M%S")
[ -f ~/.emacs ] && mv ~/.emacs ~/.emacs.bak.$(date +"%Y%m%d_%H%M%S")
git clone --depth 1 https://github.com/hlissner/doom-emacs ~/.emacs.d
~/.emacs.d/bin/doom install
~/.emacs.d/bin/doom sync
PS3='Set default USER shell (enter number): '
shells=("fish" "zsh" "bash" "quit")
select choice in "${shells[@]}"; do
case $choice in
fish | bash | zsh)
sudo chsh $USER -s "/bin/$choice" && \
echo -e "$choice has been set as the default USER shell for your account. \
\nLogging out is required for this to take effect."
break
;;
quit)
echo "User quit without changing their shell."
break
;;
*)
echo "invalid option $REPLY"
;;
esac
done
# Disable Current Login Manager, if any.
sudo systemctl disable $(grep '/usr/s\?bin' /etc/systemd/system/display-manager.service | awk -F / '{print $NF}') || echo "Cannot Disable current Display Manager"
# Then enable SDDM as the Login Manager
sudo systemctl enable sddm
echo "###################################"
echo "## Enable sddm as login manager. ##"
echo "###################################"
## Next, Set cbsh-sddm-theme as the default theme for SDDM ##
# System Configuration File
[ -f "/usr/lib/sddm/sddm.conf.d/default.conf" ] && \
sudo cp /usr/lib/sddm/sddm.conf.d/default.conf /usr/lib/sddm/sddm.conf.d/default.conf.backup && \
sudo sed -i 's/^Current=*.*/Current=cbsh-sddm-theme/g' /usr/lib/sddm/sddm.conf.d/default.conf
# Local SDDM Configuration File
[ -f "/etc/sddm.conf" ] && \
sudo cp /etc/sddm.conf /etc/sddm.conf.backup && \
sudo sed -i 's/^Current=*.*/Current=cbsh-sddm-theme/g' /etc/sddm.conf
# Create a local file if it doesnt exist (Mainline Arch Linux doesn't by default)
[ ! -f "/etc/sddm.conf" ] && \
sudo cp /usr/lib/sddm/sddm.conf.d/default.conf /etc/sddm.conf || echo "Default sddm system config file is not found."
# Enable NetworkManager for networking
sudo systemctl enable NetworkManager
echo "###########################################"
echo "## CBSH has been installed successfully! ##"
echo "###########################################"
while true; do
read -p "Do you want to reboot to get into your installation of CBSH? [Y/n]" yn
case $yn in
[Yy]* ) reboot;;
[Nn]* ) break;;
"" ) reboot;;
* ) echo "Please answer yes or no.";;
esac
done