system update option

This commit is contained in:
Chris Titus 2024-07-12 20:57:34 -05:00
parent 5cd59c5d06
commit 36f04065c0
4 changed files with 439 additions and 7 deletions

View File

@ -0,0 +1,159 @@
#!/bin/bash
RC='\e[0m'
RED='\e[31m'
YELLOW='\e[33m'
GREEN='\e[32m'
# Check if the home directory and linuxtoolbox folder exist, create them if they don't
LINUXTOOLBOXDIR="$HOME/linuxtoolbox"
if [[ ! -d "$LINUXTOOLBOXDIR" ]]; then
echo -e "${YELLOW}Creating linuxtoolbox directory: $LINUXTOOLBOXDIR${RC}"
mkdir -p "$LINUXTOOLBOXDIR"
echo -e "${GREEN}linuxtoolbox directory created: $LINUXTOOLBOXDIR${RC}"
fi
if [[ ! -d "$LINUXTOOLBOXDIR/linux-setup" ]]; then
echo -e "${YELLOW}Cloning linux-setup repository into: $LINUXTOOLBOXDIR/linux-setup${RC}"
git clone https://github.com/ChrisTitusTech/linux-setup "$LINUXTOOLBOXDIR/linux-setup"
if [[ $? -eq 0 ]]; then
echo -e "${GREEN}Successfully cloned linux-setup repository${RC}"
else
echo -e "${RED}Failed to clone linux-setup repository${RC}"
exit 1
fi
fi
cd "$LINUXTOOLBOXDIR/linux-setup" || exit
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 if the current directory is writable.
GITPATH="$(dirname "$(realpath "$0")")"
if [[ ! -w ${GITPATH} ]]; then
echo -e "${RED}Can't write to ${GITPATH}${RC}"
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
}
installDepend() {
## Check for dependencies.
DEPENDENCIES='tar tree multitail tldr trash-cli unzip cmake make jq'
echo -e "${YELLOW}Installing dependencies...${RC}"
case $PACKAGER in
pacman)
if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then
echo "[multilib]" | sudo tee -a /etc/pacman.conf
echo "Include = /etc/pacman.d/mirrorlist" | sudo tee -a /etc/pacman.conf
sudo ${PACKAGER} -Sy
else
echo "Multilib is already enabled."
fi
if ! command_exists yay && ! command_exists paru; then
echo "Installing yay as AUR helper..."
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 "Aur helper already installed"
fi
if command_exists yay; then
AUR_HELPER="yay"
elif command_exists paru; then
AUR_HELPER="paru"
else
echo "No AUR helper found. Please install yay or paru."
exit 1
fi
${AUR_HELPER} --noconfirm -S ${DEPENDENCIES}
;;
apt)
COMPILEDEPS='build-essential'
sudo ${PACKAGER} update
sudo dpkg --add-architecture i386
sudo ${PACKAGER} update
sudo ${PACKAGER} install -y ${DEPENDENCIES} ${COMPILEDEPS}
;;
dnf)
COMPILEDEPS='@development-tools'
sudo ${PACKAGER} update
sudo ${PACKAGER} config-manager --set-enabled powertools
sudo ${PACKAGER} install -y ${DEPENDENCIES} ${COMPILEDEPS}
sudo ${PACKAGER} install -y glibc-devel.i686 libgcc.i686
;;
zypper)
COMPILEDEPS='patterns-devel-base-devel_basis'
sudo ${PACKAGER} refresh
sudo ${PACKAGER} --non-interactive install ${DEPENDENCIES} ${COMPILEDEPS} # non-interactive is the equivalent of -y for opensuse also install could be in (for install)
sudo ${PACKAGER} --non-interactive install libgcc_s1-gcc7-32bit glibc-devel-32bit # non-interactive is the equivalent of -y for opensuse
;;
*)
sudo ${PACKAGER} install -y ${DEPENDENCIES}
;;
esac
}
install_additional_dependencies() {
case $(command -v apt || command -v zypper || command -v dnf || command -v pacman) in
*apt)
;;
*zypper)
;;
*dnf)
;;
*pacman)
;;
*)
;;
esac
}
checkEnv
installDepend
install_additional_dependencies

View File

@ -0,0 +1,141 @@
#!/bin/bash
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-get 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 if the current directory is writable.
GITPATH="$(dirname "$(realpath "$0")")"
if [[ ! -w ${GITPATH} ]]; then
echo -e "${RED}Can't write to ${GITPATH}${RC}"
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
}
installDepend() {
## Check for dependencies.
echo -e "${YELLOW}Installing dependencies...${RC}"
if [[ $PACKAGER == "pacman" ]]; then
if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then
echo "[multilib]" | sudo tee -a /etc/pacman.conf
echo "Include = /etc/pacman.d/mirrorlist" | sudo tee -a /etc/pacman.conf
sudo ${PACKAGER} -Sy
else
echo "Multilib is already enabled."
fi
if ! command_exists yay && ! command_exists paru; then
echo "Installing yay as AUR helper..."
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 "Aur helper already installed"
fi
if command_exists yay; then
AUR_HELPER="yay"
elif command_exists paru; then
AUR_HELPER="paru"
else
echo "No AUR helper found. Please install yay or paru."
exit 1
fi
${AUR_HELPER} --noconfirm -S wine giflib lib32-giflib libpng lib32-libpng libldap lib32-libldap gnutls lib32-gnutls \
mpg123 lib32-mpg123 openal lib32-openal v4l-utils lib32-v4l-utils libpulse lib32-libpulse libgpg-error \
lib32-libgpg-error alsa-plugins lib32-alsa-plugins alsa-lib lib32-alsa-lib libjpeg-turbo lib32-libjpeg-turbo \
sqlite lib32-sqlite libxcomposite lib32-libxcomposite libxinerama lib32-libgcrypt libgcrypt lib32-libxinerama \
ncurses lib32-ncurses ocl-icd lib32-ocl-icd libxslt lib32-libxslt libva lib32-libva gtk3 \
lib32-gtk3 gst-plugins-base-libs lib32-gst-plugins-base-libs vulkan-icd-loader lib32-vulkan-icd-loader
elif [[ $PACKAGER == "apt-get" ]]; then
sudo ${PACKAGER} update
sudo ${PACKAGER} install -y wine64 wine32 libasound2-plugins:i386 libsdl2-2.0-0:i386 libdbus-1-3:i386 libsqlite3-0:i386
elif [[ $PACKAGER == "dnf|zypper" ]]; then
sudo ${PACKAGER} install -y wine
else
sudo ${PACKAGER} install -y ${DEPENDENCIES}
fi
}
install_additional_dependencies() {
case $(command -v apt-get || command -v zypper || command -v dnf || command -v pacman) in
*apt-get)
version=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/lutris/lutris |
grep -v 'beta' |
tail -n1 |
cut -d '/' --fields=3)
version_no_v=$(echo "$version" | tr -d v)
wget "https://github.com/lutris/lutris/releases/download/${version}/lutris_${version_no_v}_all.deb"
# Install the downloaded .deb package using apt-get
echo "Installing lutris_${version_no_v}_all.deb"
sudo apt-get update
sudo apt-get install ./lutris_${version_no_v}_all.deb
# Clean up the downloaded .deb file
rm lutris_${version_no_v}_all.deb
echo "Lutris Installation complete."
echo "Installing steam..."
sudo apt-get install -y steam
;;
*zypper)
;;
*dnf)
;;
*pacman)
;;
*)
;;
esac
}
checkEnv
installDepend
install_additional_dependencies

View File

@ -0,0 +1,132 @@
#!/bin/bash
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-get 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
DTYPE="unknown" # Default to unknown
# Use /etc/os-release for modern distro identification
if [ -f /etc/os-release ]; then
source /etc/os-release
DTYPE=$ID
fi
}
fastUpdate() {
case ${PACKAGER} in
pacman)
if ! command_exists yay && ! command_exists paru; then
echo "Installing yay as AUR helper..."
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 "Aur helper already installed"
fi
if command_exists yay; then
AUR_HELPER="yay"
elif command_exists paru; then
AUR_HELPER="paru"
else
echo "No AUR helper found. Please install yay or paru."
exit 1
fi
${AUR_HELPER} --noconfirm -S rate-mirrors-bin
sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
sudo rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${DTYPE}
;;
apt-get|nala)
sudo apt-get update
sudo apt-get install -y nala
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo nala update
PACKAGER="nala"
sudo ${PACKAGER} upgrade -y
;;
dnf)
;;
zypper)
;;
*)
echo -e "${RED}Unsupported package manager: ${PACKAGER}${RC}"
exit 1
;;
esac
}
updateSystem() {
echo -e "${GREEN}Updating system${RC}"
case ${PACKAGER} in
nala)
sudo ${PACKAGER} update -y
sudo ${PACKAGER} upgrade -y
;;
yum)
sudo ${PACKAGER} update -y
sudo ${PACKAGER} upgrade -y
;;
dnf)
sudo ${PACKAGER} update -y
sudo ${PACKAGER} upgrade -y
;;
pacman)
sudo ${PACKAGER} -Syu --noconfirm
;;
zypper)
sudo ${PACKAGER} refresh
sudo ${PACKAGER} update -y
;;
*)
echo -e "${RED}Unsupported package manager: ${PACKAGER}${RC}"
exit 1
;;
esac
}
checkEnv
fastUpdate
updateSystem

View File

@ -40,8 +40,8 @@ impl CustomList {
command: "bash"
},
ListNode {
name: "Full zsh",
command: "zsh"
name: "Full System Update",
command: "bash -c \"sudo pacman -Syu\""
},
ListNode {
name: "Setup Bash Prompt",
@ -56,16 +56,16 @@ impl CustomList {
// command: include_str!("commands/special_ls.sh"),
// },
ListNode {
name: "Test Category",
name: "System Setup",
command: ""
} => {
ListNode {
name: "sleep, eza, sleep, eza",
command: "sleep 1 && eza -la && sleep 1 && eza -la && echo Bonus eza comming... && sleep 1 && eza -la"
name: "Build Prerequisites",
command: include_str!("commands/system-setup/1-compile-setup.sh"),
},
ListNode {
name: "Just open neovim :), because I can",
command: "nvim"
name: "Gaming Dependencies",
command: include_str!("commands/system-setup/2-gaming-setup.sh"),
},
ListNode {
name: "Recursion?",