From 61d8adce97860b75bc43f89e5f594f3206693ac6 Mon Sep 17 00:00:00 2001 From: pika Date: Sun, 6 Apr 2025 21:12:25 +0200 Subject: [PATCH] wip --- setup/postinstall.sh | 662 ++++++++++++++++++++++--------------------- 1 file changed, 332 insertions(+), 330 deletions(-) diff --git a/setup/postinstall.sh b/setup/postinstall.sh index 2f45ff8..e79f838 100755 --- a/setup/postinstall.sh +++ b/setup/postinstall.sh @@ -1,355 +1,357 @@ -#!/bin/sh +{ + #!/bin/sh -# ╭──────────────╮ -# │ dependencies │ -# ╰──────────────╯ -deps="7zip bc btop exa fzf gawk gdu git make pv ripgrep rsync stow tmux trash-cli unzip zoxide zsh" + # ╭──────────────╮ + # │ dependencies │ + # ╰──────────────╯ + deps="7zip bc btop exa fzf gawk gdu git make pv ripgrep rsync stow tmux trash-cli unzip zoxide zsh" -# ╭─────────────╮ -# │ ENVIRONMENT │ -# ╰─────────────╯ -# 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' + # ╭─────────────╮ + # │ ENVIRONMENT │ + # ╰─────────────╯ + # 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' -# Initialize storage variables -_STORED_ERRORS="" -_STORED_WARNINGS="" -_STORED_INFOS="" -_STORED_NOTES="" + # Initialize storage variables + _STORED_ERRORS="" + _STORED_WARNINGS="" + _STORED_INFOS="" + _STORED_NOTES="" -# Modified echo functions that store and display messages -echo_error() { - message="${RED}$1${NC}\n" - printf "$message" >&2 - _STORED_ERRORS="${_STORED_ERRORS}${message}" -} + # Modified echo functions that store and display messages + echo_error() { + message="${RED}$1${NC}\n" + printf "$message" >&2 + _STORED_ERRORS="${_STORED_ERRORS}${message}" + } -echo_warning() { - message="${YELLOW}$1${NC}\n" - printf "$message" - _STORED_WARNINGS="${_STORED_WARNINGS}${message}" -} + echo_warning() { + message="${YELLOW}$1${NC}\n" + printf "$message" + _STORED_WARNINGS="${_STORED_WARNINGS}${message}" + } -echo_info() { - message="${CYAN}$1${NC}\n" - printf "$message" - _STORED_INFOS="${_STORED_INFOS}${message}" -} + echo_info() { + message="${CYAN}$1${NC}\n" + printf "$message" + _STORED_INFOS="${_STORED_INFOS}${message}" + } -echo_note() { - message="${LIGHT_GREEN}$1${NC}\n" - printf "$message" - _STORED_NOTES="${_STORED_NOTES}${message}" -} + echo_note() { + message="${LIGHT_GREEN}$1${NC}\n" + printf "$message" + _STORED_NOTES="${_STORED_NOTES}${message}" + } -# ─< Check if the given command exists silently >───────────────────────────────────────── -command_exists() { - command -v "$@" >/dev/null 2>&1 -} + # ─< Check if the given command exists silently >───────────────────────────────────────── + command_exists() { + command -v "$@" >/dev/null 2>&1 + } -# ─────────────────────────────────────< get packager >───────────────────────────────────── -checkPkg() { - pkger="" - for pkg in apt-get dnf pacman apk zypper; do - if command_exists $pkg; then - printf "Using ${RED}${pkg}${NC} method.." - pkger="$pkg" + # ─────────────────────────────────────< get packager >───────────────────────────────────── + checkPkg() { + pkger="" + for pkg in apt-get dnf pacman apk zypper; do + if command_exists $pkg; then + printf "Using ${RED}${pkg}${NC} method.." + pkger="$pkg" - # break - return 0 - fi - done -} - -# ─────────────────────────────────< check for root/sudo >─────────────────────────────── -# checkRoot() { -if [ "$(id -u)" -ne 0 ]; then - if command_exists sudo; then - echo_info "User is not root. Using sudo for privileged operations." - _sudo="sudo -E" - 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 -# } - -# ╭─────╮ -# │ apt │ -# ╰─────╯ -aptCommentCDinSources() { - # Path to sources.list - sources_file="/etc/apt/sources.list" - - # Check if file exists - if [ ! -f "$sources_file" ]; then - echo_error "Error: $sources_file not found" - return 1 - fi - - # Comment out CD-ROM entries using sudo - $_sudo sed -i 's/^[[:space:]]*deb[[:space:]]\+cdrom:/#&/' "$sources_file" - echo_info "CD-ROM entries have been commented out in $sources_file" -} - -aptBase() { - aptCommentCDinSources - echo_info "Updating sources.." - $_sudo apt-get update - - if ! command_exists sudo; then - echo_note "Installing sudo" - apt-get install sudo --assume-yes - fi - - echo_note "Installing base packages: $deps" - - for _deps in $deps; do - if ! command_exists "$_deps"; then - echo_info "Installing $_deps.." - if ! $_sudo apt-get install "$_deps" --assume-yes; then - echo_error "$_deps - failed to install!" + # break + return 0 fi - else - echo_note "$_deps - was already installed!" - fi - done -} + done + } -aptOptimize() { - if command_exists nala; then - echo_info "Nala is already present, fetching mirros now! (This might take a minute or two, depending on your internet speed)" - $_sudo nala fetch --auto --assume-yes --https-only + # ─────────────────────────────────< check for root/sudo >─────────────────────────────── + # checkRoot() { + if [ "$(id -u)" -ne 0 ]; then + if command_exists sudo; then + echo_info "User is not root. Using sudo for privileged operations." + _sudo="sudo -E" + else + echo_error "No sudo found and you're not root! Can't install packages." + return 1 + fi else - echo_note "Nala is not installed on the system, do you want to install it now? (Y/n): " - read -r inst_nala