initial commit
This commit is contained in:
parent
212a05d71a
commit
e1427912f5
80 changed files with 8684 additions and 0 deletions
87
core/tabs/applications-setup/docker-setup.sh
Executable file
87
core/tabs/applications-setup/docker-setup.sh
Executable file
|
@ -0,0 +1,87 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../common-script.sh
|
||||
|
||||
# Function to prompt the user for installation choice
|
||||
choose_installation() {
|
||||
clear
|
||||
printf "%b\n" "${YELLOW}Choose what to install:${RC}"
|
||||
printf "%b\n" "1. ${YELLOW}Docker${RC}"
|
||||
printf "%b\n" "2. ${YELLOW}Docker Compose${RC}"
|
||||
printf "%b\n" "3. ${YELLOW}Both${RC}"
|
||||
printf "%b" "Enter your choice [1-3]: "
|
||||
read -r CHOICE
|
||||
|
||||
case "$CHOICE" in
|
||||
1) INSTALL_DOCKER=1; INSTALL_COMPOSE=0 ;;
|
||||
2) INSTALL_DOCKER=0; INSTALL_COMPOSE=1 ;;
|
||||
3) INSTALL_DOCKER=1; INSTALL_COMPOSE=1 ;;
|
||||
*) printf "%b\n" "${RED}Invalid choice. Exiting.${RC}"; exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
install_docker() {
|
||||
printf "%b\n" "${YELLOW}Installing Docker...${RC}"
|
||||
case "$PACKAGER" in
|
||||
apt-get|nala)
|
||||
curl -fsSL https://get.docker.com | sh
|
||||
;;
|
||||
zypper)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker
|
||||
"$ESCALATION_TOOL" systemctl enable docker
|
||||
"$ESCALATION_TOOL" systemctl start docker
|
||||
;;
|
||||
pacman)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm docker
|
||||
"$ESCALATION_TOOL" systemctl enable docker
|
||||
"$ESCALATION_TOOL" systemctl start docker
|
||||
;;
|
||||
*)
|
||||
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
install_docker_compose() {
|
||||
printf "%b\n" "${YELLOW}Installing Docker Compose...${RC}"
|
||||
case "$PACKAGER" in
|
||||
apt-get|nala)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" install -y docker-compose-plugin
|
||||
;;
|
||||
zypper)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker-compose
|
||||
;;
|
||||
pacman)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm docker-compose
|
||||
;;
|
||||
*)
|
||||
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
install_components() {
|
||||
choose_installation
|
||||
|
||||
if [ "$INSTALL_DOCKER" -eq 1 ]; then
|
||||
if ! command_exists docker; then
|
||||
install_docker
|
||||
else
|
||||
printf "%b\n" "${GREEN}Docker is already installed.${RC}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$INSTALL_COMPOSE" -eq 1 ]; then
|
||||
if ! command_exists docker-compose || ! command_exists docker compose version; then
|
||||
install_docker_compose
|
||||
else
|
||||
printf "%b\n" "${GREEN}Docker Compose is already installed.${RC}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
install_components
|
38
core/tabs/applications-setup/fastfetch-setup.sh
Normal file
38
core/tabs/applications-setup/fastfetch-setup.sh
Normal file
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../common-script.sh
|
||||
|
||||
installFastfetch() {
|
||||
if ! command_exists fastfetch; then
|
||||
printf "%b\n" "${YELLOW}Installing Fastfetch...${RC}"
|
||||
case "$PACKAGER" in
|
||||
pacman)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm fastfetch
|
||||
;;
|
||||
apt-get|nala)
|
||||
curl -sSLo /tmp/fastfetch.deb https://github.com/fastfetch-cli/fastfetch/releases/latest/download/fastfetch-linux-amd64.deb
|
||||
"$ESCALATION_TOOL" "$PACKAGER" install -y /tmp/fastfetch.deb
|
||||
rm /tmp/fastfetch.deb
|
||||
;;
|
||||
*)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" install -y fastfetch
|
||||
;;
|
||||
esac
|
||||
else
|
||||
printf "%b\n" "${GREEN}Fastfetch is already installed.${RC}"
|
||||
fi
|
||||
}
|
||||
|
||||
setupFastfetchConfig() {
|
||||
printf "%b\n" "${YELLOW}Copying Fastfetch config files...${RC}"
|
||||
if [ -d "${HOME}/.config/fastfetch" ] && [ ! -d "${HOME}/.config/fastfetch-bak" ]; then
|
||||
cp -r "${HOME}/.config/fastfetch" "${HOME}/.config/fastfetch-bak"
|
||||
fi
|
||||
mkdir -p "${HOME}/.config/fastfetch/"
|
||||
curl -sSLo "${HOME}/.config/fastfetch/config.jsonc" https://raw.githubusercontent.com/ChrisTitusTech/mybash/main/config.jsonc
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
installFastfetch
|
||||
setupFastfetchConfig
|
42
core/tabs/applications-setup/githubdesktop-setup.sh
Normal file
42
core/tabs/applications-setup/githubdesktop-setup.sh
Normal file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../common-script.sh
|
||||
|
||||
installGithubDesktop() {
|
||||
if ! command_exists github-desktop; then
|
||||
printf "%b\n" "${YELLOW}Installing Github Desktop...${RC}"
|
||||
case "$PACKAGER" in
|
||||
apt-get | nala)
|
||||
curl -fsSL https://apt.packages.shiftkey.dev/gpg.key | gpg --dearmor | "$ESCALATION_TOOL" tee /usr/share/keyrings/shiftkey-packages.gpg >/dev/null
|
||||
printf "%b\n" 'deb [arch=amd64 signed-by=/usr/share/keyrings/shiftkey-packages.gpg] https://apt.packages.shiftkey.dev/ubuntu/ any main\n' | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/shiftkey-packages.list >/dev/null
|
||||
"$ESCALATION_TOOL" "$PACKAGER" update
|
||||
"$ESCALATION_TOOL" "$PACKAGER" install -y github-desktop
|
||||
;;
|
||||
zypper)
|
||||
"$ESCALATION_TOOL" rpm --import https://rpm.packages.shiftkey.dev/gpg.key
|
||||
printf "%b\n" '[shiftkey-packages]\nname=GitHub Desktop\nbaseurl=https://rpm.packages.shiftkey.dev/rpm/\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://rpm.packages.shiftkey.dev/gpg.key\n' | "$ESCALATION_TOOL" tee /etc/zypp/repos.d/shiftkey-packages.repo >/dev/null
|
||||
"$ESCALATION_TOOL" "$PACKAGER" refresh
|
||||
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install github-desktop
|
||||
;;
|
||||
pacman)
|
||||
"$AUR_HELPER" -S --needed --noconfirm github-desktop-bin
|
||||
;;
|
||||
dnf)
|
||||
"$ESCALATION_TOOL" rpm --import https://rpm.packages.shiftkey.dev/gpg.key
|
||||
printf "%b\n" '[shiftkey-packages]\nname=GitHub Desktop\nbaseurl=https://rpm.packages.shiftkey.dev/rpm/\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://rpm.packages.shiftkey.dev/gpg.key\n' | "$ESCALATION_TOOL" tee /etc/yum.repos.d/shiftkey-packages.repo >/dev/null
|
||||
"$ESCALATION_TOOL" "$PACKAGER" install -y github-desktop
|
||||
;;
|
||||
*)
|
||||
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
printf "%b\n" "${GREEN}Github Desktop is already installed.${RC}"
|
||||
fi
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
checkAURHelper
|
||||
installGithubDesktop
|
75
core/tabs/applications-setup/setup-flatpak.sh
Executable file
75
core/tabs/applications-setup/setup-flatpak.sh
Executable file
|
@ -0,0 +1,75 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../common-script.sh
|
||||
|
||||
# Used to detect the desktop environment, Only used for the If statement in the setup_flatpak function.
|
||||
# Perhaps this should be moved to common-script.sh later on?
|
||||
detect_de() {
|
||||
if [ -n "$XDG_CURRENT_DESKTOP" ]; then
|
||||
case "$XDG_CURRENT_DESKTOP" in
|
||||
*GNOME*)
|
||||
DE="GNOME"
|
||||
;;
|
||||
*KDE*)
|
||||
DE="KDE"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
# Install Flatpak if not already installed.
|
||||
setup_flatpak() {
|
||||
if ! command_exists flatpak; then
|
||||
printf "%b\n" "${YELLOW}Installing Flatpak...${RC}"
|
||||
case "$PACKAGER" in
|
||||
pacman)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm flatpak
|
||||
;;
|
||||
*)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" install -y flatpak
|
||||
;;
|
||||
esac
|
||||
printf "%b\n" "Adding Flathub remote..."
|
||||
"$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
|
||||
else
|
||||
if command_exists flatpak; then
|
||||
if ! flatpak remotes | grep -q "flathub"; then
|
||||
printf "%b" "${YELLOW}Detected Flatpak package manager but Flathub remote is not added. Would you like to add it? (y/N): ${RC}"
|
||||
read -r add_remote
|
||||
case "$add_remote" in
|
||||
[Yy]*)
|
||||
printf "%b\n" "Adding Flathub remote..."
|
||||
"$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
|
||||
;;
|
||||
esac
|
||||
else
|
||||
# Needed mostly for systems without a polkit agent running (Error: updating: Unable to connect to system bus)
|
||||
printf "%b\n" "${GREEN}Flathub already setup. You can quit.${RC}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$PACKAGER" = "apt-get" ] || [ "$PACKAGER" = "nala" ]; then
|
||||
detect_de
|
||||
# Only used for Ubuntu GNOME. Ubuntu GNOME doesnt allow flathub to be added as a remote to their store.
|
||||
# So in case the user wants to use a GUI siftware manager they can setup it here
|
||||
if [ "$DE" = "GNOME" ]; then
|
||||
printf "%b" "${YELLOW}Detected GNOME desktop environment. Would you like to install GNOME Software plugin for Flatpak? (y/N): ${RC}"
|
||||
read -r install_gnome
|
||||
if [ "$install_gnome" = "y" ] || [ "$install_gnome" = "Y" ]; then
|
||||
"$ESCALATION_TOOL" "$PACKAGER" install -y gnome-software-plugin-flatpak
|
||||
fi
|
||||
# Useful for Debian KDE spin as well
|
||||
elif [ "$DE" = "KDE" ]; then
|
||||
printf "%b" "${YELLOW}Detected KDE desktop environment. Would you like to install KDE Plasma Discover backend for Flatpak? (y/N): ${RC}"
|
||||
read -r install_kde
|
||||
if [ "$install_kde" = "y" ] || [ "$install_kde" = "Y" ]; then
|
||||
"$ESCALATION_TOOL" "$PACKAGER" install -y plasma-discover-backend-flatpak
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
setup_flatpak
|
38
core/tabs/applications-setup/tab_data.toml
Normal file
38
core/tabs/applications-setup/tab_data.toml
Normal file
|
@ -0,0 +1,38 @@
|
|||
name = "Applications Setup"
|
||||
multi_selectable = false
|
||||
|
||||
[[data]]
|
||||
name = "Fastfetch"
|
||||
description = "Fastfetch is a neofetch-like tool for fetching system information and displaying it prettily.\nIt is written mainly in C, with performance and customizability in mind.\nThis command installs fastfetch and configures from CTT's mybash repository.\nhttps://github.com/ChrisTitusTech/mybash"
|
||||
script = "fastfetch-setup.sh"
|
||||
task_list = "I"
|
||||
|
||||
[[data]]
|
||||
name = "Flatpak / Flathub"
|
||||
description = "Flatpak is a universal application sandbox for Linux that uses isolated packages from Flathub to prevent conflicts and system alterations, while alleviating dependency concerns.\nThis command installs Flatpak and adds the Flathub repository"
|
||||
script = "setup-flatpak.sh"
|
||||
task_list = "I"
|
||||
|
||||
[[data]]
|
||||
name = "github-desktop"
|
||||
description = "GitHub Desktop is a free Git client that allows you to manage your GitHub repositories on your desktop."
|
||||
script = "githubdesktop-setup.sh"
|
||||
task_list = "I"
|
||||
|
||||
[[data]]
|
||||
name = "xmrig"
|
||||
description = "xmrig is a CPU miner for the Monero cryptocurrency."
|
||||
script = "xmrig.sh"
|
||||
task_list = "I"
|
||||
|
||||
[[data]]
|
||||
name = "yazi"
|
||||
description = "yazi is a terminal file manager with a minimal UI and a focus on performance."
|
||||
script = "yazi.sh"
|
||||
task_list = "I"
|
||||
|
||||
[[data]]
|
||||
name = "ytgo"
|
||||
description = "ytgo is a command-line tool for searching and watching YouTube videos from the terminal."
|
||||
script = "ytgo.sh"
|
||||
task_list = "I"
|
185
core/tabs/applications-setup/xmrig.sh
Executable file
185
core/tabs/applications-setup/xmrig.sh
Executable file
|
@ -0,0 +1,185 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# ANSI color codes
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
YELLOW='\033[0;33m'
|
||||
LIGHT_GREEN='\033[0;92m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo_error() {
|
||||
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||
}
|
||||
|
||||
echo_info() {
|
||||
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_warning() {
|
||||
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_note() {
|
||||
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
# Check if the user is root and set sudo variable if necessary
|
||||
check_root() {
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if command_exists sudo; then
|
||||
echo_info "User is not root. Using sudo for privileged operations."
|
||||
_sudo="sudo"
|
||||
else
|
||||
echo_error "No sudo found and you're not root! Can't install packages."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo_info "Root access confirmed."
|
||||
_sudo=""
|
||||
fi
|
||||
}
|
||||
|
||||
# < Distribution detection and installation >
|
||||
get_packager() {
|
||||
if [ -e /etc/os-release ]; then
|
||||
echo_info "Detecting distribution..."
|
||||
. /etc/os-release
|
||||
|
||||
# < Convert $ID and $ID_LIKE to lowercase >
|
||||
ID=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]')
|
||||
ID_LIKE=$(printf "%s" "$ID_LIKE" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
case "$ID" in
|
||||
ubuntu | pop) _install() {
|
||||
$_sudo apt-get install "$@" --assume-yes
|
||||
} ;;
|
||||
debian) _install() {
|
||||
$_sudo apt-get install "$@" --assume-yes
|
||||
} ;;
|
||||
fedora) _install() {
|
||||
$_sudo dnf install "$@" -y
|
||||
} ;;
|
||||
alpine) _install() {
|
||||
$_sudo apk add "$@"
|
||||
} ;;
|
||||
arch | manjaro | garuda | endeavour) _install() {
|
||||
$_sudo pacman -S "$@" --noconfirm
|
||||
} ;;
|
||||
opensuse*) _install() { $_sudo zypper in "$@" -y; } ;;
|
||||
*)
|
||||
if [ "${ID_LIKE#*debian}" != "$ID_LIKE" ]; then
|
||||
_install() { $_sudo apt-get install "$@" --assume-yes; }
|
||||
elif [ "${ID_LIKE#*ubuntu}" != "$ID_LIKE" ]; then
|
||||
_install() { $_sudo apt-get install "$@" --assume-yes; }
|
||||
elif [ "${ID_LIKE#*arch}" != "$ID_LIKE" ]; then
|
||||
_install() { $_sudo pacman -S "$@" --noconfirm; }
|
||||
elif [ "${ID_LIKE#*fedora}" != "$ID_LIKE" ]; then
|
||||
_install() { $_sudo dnf install "$@" -y; }
|
||||
elif [ "${ID_LIKE#*suse}" != "$ID_LIKE" ]; then
|
||||
_install() { $_sudo zypper in "$@" -y; }
|
||||
else
|
||||
echo_error "Unsupported distribution: $ID"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo_error "Unable to detect distribution. /etc/os-release not found."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if a command exists
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Install dependencies
|
||||
_dependencies() {
|
||||
tools="git cmake make"
|
||||
packages="libuv1-dev libssl-dev libhwloc-dev"
|
||||
|
||||
for tool in $tools; do
|
||||
if command_exists "$tool"; then
|
||||
echo_note "$tool is already installed"
|
||||
else
|
||||
echo_info "Installing $tool.."
|
||||
_install "$tool" || echo_error "Failed to install $tool"
|
||||
fi
|
||||
done
|
||||
|
||||
for package in $packages; do
|
||||
echo_info "Installing $package"
|
||||
_install "$package" || echo_error "Failed to install $package"
|
||||
done
|
||||
|
||||
echo_note "Dependency check completed!"
|
||||
}
|
||||
|
||||
# Clone the repository and prepare build directory
|
||||
_git() {
|
||||
xmrig_dir="$HOME/.bin/xmrig"
|
||||
|
||||
if [ -d "$xmrig_dir" ]; then
|
||||
echo_warning "$xmrig_dir already exists. Skipping clone."
|
||||
else
|
||||
echo_info "Cloning xmrig repository to $xmrig_dir"
|
||||
mkdir -p "$HOME/.bin"
|
||||
if ! git clone --depth=1 https://github.com/xmrig/xmrig.git "$xmrig_dir"; then
|
||||
echo_error "Failed to clone xmrig repository."
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
build_dir="$xmrig_dir/build"
|
||||
mkdir -p "$build_dir" || {
|
||||
echo_error "Failed to create build directory: $build_dir"
|
||||
return 1
|
||||
}
|
||||
|
||||
cd "$build_dir" || {
|
||||
echo_error "Failed to navigate to build directory: $build_dir"
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
# Initialize and build the application
|
||||
_appinit() {
|
||||
echo_info "Running cmake .."
|
||||
if ! cmake ..; then
|
||||
echo_error "CMake failed."
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo_info "Running make (this could take a while)"
|
||||
if ! make; then
|
||||
echo_error "Make failed."
|
||||
return 1
|
||||
fi
|
||||
|
||||
$_sudo ln -s ./xmrig /usr/bin/xmrig || "Link of application failed hard! Is not accessible at /usr/bin/xmrig"
|
||||
}
|
||||
|
||||
# Main function
|
||||
main() {
|
||||
if ! check_root; then
|
||||
echo_error "Root check failed. Exiting."
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! get_packager; then
|
||||
echo_error "Failed to detect distribution or set packager."
|
||||
return 1
|
||||
fi
|
||||
|
||||
_dependencies || return 1
|
||||
|
||||
if _git; then
|
||||
_appinit || echo_error "Build initialization failed."
|
||||
else
|
||||
echo_error "Failed during Git operations."
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
135
core/tabs/applications-setup/yazi.sh
Normal file
135
core/tabs/applications-setup/yazi.sh
Normal file
|
@ -0,0 +1,135 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# ─< ANSI color codes >───────────────────────────────────────────────────────────────────
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
YELLOW='\033[0;33m'
|
||||
LIGHT_GREEN='\033[0;92m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo_error() {
|
||||
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||
}
|
||||
|
||||
echo_info() {
|
||||
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_warning() {
|
||||
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_note() {
|
||||
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# ─< Check if the user is root and set sudo variable if necessary >───────────────────────
|
||||
check_root() {
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if command_exists sudo; then
|
||||
echo_info "User is not root. Using sudo for privileged operations."
|
||||
_sudo="sudo"
|
||||
else
|
||||
echo_error "No sudo found and you're not root! Can't install packages."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo_info "Root access confirmed."
|
||||
_sudo=""
|
||||
fi
|
||||
}
|
||||
|
||||
i_cargo() {
|
||||
# if ! command_exists make || ! command_exists gcc; then
|
||||
# echo_error "The script might run into issues, because of make and gcc not being installed. Please install it, and run the script again, if it fails!"
|
||||
# fi
|
||||
|
||||
if command_exists cargo; then
|
||||
echo_info "Installing yazi through cargo"
|
||||
cargo install --locked yazi-fm yazi-cli
|
||||
elif command_exists curl; then
|
||||
echo_note "no cargo found, using curl to install rustup"
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
rustup update
|
||||
echo_info "Installing yazi through cargo"
|
||||
cargo install --locked yazi-fm yazi-cli
|
||||
else
|
||||
echo_warning "neither cargo, nor curl were found. Cannot continue!"
|
||||
fi
|
||||
|
||||
c_yazi
|
||||
}
|
||||
|
||||
i_arch() {
|
||||
$_sudo pacman -S yazi --noconfirm
|
||||
c_yazi
|
||||
}
|
||||
|
||||
i_opensuse() {
|
||||
$_sudo zypper install yazi
|
||||
c_yazi
|
||||
}
|
||||
|
||||
c_yazi() {
|
||||
if [ -e "$HOME/.config/yazi/package.toml" ]; then
|
||||
if command_exists ya; then
|
||||
ya pack -i
|
||||
fi
|
||||
else
|
||||
echo_warning "There was no yazi config found.. "
|
||||
fi
|
||||
}
|
||||
|
||||
# ─< Distribution detection and installation >────────────────────────────────────────
|
||||
get_packager() {
|
||||
if [ -e /etc/os-release ]; then
|
||||
echo_info "Detecting distribution..."
|
||||
. /etc/os-release
|
||||
|
||||
# ─< Convert $ID and $ID_LIKE to lowercase >──────────────────────────────────────────────
|
||||
ID=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]')
|
||||
ID_LIKE=$(printf "%s" "$ID_LIKE" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
case "$ID" in
|
||||
ubuntu | pop) i_cargo ;;
|
||||
debian) i_cargo ;;
|
||||
fedora) i_cargo ;;
|
||||
alpine) i_cargo ;;
|
||||
arch | manjaro | garuda | endeavour) i_arch ;;
|
||||
opensuse*) i_opensuse ;;
|
||||
*)
|
||||
if [ "${ID_LIKE#*debian}" != "$ID_LIKE" ]; then
|
||||
i_cargo
|
||||
elif [ "${ID_LIKE#*ubuntu}" != "$ID_LIKE" ]; then
|
||||
i_cargo
|
||||
elif [ "${ID_LIKE#*arch}" != "$ID_LIKE" ]; then
|
||||
i_arch
|
||||
elif [ "${ID_LIKE#*fedora}" != "$ID_LIKE" ]; then
|
||||
i_cargo
|
||||
elif [ "${ID_LIKE#*suse}" != "$ID_LIKE" ]; then
|
||||
i_opensuse
|
||||
else
|
||||
echo_error "Unsupported distribution: $ID"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo_error "Unable to detect distribution. /etc/os-release not found."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
if check_root; then
|
||||
get_packager
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
153
core/tabs/applications-setup/ytgo.sh
Normal file
153
core/tabs/applications-setup/ytgo.sh
Normal file
|
@ -0,0 +1,153 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# ╭───────────────╮
|
||||
# │ env functions │
|
||||
# ╰───────────────╯
|
||||
# ───────────────────────────────────< ANSI color codes >───────────────────────────────────
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
YELLOW='\033[0;33m'
|
||||
LIGHT_GREEN='\033[0;92m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo_error() {
|
||||
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||
}
|
||||
|
||||
echo_info() {
|
||||
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_warning() {
|
||||
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_note() {
|
||||
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# ─────────────< Check if the user is root and set sudo variable if necessary >─────────────
|
||||
check_root() {
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if command_exists sudo; then
|
||||
echo_info "User is not root. Using sudo for privileged operations."
|
||||
_sudo="sudo"
|
||||
else
|
||||
echo_error "No sudo found and you're not root! Can't install packages."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo_info "Root access confirmed."
|
||||
_sudo=""
|
||||
fi
|
||||
}
|
||||
|
||||
# ──────────────────────< Check if the given command exists silently >──────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# ╭────────────────────────────────────╮
|
||||
# │ insert your scripts/functions here │
|
||||
# ╰────────────────────────────────────╯
|
||||
|
||||
# ─< Distribution detection and installation >────────────────────────────────────────
|
||||
get_packager() {
|
||||
if [ -e /etc/os-release ]; then
|
||||
echo_info "Detecting distribution..."
|
||||
. /etc/os-release
|
||||
|
||||
# ─< Convert $ID and $ID_LIKE to lowercase >──────────────────────────────────────────────
|
||||
ID=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]')
|
||||
ID_LIKE=$(printf "%s" "$ID_LIKE" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
case "$ID" in
|
||||
ubuntu | pop) _install() {
|
||||
$_sudo apt-get install --assume-yes "$@"
|
||||
} ;;
|
||||
debian) _install() {
|
||||
$_sudo apt-get install --assume-yes "$@"
|
||||
} ;;
|
||||
fedora) _install() {
|
||||
$_sudo dnf install -y "$@"
|
||||
} ;;
|
||||
alpine) inst_alpine ;;
|
||||
arch | manjaro | garuda | endeavour) _install() {
|
||||
$_sudo pacman -S --noconfirm "$@"
|
||||
} ;;
|
||||
opensuse*) inst_opensuse ;;
|
||||
*)
|
||||
if [ "${ID_LIKE#*debian}" != "$ID_LIKE" ]; then
|
||||
_install() {
|
||||
$_sudo apt-get install --assume-yes "$@"
|
||||
}
|
||||
elif [ "${ID_LIKE#*ubuntu}" != "$ID_LIKE" ]; then
|
||||
_install() {
|
||||
$_sudo apt-get install --assume-yes "$@"
|
||||
}
|
||||
elif [ "${ID_LIKE#*arch}" != "$ID_LIKE" ]; then
|
||||
_install() {
|
||||
$_sudo pacman -S --noconfirm "$@"
|
||||
}
|
||||
elif [ "${ID_LIKE#*fedora}" != "$ID_LIKE" ]; then
|
||||
_install() {
|
||||
$_sudo dnf install -y "$@"
|
||||
}
|
||||
elif [ "${ID_LIKE#*suse}" != "$ID_LIKE" ]; then
|
||||
inst_opensuse
|
||||
else
|
||||
echo_error "Unsupported distribution: $ID"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo_error "Unable to detect distribution. /etc/os-release not found."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
_dependencies() {
|
||||
get_packager
|
||||
_deps="golang git mpv"
|
||||
|
||||
for dependency in $_deps; do
|
||||
if ! command_exists "$dependency"; then
|
||||
echo_info "Installing $dependency"
|
||||
_install "$dependency" || echo_error "$dependency could not be installed!"
|
||||
else
|
||||
echo_note "$dependency - was already installed."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
_clone() {
|
||||
tmpdir="$(mktemp --dir)"
|
||||
repo="https://git.k4li.de/pika/ytgo.git"
|
||||
|
||||
cd "$tmpdir" || echo_error "$tmpdir is not a valid directory!"
|
||||
git clone --depth=1 "$repo"
|
||||
cd ytgo || echo_error "$tmpdir/ytgo is not a valid directory!"
|
||||
}
|
||||
|
||||
_build() {
|
||||
$_sudo make install
|
||||
}
|
||||
|
||||
# ───────────────────────────────< main function to execute >───────────────────────────────
|
||||
main() {
|
||||
if check_root; then
|
||||
_dependencies || echo_error "dependency function failed hard!"
|
||||
_clone || echo_error "clone function failed hard!"
|
||||
_build || echo_error "build function failed hard!"
|
||||
else
|
||||
echo_error "Something went terribly wrong!"
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
Loading…
Add table
Add a link
Reference in a new issue