From 77008987ab57c0422cf23c6f539ea87554f5d7c8 Mon Sep 17 00:00:00 2001 From: rezzect Date: Wed, 8 May 2024 14:18:11 -0700 Subject: [PATCH] testing dotfiles setup for linux --- linux-setup/setup.sh | 110 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 linux-setup/setup.sh diff --git a/linux-setup/setup.sh b/linux-setup/setup.sh new file mode 100644 index 0000000..c219167 --- /dev/null +++ b/linux-setup/setup.sh @@ -0,0 +1,110 @@ +#!/bin/bash + +mkdir ~/.rezz-dotfiles +mkdir ~/.rezz-dotfiles/zsh +mkdir ~/.rezz-dotfiles/kitty +mkdir ~/.rezz-dotfiles/ssh +mkdir ~/.ssh +mkdir ~/.omp-themes + +cd ~/.rezz-dotfiles +RC='\e[0m' +RED='\e[31m' +YELLOW='\e[33m' +GREEN='\e[32m' + +command_exists() { + command -v $1 >/dev/null 2>&1 +} + +checkEnv() { + ## Check for requirements. + REQUIREMENTS='curl groups sudo' + if ! command_exists ${REQUIREMENTS}; then + echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}" + exit 1 + fi + + ## Check Package Handeler + PACKAGEMANAGER='apt yum dnf pacman zypper' + for pgm in ${PACKAGEMANAGER}; do + if command_exists ${pgm}; then + PACKAGER=${pgm} + echo -e "Using ${pgm}" + fi + done + + if [ -z "${PACKAGER}" ]; then + echo -e "${RED}Can't find a supported package manager" + exit 1 + fi + + ## Check SuperUser Group + SUPERUSERGROUP='wheel sudo root' + for sug in ${SUPERUSERGROUP}; do + if groups | grep ${sug}; then + SUGROUP=${sug} + echo -e "Super user group ${SUGROUP}" + fi + done + + ## Check if member of the sudo group. + if ! groups | grep ${SUGROUP} >/dev/null; then + echo -e "${RED}You need to be a member of the sudo group to run me!" + exit 1 + fi + +} + +curl -o ~/.rezz-dotfiles/zsh/.zshrc https://raw.githubusercontent.com/rezzect/rezz-dotfiles/master/zsh/.zshrc +touch ~/.aliases +curl -o ~/.rezz-dotfiles/ssh/authorized_keys https://raw.githubusercontent.com/rezzect/rezz-dotfiles/master/ssh/authorized_keys +curl -o ~/.rezz-dotfiles/omp-themes/rezztheme-edit.omp.json https://raw.githubusercontent.com/rezzect/rezz-dotfiles/master/omp-themes/rezztheme-edit.omp.json +curl -o ~/.rezz-dotfiles/kitty/kitty.conf https://raw.githubusercontent.com/rezzect/rezz-dotfiles/master/kitty/kitty.conf + +installDepend() { + ## Check for dependencies. + DEPENDENCIES='zsh zoxide trach-cli' + echo -e "${YELLOW}Installing dependencies...${RC}" + if [[ $PACKAGER == "pacman" ]]; then + if ! command_exists yay; then + echo "Installing yay..." + sudo ${PACKAGER} --noconfirm -S base-devel + $(cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R ${USER}:${USER} ./yay-git && cd yay-git && makepkg --noconfirm -si) + else + echo "Command yay already installed" + fi + yay --noconfirm -S ${DEPENDENCIES} + else + sudo ${PACKAGER} install -yq ${DEPENDENCIES} + fi +} + +installOhMyPosh() { + if command_exists oh-my-posh; then + echo "Oh My Posh already installed" + return + fi + + if ! sudo curl -sS https://starship.rs/install.sh | sh; then + echo -e "${RED}Something went wrong during starship install!${RC}" + exit 1 + fi +} + +linkConfig() { + ln -svf ~/.rezz-dotfiles/zsh/.zshrc ~/.zshrc + ln -svf ~/.rezz-dotfiles/omp-themes/rezztheme-edit.omp.json ~/.omp-themes + ln -svf ~/.rezz-dotfiles/kitty/kitty.conf ~/.config/kitty/ + ln -svf ~/.rezz-dotfiles/ssh/authorized_keys ~/.ssh/ +} + +checkEnv +installDepend +installOhMyPosh + +if linkConfig; then + echo -e "${GREEN}Done!\nrestart your shell to see the changes.${RC}" +else + echo -e "${RED}Something went wrong!${RC}" +fi