diff --git a/core/tabs/applications-setup/Developer-tools/githubdesktop-setup.sh b/core/tabs/applications-setup/Developer-tools/githubdesktop-setup.sh index 966cb914..cf063aa9 100644 --- a/core/tabs/applications-setup/Developer-tools/githubdesktop-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/githubdesktop-setup.sh @@ -6,15 +6,15 @@ 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 + 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 + 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 ;; @@ -23,7 +23,7 @@ installGithubDesktop() { ;; 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 + 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 ;; *) diff --git a/core/tabs/applications-setup/Developer-tools/meld-setup.sh b/core/tabs/applications-setup/Developer-tools/meld-setup.sh index 031a09ae..4cabc3b1 100644 --- a/core/tabs/applications-setup/Developer-tools/meld-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/meld-setup.sh @@ -9,7 +9,7 @@ installMeld() { pacman) "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm meld ;; - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" -y install meld ;; *) @@ -24,4 +24,4 @@ installMeld() { checkEnv checkEscalationTool -installMeld \ No newline at end of file +installMeld diff --git a/core/tabs/applications-setup/Developer-tools/neovim-setup.sh b/core/tabs/applications-setup/Developer-tools/neovim-setup.sh index ac0d2637..c1186a82 100755 --- a/core/tabs/applications-setup/Developer-tools/neovim-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/neovim-setup.sh @@ -15,25 +15,25 @@ cloneNeovim() { installNeovim() { if ! command_exists neovim ripgrep git fzf; then - printf "%b\n" "${YELLOW}Installing Neovim...${RC}" - case "$PACKAGER" in - pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm neovim ripgrep fzf python-virtualenv luarocks go shellcheck git - ;; - apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" install -y ripgrep fd-find python3-venv luarocks golang-go shellcheck git - curl -sSLo /tmp/nvim.appimage https://github.com/neovim/neovim/releases/latest/download/nvim.appimage - chmod u+x /tmp/nvim.appimage - "$ESCALATION_TOOL" mv /tmp/nvim.appimage /usr/local/bin/nvim - ;; - dnf|zypper) - "$ESCALATION_TOOL" "$PACKAGER" install -y neovim ripgrep fzf python3-virtualenv luarocks golang ShellCheck git - ;; - *) - printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" - exit 1 - ;; - esac + printf "%b\n" "${YELLOW}Installing Neovim...${RC}" + case "$PACKAGER" in + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm neovim ripgrep fzf python-virtualenv luarocks go shellcheck git + ;; + apt-get | nala) + "$ESCALATION_TOOL" "$PACKAGER" install -y ripgrep fd-find python3-venv luarocks golang-go shellcheck git + curl -sSLo /tmp/nvim.appimage https://github.com/neovim/neovim/releases/latest/download/nvim.appimage + chmod u+x /tmp/nvim.appimage + "$ESCALATION_TOOL" mv /tmp/nvim.appimage /usr/local/bin/nvim + ;; + dnf | zypper) + "$ESCALATION_TOOL" "$PACKAGER" install -y neovim ripgrep fzf python3-virtualenv luarocks golang ShellCheck git + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + exit 1 + ;; + esac fi } diff --git a/core/tabs/applications-setup/Developer-tools/ngrok-setup.sh b/core/tabs/applications-setup/Developer-tools/ngrok-setup.sh index 1ba6ff66..18c0a774 100644 --- a/core/tabs/applications-setup/Developer-tools/ngrok-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/ngrok-setup.sh @@ -13,4 +13,4 @@ installNgrok() { checkEnv checkEscalationTool -installNgrok \ No newline at end of file +installNgrok diff --git a/core/tabs/applications-setup/Developer-tools/sublime-setup.sh b/core/tabs/applications-setup/Developer-tools/sublime-setup.sh index 16c03497..04f4a40a 100644 --- a/core/tabs/applications-setup/Developer-tools/sublime-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/sublime-setup.sh @@ -6,7 +6,7 @@ installSublime() { if ! command_exists sublime; then printf "%b\n" "${YELLOW}Installing Sublime...${RC}" case "$PACKAGER" in - apt-get|nala) + apt-get | nala) curl -fsSL https://download.sublimetext.com/sublimehq-pub.gpg | "$ESCALATION_TOOL" apt-key add - echo "deb https://download.sublimetext.com/ apt/stable/" | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/sublime-text.list "$ESCALATION_TOOL" "$PACKAGER" update diff --git a/core/tabs/applications-setup/Developer-tools/vscode-setup.sh b/core/tabs/applications-setup/Developer-tools/vscode-setup.sh index 018616a6..e58780b6 100644 --- a/core/tabs/applications-setup/Developer-tools/vscode-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/vscode-setup.sh @@ -6,17 +6,17 @@ installVsCode() { if ! command_exists code; then printf "%b\n" "${YELLOW}Installing VS Code..${RC}." case "$PACKAGER" in - apt-get|nala) - curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg + apt-get | nala) + curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor >packages.microsoft.gpg "$ESCALATION_TOOL" install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg - echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/vscode.list > /dev/null + echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/vscode.list >/dev/null rm -f packages.microsoft.gpg "$ESCALATION_TOOL" "$PACKAGER" update "$ESCALATION_TOOL" "$PACKAGER" install -y apt-transport-https code ;; zypper) "$ESCALATION_TOOL" rpm --import https://packages.microsoft.com/keys/microsoft.asc - printf "%b\n" '[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ntype=rpm-md\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc' | "$ESCALATION_TOOL" tee /etc/zypp/repos.d/vscode.repo > /dev/null + printf "%b\n" '[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ntype=rpm-md\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc' | "$ESCALATION_TOOL" tee /etc/zypp/repos.d/vscode.repo >/dev/null "$ESCALATION_TOOL" "$PACKAGER" refresh "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install code ;; @@ -25,7 +25,7 @@ installVsCode() { ;; dnf) "$ESCALATION_TOOL" rpm --import https://packages.microsoft.com/keys/microsoft.asc - printf "%b\n" '[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc' | "$ESCALATION_TOOL" tee /etc/yum.repos.d/vscode.repo > /dev/null + printf "%b\n" '[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc' | "$ESCALATION_TOOL" tee /etc/yum.repos.d/vscode.repo >/dev/null "$ESCALATION_TOOL" "$PACKAGER" install -y code ;; *) @@ -41,4 +41,4 @@ installVsCode() { checkEnv checkEscalationTool checkAURHelper -installVsCode +installVsCode diff --git a/core/tabs/applications-setup/Developer-tools/vscodium-setup.sh b/core/tabs/applications-setup/Developer-tools/vscodium-setup.sh index 5b5615ca..44ad5760 100644 --- a/core/tabs/applications-setup/Developer-tools/vscodium-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/vscodium-setup.sh @@ -6,7 +6,7 @@ installVsCodium() { if ! command_exists codium; then printf "%b\n" "${YELLOW}Installing VS Codium...${RC}" case "$PACKAGER" in - apt-get|nala) + apt-get | nala) curl -fsSL https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg | gpg --dearmor | "$ESCALATION_TOOL" dd of=/usr/share/keyrings/vscodium-archive-keyring.gpg echo 'deb [ signed-by=/usr/share/keyrings/vscodium-archive-keyring.gpg ] https://download.vscodium.com/debs vscodium main' | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/vscodium.list "$ESCALATION_TOOL" "$PACKAGER" update diff --git a/core/tabs/applications-setup/alacritty-setup.sh b/core/tabs/applications-setup/alacritty-setup.sh index 25558fed..a3bb256d 100755 --- a/core/tabs/applications-setup/alacritty-setup.sh +++ b/core/tabs/applications-setup/alacritty-setup.sh @@ -4,7 +4,7 @@ installAlacritty() { if ! command_exists alacritty; then - printf "%b\n" "${YELLOW}Installing Alacritty...${RC}" + printf "%b\n" "${YELLOW}Installing Alacritty...${RC}" case "$PACKAGER" in pacman) "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm alacritty diff --git a/core/tabs/applications-setup/android-debloat.sh b/core/tabs/applications-setup/android-debloat.sh index b4e1073a..8ad8e423 100644 --- a/core/tabs/applications-setup/android-debloat.sh +++ b/core/tabs/applications-setup/android-debloat.sh @@ -3,20 +3,20 @@ . ../common-script.sh install_adb() { - if ! command_exists adb ; then + if ! command_exists adb; then printf "%b\n" "${YELLOW}Installing ADB...${RC}." case "$PACKAGER" in - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" install -y android-sdk-platform-tools ;; pacman) "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm android-tools ;; - dnf|zypper) + dnf | zypper) "$ESCALATION_TOOL" "$PACKAGER" install -y android-tools ;; *) - printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" + printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}" exit 1 ;; esac @@ -34,9 +34,9 @@ install_universal_android_debloater() { else printf "%b\n" "${GREEN}Universal Android Debloater is already installed. Run 'uad' command to execute.${RC}" fi -} +} checkEnv checkEscalationTool install_adb -install_universal_android_debloater +install_universal_android_debloater diff --git a/core/tabs/applications-setup/bottles-setup.sh b/core/tabs/applications-setup/bottles-setup.sh index 0b29bedb..6795d80a 100755 --- a/core/tabs/applications-setup/bottles-setup.sh +++ b/core/tabs/applications-setup/bottles-setup.sh @@ -14,4 +14,4 @@ installBottles() { checkEnv checkEscalationTool checkFlatpak -installBottles \ No newline at end of file +installBottles diff --git a/core/tabs/applications-setup/browsers/brave.sh b/core/tabs/applications-setup/browsers/brave.sh index 8a7eab40..3f8b5881 100644 --- a/core/tabs/applications-setup/browsers/brave.sh +++ b/core/tabs/applications-setup/browsers/brave.sh @@ -6,7 +6,7 @@ installBrave() { if ! command_exists brave; then printf "%b\n" "${YELLOW}Installing Brave...${RC}" case "$PACKAGER" in - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" install -y curl "$ESCALATION_TOOL" curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main" | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/brave-browser-release.list @@ -42,4 +42,4 @@ installBrave() { checkEnv checkEscalationTool checkAURHelper -installBrave \ No newline at end of file +installBrave diff --git a/core/tabs/applications-setup/browsers/chromium.sh b/core/tabs/applications-setup/browsers/chromium.sh index e929dbc9..30df3467 100644 --- a/core/tabs/applications-setup/browsers/chromium.sh +++ b/core/tabs/applications-setup/browsers/chromium.sh @@ -3,21 +3,21 @@ . ../../common-script.sh installChromium() { -if ! command_exists chromium; then - printf "%b\n" "${YELLOW}Installing Chromium...${RC}" - case "$PACKAGER" in - pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm chromium - ;; - *) - "$ESCALATION_TOOL" "$PACKAGER" install -y chromium - ;; - esac -else - printf "%b\n" "${GREEN}Chromium Browser is already installed.${RC}" -fi + if ! command_exists chromium; then + printf "%b\n" "${YELLOW}Installing Chromium...${RC}" + case "$PACKAGER" in + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm chromium + ;; + *) + "$ESCALATION_TOOL" "$PACKAGER" install -y chromium + ;; + esac + else + printf "%b\n" "${GREEN}Chromium Browser is already installed.${RC}" + fi } checkEnv checkEscalationTool -installChromium \ No newline at end of file +installChromium diff --git a/core/tabs/applications-setup/browsers/firefox.sh b/core/tabs/applications-setup/browsers/firefox.sh index 67980858..70c01a09 100644 --- a/core/tabs/applications-setup/browsers/firefox.sh +++ b/core/tabs/applications-setup/browsers/firefox.sh @@ -6,7 +6,7 @@ installFirefox() { if ! command_exists firefox; then printf "%b\n" "${YELLOW}Installing Mozilla Firefox...${RC}" case "$PACKAGER" in - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" install -y firefox-esr ;; zypper) diff --git a/core/tabs/applications-setup/browsers/google-chrome.sh b/core/tabs/applications-setup/browsers/google-chrome.sh index d66ec9a5..4cd892fc 100644 --- a/core/tabs/applications-setup/browsers/google-chrome.sh +++ b/core/tabs/applications-setup/browsers/google-chrome.sh @@ -6,7 +6,7 @@ installChrome() { if ! command_exists google-chrome; then printf "%b\n" "${YELLOW}Installing Google Chrome...${RC}" case "$PACKAGER" in - apt-get|nala) + apt-get | nala) curl -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb "$ESCALATION_TOOL" "$PACKAGER" install -y ./google-chrome-stable_current_amd64.deb ;; @@ -36,4 +36,4 @@ installChrome() { checkEnv checkEscalationTool checkAURHelper -installChrome \ No newline at end of file +installChrome diff --git a/core/tabs/applications-setup/browsers/librewolf.sh b/core/tabs/applications-setup/browsers/librewolf.sh index a630b9c7..0debf5be 100644 --- a/core/tabs/applications-setup/browsers/librewolf.sh +++ b/core/tabs/applications-setup/browsers/librewolf.sh @@ -6,21 +6,21 @@ installLibreWolf() { if ! command_exists librewolf; then printf "%b\n" "${YELLOW}Installing Librewolf...${RC}" case "$PACKAGER" in - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" install -y gnupg lsb-release apt-transport-https ca-certificates - distro=`if echo " una bookworm vanessa focal jammy bullseye vera uma " | grep -q " $(lsb_release -sc) "; then lsb_release -sc; else echo focal; fi` + distro=$(if echo " una bookworm vanessa focal jammy bullseye vera uma " | grep -q " $(lsb_release -sc) "; then lsb_release -sc; else echo focal; fi) curl -fsSL https://deb.librewolf.net/keyring.gpg | "$ESCALATION_TOOL" gpg --dearmor -o /usr/share/keyrings/librewolf.gpg echo "Types: deb URIs: https://deb.librewolf.net Suites: $distro Components: main Architectures: amd64 -Signed-By: /usr/share/keyrings/librewolf.gpg" | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/librewolf.sources > /dev/null +Signed-By: /usr/share/keyrings/librewolf.gpg" | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/librewolf.sources >/dev/null "$ESCALATION_TOOL" "$PACKAGER" update "$ESCALATION_TOOL" "$PACKAGER" install -y librewolf ;; dnf) - curl -fsSL https://rpm.librewolf.net/librewolf-repo.repo | pkexec tee /etc/yum.repos.d/librewolf.repo > /dev/null + curl -fsSL https://rpm.librewolf.net/librewolf-repo.repo | pkexec tee /etc/yum.repos.d/librewolf.repo >/dev/null "$ESCALATION_TOOL" "$PACKAGER" install -y librewolf ;; zypper) @@ -45,4 +45,4 @@ Signed-By: /usr/share/keyrings/librewolf.gpg" | "$ESCALATION_TOOL" tee /etc/apt/ checkEnv checkEscalationTool checkAURHelper -installLibreWolf \ No newline at end of file +installLibreWolf diff --git a/core/tabs/applications-setup/browsers/lynx.sh b/core/tabs/applications-setup/browsers/lynx.sh index 002ff7e3..404579fe 100644 --- a/core/tabs/applications-setup/browsers/lynx.sh +++ b/core/tabs/applications-setup/browsers/lynx.sh @@ -20,4 +20,4 @@ installLynx() { checkEnv checkEscalationTool -installLynx \ No newline at end of file +installLynx diff --git a/core/tabs/applications-setup/browsers/thorium.sh b/core/tabs/applications-setup/browsers/thorium.sh index c45ebc80..7e240a20 100644 --- a/core/tabs/applications-setup/browsers/thorium.sh +++ b/core/tabs/applications-setup/browsers/thorium.sh @@ -6,13 +6,13 @@ installThrorium() { if ! command_exists thorium-browser; then printf "%b\n" "${YELLOW}Installing Thorium Browser...${RC}" case "$PACKAGER" in - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" rm -fv /etc/apt/sources.list.d/thorium.list "$ESCALATION_TOOL" curl http://dl.thorium.rocks/debian/dists/stable/thorium.list -o /etc/apt/sources.list.d/thorium.list "$ESCALATION_TOOL" "$PACKAGER" update "$ESCALATION_TOOL" "$PACKAGER" install -y thorium-browser ;; - zypper|dnf) + zypper | dnf) url=$(curl -s https://api.github.com/repos/Alex313031/Thorium/releases/latest | grep -oP '(?<=browser_download_url": ")[^"]*\.rpm') echo "$url" && curl -L "$url" -o thorium-latest.rpm "$ESCALATION_TOOL" "$PACKAGER" install -y thorium-latest.rpm && rm thorium-latest.rpm @@ -32,4 +32,4 @@ installThrorium() { checkEnv checkEscalationTool checkAURHelper -installThrorium \ No newline at end of file +installThrorium diff --git a/core/tabs/applications-setup/browsers/vivaldi.sh b/core/tabs/applications-setup/browsers/vivaldi.sh index 311816d0..4f997e2e 100644 --- a/core/tabs/applications-setup/browsers/vivaldi.sh +++ b/core/tabs/applications-setup/browsers/vivaldi.sh @@ -6,7 +6,7 @@ installVivaldi() { if ! command_exists vivaldi; then printf "%b\n" "${YELLOW}Installing Vivaldi...${RC}" case "$PACKAGER" in - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" install -y curl "$ESCALATION_TOOL" curl -fsSL https://repo.vivaldi.com/archive/linux_signing_key.pub | gpg --dearmor | sudo dd of=/usr/share/keyrings/vivaldi-browser.gpg "$ESCALATION_TOOL" echo "deb [signed-by=/usr/share/keyrings/vivaldi-browser.gpg arch=$(dpkg --print-architecture)] https://repo.vivaldi.com/archive/deb/ stable main" | sudo dd of=/etc/apt/sources.list.d/vivaldi-archive.list diff --git a/core/tabs/applications-setup/browsers/waterfox.sh b/core/tabs/applications-setup/browsers/waterfox.sh index 3cef5106..eb6164e3 100644 --- a/core/tabs/applications-setup/browsers/waterfox.sh +++ b/core/tabs/applications-setup/browsers/waterfox.sh @@ -7,10 +7,10 @@ installWaterfox() { printf "%b\n" "${YELLOW}Installing waterfox...${RC}" case "$PACKAGER" in pacman) - "$AUR_HELPER" -S --needed --noconfirm waterfox-bin + "$AUR_HELPER" -S --needed --noconfirm waterfox-bin ;; *) - . ../setup-flatpak.sh + . ../setup-flatpak.sh flatpak install -y flathub net.waterfox.waterfox ;; esac diff --git a/core/tabs/applications-setup/communication-apps/discord-setup.sh b/core/tabs/applications-setup/communication-apps/discord-setup.sh index 6c7a0a83..c450a445 100644 --- a/core/tabs/applications-setup/communication-apps/discord-setup.sh +++ b/core/tabs/applications-setup/communication-apps/discord-setup.sh @@ -6,7 +6,7 @@ installDiscord() { if ! command_exists discord; then printf "%b\n" "${YELLOW}Installing Discord...${RC}" case "$PACKAGER" in - apt-get|nala) + apt-get | nala) curl -Lo discord.deb "https://discord.com/api/download?platform=linux&format=deb" "$ESCALATION_TOOL" "$PACKAGER" install -y discord.deb ;; @@ -14,14 +14,14 @@ installDiscord() { "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install discord ;; pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm discord + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm discord ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm + "$ESCALATION_TOOL" "$PACKAGER" install -y https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm "$ESCALATION_TOOL" "$PACKAGER" install -y discord ;; *) - printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}" exit 1 ;; esac @@ -32,4 +32,4 @@ installDiscord() { checkEnv checkEscalationTool -installDiscord \ No newline at end of file +installDiscord diff --git a/core/tabs/applications-setup/communication-apps/jitsi-setup.sh b/core/tabs/applications-setup/communication-apps/jitsi-setup.sh index 2b6b4bbe..9518566b 100644 --- a/core/tabs/applications-setup/communication-apps/jitsi-setup.sh +++ b/core/tabs/applications-setup/communication-apps/jitsi-setup.sh @@ -6,9 +6,9 @@ installJitsi() { if ! command_exists jitsi-meet; then printf "%b\n" "${YELLOW}Installing Jitsi meet...${RC}" case "$PACKAGER" in - apt-get|nala) - curl https://download.jitsi.org/jitsi-key.gpg.key | "$ESCALATION_TOOL" gpg --dearmor > /usr/share/keyrings/jitsi-keyring.gpg - printf "%b\n" 'deb [signed-by=/usr/share/keyrings/jitsi-keyring.gpg] https://download.jitsi.org stable/' | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/jitsi-stable.list > /dev/null + apt-get | nala) + curl https://download.jitsi.org/jitsi-key.gpg.key | "$ESCALATION_TOOL" gpg --dearmor >/usr/share/keyrings/jitsi-keyring.gpg + printf "%b\n" 'deb [signed-by=/usr/share/keyrings/jitsi-keyring.gpg] https://download.jitsi.org stable/' | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/jitsi-stable.list >/dev/null "$ESCALATION_TOOL" "$PACKAGER" update "$ESCALATION_TOOL" "$PACKAGER" -y install jitsi-meet ;; @@ -34,4 +34,4 @@ installJitsi() { checkEnv checkEscalationTool checkAURHelper -installJitsi \ No newline at end of file +installJitsi diff --git a/core/tabs/applications-setup/communication-apps/signal-setup.sh b/core/tabs/applications-setup/communication-apps/signal-setup.sh index cdd71b55..0768e016 100644 --- a/core/tabs/applications-setup/communication-apps/signal-setup.sh +++ b/core/tabs/applications-setup/communication-apps/signal-setup.sh @@ -6,9 +6,8 @@ installSignal() { if ! command_exists org.signal.Signal && ! command_exists signal; then printf "%b\n" "${YELLOW}Installing Signal...${RC}" case "$PACKAGER" in - apt-get|nala) - curl -fsSL https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor > signal-desktop-keyring.gpg - cat signal-desktop-keyring.gpg | "$ESCALATION_TOOL" tee /usr/share/keyrings/signal-desktop-keyring.gpg > /dev/null + apt-get | nala) + curl -fsSL https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor | "$ESCALATION_TOOL" tee /usr/share/keyrings/signal-desktop-keyring.gpg >/dev/null printf "%b\n" 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/signal-xenial.list "$ESCALATION_TOOL" "$PACKAGER" update "$ESCALATION_TOOL" "$PACKAGER" -y install signal-desktop @@ -35,4 +34,4 @@ installSignal() { checkEnv checkEscalationTool -installSignal \ No newline at end of file +installSignal diff --git a/core/tabs/applications-setup/communication-apps/slack-setup.sh b/core/tabs/applications-setup/communication-apps/slack-setup.sh index 24d6e532..55fd9c35 100644 --- a/core/tabs/applications-setup/communication-apps/slack-setup.sh +++ b/core/tabs/applications-setup/communication-apps/slack-setup.sh @@ -9,7 +9,7 @@ installSlack() { pacman) "$AUR_HELPER" -S --needed --noconfirm slack-desktop ;; - *) + *) checkFlatpak flatpak install -y flathub com.slack.Slack ;; @@ -22,4 +22,4 @@ installSlack() { checkEnv checkEscalationTool checkAURHelper -installSlack \ No newline at end of file +installSlack diff --git a/core/tabs/applications-setup/communication-apps/telegram-setup.sh b/core/tabs/applications-setup/communication-apps/telegram-setup.sh index a21b53e4..5a235bae 100644 --- a/core/tabs/applications-setup/communication-apps/telegram-setup.sh +++ b/core/tabs/applications-setup/communication-apps/telegram-setup.sh @@ -7,10 +7,10 @@ installTelegram() { printf "%b\n" "${YELLOW}Installing Telegram...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm telegram-desktop + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm telegram-desktop ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y telegram-desktop + "$ESCALATION_TOOL" "$PACKAGER" install -y telegram-desktop ;; esac else @@ -20,4 +20,4 @@ installTelegram() { checkEnv checkEscalationTool -installTelegram \ No newline at end of file +installTelegram diff --git a/core/tabs/applications-setup/communication-apps/thunderbird-setup.sh b/core/tabs/applications-setup/communication-apps/thunderbird-setup.sh index f49dcb78..a86d0ff9 100644 --- a/core/tabs/applications-setup/communication-apps/thunderbird-setup.sh +++ b/core/tabs/applications-setup/communication-apps/thunderbird-setup.sh @@ -10,7 +10,7 @@ installThunderBird() { "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm thunderbird ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y thunderbird + "$ESCALATION_TOOL" "$PACKAGER" install -y thunderbird ;; esac else @@ -20,4 +20,4 @@ installThunderBird() { checkEnv checkEscalationTool -installThunderBird \ No newline at end of file +installThunderBird diff --git a/core/tabs/applications-setup/communication-apps/zoom-setup.sh b/core/tabs/applications-setup/communication-apps/zoom-setup.sh index 19d7e407..aeb648c3 100644 --- a/core/tabs/applications-setup/communication-apps/zoom-setup.sh +++ b/core/tabs/applications-setup/communication-apps/zoom-setup.sh @@ -22,4 +22,4 @@ installZoom() { checkEnv checkEscalationTool checkAURHelper -installZoom \ No newline at end of file +installZoom diff --git a/core/tabs/applications-setup/docker-setup.sh b/core/tabs/applications-setup/docker-setup.sh index 4844d10e..7b69f6d2 100755 --- a/core/tabs/applications-setup/docker-setup.sh +++ b/core/tabs/applications-setup/docker-setup.sh @@ -13,18 +13,30 @@ choose_installation() { 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 ;; + 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 + apt-get | nala) + curl -fsSL https://get.docker.com | sh ;; dnf) "$ESCALATION_TOOL" "$PACKAGER" -y install dnf-plugins-core @@ -52,7 +64,7 @@ install_docker() { install_docker_compose() { printf "%b\n" "${YELLOW}Installing Docker Compose...${RC}" case "$PACKAGER" in - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" install -y docker-compose-plugin ;; dnf) @@ -74,7 +86,7 @@ install_docker_compose() { } install_components() { - choose_installation + choose_installation if [ "$INSTALL_DOCKER" -eq 1 ]; then if ! command_exists docker; then @@ -95,4 +107,4 @@ install_components() { checkEnv checkEscalationTool -install_components \ No newline at end of file +install_components diff --git a/core/tabs/applications-setup/dwmtitus-setup.sh b/core/tabs/applications-setup/dwmtitus-setup.sh index 01ec0ef1..55b2fe3f 100755 --- a/core/tabs/applications-setup/dwmtitus-setup.sh +++ b/core/tabs/applications-setup/dwmtitus-setup.sh @@ -8,7 +8,7 @@ setupDWM() { pacman) "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm base-devel libx11 libxinerama libxft imlib2 libxcb git unzip flameshot lxappearance feh mate-polkit ;; - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" install -y build-essential libx11-dev libxinerama-dev libxft-dev libimlib2-dev libx11-xcb-dev libfontconfig1 libx11-6 libxft2 libxinerama1 libxcb-res0-dev git unzip flameshot lxappearance feh mate-polkit ;; dnf) @@ -25,7 +25,7 @@ setupDWM() { makeDWM() { cd "$HOME" && git clone https://github.com/ChrisTitusTech/dwm-titus.git # CD to Home directory to install dwm-titus # This path can be changed (e.g. to linux-toolbox directory) - cd dwm-titus/ # Hardcoded path, maybe not the best. + cd dwm-titus/ # Hardcoded path, maybe not the best. "$ESCALATION_TOOL" make clean install # Run make clean install } @@ -105,7 +105,10 @@ picom_animations() { printf "%b\n" "${GREEN}Repository already exists, skipping clone${RC}" fi - cd "$HOME/.local/share/ftlabs-picom" || { printf "%b\n" "${RED}Failed to change directory to picom${RC}"; return 1; } + cd "$HOME/.local/share/ftlabs-picom" || { + printf "%b\n" "${RED}Failed to change directory to picom${RC}" + return 1 + } # Build the project if ! meson setup --buildtype=release build; then @@ -172,7 +175,7 @@ configure_backgrounds() { # Rename the cloned directory to 'backgrounds' mv "$PIC_DIR/nord-background" "$PIC_DIR/backgrounds" # Print a success message indicating that the backgrounds have been downloaded - printf "%b\n" "${GREEN}Downloaded desktop backgrounds to $BG_DIR${RC}" + printf "%b\n" "${GREEN}Downloaded desktop backgrounds to $BG_DIR${RC}" else # If the backgrounds directory already exists, print a message indicating that the download is being skipped printf "%b\n" "${GREEN}Path $BG_DIR exists for desktop backgrounds, skipping download of backgrounds${RC}" @@ -185,14 +188,14 @@ setupDisplayManager() { pacman) "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm xorg-xinit xorg-server ;; - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" install -y xorg xinit ;; dnf) "$ESCALATION_TOOL" "$PACKAGER" install -y xorg-x11-xinit xorg-x11-server-Xorg ;; *) - printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" + printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}" exit 1 ;; esac @@ -207,41 +210,44 @@ setupDisplayManager() { done printf "%b\n" "${GREEN}Current display manager: $currentdm${RC}" if [ "$currentdm" = "none" ]; then - printf "%b\n" "${YELLOW}--------------------------${RC}" - printf "%b\n" "${YELLOW}Pick your Display Manager ${RC}" - printf "%b\n" "${YELLOW}1. SDDM ${RC}" - printf "%b\n" "${YELLOW}2. LightDM ${RC}" - printf "%b\n" "${YELLOW}3. GDM ${RC}" - printf "%b\n" "${YELLOW} ${RC}" + printf "%b\n" "${YELLOW}--------------------------${RC}" + printf "%b\n" "${YELLOW}Pick your Display Manager ${RC}" + printf "%b\n" "${YELLOW}1. SDDM ${RC}" + printf "%b\n" "${YELLOW}2. LightDM ${RC}" + printf "%b\n" "${YELLOW}3. GDM ${RC}" + printf "%b\n" "${YELLOW} ${RC}" printf "%b" "${YELLOW}Please select one: ${RC}" read -r DM case "$PACKAGER" in pacman) "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm "$DM" ;; - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" install -y "$DM" ;; dnf) "$ESCALATION_TOOL" "$PACKAGER" install -y "$DM" ;; *) - printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" + printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}" exit 1 ;; esac printf "%b\n" "${GREEN}$DM installed successfully${RC}" systemctl enable "$DM" - + fi } install_slstatus() { printf "Do you want to install slstatus? (y/N): " # using printf instead of 'echo' to avoid newline, -n flag for 'echo' is not supported in POSIX - read -r response # -r flag to prevent backslashes from being interpreted + read -r response # -r flag to prevent backslashes from being interpreted if [ "$response" = "y" ] || [ "$response" = "Y" ]; then printf "%b\n" "${YELLOW}Installing slstatus${RC}" - cd "$HOME/dwm-titus/slstatus" || { printf "%b\n" "${RED}Failed to change directory to slstatus${RC}"; return 1; } + cd "$HOME/dwm-titus/slstatus" || { + printf "%b\n" "${RED}Failed to change directory to slstatus${RC}" + return 1 + } if "$ESCALATION_TOOL" make clean install; then printf "%b\n" "${GREEN}slstatus installed successfully${RC}" else diff --git a/core/tabs/applications-setup/fastfetch-setup.sh b/core/tabs/applications-setup/fastfetch-setup.sh index cb523441..d547256f 100644 --- a/core/tabs/applications-setup/fastfetch-setup.sh +++ b/core/tabs/applications-setup/fastfetch-setup.sh @@ -9,7 +9,7 @@ installFastfetch() { pacman) "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm fastfetch ;; - apt-get|nala) + 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 @@ -35,4 +35,4 @@ setupFastfetchConfig() { checkEnv checkEscalationTool installFastfetch -setupFastfetchConfig \ No newline at end of file +setupFastfetchConfig diff --git a/core/tabs/applications-setup/grub-theme.sh b/core/tabs/applications-setup/grub-theme.sh index 9b79b39b..32a56fc4 100644 --- a/core/tabs/applications-setup/grub-theme.sh +++ b/core/tabs/applications-setup/grub-theme.sh @@ -2,7 +2,7 @@ . ../common-script.sh -themeinstall(){ +themeinstall() { mkdir -p "$HOME/.local/share" cd "$HOME/.local/share" if [ -d 'Top-5-Bootloader-Themes' ]; then diff --git a/core/tabs/applications-setup/kitty-setup.sh b/core/tabs/applications-setup/kitty-setup.sh index 85ef129b..ec25377b 100755 --- a/core/tabs/applications-setup/kitty-setup.sh +++ b/core/tabs/applications-setup/kitty-setup.sh @@ -31,4 +31,4 @@ setupKittyConfig() { checkEnv checkEscalationTool installKitty -setupKittyConfig \ No newline at end of file +setupKittyConfig diff --git a/core/tabs/applications-setup/linutil-installer.sh b/core/tabs/applications-setup/linutil-installer.sh index fd925e0b..4c514b86 100755 --- a/core/tabs/applications-setup/linutil-installer.sh +++ b/core/tabs/applications-setup/linutil-installer.sh @@ -2,6 +2,7 @@ . ../common-script.sh +#shellcheck disable=SC1091 installLinutil() { printf "%b\n" "${YELLOW}Installing Linutil...${RC}" case "$PACKAGER" in @@ -30,7 +31,7 @@ installLinutil() { printf "%b" "${YELLOW}Do you want to install the crates.io package? (y/N): ${RC}" read -r choice case $choice in - y|Y) + y | Y) if ! command_exists cargo; then printf "%b\n" "${YELLOW}Installing rustup...${RC}" case "$PACKAGER" in @@ -43,11 +44,11 @@ installLinutil() { zypper) "$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - . $HOME/.cargo/env + . "$HOME/.cargo/env" ;; *) curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - . $HOME/.cargo/env + . "$HOME/.cargo/env" ;; esac fi @@ -58,16 +59,17 @@ installLinutil() { ;; *) printf "%b\n" "${RED}Linutil not installed.${RC}" ;; esac + ;; esac } installExtra() { printf "%b\n" "${YELLOW}Installing the manpage...${RC}" "$ESCALATION_TOOL" mkdir -p /usr/share/man/man1 - curl 'https://raw.githubusercontent.com/ChrisTitusTech/linutil/refs/heads/main/man/linutil.1' | "$ESCALATION_TOOL" tee '/usr/share/man/man1/linutil.1' > /dev/null + curl 'https://raw.githubusercontent.com/ChrisTitusTech/linutil/refs/heads/main/man/linutil.1' | "$ESCALATION_TOOL" tee '/usr/share/man/man1/linutil.1' >/dev/null printf "%b\n" "${YELLOW}Creating a Desktop Entry...${RC}" "$ESCALATION_TOOL" mkdir -p /usr/share/applications - curl 'https://raw.githubusercontent.com/ChrisTitusTech/linutil/refs/heads/main/linutil.desktop' | "$ESCALATION_TOOL" tee /usr/share/applications/linutil.desktop > /dev/null + curl 'https://raw.githubusercontent.com/ChrisTitusTech/linutil/refs/heads/main/linutil.desktop' | "$ESCALATION_TOOL" tee /usr/share/applications/linutil.desktop >/dev/null printf "%b\n" "${GREEN}Done.${RC}" } diff --git a/core/tabs/applications-setup/linutil-updater.sh b/core/tabs/applications-setup/linutil-updater.sh index 8cf1762d..304af00b 100755 --- a/core/tabs/applications-setup/linutil-updater.sh +++ b/core/tabs/applications-setup/linutil-updater.sh @@ -2,6 +2,7 @@ . ../common-script.sh +#shellcheck disable=SC1091 updateLinutil() { if [ ! -e "$HOME/.cargo/bin/linutil" ]; then printf "%b\n" "${RED}This script only updates the binary installed through cargo.\nlinutil_tui is not installed.${RC}" @@ -10,19 +11,19 @@ updateLinutil() { if ! command_exists cargo; then printf "%b\n" "${YELLOW}Installing rustup...${RC}" - case "$PACKAGER" in - pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup - ;; - zypper) - "$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - . $HOME/.cargo/env - ;; - *) - "$ESCALATION_TOOL" "$PACKAGER" install -y rustup - ;; - esac + case "$PACKAGER" in + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup + ;; + zypper) + "$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + . "$HOME/.cargo/env" + ;; + *) + "$ESCALATION_TOOL" "$PACKAGER" install -y rustup + ;; + esac fi INSTALLED_VERSION=$(cargo install --list | grep "linutil_tui" | awk '{print $2}' | tr -d 'v:') diff --git a/core/tabs/applications-setup/office-suites/freeoffice.sh b/core/tabs/applications-setup/office-suites/freeoffice.sh index d289165e..165c9862 100644 --- a/core/tabs/applications-setup/office-suites/freeoffice.sh +++ b/core/tabs/applications-setup/office-suites/freeoffice.sh @@ -2,30 +2,30 @@ . ../../common-script.sh -installFreeOffice() { +installFreeOffice() { if ! command_exists softmaker-freeoffice-2024 freeoffice softmaker; then printf "%b\n" "${YELLOW}Installing Free Office...${RC}" case "$PACKAGER" in - apt-get|nala) - curl -O https://www.softmaker.net/down/softmaker-freeoffice-2024_1218-01_amd64.deb - "$ESCALATION_TOOL" "$PACKAGER" install -y ./softmaker-freeoffice-2024_1218-01_amd64.deb - ;; - zypper) - "$ESCALATION_TOOL" "$PACKAGER" addrepo -f https://shop.softmaker.com/repo/rpm SoftMaker - "$ESCALATION_TOOL" "$PACKAGER" --gpg-auto-import-keys refresh - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install softmaker-freeoffice-2024 - ;; - pacman) - "$AUR_HELPER" -S --needed --noconfirm freeoffice - ;; - dnf) - "$ESCALATION_TOOL" curl -O -qO /etc/yum.repos.d/softmaker.repo https://shop.softmaker.com/repo/softmaker.repo - "$ESCALATION_TOOL" "$PACKAGER" install -y softmaker-freeoffice-2024 - ;; - *) - printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" - exit 1 - ;; + apt-get | nala) + curl -O https://www.softmaker.net/down/softmaker-freeoffice-2024_1218-01_amd64.deb + "$ESCALATION_TOOL" "$PACKAGER" install -y ./softmaker-freeoffice-2024_1218-01_amd64.deb + ;; + zypper) + "$ESCALATION_TOOL" "$PACKAGER" addrepo -f https://shop.softmaker.com/repo/rpm SoftMaker + "$ESCALATION_TOOL" "$PACKAGER" --gpg-auto-import-keys refresh + "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install softmaker-freeoffice-2024 + ;; + pacman) + "$AUR_HELPER" -S --needed --noconfirm freeoffice + ;; + dnf) + "$ESCALATION_TOOL" curl -O -qO /etc/yum.repos.d/softmaker.repo https://shop.softmaker.com/repo/softmaker.repo + "$ESCALATION_TOOL" "$PACKAGER" install -y softmaker-freeoffice-2024 + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + exit 1 + ;; esac else printf "%b\n" "${GREEN}Free Office is already installed.${RC}" @@ -35,4 +35,4 @@ installFreeOffice() { checkEnv checkEscalationTool checkAurHelper -installFreeOffice \ No newline at end of file +installFreeOffice diff --git a/core/tabs/applications-setup/office-suites/libreoffice.sh b/core/tabs/applications-setup/office-suites/libreoffice.sh index f389abd8..078238c5 100644 --- a/core/tabs/applications-setup/office-suites/libreoffice.sh +++ b/core/tabs/applications-setup/office-suites/libreoffice.sh @@ -6,10 +6,10 @@ installLibreOffice() { if ! command_exists org.libreoffice.LibreOffice && ! command_exists libreoffice; then printf "%b\n" "${YELLOW}Installing Libre Office...${RC}" case "$PACKAGER" in - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" install -y libreoffice-core ;; - zypper|dnf) + zypper | dnf) checkFlatpak flatpak install -y flathub org.libreoffice.LibreOffice ;; @@ -28,4 +28,4 @@ installLibreOffice() { checkEnv checkEscalationTool -installLibreOffice \ No newline at end of file +installLibreOffice diff --git a/core/tabs/applications-setup/office-suites/onlyoffice.sh b/core/tabs/applications-setup/office-suites/onlyoffice.sh index f6fb97f6..2ff5d41a 100644 --- a/core/tabs/applications-setup/office-suites/onlyoffice.sh +++ b/core/tabs/applications-setup/office-suites/onlyoffice.sh @@ -6,11 +6,11 @@ installOnlyOffice() { if ! command_exists org.onlyoffice.desktopeditors && ! command_exists onlyoffice-desktopeditors; then printf "%b\n" "${YELLOW}Installing Only Office..${RC}." case "$PACKAGER" in - apt-get|nala) + apt-get | nala) curl -O https://download.onlyoffice.com/install/desktop/editors/linux/onlyoffice-desktopeditors_amd64.deb "$ESCALATION_TOOL" "$PACKAGER" install -y ./onlyoffice-desktopeditors_amd64.deb ;; - zypper|dnf) + zypper | dnf) checkFlatpak flatpak install -y flathub org.onlyoffice.desktopeditors ;; @@ -30,4 +30,4 @@ installOnlyOffice() { checkEnv checkEscalationTool checkAurHelper -installOnlyOffice \ No newline at end of file +installOnlyOffice diff --git a/core/tabs/applications-setup/office-suites/wpsoffice.sh b/core/tabs/applications-setup/office-suites/wpsoffice.sh index 4ce1f5c5..3d9389af 100644 --- a/core/tabs/applications-setup/office-suites/wpsoffice.sh +++ b/core/tabs/applications-setup/office-suites/wpsoffice.sh @@ -22,4 +22,4 @@ installWpsOffice() { checkEnv checkEscalationTool checkAurHelper -installWpsOffice \ No newline at end of file +installWpsOffice diff --git a/core/tabs/applications-setup/pdf-suites/evince.sh b/core/tabs/applications-setup/pdf-suites/evince.sh index 9118d36d..aaf9f918 100644 --- a/core/tabs/applications-setup/pdf-suites/evince.sh +++ b/core/tabs/applications-setup/pdf-suites/evince.sh @@ -20,4 +20,4 @@ installEvince() { checkEnv checkEscalationTool -installEvince \ No newline at end of file +installEvince diff --git a/core/tabs/applications-setup/pdf-suites/okular.sh b/core/tabs/applications-setup/pdf-suites/okular.sh index 785d512c..3baf6b20 100644 --- a/core/tabs/applications-setup/pdf-suites/okular.sh +++ b/core/tabs/applications-setup/pdf-suites/okular.sh @@ -20,4 +20,4 @@ installOkular() { checkEnv checkEscalationTool -installOkular \ No newline at end of file +installOkular diff --git a/core/tabs/applications-setup/rofi-setup.sh b/core/tabs/applications-setup/rofi-setup.sh index 24ce1a67..fa3ae42c 100755 --- a/core/tabs/applications-setup/rofi-setup.sh +++ b/core/tabs/applications-setup/rofi-setup.sh @@ -4,7 +4,7 @@ installRofi() { if ! command_exists rofi; then - printf "%b\n" "${YELLOW}Installing Rofi...${RC}" + printf "%b\n" "${YELLOW}Installing Rofi...${RC}" case "$PACKAGER" in pacman) "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rofi diff --git a/core/tabs/applications-setup/setup-flatpak.sh b/core/tabs/applications-setup/setup-flatpak.sh index 379467a6..4bc65d7c 100755 --- a/core/tabs/applications-setup/setup-flatpak.sh +++ b/core/tabs/applications-setup/setup-flatpak.sh @@ -40,4 +40,4 @@ installExtra() { checkEnv checkEscalationTool checkFlatpak -installExtra \ No newline at end of file +installExtra diff --git a/core/tabs/applications-setup/waydroid-setup.sh b/core/tabs/applications-setup/waydroid-setup.sh index 8cac399f..26cbb7d0 100755 --- a/core/tabs/applications-setup/waydroid-setup.sh +++ b/core/tabs/applications-setup/waydroid-setup.sh @@ -3,7 +3,7 @@ . ../common-script.sh checkGpu() { - if lspci | grep -i nvidia > /dev/null; then + if lspci | grep -i nvidia >/dev/null; then printf "%b\n" "${RED}Waydroid is not compatible with NVIDIA GPUs.${RC}" exit 1 fi @@ -11,7 +11,7 @@ checkGpu() { installWaydroid() { if ! command_exists waydroid; then - printf "%b\n" "${YELLOW}Installing Waydroid...${RC}" + printf "%b\n" "${YELLOW}Installing Waydroid...${RC}" case "$PACKAGER" in pacman) "$AUR_HELPER" -S --needed --noconfirm waydroid @@ -27,7 +27,7 @@ installWaydroid() { "$AUR_HELPER" -S --needed --noconfirm binder_linux-dkms "$ESCALATION_TOOL" modprobe binder-linux device=binder,hwbinder,vndbinder ;; - apt-get|nala) + apt-get | nala) curl https://repo.waydro.id | "$ESCALATION_TOOL" sh "$ESCALATION_TOOL" "$PACKAGER" install -y waydroid if command_exists dkms; then diff --git a/core/tabs/applications-setup/zsh-setup.sh b/core/tabs/applications-setup/zsh-setup.sh index a85b9240..19912c2b 100644 --- a/core/tabs/applications-setup/zsh-setup.sh +++ b/core/tabs/applications-setup/zsh-setup.sh @@ -4,33 +4,33 @@ # Function to install zsh installZsh() { - if ! command_exists zsh; then - printf "%b\n" "${YELLOW}Installing Zsh...${RC}" - case "$PACKAGER" in - pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm zsh - ;; - *) - "$ESCALATION_TOOL" "$PACKAGER" install -y zsh - ;; - esac - else - printf "%b\n" "${GREEN}ZSH is already installed.${RC}" - fi + if ! command_exists zsh; then + printf "%b\n" "${YELLOW}Installing Zsh...${RC}" + case "$PACKAGER" in + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm zsh + ;; + *) + "$ESCALATION_TOOL" "$PACKAGER" install -y zsh + ;; + esac + else + printf "%b\n" "${GREEN}ZSH is already installed.${RC}" + fi } # Function to setup zsh configuration setupZshConfig() { - printf "%b\n" "${YELLOW}Setting up Zsh configuration...${RC}" - CONFIG_DIR="$HOME/.config/zsh" - ZSHRC_FILE="$CONFIG_DIR/.zshrc" + printf "%b\n" "${YELLOW}Setting up Zsh configuration...${RC}" + CONFIG_DIR="$HOME/.config/zsh" + ZSHRC_FILE="$CONFIG_DIR/.zshrc" - if [ ! -d "$CONFIG_DIR" ]; then - mkdir -p "$CONFIG_DIR" - fi + if [ ! -d "$CONFIG_DIR" ]; then + mkdir -p "$CONFIG_DIR" + fi - # Write the configuration to .zshrc - cat <"$ZSHRC_FILE" + # Write the configuration to .zshrc + cat <"$ZSHRC_FILE" HISTFILE=~/.config/zsh/.histfile HISTSIZE=5000 SAVEHIST=100000 @@ -43,9 +43,9 @@ PROMPT='%F{32}%n%f%F{166}@%f%F{64}%m:%F{166}%~%f%F{15}$%f ' RPROMPT='%F{15}(%F{166}%D{%H:%M}%F{15})%f' EOL - # Ensure /etc/zsh/zshenv sets ZDOTDIR to the user's config directory - [ ! -f /etc/zsh/zshenv ] && "$ESCALATION_TOOL" mkdir -p /etc/zsh && "$ESCALATION_TOOL" touch /etc/zsh/zshenv - echo "export ZDOTDIR=\"$HOME/.config/zsh\"" | "$ESCALATION_TOOL" tee -a /etc/zsh/zshenv + # Ensure /etc/zsh/zshenv sets ZDOTDIR to the user's config directory + [ ! -f /etc/zsh/zshenv ] && "$ESCALATION_TOOL" mkdir -p /etc/zsh && "$ESCALATION_TOOL" touch /etc/zsh/zshenv + echo "export ZDOTDIR=\"$HOME/.config/zsh\"" | "$ESCALATION_TOOL" tee -a /etc/zsh/zshenv } checkEnv diff --git a/core/tabs/common-script.sh b/core/tabs/common-script.sh index a9dd5d62..56d5f9e9 100644 --- a/core/tabs/common-script.sh +++ b/core/tabs/common-script.sh @@ -9,11 +9,11 @@ CYAN='\033[36m' GREEN='\033[32m' command_exists() { -for cmd in "$@"; do - export PATH=/home/jeeva/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:$PATH - command -v "$cmd" >/dev/null 2>&1 || return 1 -done -return 0 + for cmd in "$@"; do + export PATH="/home/jeeva/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:$PATH" + command -v "$cmd" >/dev/null 2>&1 || return 1 + done + return 0 } checkFlatpak() { @@ -157,9 +157,10 @@ checkCurrentDirectoryWritable() { } checkDistro() { - DTYPE="unknown" # Default to unknown + DTYPE="unknown" # Default to unknown # Use /etc/os-release for modern distro identification if [ -f /etc/os-release ]; then + # shellcheck disable=SC1091 . /etc/os-release DTYPE=$ID fi diff --git a/core/tabs/gaming/diablo-ii/d2r-loot-filters.sh b/core/tabs/gaming/diablo-ii/d2r-loot-filters.sh index 2a55c709..fa3b2108 100755 --- a/core/tabs/gaming/diablo-ii/d2r-loot-filters.sh +++ b/core/tabs/gaming/diablo-ii/d2r-loot-filters.sh @@ -41,7 +41,7 @@ print_menu() { if [ $start -lt 0 ]; then start=0; fi if [ $((start + max_display)) -gt $total ]; then start=$((total - max_display)); fi if [ $start -lt 0 ]; then start=0; fi - + printf "%b\n" "Please select the Diablo II: Resurrected installation path:" i=0 echo "$paths_string" | tr '|' '\n' | while IFS= read -r path; do @@ -129,4 +129,4 @@ printf "%b\n" "3. Click the gear icon next to the 'Play' button" printf "%b\n" "4. Select 'Game Settings'" printf "%b\n" "5. In the 'Additional command line arguments' field, enter: -mod lootfilter -txt" printf "%b\n" "6. Click 'Done' to save the changes" -printf "%b\n" "After completing these steps, launch Diablo II: Resurrected through Battle.net to use the loot filter." \ No newline at end of file +printf "%b\n" "After completing these steps, launch Diablo II: Resurrected through Battle.net to use the loot filter." diff --git a/core/tabs/security/firewall-baselines.sh b/core/tabs/security/firewall-baselines.sh index 9c0810f4..c5af3481 100644 --- a/core/tabs/security/firewall-baselines.sh +++ b/core/tabs/security/firewall-baselines.sh @@ -4,7 +4,7 @@ installPkg() { if ! command_exists ufw; then - printf "%b\n" "${YELLOW}Installing UFW...${RC}" + printf "%b\n" "${YELLOW}Installing UFW...${RC}" case "$PACKAGER" in pacman) "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm ufw diff --git a/core/tabs/system-setup/arch/server-setup.sh b/core/tabs/system-setup/arch/server-setup.sh index 913d5f61..2d68885d 100755 --- a/core/tabs/system-setup/arch/server-setup.sh +++ b/core/tabs/system-setup/arch/server-setup.sh @@ -86,7 +86,7 @@ select_option() { fi done - last_selected=$selected + last_selected="$selected" # Read user input read -rsn1 key @@ -96,13 +96,13 @@ select_option() { case $key in '[A') # Up arrow ((selected--)) - if [ $selected -lt 0 ]; then + if [ "$selected" -lt 0 ]; then selected=$((num_options - 1)) fi ;; '[B') # Down arrow ((selected++)) - if [ $selected -ge $num_options ]; then + if [ "$selected" -ge "$num_options" ]; then selected=0 fi ;; @@ -119,9 +119,9 @@ select_option() { # @description Displays ArchTitus logo # @noargs -logo () { -# This will be shown on every set as user is progressing -echo -ne " +logo() { + # This will be shown on every set as user is progressing + echo -ne " ------------------------------------------------------------------------- █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ ██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ @@ -136,7 +136,7 @@ echo -ne " } # @description This function will handle file systems. At this movement we are handling only # btrfs and ext4. Others will be added in future. -filesystem () { +filesystem() { echo -ne " Please Select your file system for both boot and root " @@ -144,19 +144,22 @@ filesystem () { select_option "${options[@]}" case $? in - 0) export FS=btrfs;; - 1) export FS=ext4;; - 2) - set_password "LUKS_PASSWORD" - export FS=luks - ;; - 3) exit ;; - *) echo "Wrong option please select again"; filesystem;; + 0) export FS=btrfs ;; + 1) export FS=ext4 ;; + 2) + set_password "LUKS_PASSWORD" + export FS=luks + ;; + 3) exit ;; + *) + echo "Wrong option please select again" + filesystem + ;; esac } # @description Detects and sets timezone. -timezone () { +timezone() { # Added this from arch wiki https://wiki.archlinux.org/title/System_time time_zone="$(curl --fail https://ipapi.co/timezone)" echo -ne " @@ -167,23 +170,28 @@ timezone () { select_option "${options[@]}" case ${options[$?]} in - y|Y|yes|Yes|YES) - echo "${time_zone} set as timezone" - export TIMEZONE=$time_zone;; - n|N|no|NO|No) - echo "Please enter your desired timezone e.g. Europe/London :" - read -r new_timezone - echo "${new_timezone} set as timezone" - export TIMEZONE=$new_timezone;; - *) echo "Wrong option. Try again";timezone;; + y | Y | yes | Yes | YES) + echo "${time_zone} set as timezone" + export TIMEZONE=$time_zone + ;; + n | N | no | NO | No) + echo "Please enter your desired timezone e.g. Europe/London :" + read -r new_timezone + echo "${new_timezone} set as timezone" + export TIMEZONE=$new_timezone + ;; + *) + echo "Wrong option. Try again" + timezone + ;; esac } # @description Set user's keyboard mapping. -keymap () { +keymap() { echo -ne " Please select key board layout from this list" # These are default key maps as presented in official arch repo archinstall - options=(us by ca cf cz de dk es et fa fi fr gr hu il it lt lv mk nl no pl ro ru se sg ua uk) + options=('us' 'by' 'ca' 'cf' 'cz' 'de' 'dk' 'es' 'et' 'fa' 'fi' 'fr' 'gr' 'hu' 'il' 'it' 'lt' 'lv' 'mk' 'nl' 'no' 'pl' 'ro' 'ru' 'se' 'sg' 'ua' 'uk') select_option "${options[@]}" keymap=${options[$?]} @@ -193,7 +201,7 @@ keymap () { } # @description Choose whether drive is SSD or not. -drivessd () { +drivessd() { echo -ne " Is this an ssd? yes/no: " @@ -202,17 +210,22 @@ drivessd () { select_option "${options[@]}" case ${options[$?]} in - y|Y|yes|Yes|YES) - export MOUNT_OPTIONS="noatime,compress=zstd,ssd,commit=120";; - n|N|no|NO|No) - export MOUNT_OPTIONS="noatime,compress=zstd,commit=120";; - *) echo "Wrong option. Try again";drivessd;; + y | Y | yes | Yes | YES) + export MOUNT_OPTIONS="noatime,compress=zstd,ssd,commit=120" + ;; + n | N | no | NO | No) + export MOUNT_OPTIONS="noatime,compress=zstd,commit=120" + ;; + *) + echo "Wrong option. Try again" + drivessd + ;; esac } # @description Disk selection for drive to be used with installation. -diskpart () { -echo -ne " +diskpart() { + echo -ne " ------------------------------------------------------------------------ THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK Please make sure you know what you are doing because @@ -225,33 +238,31 @@ echo -ne " PS3=' Select the disk to install on: ' + # shellcheck disable=SC2207 options=($(lsblk -n --output TYPE,KNAME,SIZE | awk '$1=="disk"{print "/dev/"$2"|"$3}')) select_option "${options[@]}" disk=${options[$?]%|*} echo -e "\n${disk%|*} selected \n" - export DISK=${disk%|*} + export DISK=${disk%|*} drivessd } # @description Gather username and password to be used for installation. -userinfo () { +userinfo() { # Loop through user input until the user gives a valid username - while true - do - read -r -p "Please enter username: " username - if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]] - then - break - fi - echo "Incorrect username." + while true; do + read -r -p "Please enter username: " username + if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]]; then + break + fi + echo "Incorrect username." done export USERNAME=$username - while true - do + while true; do read -rs -p "Please enter password: " PASSWORD1 echo -ne "\n" read -rs -p "Please re-enter password: " PASSWORD2 @@ -264,21 +275,18 @@ userinfo () { done export PASSWORD=$PASSWORD1 - # Loop through user input until the user gives a valid hostname, but allow the user to force save - while true - do - read -r -p "Please name your machine: " name_of_machine - # hostname regex (!!couldn't find spec for computer name!!) - if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]] - then - break - fi - # if validation fails allow the user to force saving of the hostname - read -r -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force - if [[ "${force,,}" = "y" ]] - then - break - fi + # Loop through user input until the user gives a valid hostname, but allow the user to force save + while true; do + read -r -p "Please name your machine: " name_of_machine + # hostname regex (!!couldn't find spec for computer name!!) + if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]; then + break + fi + # if validation fails allow the user to force saving of the hostname + read -r -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force + if [[ "${force,,}" = "y" ]]; then + break + fi done export NAME_OF_MACHINE=$name_of_machine } @@ -333,14 +341,14 @@ echo -ne " " umount -A --recursive /mnt # make sure everything is unmounted before we start # disk prep -sgdisk -Z "${DISK}" # zap all on disk +sgdisk -Z "${DISK}" # zap all on disk sgdisk -a 2048 -o "${DISK}" # new gpt disk 2048 alignment # create partitions -sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:'BIOSBOOT' "${DISK}" # partition 1 (BIOS Boot Partition) +sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:'BIOSBOOT' "${DISK}" # partition 1 (BIOS Boot Partition) sgdisk -n 2::+1GiB --typecode=2:ef00 --change-name=2:'EFIBOOT' "${DISK}" # partition 2 (UEFI Boot Partition) -sgdisk -n 3::-0 --typecode=3:8300 --change-name=3:'ROOT' "${DISK}" # partition 3 (Root), default start, remaining -if [[ ! -d "/sys/firmware/efi" ]]; then # Checking for bios system +sgdisk -n 3::-0 --typecode=3:8300 --change-name=3:'ROOT' "${DISK}" # partition 3 (Root), default start, remaining +if [[ ! -d "/sys/firmware/efi" ]]; then # Checking for bios system sgdisk -A 1:set:2 "${DISK}" fi partprobe "${DISK}" # reread partition table to ensure it is correct @@ -352,27 +360,27 @@ echo -ne " ------------------------------------------------------------------------- " # @description Creates the btrfs subvolumes. -createsubvolumes () { +createsubvolumes() { btrfs subvolume create /mnt/@ btrfs subvolume create /mnt/@home } # @description Mount all btrfs subvolumes after root has been mounted. -mountallsubvol () { +mountallsubvol() { mount -o "${MOUNT_OPTIONS}",subvol=@home "${partition3}" /mnt/home } # @description BTRFS subvolulme creation and mounting. -subvolumesetup () { -# create nonroot subvolumes +subvolumesetup() { + # create nonroot subvolumes createsubvolumes -# unmount root to remount with subvolume + # unmount root to remount with subvolume umount /mnt -# mount @ subvolume + # mount @ subvolume mount -o "${MOUNT_OPTIONS}",subvol=@ "${partition3}" /mnt -# make directories home, .snapshots, var, tmp + # make directories home, .snapshots, var, tmp mkdir -p /mnt/home -# mount subvolumes + # mount subvolumes mountallsubvol } @@ -395,13 +403,13 @@ elif [[ "${FS}" == "ext4" ]]; then mount -t ext4 "${partition3}" /mnt elif [[ "${FS}" == "luks" ]]; then mkfs.vfat -F32 "${partition2}" -# enter luks password to cryptsetup and format root partition + # enter luks password to cryptsetup and format root partition echo -n "${LUKS_PASSWORD}" | cryptsetup -y -v luksFormat "${partition3}" - -# open luks container and ROOT will be place holder + # open luks container and ROOT will be place holder echo -n "${LUKS_PASSWORD}" | cryptsetup open "${partition3}" ROOT - -# now format that container + # now format that container mkfs.btrfs "${partition3}" -# create subvolumes for btrfs + # create subvolumes for btrfs mount -t btrfs "${partition3}" /mnt subvolumesetup ENCRYPTED_PARTITION_UUID=$(blkid -s UUID -o value "${partition3}") @@ -435,10 +443,10 @@ if [[ ! -d "/sys/firmware/efi" ]]; then else pacstrap /mnt base base-devel linux-lts linux-firmware efibootmgr --noconfirm --needed fi -echo "keyserver hkp://keyserver.ubuntu.com" >> /mnt/etc/pacman.d/gnupg/gpg.conf +echo "keyserver hkp://keyserver.ubuntu.com" >>/mnt/etc/pacman.d/gnupg/gpg.conf cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist -genfstab -U /mnt >> /mnt/etc/fstab +genfstab -U /mnt >>/mnt/etc/fstab echo " Generated /etc/fstab: " @@ -456,8 +464,8 @@ echo -ne " Checking for low memory systems <8G ------------------------------------------------------------------------- " -TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*') -if [[ $TOTAL_MEM -lt 8000000 ]]; then +TOTAL_MEM=$(grep -i 'memtotal' /proc/meminfo | grep -o '[[:digit:]]*') +if [[ $TOTAL_MEM -lt 8000000 ]]; then # Put swap into the actual system, not into RAM disk, otherwise there is no point in it, it'll cache RAM into RAM. So, /mnt/ everything. mkdir -p /mnt/opt/swap # make a dir that we can apply NOCOW to to make it btrfs-friendly. if findmnt -n -o FSTYPE /mnt | grep -q btrfs; then @@ -469,11 +477,12 @@ if [[ $TOTAL_MEM -lt 8000000 ]]; then mkswap /mnt/opt/swap/swapfile swapon /mnt/opt/swap/swapfile # The line below is written to /mnt/ but doesn't contain /mnt/, since it's just / for the system itself. - echo "/opt/swap/swapfile none swap sw 0 0" >> /mnt/etc/fstab # Add swap to fstab, so it KEEPS working after installation. + echo "/opt/swap/swapfile none swap sw 0 0" >>/mnt/etc/fstab # Add swap to fstab, so it KEEPS working after installation. fi gpu_type=$(lspci | grep -E "VGA|3D|Display") +# shellcheck disable=SC2154 arch-chroot /mnt /bin/bash -c "KEYMAP='${KEYMAP}' /bin/bash" <> /etc/dnf/dnf.conf - echo "fastestmirror=True" | "$ESCALATION_TOOL" tee -a /etc/dnf/dnf.conf > /dev/null - echo "defaultyes=True" | "$ESCALATION_TOOL" tee -a /etc/dnf/dnf.conf > /dev/null + "$ESCALATION_TOOL" sed -i '/^max_parallel_downloads=/c\max_parallel_downloads=10' /etc/dnf/dnf.conf || echo 'max_parallel_downloads=10' >>/etc/dnf/dnf.conf + echo "fastestmirror=True" | "$ESCALATION_TOOL" tee -a /etc/dnf/dnf.conf >/dev/null + echo "defaultyes=True" | "$ESCALATION_TOOL" tee -a /etc/dnf/dnf.conf >/dev/null "$ESCALATION_TOOL" "$PACKAGER" -y install dnf-plugins-core printf "%b\n" "${GREEN}DNF Configured Successfully.${RC}" ;; diff --git a/core/tabs/system-setup/fedora/fedora-upgrade.sh b/core/tabs/system-setup/fedora/fedora-upgrade.sh index 47f1e061..951b6fb7 100644 --- a/core/tabs/system-setup/fedora/fedora-upgrade.sh +++ b/core/tabs/system-setup/fedora/fedora-upgrade.sh @@ -9,20 +9,20 @@ update() { printf "%b\n" "${YELLOW}Make sure your system is fully updated; if not, update it first and reboot once.${RC}" printf "%b\n" "${CYAN}Your current Fedora version is $current_version.${RC}" printf "%b\n" "${CYAN}The next available version is $next_version.${RC}" - - printf "%b\n" "${YELLOW}Do you want to update to $next_version? (y/n): ${RC}" + + printf "%b\n" "${YELLOW}Do you want to update to $next_version? (y/n): ${RC}" read -r response - + case "$response" in - y|Y) + y | Y) printf "%b\n" "${CYAN}Preparing to update to $next_version...${RC}" - + if ! "$ESCALATION_TOOL" "$PACKAGER" install dnf-plugin-system-upgrade -y; then printf "%b\n" "${RED}Failed to install dnf-plugin-system-upgrade.${RC}" exit 1 fi - - if ! "$ESCALATION_TOOL" "$PACKAGER" system-upgrade download --releasever="$next_version" -y ; then + + if ! "$ESCALATION_TOOL" "$PACKAGER" system-upgrade download --releasever="$next_version" -y; then printf "%b\n" "${RED}Failed to download the upgrade packages.${RC}" exit 1 fi @@ -31,7 +31,7 @@ update() { read -r reboot_response case "$reboot_response" in - y|Y) + y | Y) printf "%b\n" "${YELLOW}Rebooting to apply the upgrade...${RC}" "$ESCALATION_TOOL" "$PACKAGER" system-upgrade reboot ;; @@ -48,10 +48,10 @@ update() { post_upgrade() { printf "%b\n" "${YELLOW}Running post-upgrade tasks...${RC}" - + case "$PACKAGER" in dnf) - "$ESCALATION_TOOL" "$PACKAGER" autoremove + "$ESCALATION_TOOL" "$PACKAGER" autoremove "$ESCALATION_TOOL" "$PACKAGER" distro-sync -y ;; *) diff --git a/core/tabs/system-setup/fedora/multimedia-codecs.sh b/core/tabs/system-setup/fedora/multimedia-codecs.sh index 751e4547..cd979c67 100644 --- a/core/tabs/system-setup/fedora/multimedia-codecs.sh +++ b/core/tabs/system-setup/fedora/multimedia-codecs.sh @@ -23,4 +23,4 @@ multimedia() { checkEnv checkEscalationTool -multimedia \ No newline at end of file +multimedia diff --git a/core/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh b/core/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh index e123e8f0..e39a3d50 100755 --- a/core/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh +++ b/core/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh @@ -1,6 +1,7 @@ #!/bin/sh -e . ../../common-script.sh + # This script allows user to download proprietary drivers for nvidia in fedora # It also disables nouveau nvidia drivers @@ -10,84 +11,78 @@ # NOTE: Currently script only provides drivers for gpu 2014 and above (510+ and above) checkRepo() { - REPO_ID="rpmfusion-nonfree-nvidia-driver" + REPO_ID="rpmfusion-nonfree-nvidia-driver" - if [ "$(dnf repolist enabled 2>/dev/null | grep -c "$REPO_ID")" -gt 0 ]; then - printf "%b\n" "${GREEN}Nvidia non-free repository is already enabled.${RC}" - else - printf "%b\n" "${YELLOW}Nvidia non-free repository is not enabled. Enabling now...${RC}" - - # Enable the repository - "$ESCALATION_TOOL" dnf config-manager --set-enabled "$REPO_ID" - - # Refreshing repository list - "$ESCALATION_TOOL" dnf makecache - - # Verify if the repository is enabled if [ "$(dnf repolist enabled 2>/dev/null | grep -c "$REPO_ID")" -gt 0 ]; then - printf "%b\n" "${GREEN}Nvidia non-free repository is now enabled...${RC}" + printf "%b\n" "${GREEN}Nvidia non-free repository is already enabled.${RC}" else - printf "%b\n" "${RED}Failed to enable nvidia non-free repository...${RC}" - exit 1 + printf "%b\n" "${YELLOW}Nvidia non-free repository is not enabled. Enabling now...${RC}" + + "$ESCALATION_TOOL" dnf config-manager --set-enabled "$REPO_ID" + "$ESCALATION_TOOL" dnf makecache + + if [ "$(dnf repolist enabled 2>/dev/null | grep -c "$REPO_ID")" -gt 0 ]; then + printf "%b\n" "${GREEN}Nvidia non-free repository is now enabled...${RC}" + else + printf "%b\n" "${RED}Failed to enable nvidia non-free repository...${RC}" + exit 1 + fi fi - fi } checkDriverInstallation() { - if modinfo -F version nvidia >/dev/null 2>&1; then - return 0 - else - return 1 - fi + if modinfo -F version nvidia >/dev/null 2>&1; then + return 0 + else + return 1 + fi } installDriver() { - if checkDriverInstallation; then - printf "%b\n" "${GREEN}NVIDIA driver is already installed.${RC}" - exit 0 - fi - - # NOTE:: Installing graphics driver. - "$ESCALATION_TOOL" dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda -y - printf "%b\n" "${YELLOW}Building the drivers may take upto 5 minutes. Please don't kill the script!\n If the build failed try running the script again, select \"Remove Nvidia Drivers\" and reboot the system, then try installing drivers again.${RC}" - - for i in $(seq 1 5); do if checkDriverInstallation; then - printf "%b\n" "${GREEN}Driver installed successfully.${RC}" - printf "%b\n" "${GREEN}Installed driver version $(modinfo -F version nvidia)${RC}" - break + printf "%b\n" "${GREEN}NVIDIA driver is already installed.${RC}" + exit 0 fi - printf "%b\n" "${YELLOW}Waiting for driver to be built..." - sleep 1m - done - printf "%b\n" "${GREEN}Now you can reboot the system.${RC}" + "$ESCALATION_TOOL" dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda -y + printf "%b\n" "${YELLOW}Building the drivers may take upto 5 minutes. Please don't kill the script!\n If the build failed try running the script again, select \"Remove Nvidia Drivers\" and reboot the system, then try installing drivers again.${RC}" + + for _ in $(seq 1 5); do + if checkDriverInstallation; then + printf "%b\n" "${GREEN}Driver installed successfully.${RC}" + printf "%b\n" "${GREEN}Installed driver version $(modinfo -F version nvidia)${RC}" + break + fi + printf "%b\n" "${YELLOW}Waiting for driver to be built..." + sleep 1m + done + + printf "%b\n" "${GREEN}Now you can reboot the system.${RC}" } -# NOTE: A confirmation option to proceed or not userConfirmation() { - printf "%b" "${YELLOW}Do you want to continue? (y/N): ${RC}" - read -r choice - case "$choice" in - y | Y) - checkRepo - installDriver - return - ;; - n | N) - printf "%b\n" "${RED} Exiting the Script ${RC}" - return - ;; - *) - printf "%b\n" "${RED} Invalid Option! ${RC}" - userConfirmation - ;; - esac + printf "%b" "${YELLOW}Do you want to continue? (y/N): ${RC}" + read -r choice + case "$choice" in + y | Y) + checkRepo + installDriver + return + ;; + n | N) + printf "%b\n" "${RED}Exiting the script.${RC}" + return + ;; + *) + printf "%b\n" "${RED}Invalid Option!${RC}" + userConfirmation + ;; + esac } -printf "%b\n" "${YELLOW}Warning! This script will enable Nvidia non-free repository and only install drivers for GPUs from 2014 or later. It works on fedora 34 and above.\n It is recommended remove this driver while updating your kernel packages to newer version.${RC}" +printf "%b\n" "${YELLOW}Warning! This script will enable nvidia non-free repository and only install drivers for GPUs from 2014 or later. It works on fedora 34 and above.\n It is recommended remove this driver while updating your kernel packages to newer version.${RC}" checkEnv checkEscalationTool diff --git a/core/tabs/system-setup/fedora/rpm-fusion-setup.sh b/core/tabs/system-setup/fedora/rpm-fusion-setup.sh index aeb7d24c..bc7ac033 100644 --- a/core/tabs/system-setup/fedora/rpm-fusion-setup.sh +++ b/core/tabs/system-setup/fedora/rpm-fusion-setup.sh @@ -26,4 +26,4 @@ installRPMFusion() { checkEnv checkEscalationTool -installRPMFusion \ No newline at end of file +installRPMFusion diff --git a/core/tabs/system-setup/fedora/virtualization.sh b/core/tabs/system-setup/fedora/virtualization.sh index 3359efeb..58ffe872 100644 --- a/core/tabs/system-setup/fedora/virtualization.sh +++ b/core/tabs/system-setup/fedora/virtualization.sh @@ -7,7 +7,7 @@ configureVirtualization() { case "$PACKAGER" in dnf) printf "%b\n" "${YELLOW}Installing virtualization tools...${RC}" - "$ESCALATION_TOOL" "$PACKAGER" install -y @virtualization + "$ESCALATION_TOOL" "$PACKAGER" install -y @virtualization printf "%b\n" "${GREEN}Installed virtualization tools...${RC}" ;; *) diff --git a/core/tabs/system-setup/gaming-setup.sh b/core/tabs/system-setup/gaming-setup.sh index 92c666c7..94bf84d9 100755 --- a/core/tabs/system-setup/gaming-setup.sh +++ b/core/tabs/system-setup/gaming-setup.sh @@ -1,14 +1,14 @@ #!/bin/sh -e +# shellcheck disable=SC2086 + . ../common-script.sh installDepend() { - # Check for dependencies DEPENDENCIES='wine dbus' printf "%b\n" "${YELLOW}Installing dependencies...${RC}" case "$PACKAGER" in pacman) - #Check for multilib if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then echo "[multilib]" | "$ESCALATION_TOOL" tee -a /etc/pacman.conf echo "Include = /etc/pacman.d/mirrorlist" | "$ESCALATION_TOOL" tee -a /etc/pacman.conf @@ -25,7 +25,7 @@ installDepend() { $AUR_HELPER -S --needed --noconfirm $DEPENDENCIES $DISTRO_DEPS ;; - apt-get|nala) + apt-get | nala) DISTRO_DEPS="libasound2 libsdl2 wine64 wine32" "$ESCALATION_TOOL" "$PACKAGER" update @@ -36,7 +36,7 @@ installDepend() { "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $DISTRO_DEPS ;; dnf) - if [ "$(rpm -E %fedora)" -le 41 ]; then + if [ "$(rpm -E %fedora)" -le 41 ]; then "$ESCALATION_TOOL" "$PACKAGER" install ffmpeg ffmpeg-libs -y "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES else @@ -61,7 +61,7 @@ installAdditionalDepend() { DISTRO_DEPS='steam lutris goverlay' "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm $DISTRO_DEPS ;; - apt-get|nala) + apt-get | nala) version=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/lutris/lutris | grep -v 'beta' | tail -n1 | @@ -69,7 +69,7 @@ installAdditionalDepend() { version_no_v=$(echo "$version" | tr -d v) curl -sSLo "lutris_${version_no_v}_all.deb" "https://github.com/lutris/lutris/releases/download/${version}/lutris_${version_no_v}_all.deb" - + printf "%b\n" "${YELLOW}Installing Lutris...${RC}" "$ESCALATION_TOOL" "$PACKAGER" install ./lutris_"${version_no_v}"_all.deb @@ -94,8 +94,7 @@ installAdditionalDepend() { DISTRO_DEPS='lutris' "$ESCALATION_TOOL" "$PACKAGER" -n install $DISTRO_DEPS ;; - *) - ;; + *) ;; esac } diff --git a/core/tabs/system-setup/global-theme.sh b/core/tabs/system-setup/global-theme.sh index 07f9d4b2..cf028220 100755 --- a/core/tabs/system-setup/global-theme.sh +++ b/core/tabs/system-setup/global-theme.sh @@ -5,7 +5,7 @@ install_theme_tools() { printf "%b\n" "${YELLOW}Installing theme tools (qt6ct and kvantum)...${RC}" case "$PACKAGER" in - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" install -y qt6ct kvantum ;; zypper) @@ -47,7 +47,7 @@ applyTheming() { configure_qt6ct() { printf "%b\n" "${YELLOW}Configuring qt6ct...${RC}" mkdir -p "$HOME/.config/qt6ct" - cat < "$HOME/.config/qt6ct/qt6ct.conf" + cat <"$HOME/.config/qt6ct/qt6ct.conf" [Appearance] style=kvantum color_scheme=default @@ -58,7 +58,7 @@ EOF # Add QT_QPA_PLATFORMTHEME to /etc/environment if ! grep -q "QT_QPA_PLATFORMTHEME=qt6ct" /etc/environment; then printf "%b\n" "${YELLOW}Adding QT_QPA_PLATFORMTHEME to /etc/environment...${RC}" - echo "QT_QPA_PLATFORMTHEME=qt6ct" | "$ESCALATION_TOOL" tee -a /etc/environment > /dev/null + echo "QT_QPA_PLATFORMTHEME=qt6ct" | "$ESCALATION_TOOL" tee -a /etc/environment >/dev/null printf "%b\n" "${GREEN}QT_QPA_PLATFORMTHEME added to /etc/environment.${RC}" else printf "%b\n" "${GREEN}QT_QPA_PLATFORMTHEME already set in /etc/environment.${RC}" @@ -68,7 +68,7 @@ EOF configure_kvantum() { printf "%b\n" "${YELLOW}Configuring Kvantum...${RC}" mkdir -p "$HOME/.config/Kvantum" - cat < "$HOME/.config/Kvantum/kvantum.kvconfig" + cat <"$HOME/.config/Kvantum/kvantum.kvconfig" [General] theme=KvArcDark EOF @@ -85,4 +85,4 @@ applyTheming install_theme_tools configure_qt6ct configure_kvantum -successOutput \ No newline at end of file +successOutput diff --git a/core/tabs/system-setup/remove-snaps.sh b/core/tabs/system-setup/remove-snaps.sh index a46ef323..960db64b 100644 --- a/core/tabs/system-setup/remove-snaps.sh +++ b/core/tabs/system-setup/remove-snaps.sh @@ -8,13 +8,13 @@ removeSnaps() { pacman) "$ESCALATION_TOOL" "$PACKAGER" -Rns snapd ;; - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" autoremove --purge snapd if [ "$ID" = ubuntu ]; then "$ESCALATION_TOOL" apt-mark hold snapd fi ;; - dnf|zypper) + dnf | zypper) "$ESCALATION_TOOL" "$PACKAGER" remove snapd ;; *) diff --git a/core/tabs/system-setup/system-cleanup.sh b/core/tabs/system-setup/system-cleanup.sh index 57b827b9..5f7c0dd4 100755 --- a/core/tabs/system-setup/system-cleanup.sh +++ b/core/tabs/system-setup/system-cleanup.sh @@ -5,9 +5,9 @@ cleanup_system() { printf "%b\n" "${YELLOW}Performing system cleanup...${RC}" case "$PACKAGER" in - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" clean - "$ESCALATION_TOOL" "$PACKAGER" autoremove -y + "$ESCALATION_TOOL" "$PACKAGER" autoremove -y "$ESCALATION_TOOL" du -h /var/cache/apt ;; zypper) @@ -21,7 +21,8 @@ cleanup_system() { ;; pacman) "$ESCALATION_TOOL" "$PACKAGER" -Sc --noconfirm - "$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null 2>&1 + # shellcheck disable=SC2046 + "$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm >/dev/null 2>&1 ;; *) printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}. Skipping.${RC}" @@ -46,7 +47,7 @@ clean_data() { printf "%b" "${YELLOW}Clean up old cache files and empty the trash? (y/N): ${RC}" read -r clean_response case $clean_response in - y|Y) + y | Y) printf "%b\n" "${YELLOW}Cleaning up old cache files and emptying trash...${RC}" if [ -d "$HOME/.cache" ]; then find "$HOME/.cache/" -type f -atime +5 -delete diff --git a/core/tabs/system-setup/system-update.sh b/core/tabs/system-setup/system-update.sh index c213156a..e18b4959 100755 --- a/core/tabs/system-setup/system-update.sh +++ b/core/tabs/system-setup/system-update.sh @@ -20,17 +20,19 @@ fastUpdate() { dtype_local="arch" fi - "$ESCALATION_TOOL" rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${dtype_local} - if [ $? -ne 0 ] || [ ! -s /etc/pacman.d/mirrorlist ]; then + if "$ESCALATION_TOOL" rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root "$dtype_local" || [ ! -s /etc/pacman.d/mirrorlist ]; then printf "%b\n" "${RED}Rate-mirrors failed, restoring backup.${RC}" "$ESCALATION_TOOL" cp /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist fi ;; - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" apt-get update if ! command_exists nala; then - "$ESCALATION_TOOL" apt-get install -y nala || { printf "%b\n" "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; } + "$ESCALATION_TOOL" apt-get install -y nala || { + printf "%b\n" "${YELLOW}Falling back to apt-get${RC}" + PACKAGER="apt-get" + } fi if [ "$PACKAGER" = "nala" ]; then @@ -49,7 +51,7 @@ fastUpdate() { "$ESCALATION_TOOL" "$PACKAGER" --non-interactive dup ;; *) - printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" + printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}" exit 1 ;; esac @@ -58,7 +60,7 @@ fastUpdate() { updateSystem() { printf "%b\n" "${GREEN}Updating system${RC}" case "$PACKAGER" in - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" update "$ESCALATION_TOOL" "$PACKAGER" upgrade -y ;; @@ -75,7 +77,7 @@ updateSystem() { "$ESCALATION_TOOL" "$PACKAGER" --non-interactive dup ;; *) - printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" + printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}" exit 1 ;; esac diff --git a/core/tabs/system-setup/terminus-tty.sh b/core/tabs/system-setup/terminus-tty.sh index 2c1deaa0..90a544a1 100755 --- a/core/tabs/system-setup/terminus-tty.sh +++ b/core/tabs/system-setup/terminus-tty.sh @@ -2,15 +2,15 @@ . ../common-script.sh InstallTermiusFonts() { - if [ ! -f "/usr/share/kbd/consolefonts/ter-c18b.psf.gz" ] && - [ ! -f "/usr/share/consolefonts/Uni3-TerminusBold18x10.psf.gz" ] && - [ ! -f "/usr/lib/kbd/consolefonts/ter-p32n.psf.gz" ]; then - printf "%b\n" "${YELLOW}Installing Terminus Fonts...${RC}" + if [ ! -f "/usr/share/kbd/consolefonts/ter-c18b.psf.gz" ] && + [ ! -f "/usr/share/consolefonts/Uni3-TerminusBold18x10.psf.gz" ] && + [ ! -f "/usr/lib/kbd/consolefonts/ter-p32n.psf.gz" ]; then + printf "%b\n" "${YELLOW}Installing Terminus Fonts...${RC}" case "$PACKAGER" in pacman) "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm terminus-font ;; - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" install -y fonts-terminus ;; dnf) @@ -27,38 +27,38 @@ InstallTermiusFonts() { } SetTermiusFonts() { - case "$DTYPE" in - arch) - printf "%b\n" "${YELLOW}Updating FONT= line in /etc/vconsole.conf...${RC}" - "$ESCALATION_TOOL" sed -i 's/^FONT=.*/FONT=ter-v32b/' /etc/vconsole.conf - if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then - "$ESCALATION_TOOL" setfont -C /dev/tty1 ter-v32b - fi - printf "%b\n" "${GREEN}Terminus font set for TTY.${RC}" - ;; - debian) - - printf "%b\n" "${YELLOW}Updating console-setup configuration...${RC}" - "$ESCALATION_TOOL" sed -i 's/^CODESET=.*/CODESET="guess"/' /etc/default/console-setup - "$ESCALATION_TOOL" sed -i 's/^FONTFACE=.*/FONTFACE="TerminusBold"/' /etc/default/console-setup - "$ESCALATION_TOOL" sed -i 's/^FONTSIZE=.*/FONTSIZE="16x32"/' /etc/default/console-setup - printf "%b\n" "${GREEN}Console-setup configuration updated for Terminus font.${RC}" - # Editing console-setup requires initramfs to be regenerated - "$ESCALATION_TOOL" update-initramfs -u - if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then - "$ESCALATION_TOOL" setfont -C /dev/tty1 /usr/share/consolefonts/Uni3-TerminusBold32x16.psf.gz - fi - printf "%b\n" "${GREEN}Terminus font has been set for TTY.${RC}" - ;; - fedora) - printf "%b\n" "${YELLOW}Updating FONT= line in /etc/vconsole.conf...${RC}" - "$ESCALATION_TOOL" sed -i 's/^FONT=.*/FONT=ter-v32b/' /etc/vconsole.conf - if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then - "$ESCALATION_TOOL" setfont -C /dev/tty1 ter-v32b - fi - printf "%b\n" "${GREEN}Terminus font has been set for TTY.${RC}" - ;; - esac + case "$DTYPE" in + arch) + printf "%b\n" "${YELLOW}Updating FONT= line in /etc/vconsole.conf...${RC}" + "$ESCALATION_TOOL" sed -i 's/^FONT=.*/FONT=ter-v32b/' /etc/vconsole.conf + if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then + "$ESCALATION_TOOL" setfont -C /dev/tty1 ter-v32b + fi + printf "%b\n" "${GREEN}Terminus font set for TTY.${RC}" + ;; + debian) + + printf "%b\n" "${YELLOW}Updating console-setup configuration...${RC}" + "$ESCALATION_TOOL" sed -i 's/^CODESET=.*/CODESET="guess"/' /etc/default/console-setup + "$ESCALATION_TOOL" sed -i 's/^FONTFACE=.*/FONTFACE="TerminusBold"/' /etc/default/console-setup + "$ESCALATION_TOOL" sed -i 's/^FONTSIZE=.*/FONTSIZE="16x32"/' /etc/default/console-setup + printf "%b\n" "${GREEN}Console-setup configuration updated for Terminus font.${RC}" + # Editing console-setup requires initramfs to be regenerated + "$ESCALATION_TOOL" update-initramfs -u + if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then + "$ESCALATION_TOOL" setfont -C /dev/tty1 /usr/share/consolefonts/Uni3-TerminusBold32x16.psf.gz + fi + printf "%b\n" "${GREEN}Terminus font has been set for TTY.${RC}" + ;; + fedora) + printf "%b\n" "${YELLOW}Updating FONT= line in /etc/vconsole.conf...${RC}" + "$ESCALATION_TOOL" sed -i 's/^FONT=.*/FONT=ter-v32b/' /etc/vconsole.conf + if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then + "$ESCALATION_TOOL" setfont -C /dev/tty1 ter-v32b + fi + printf "%b\n" "${GREEN}Terminus font has been set for TTY.${RC}" + ;; + esac } checkEnv diff --git a/core/tabs/utils/auto-login.sh b/core/tabs/utils/auto-login.sh index 561250d5..686024e9 100644 --- a/core/tabs/utils/auto-login.sh +++ b/core/tabs/utils/auto-login.sh @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/sh -e -. ../common-script.sh +. ../common-script.sh # Function to list common session options list_sessions() { @@ -28,12 +28,14 @@ list_sessions() { 7) session="mate.desktop" ;; 8) session="openbox.desktop" ;; 9) session="i3.desktop" ;; - 10) + 10) printf "%b" "Enter custom session name (e.g., mysession): " - read -r session ;; - *) + read -r session + ;; + *) printf "%b\n" "Invalid option selected." - exit 1 ;; + exit 1 + ;; esac } @@ -84,7 +86,7 @@ configure_sddm() { printf "%b\n" "Configuring SDDM for autologin..." printf "%b" "Enter username for SDDM autologin: " read -r user - list_sessions # Show session options + list_sessions # Show session options printf "%b\n" '[Autologin]' | "$ESCALATION_TOOL" tee -a /etc/sddm.conf printf "%s\n" "User=$user" | "$ESCALATION_TOOL" tee -a /etc/sddm.conf @@ -105,8 +107,8 @@ configure_lxdm() { printf "%b\n" "Configuring LXDM for autologin..." printf "%b" "Enter username for LXDM autologin: " read -r user - list_sessions # Show session options - + list_sessions # Show session options + "$ESCALATION_TOOL" sed -i'' "s/^#.*autologin=.*$/autologin=${user}/" /etc/lxdm/lxdm.conf "$ESCALATION_TOOL" sed -i'' "s|^#.*session=.*$|session=/usr/bin/${session}|; s|^session=.*$|session=/usr/bin/${session}|" /etc/lxdm/lxdm.conf diff --git a/core/tabs/utils/auto-mount.sh b/core/tabs/utils/auto-mount.sh index f4eb59b2..c9e60c99 100644 --- a/core/tabs/utils/auto-mount.sh +++ b/core/tabs/utils/auto-mount.sh @@ -58,21 +58,20 @@ update_fstab() { fstab_entry="UUID=$UUID $mount_point $FSTYPE defaults 0 2" # Append the comment and the entry to /etc/fstab - printf "%b\n" "$comment" | "$ESCALATION_TOOL" tee -a /etc/fstab > /dev/null - printf "%b\n" "$fstab_entry" | "$ESCALATION_TOOL" tee -a /etc/fstab > /dev/null - printf "%b\n" "" | "$ESCALATION_TOOL" tee -a /etc/fstab > /dev/null + printf "%b\n" "$comment" | "$ESCALATION_TOOL" tee -a /etc/fstab >/dev/null + printf "%b\n" "$fstab_entry" | "$ESCALATION_TOOL" tee -a /etc/fstab >/dev/null + printf "%b\n" "" | "$ESCALATION_TOOL" tee -a /etc/fstab >/dev/null printf "%b\n" "Entry added to /etc/fstab:" printf "%b\n" "$comment" printf "%b\n" "$fstab_entry" } - # Function to mount the drive mount_drive() { printf "%b\n" "Mounting the drive..." - "$ESCALATION_TOOL" mount -a - if mount | grep "$mount_point" > /dev/null; then + "$ESCALATION_TOOL" mount -a + if mount | grep "$mount_point" >/dev/null; then printf "%b\n" "${GREEN}Drive mounted successfully at $mount_point${RC}." else printf "%b\n" "${RED}Failed to mount the drive.${RC}" diff --git a/core/tabs/utils/bluetooth-control.sh b/core/tabs/utils/bluetooth-control.sh index da7ee23d..76e493d9 100644 --- a/core/tabs/utils/bluetooth-control.sh +++ b/core/tabs/utils/bluetooth-control.sh @@ -2,13 +2,12 @@ . ../common-script.sh -# Function to check Bluez is installed setupBluetooth() { printf "%b\n" "${YELLOW}Installing Bluez...${RC}" if ! command_exists bluetoothctl; then case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm bluez-utils + "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm bluez-utils bluez ;; *) "$ESCALATION_TOOL" "$PACKAGER" install -y bluez @@ -18,18 +17,16 @@ setupBluetooth() { printf "%b\n" "${GREEN}Bluez is already installed.${RC}" fi - # Check if bluetooth service is running if ! systemctl is-active --quiet bluetooth; then printf "%b\n" "${YELLOW}Bluetooth service is not running. Starting it now...${RC}" "$ESCALATION_TOOL" systemctl start bluetooth - + if systemctl is-active --quiet bluetooth; then printf "%b\n" "${GREEN}Bluetooth service started successfully.${RC}" fi fi } -# Function to display the main menu main_menu() { while true; do clear @@ -56,7 +53,6 @@ main_menu() { done } -# Function to scan for devices scan_devices() { clear printf "%b\n" "${YELLOW}Scanning for devices...${RC}" @@ -69,16 +65,14 @@ scan_devices() { printf "%b\n" "$devices" fi printf "%b" "Press any key to return to the main menu..." - read -r dummy + read -r _ } -# Function to prompt for MAC address using numbers prompt_for_mac() { - action=$1 - command=$2 - prompt_msg=$3 - success_msg=$4 - failure_msg=$5 + command=$1 + prompt_msg=$2 + success_msg=$3 + failure_msg=$4 while true; do clear @@ -86,7 +80,7 @@ prompt_for_mac() { if [ -z "$devices" ]; then printf "%b\n" "${RED}No devices available. Please scan for devices first.${RC}" printf "%b" "Press any key to return to the main menu..." - read -r dummy + read -r _ return fi @@ -95,23 +89,24 @@ prompt_for_mac() { i=1 echo "$device_list" | while IFS= read -r device; do printf "%d. %s\n" "$i" "$device" + #shellcheck disable=SC2030 i=$((i + 1)) done printf "%b\n" "0. Exit to main menu" printf "%b\n" "$prompt_msg" read -r choice - # Validate the choice + # shellcheck disable=SC2031 if echo "$choice" | grep -qE '^[0-9]+$' && [ "$choice" -le "$((i - 1))" ] && [ "$choice" -gt 0 ]; then device=$(echo "$device_list" | sed -n "${choice}p") mac=$(echo "$device" | awk '{print $2}') - if bluetoothctl info "$mac" > /dev/null 2>&1; then - bluetoothctl "$command" "$mac" && { + if bluetoothctl info "$mac" >/dev/null 2>&1; then + if bluetoothctl "$command" "$mac"; then printf "%b\n" "${GREEN}$success_msg${RC}" break - } || { + else printf "%b\n" "${RED}$failure_msg${RC}" - } + fi else printf "%b\n" "${RED}Invalid MAC address. Please try again.${RC}" fi @@ -122,30 +117,25 @@ prompt_for_mac() { fi done printf "%b" "Press any key to return to the main menu..." - read -r dummy + read -r _ } -# Function to pair with a device pair_device() { - prompt_for_mac "pair" "pair" "Enter the number of the device to pair: " "Pairing with device completed." "Failed to pair with device." + prompt_for_mac "pair" "Enter the number of the device to pair: " "Pairing with device completed." "Failed to pair with device." } -# Function to connect to a device connect_device() { - prompt_for_mac "connect" "connect" "Enter the number of the device to connect: " "Connecting to device completed." "Failed to connect to device." + prompt_for_mac "connect" "Enter the number of the device to connect: " "Connecting to device completed." "Failed to connect to device." } -# Function to disconnect from a device disconnect_device() { - prompt_for_mac "disconnect" "disconnect" "Enter the number of the device to disconnect: " "Disconnecting from device completed." "Failed to disconnect from device." + prompt_for_mac "disconnect" "Enter the number of the device to disconnect: " "Disconnecting from device completed." "Failed to disconnect from device." } -# Function to remove a device remove_device() { - prompt_for_mac "remove" "remove" "Enter the number of the device to remove: " "Removing device completed." "Failed to remove device." + prompt_for_mac "remove" "Enter the number of the device to remove: " "Removing device completed." "Failed to remove device." } -# Initialize checkEnv checkEscalationTool setupBluetooth diff --git a/core/tabs/utils/create-bootable-usb.sh b/core/tabs/utils/create-bootable-usb.sh index f05830d3..b6f2a5eb 100644 --- a/core/tabs/utils/create-bootable-usb.sh +++ b/core/tabs/utils/create-bootable-usb.sh @@ -1,10 +1,9 @@ #!/bin/sh -e -. ../common-script.sh +. ../common-script.sh CONFIGURATION_URL="https://github.com/quickemu-project/quickget_configs/releases/download/daily/quickget_data.json" -# Function to display all available block devices list_devices() { printf "%b\n" "${YELLOW} Available devices and partitions: ${RC}" printf "\n" @@ -12,17 +11,21 @@ list_devices() { printf "\n" } +# shellcheck disable=SC2086 installDependencies() { DEPENDENCIES="xz gzip bzip2 jq" if ! command_exists ${DEPENDENCIES}; then printf "%b\n" "${YELLOW}Installing dependencies...${RC}" case "${PACKAGER}" in - apt-get|nala) - "${ESCALATION_TOOL}" "${PACKAGER}" install -y xz-utils gzip bzip2 jq;; - dnf|zypper) - "${ESCALATION_TOOL}" "${PACKAGER}" install -y ${DEPENDENCIES};; + apt-get | nala) + "${ESCALATION_TOOL}" "${PACKAGER}" install -y xz-utils gzip bzip2 jq + ;; + dnf | zypper) + "${ESCALATION_TOOL}" "${PACKAGER}" install -y ${DEPENDENCIES} + ;; pacman) - "${ESCALATION_TOOL}" "${PACKAGER}" -S --noconfirm --needed ${DEPENDENCIES};; + "${ESCALATION_TOOL}" "${PACKAGER}" -S --noconfirm --needed ${DEPENDENCIES} + ;; *) printf "%b\n" "${RED}Unsupported package manager.${RC}" exit 1 @@ -31,7 +34,6 @@ installDependencies() { fi } -# Function to ask whether to use local or online ISO choose_iso_source() { printf "%b\n" "${YELLOW} Do you want to use a local ISO or download online? ${RC}" printf "1) Download online\n" @@ -64,14 +66,17 @@ decompress_iso() { case "${ISO_ARCHIVE_FORMAT}" in xz) xz -d "${ISO_PATH}" - ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.xz//')";; + ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.xz//')" + ;; gz) gzip -d "${ISO_PATH}" - ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.gz//')";; + ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.gz//')" + ;; bz2) bzip2 -d "${ISO_PATH}" - ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.bz2//')";; - *) + ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.bz2//')" + ;; + *) printf "%b\n" "${RED}Unsupported archive format. Try manually decompressing the ISO and choosing it as a local file instead.${RC}" exit 1 ;; @@ -82,12 +87,14 @@ decompress_iso() { check_hash() { case "${#ISO_CHECKSUM}" in - 32) HASH_ALGO="md5sum";; - 40) HASH_ALGO="sha1sum";; - 64) HASH_ALGO="sha256sum";; - 128) HASH_ALGO="sha512sum";; - *) printf "%b\n" "${RED}Invalid checksum length. Skipping checksum verification.${RC}" - return;; + 32) HASH_ALGO="md5sum" ;; + 40) HASH_ALGO="sha1sum" ;; + 64) HASH_ALGO="sha256sum" ;; + 128) HASH_ALGO="sha512sum" ;; + *) + printf "%b\n" "${RED}Invalid checksum length. Skipping checksum verification.${RC}" + return + ;; esac printf "%b\n" "Checking ISO integrity using ${HASH_ALGO}..." if ! echo "${ISO_CHECKSUM} ${ISO_PATH}" | "${HASH_ALGO}" --check --status; then @@ -115,9 +122,9 @@ get_architecture() { printf "%b" "Select an option (1-3): " read -r ARCH case "${ARCH}" in - 1) ARCH="x86_64";; - 2) ARCH="aarch64";; - 3) ARCH="riscv64";; + 1) ARCH="x86_64" ;; + 2) ARCH="aarch64" ;; + 3) ARCH="riscv64" ;; *) printf "%b\n" "${RED}Invalid architecture selected. ${RC}" exit 1 @@ -209,27 +216,21 @@ get_online_iso() { fi } -write_iso(){ +write_iso() { clear - - # Ask whether to use a local or online ISO choose_iso_source clear - # Display all available devices list_devices - # Prompt user for USB device printf "%b" "Enter the USB device (e.g. /dev/sdX): " read -r USB_DEVICE - # Verify that the USB device exists if [ ! -b "$USB_DEVICE" ]; then printf "%b\n" "${RED}USB device not found: $USB_DEVICE${RC}" exit 1 fi - # Confirm the device selection with the user printf "%b" "${RED}WARNING: This will erase all data on ${USB_DEVICE}. Are you sure you want to continue? (y/N): ${RC}" read -r CONFIRMATION @@ -238,22 +239,19 @@ write_iso(){ exit 1 fi - # Display progress and create the bootable USB drive printf "%b\n" "${YELLOW}Creating bootable USB drive...${RC}" if ! "$ESCALATION_TOOL" dd if="$ISO_PATH" of="$USB_DEVICE" bs=4M status=progress oflag=sync; then printf "%b\n" "${RED}Failed to create bootable USB drive${RC}" exit 1 fi - # Sync to ensure all data is written if ! "$ESCALATION_TOOL" sync; then - printf "%b\n" "${RED}Failed to sync data${RC}" + printf "%b\n" "${RED}Failed to sync data${RC}" exit 1 fi printf "%b\n" "${GREEN}Bootable USB drive created successfully!${RC}" - # Eject the USB device printf "%b\n" "${YELLOW}Ejecting ${USB_DEVICE}...${RC}" if ! "$ESCALATION_TOOL" umount "${USB_DEVICE}"* 2>/dev/null; then printf "%b\n" "${RED}Failed to unmount ${USB_DEVICE}${RC}" diff --git a/core/tabs/utils/encrypt_decrypt_tool.sh b/core/tabs/utils/encrypt_decrypt_tool.sh index 46fead9d..fb6c53b3 100644 --- a/core/tabs/utils/encrypt_decrypt_tool.sh +++ b/core/tabs/utils/encrypt_decrypt_tool.sh @@ -1,16 +1,17 @@ #!/bin/sh -e +# shellcheck disable=SC2181 + . ../common-script.sh -# Function to display the menu + printf "%b\n" "${YELLOW}Ensuring OpenSSL is installed...${RC}" -# Install OpenSSL if ! command_exists openssl; then case "$PACKAGER" in pacman) "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm --needed openssl ;; - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" install -y openssl ;; dnf) @@ -40,7 +41,6 @@ show_menu() { printf "%b\n" "========================================================" } -# Function to encrypt a file encrypt_file() { printf "%b" "Enter the path to the file or directory to encrypt: " read -r INPUT_PATH @@ -49,7 +49,7 @@ encrypt_file() { printf "%b\n" "Path does not exist!" return fi - + printf "%b" "Enter the path for the encrypted file or directory: " read -r OUTPUT_PATH @@ -59,15 +59,12 @@ encrypt_file() { if [ -d "$INPUT_PATH" ]; then # Encrypt each file in the directory find "$INPUT_PATH" -type f | while read -r FILE; do - REL_PATH="${FILE#$INPUT_PATH/}" + REL_PATH="${FILE#"$INPUT_PATH"/}" OUTPUT_FILE="$OUTPUT_PATH/$REL_PATH.enc" mkdir -p "$(dirname "$OUTPUT_FILE")" openssl enc -aes-256-cbc -salt -pbkdf2 -in "$FILE" -out "$OUTPUT_FILE" -k "$PASSWORD" - if [ $? -eq 0 ]; then - printf "%b\n" "Encrypted: $OUTPUT_FILE" - else - printf "%b\n" "Failed to encrypt: $FILE" - fi + + printf "%b\n" "Encrypted: $OUTPUT_FILE" done else # Encrypt a single file @@ -77,15 +74,11 @@ encrypt_file() { fi mkdir -p "$(dirname "$OUTPUT_PATH")" openssl enc -aes-256-cbc -salt -pbkdf2 -in "$INPUT_PATH" -out "$OUTPUT_PATH" -k "$PASSWORD" - if [ $? -eq 0 ]; then - printf "%b\n" "Encrypted: $OUTPUT_PATH" - else - printf "%b\n" "Failed to encrypt: $INPUT_PATH" - fi + + printf "%b\n" "Encrypted: $OUTPUT_PATH" fi } -# Function to decrypt a file decrypt_file() { printf "%b" "Enter the path to the file or directory to decrypt: " read -r INPUT_PATH @@ -104,15 +97,12 @@ decrypt_file() { if [ -d "$INPUT_PATH" ]; then # Decrypt each file in the directory find "$INPUT_PATH" -type f -name '*.enc' | while read -r FILE; do - REL_PATH="${FILE#$INPUT_PATH/}" + REL_PATH="${FILE#"$INPUT_PATH"/}" OUTPUT_FILE="$OUTPUT_PATH/${REL_PATH%.enc}" mkdir -p "$(dirname "$OUTPUT_FILE")" openssl enc -aes-256-cbc -d -pbkdf2 -in "$FILE" -out "$OUTPUT_FILE" -k "$PASSWORD" - if [ $? -eq 0 ]; then - printf "%b\n" "Decrypted: $OUTPUT_FILE" - else - printf "%b\n" "Failed to decrypt: $FILE" - fi + + printf "%b\n" "Decrypted: $OUTPUT_FILE" done else # Decrypt a single file @@ -122,15 +112,12 @@ decrypt_file() { fi mkdir -p "$(dirname "$OUTPUT_PATH")" openssl enc -aes-256-cbc -d -pbkdf2 -in "$INPUT_PATH" -out "$OUTPUT_PATH" -k "$PASSWORD" - if [ $? -eq 0 ]; then - printf "%b\n" "Decrypted: $OUTPUT_PATH" - else - printf "%b\n" "Failed to decrypt: $INPUT_PATH" - fi + + printf "%b\n" "Decrypted: $OUTPUT_PATH" fi } -main(){ +main() { clear while true; do show_menu @@ -140,15 +127,18 @@ main(){ case $CHOICE in 1) encrypt_file ;; 2) decrypt_file ;; - 3) printf "%b\n" "Exiting..."; exit 0 ;; + 3) + printf "%b\n" "Exiting..." + exit 0 + ;; *) printf "%b\n" "Invalid choice. Please try again." ;; esac printf "%b\n" "Press [Enter] to continue..." - read -r dummy + read -r _ done } checkEnv checkEscalationTool -main \ No newline at end of file +main diff --git a/core/tabs/utils/monitor-control/auto_detect_displays.sh b/core/tabs/utils/monitor-control/auto_detect_displays.sh index 2613f99e..f1f2810b 100755 --- a/core/tabs/utils/monitor-control/auto_detect_displays.sh +++ b/core/tabs/utils/monitor-control/auto_detect_displays.sh @@ -8,7 +8,7 @@ auto_detect_displays() { if confirm_action "Auto-detect displays and set common resolution?"; then execute_command "xrandr --auto" - + monitors=$(detect_connected_monitors) first_monitor=$(echo "$monitors" | head -n 1) common_resolutions=$(get_unique_resolutions "$first_monitor") @@ -18,14 +18,14 @@ auto_detect_displays() { temp_common_resolutions=$(mktemp) temp_resolutions=$(mktemp) - printf "%b\n" "$common_resolutions" > "$temp_common_resolutions" - printf "%b\n" "$resolutions" > "$temp_resolutions" + printf "%b\n" "$common_resolutions" >"$temp_common_resolutions" + printf "%b\n" "$resolutions" >"$temp_resolutions" common_resolutions=$(comm -12 "$temp_common_resolutions" "$temp_resolutions") rm -f "$temp_common_resolutions" "$temp_resolutions" done - + if [ -z "$common_resolutions" ]; then printf "%b\n" "${RED}No common resolution found among connected monitors.${RC}" return diff --git a/core/tabs/utils/monitor-control/change_orientation.sh b/core/tabs/utils/monitor-control/change_orientation.sh index 00ac1b95..8bff43e7 100755 --- a/core/tabs/utils/monitor-control/change_orientation.sh +++ b/core/tabs/utils/monitor-control/change_orientation.sh @@ -47,7 +47,10 @@ change_orientation() { 2) orientation="left" ;; 3) orientation="right" ;; 4) orientation="inverted" ;; - *) printf "%b\n" "${RED}Invalid selection.${RC}"; return ;; + *) + printf "%b\n" "${RED}Invalid selection.${RC}" + return + ;; esac if confirm_action "Change orientation of $monitor_name to $orientation?"; then diff --git a/core/tabs/utils/monitor-control/disable_monitor.sh b/core/tabs/utils/monitor-control/disable_monitor.sh index 649d71a2..2159723a 100755 --- a/core/tabs/utils/monitor-control/disable_monitor.sh +++ b/core/tabs/utils/monitor-control/disable_monitor.sh @@ -31,7 +31,7 @@ disable_monitor() { monitor_name=$(echo "$monitor_array" | cut -d' ' -f"$monitor_choice") printf "%b\n" "${RED}Warning: Disabling the monitor will turn it off and may affect your display setup.${RC}" - + if confirm_action "Do you really want to disable ${GREEN}$monitor_name${RC}?"; then printf "%b\n" "${GREEN}Disabling $monitor_name${RC}" execute_command "xrandr --output $monitor_name --off" diff --git a/core/tabs/utils/monitor-control/enable_monitor.sh b/core/tabs/utils/monitor-control/enable_monitor.sh index ec4db8d6..00bc49e2 100755 --- a/core/tabs/utils/monitor-control/enable_monitor.sh +++ b/core/tabs/utils/monitor-control/enable_monitor.sh @@ -14,7 +14,7 @@ enable_monitor() { printf "%b\n" "${YELLOW} Enable Monitor${RC}" printf "%b\n" "${YELLOW}=========================================${RC}" printf "%b\n" "${YELLOW}Choose a monitor to enable: ${RC}" - + i=1 for monitor in $monitor_array; do printf "%b\n" "$i. ${GREEN}$monitor${RC}" diff --git a/core/tabs/utils/monitor-control/extend_displays.sh b/core/tabs/utils/monitor-control/extend_displays.sh index ebe729f3..3c96930e 100755 --- a/core/tabs/utils/monitor-control/extend_displays.sh +++ b/core/tabs/utils/monitor-control/extend_displays.sh @@ -11,7 +11,7 @@ extend_displays() { i=1 for monitor in $monitor_array; do if [ "$i" -gt 1 ]; then - prev_monitor=$(echo "$monitor_array" | cut -d' ' -f$((i-1))) + prev_monitor=$(echo "$monitor_array" | cut -d' ' -f$((i - 1))) if confirm_action "Extend $monitor to the right of $prev_monitor?"; then printf "%b\n" "${GREEN}Extending $monitor to the right of $prev_monitor${RC}" execute_command "xrandr --output $monitor --right-of $prev_monitor" diff --git a/core/tabs/utils/monitor-control/manage_arrangement.sh b/core/tabs/utils/monitor-control/manage_arrangement.sh index 5d73b1ff..2b00d7ac 100755 --- a/core/tabs/utils/monitor-control/manage_arrangement.sh +++ b/core/tabs/utils/monitor-control/manage_arrangement.sh @@ -45,7 +45,10 @@ manage_arrangement() { 2) position="--right-of" ;; 3) position="--above" ;; 4) position="--below" ;; - *) printf "%b\n" "${RED}Invalid selection.${RC}"; return ;; + *) + printf "%b\n" "${RED}Invalid selection.${RC}" + return + ;; esac printf "%b\n" "${YELLOW}Choose the reference monitor:${RC}" diff --git a/core/tabs/utils/monitor-control/set_brightness.sh b/core/tabs/utils/monitor-control/set_brightness.sh index 0b7a2a83..ce77e35b 100755 --- a/core/tabs/utils/monitor-control/set_brightness.sh +++ b/core/tabs/utils/monitor-control/set_brightness.sh @@ -29,7 +29,7 @@ adjust_monitor_brightness() { if ! echo "$monitor_choice" | grep -qE '^[0-9]+$'; then printf "%b\n" "${RED}Invalid selection. Please try again.${RC}" printf "Press [Enter] to continue..." - read -r dummy + read -r _ continue fi @@ -37,7 +37,7 @@ adjust_monitor_brightness() { if [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$monitor_count" ]; then printf "%b\n" "${RED}Invalid selection. Please try again.${RC}" printf "Press [Enter] to continue..." - read -r dummy + read -r _ continue fi diff --git a/core/tabs/utils/monitor-control/set_resolutions.sh b/core/tabs/utils/monitor-control/set_resolutions.sh index 84aea4d5..7d261848 100755 --- a/core/tabs/utils/monitor-control/set_resolutions.sh +++ b/core/tabs/utils/monitor-control/set_resolutions.sh @@ -4,7 +4,6 @@ . ../../common-script.sh -# Function to set resolutions set_resolutions() { monitor_list=$(detect_connected_monitors) monitor_array=$(echo "$monitor_list" | tr '\n' ' ') @@ -33,7 +32,7 @@ set_resolutions() { if ! echo "$monitor_choice" | grep -qE '^[0-9]+$' || [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$((i - 1))" ]; then printf "%b\n" "${RED}Invalid selection. Please try again.${RC}" printf "%b\n" "Press [Enter] to continue..." - read -r dummy + read -r _ continue fi @@ -41,13 +40,13 @@ set_resolutions() { resolutions=$(get_unique_resolutions "$monitor_name" | sort -rn -t'x' -k1,1 -k2,2) temp_res_file=$(mktemp) - printf "%b\n" "$resolutions" | awk '{print NR " " $0}' > "$temp_res_file" + printf "%b\n" "$resolutions" | awk '{print NR " " $0}' >"$temp_res_file" i=1 while read -r resolution; do - echo "$resolution" >> "$temp_res_file" + echo "$resolution" >>"$temp_res_file" i=$((i + 1)) - done < "$temp_res_file" + done <"$temp_res_file" clear printf "%b\n" "${YELLOW}=========================================${RC}" diff --git a/core/tabs/utils/numlock.sh b/core/tabs/utils/numlock.sh index 742ceeb7..ccf1c5ca 100755 --- a/core/tabs/utils/numlock.sh +++ b/core/tabs/utils/numlock.sh @@ -8,8 +8,8 @@ # Create a script to toggle numlock create_file() { - printf "%b\n" "Creating script..." - "$ESCALATION_TOOL" tee "/usr/local/bin/numlock" >/dev/null <<'EOF' + printf "%b\n" "Creating script..." + "$ESCALATION_TOOL" tee "/usr/local/bin/numlock" >/dev/null <<'EOF' #!/bin/bash for tty in /dev/tty{1..6} @@ -18,13 +18,13 @@ do done EOF - "$ESCALATION_TOOL" chmod +x /usr/local/bin/numlock + "$ESCALATION_TOOL" chmod +x /usr/local/bin/numlock } # Create a systemd service to run the script on boot create_service() { - printf "%b\n" "Creating service..." - "$ESCALATION_TOOL" tee "/etc/systemd/system/numlock.service" >/dev/null <<'EOF' + printf "%b\n" "Creating service..." + "$ESCALATION_TOOL" tee "/etc/systemd/system/numlock.service" >/dev/null <<'EOF' [Unit] Description=numlock @@ -39,24 +39,23 @@ EOF } numlockSetup() { - # Check if the script and service files exists - if [ ! -f "/usr/local/bin/numlock" ]; then - create_file - fi + if [ ! -f "/usr/local/bin/numlock" ]; then + create_file + fi - if [ ! -f "/etc/systemd/system/numlock.service" ]; then - create_service - fi + if [ ! -f "/etc/systemd/system/numlock.service" ]; then + create_service + fi - printf "%b" "Do you want to enable Numlock on boot? (y/N): " - read -r confirm - if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then - "$ESCALATION_TOOL" systemctl enable numlock.service --quiet - printf "%b\n" "Numlock will be enabled on boot" - else - "$ESCALATION_TOOL" systemctl disable numlock.service --quiet - printf "%b\n" "Numlock will not be enabled on boot" - fi + printf "%b" "Do you want to enable Numlock on boot? (y/N): " + read -r confirm + if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then + "$ESCALATION_TOOL" systemctl enable numlock.service --quiet + printf "%b\n" "Numlock will be enabled on boot" + else + "$ESCALATION_TOOL" systemctl disable numlock.service --quiet + printf "%b\n" "Numlock will not be enabled on boot" + fi } checkEnv diff --git a/core/tabs/utils/ollama.sh b/core/tabs/utils/ollama.sh index 35453ba3..2535c8e2 100644 --- a/core/tabs/utils/ollama.sh +++ b/core/tabs/utils/ollama.sh @@ -11,7 +11,7 @@ installollama() { else printf "%b\n" "${YELLOW}Installing ollama...${RC}" curl -fsSL https://ollama.com/install.sh | sh - "$ESCALATION_TOOL" systemctl start ollama + "$ESCALATION_TOOL" systemctl start ollama fi } @@ -52,27 +52,26 @@ display_models() { printf "%b\n" "16. Solar - 10.7B (6.1GB)" } -# Function to select model based on user input select_model() { choice="$1" case $choice in - 1) printf "%b\n" "llama3.1";; - 2) printf "%b\n" "llama3.1:70b";; - 3) printf "%b\n" "llama3.1:405b";; - 4) printf "%b\n" "phi3";; - 5) printf "%b\n" "phi3:medium";; - 6) printf "%b\n" "gemma2:2b";; - 7) printf "%b\n" "gemma2";; - 8) printf "%b\n" "gemma2:27b";; - 9) printf "%b\n" "mistral";; - 10) printf "%b\n" "moondream";; - 11) printf "%b\n" "neural-chat";; - 12) printf "%b\n" "starling-lm";; - 13) printf "%b\n" "codellama";; - 14) printf "%b\n" "llama2-uncensored";; - 15) printf "%b\n" "llava";; - 16) printf "%b\n" "solar";; - *) printf "%b\n" "$choice";; + 1) printf "%b\n" "llama3.1" ;; + 2) printf "%b\n" "llama3.1:70b" ;; + 3) printf "%b\n" "llama3.1:405b" ;; + 4) printf "%b\n" "phi3" ;; + 5) printf "%b\n" "phi3:medium" ;; + 6) printf "%b\n" "gemma2:2b" ;; + 7) printf "%b\n" "gemma2" ;; + 8) printf "%b\n" "gemma2:27b" ;; + 9) printf "%b\n" "mistral" ;; + 10) printf "%b\n" "moondream" ;; + 11) printf "%b\n" "neural-chat" ;; + 12) printf "%b\n" "starling-lm" ;; + 13) printf "%b\n" "codellama" ;; + 14) printf "%b\n" "llama2-uncensored" ;; + 15) printf "%b\n" "llava" ;; + 16) printf "%b\n" "solar" ;; + *) printf "%b\n" "$choice" ;; esac } @@ -82,10 +81,11 @@ run_model() { printf "%b\n" "${GREEN}Installed Models${RC}" installed_models=$(ollama list) - printf "%b\n" "${installed_models}" + printf "%b\n" "$installed_models" printf "%b\n" "${YELLOW}Custom Models${RC}" - custom_models=$(ollama list | grep 'custom-model-prefix') + custom_models=$(ollama list | grep 'custom-model-prefix') + printf "%b\n" "$custom_models" printf "%b" "Select a model to run: " printf "%b" "Enter the number corresponding to the model or enter the name of a custom model: " @@ -103,7 +103,6 @@ create_model() { printf "%b\n" "${YELLOW}Let's create a new model in Ollama!${RC}" display_models - # Prompt for base model printf "%b" "Enter the base model (e.g. '13' for codellama): " read -r base_model @@ -112,11 +111,9 @@ create_model() { printf "%b\n" "${YELLOW}Running the model: $model...${RC}" ollama pull "$model" - # Prompt for custom model name printf "%b" "Enter a name for the new customized model: " read -r custom_model_name - # Prompt for temperature setting printf "%b" "Enter the desired temperature (higher values are more creative, lower values are more coherent, e.g., 1): " read -r temperature @@ -124,13 +121,11 @@ create_model() { temperature=${temperature:-1} fi - # Prompt for system message printf "%b" "Enter the system message for the model customization (e.g., 'You are Mario from Super Mario Bros. Answer as Mario, the assistant, only.'): " read -r system_message - # Create the Modelfile printf "%b\n" "${YELLOW}Creating the Modelfile...${RC}" - cat << EOF > Modelfile + cat <Modelfile FROM $base_model # set the temperature to $temperature @@ -142,13 +137,11 @@ $system_message """ EOF - # Create the model in Ollama printf "%b\n" "${YELLOW}Creating the model in Ollama...${RC}" ollama create "$custom_model_name" -f Modelfile printf "%b\n" "${GREEN}Model '$custom_model_name' created successfully.${RC}" } -# Function to remove a model remove_model() { clear printf "%b\n" "${GREEN}Installed Models${RC}" @@ -189,13 +182,16 @@ menu() { 2) show_model_info ;; 3) create_model ;; 4) run_model ;; - 5) remove_model;; - 6) printf "%b\n" "${GREEN}Exiting...${RC}"; exit 0 ;; + 5) remove_model ;; + 6) + printf "%b\n" "${GREEN}Exiting...${RC}" + exit 0 + ;; *) printf "%b\n" "${RED}Invalid choice. Please try again.${RC}" ;; esac printf "%b\n" "${YELLOW}Press Enter to continue...${RC}" - read -r dummy + read -r _ done } @@ -203,4 +199,3 @@ checkEnv checkEscalationTool installollama menu - diff --git a/core/tabs/utils/power-profile.sh b/core/tabs/utils/power-profile.sh index 536f7c69..711c6d9a 100644 --- a/core/tabs/utils/power-profile.sh +++ b/core/tabs/utils/power-profile.sh @@ -34,7 +34,7 @@ installAutoCpufreq() { cd auto-cpufreq printf "%b\n" "${YELLOW}Running auto-cpufreq installer...${RC}" "$ESCALATION_TOOL" ./auto-cpufreq-installer - "$ESCALATION_TOOL" auto-cpufreq --install + "$ESCALATION_TOOL" auto-cpufreq --install cd .. fi diff --git a/core/tabs/utils/samba-ssh-setup.sh b/core/tabs/utils/samba-ssh-setup.sh index 52004a27..5b6ae76e 100755 --- a/core/tabs/utils/samba-ssh-setup.sh +++ b/core/tabs/utils/samba-ssh-setup.sh @@ -1,24 +1,24 @@ #!/bin/sh -e # Load common script functions -. ../common-script.sh +. ../common-script.sh # Function to install packages based on the package manager install_package() { - PACKAGE=$1 - if ! command_exists "$PACKAGE"; then + package=$1 + if ! command_exists "$package"; then case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm "$PACKAGE" + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm "$package" ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y "$PACKAGE" + "$ESCALATION_TOOL" "$PACKAGER" install -y "$package" ;; esac else - echo "$PACKAGE is already installed." + echo "$package is already installed." fi -} +} # Function to setup and configure SSH setup_ssh() { @@ -26,18 +26,18 @@ setup_ssh() { # Detect package manager and install appropriate SSH package case "$PACKAGER" in - apt-get|nala) - install_package openssh-server - SSH_SERVICE="ssh" - ;; - pacman) - install_package openssh - SSH_SERVICE="sshd" - ;; - *) - install_package openssh-server - SSH_SERVICE="sshd" - ;; + apt-get | nala) + install_package openssh-server + SSH_SERVICE="ssh" + ;; + pacman) + install_package openssh + SSH_SERVICE="sshd" + ;; + *) + install_package openssh-server + SSH_SERVICE="sshd" + ;; esac # Enable and start the appropriate SSH service @@ -60,7 +60,7 @@ setup_ssh() { # Function to setup and configure Samba setup_samba() { printf "%b\n" "${YELLOW}Setting up Samba...${RC}" - + # Install Samba if not installed install_package samba @@ -112,7 +112,7 @@ setup_samba() { "$ESCALATION_TOOL" smbpasswd -a "$SAMBA_USER" # Configure Samba settings - "$ESCALATION_TOOL" tee "$SAMBA_CONFIG" > /dev/null </dev/null < /dev/null + } | "$ESCALATION_TOOL" tee "$SERVICE_FILE" >/dev/null # Set permissions and reload systemd "$ESCALATION_TOOL" chmod 644 "$SERVICE_FILE" @@ -260,17 +260,20 @@ main() { 6) start_service ;; 7) stop_service ;; 8) enable_service ;; - 9) disable_service ;; + 9) disable_service ;; 10) create_service_from_external ;; - 11) printf "%b\n" "Exiting..."; exit 0 ;; + 11) + printf "%b\n" "Exiting..." + exit 0 + ;; *) printf "%b\n" "Invalid choice. Please try again." ;; esac printf "%b\n" "Press [Enter] to continue..." - read -r dummy + read -r _ done } checkEnv checkEscalationTool -main \ No newline at end of file +main diff --git a/core/tabs/utils/ssh.sh b/core/tabs/utils/ssh.sh index e5a899ef..ae348ed7 100644 --- a/core/tabs/utils/ssh.sh +++ b/core/tabs/utils/ssh.sh @@ -2,28 +2,25 @@ . ../common-script.sh -# Check if ~/.ssh/config exists, if not, create it if [ ! -f ~/.ssh/config ]; then mkdir -p "$HOME/.ssh" touch "$HOME/.ssh/config" chmod 600 "$HOME/.ssh/config" fi -# Function to show available hosts from ~/.ssh/config show_available_hosts() { printf "%b\n" "Available Systems:" grep -E "^Host " "$HOME/.ssh/config" | awk '{print $2}' printf "%b\n" "-------------------" } -# Function to ask for host details ask_for_host_details() { printf "%b" "Enter Host Alias: " read -r host_alias - printf "%b" "Enter Remote Host (hostname or IP): " + printf "%b" "Enter Remote Host (hostname or IP): " read -r host printf "%b" "Enter Remote User: " - read -r user + read -r user { printf "%b\n" "Host $host_alias" printf "%b\n" " HostName $host" @@ -31,11 +28,10 @@ ask_for_host_details() { printf "%b\n" " IdentityFile ~/.ssh/id_rsa" printf "%b\n" " StrictHostKeyChecking no" printf "%b\n" " UserKnownHostsFile=/dev/null" - } >> ~/.ssh/config + } >>~/.ssh/config printf "%b\n" "Host $host_alias added successfully." } -# Function to generate SSH key if not exists generate_ssh_key() { if [ ! -f ~/.ssh/id_rsa ]; then printf "%b\n" "SSH key not found, generating one..." @@ -45,28 +41,26 @@ generate_ssh_key() { fi } -# Function to share the SSH public key with the remote host share_ssh_key() { - printf "%b" "Enter the alias of the host to copy the key to: " + printf "%b" "Enter the alias of the host to copy the key to: " read -r host_alias printf "%b\n" "Copying SSH key to $host_alias..." ssh-copy-id "$host_alias" printf "%b\n" "SSH key copied to $host_alias successfully." } -# Function to disable password authentication and allow only SSH keys -#repeated twice as changes should take place when in commented state or modified state. disable_password_auth() { printf "%b\n" "Disabling SSH password authentication and enabling key-only login..." - printf "%b\n" "Enter the alias of the host: " + printf "%b\n" "Enter the alias of the host: " read -r host_alias printf "\n" + # shellcheck disable=SC2029 ssh "$host_alias" " - "$ESCALATION_TOOL" -S sed -i 's/^#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config && - "$ESCALATION_TOOL" -S sed -i 's/^PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config && - "$ESCALATION_TOOL" -S sed -i 's/^#PubkeyAuthentication no/PubkeyAuthentication yes/' /etc/ssh/sshd_config && - "$ESCALATION_TOOL" -S sed -i 's/^PubkeyAuthentication no/PubkeyAuthentication yes/' /etc/ssh/sshd_config && - "$ESCALATION_TOOL" -S systemctl restart sshd + $ESCALATION_TOOL -S sed -i 's/^#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config && + $ESCALATION_TOOL -S sed -i 's/^PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config && + $ESCALATION_TOOL -S sed -i 's/^#PubkeyAuthentication no/PubkeyAuthentication yes/' /etc/ssh/sshd_config && + $ESCALATION_TOOL -S sed -i 's/^PubkeyAuthentication no/PubkeyAuthentication yes/' /etc/ssh/sshd_config && + $ESCALATION_TOOL -S systemctl restart sshd " printf "%b\n" "PasswordAuthentication set to no and PubkeyAuthentication set to yes." } @@ -76,12 +70,13 @@ enable_password_auth() { printf "%b\n" "Enter the alias of the host: " read -r host_alias printf "\n" + # shellcheck disable=SC2029 ssh "$host_alias" " - "$ESCALATION_TOOL" -S sed -i 's/^#PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config && - "$ESCALATION_TOOL" -S sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config && - "$ESCALATION_TOOL" -S sed -i 's/^#PubkeyAuthentication yes/PubkeyAuthentication no/' /etc/ssh/sshd_config && - "$ESCALATION_TOOL" -S sed -i 's/^PubkeyAuthentication yes/PubkeyAuthentication no/' /etc/ssh/sshd_config && - "$ESCALATION_TOOL" -S systemctl restart sshd + $ESCALATION_TOOL -S sed -i 's/^#PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config && + $ESCALATION_TOOL -S sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config && + $ESCALATION_TOOL -S sed -i 's/^#PubkeyAuthentication yes/PubkeyAuthentication no/' /etc/ssh/sshd_config && + $ESCALATION_TOOL -S sed -i 's/^PubkeyAuthentication yes/PubkeyAuthentication no/' /etc/ssh/sshd_config && + $ESCALATION_TOOL -S systemctl restart sshd " printf "%b\n" "PasswordAuthentication set to yes and PubkeyAuthentication set to no." } @@ -95,18 +90,19 @@ check_password_auth() { # Function to run a command on a remote server run_remote_command() { - printf "%b" "Enter the alias of the host: " + printf "%b" "Enter the alias of the host: " read -r host_alias - printf "%b" "Enter the command to run: " + printf "%b" "Enter the command to run: " read -r remote_command + # shellcheck disable=SC2029 ssh "$host_alias" "$remote_command" } # Function to copy a file to a remote server copy_file_to_remote() { - printf "%b" "Enter the local file path: " + printf "%b" "Enter the local file path: " read -r local_file - printf "%b" "Enter the alias of the host: " + printf "%b" "Enter the alias of the host: " read -r host_alias printf "%b" "Enter the remote destination path: " read -r remote_path @@ -116,31 +112,30 @@ copy_file_to_remote() { # Function to copy a directory to a remote server copy_directory_to_remote() { printf "%b" "Enter the local directory path: " - read -r local_dir - printf "%b" "Enter the alias of the host: " + read -r local_dir + printf "%b" "Enter the alias of the host: " read -r host_alias printf "%b" "Enter the remote destination path: " read -r remote_path scp -r "$local_dir" "$host_alias:$remote_path" } - # Function to move a file to a remote server (copy and delete local) move_file_to_remote() { printf "%b" "Enter the local file path: " read -r local_file printf "%b" "Enter the alias of the host: " read -r host_alias - printf "%b" "Enter the remote destination path: " + printf "%b" "Enter the remote destination path: " read -r remote_path scp "$local_file" "$host_alias:$remote_path" && rm "$local_file" } # Function to move a directory to a remote server (copy and delete local) move_directory_to_remote() { - printf "%b" "Enter the local directory path: " + printf "%b" "Enter the local directory path: " read -r local_dir - printf "%b" "Enter the alias of the host: " + printf "%b" "Enter the alias of the host: " read -r host_alias printf "%b" "Enter the remote destination path: " read -r remote_path @@ -158,7 +153,7 @@ remove_system() { # Function to view SSH configuration view_ssh_config() { printf "%b\n" "Enter the alias of the host to view (or press Enter to view all): " - read -r host_alias + read -r host_alias if [ -z "$host_alias" ]; then cat ~/.ssh/config else @@ -179,11 +174,11 @@ backup_files() { # Function to sync directories with remote host sync_directories() { - printf "%b" "Enter the local directory path: " + printf "%b" "Enter the local directory path: " read -r local_dir - printf "%b" "Enter the alias of the host: " + printf "%b" "Enter the alias of the host: " read -r host_alias - printf "%b" "Enter the remote directory path: " + printf "%b" "Enter the remote directory path: " read -r remote_dir rsync -avz "$local_dir" "$host_alias:$remote_dir" } @@ -222,32 +217,35 @@ show_menu() { # Function to execute the selected SSH operation main() { while true; do - show_menu - read -r choice - case $choice in - 1) ask_for_host_details ;; - 2) show_available_hosts && printf "%b" "Enter the alias of the host to connect to: " && read -r host_alias; ssh "$host_alias" ;; - 3) generate_ssh_key ;; - 4) share_ssh_key ;; - 5) disable_password_auth ;; - 6) enable_password_auth ;; - 7) check_password_auth ;; - 8) check_ssh_key_authentication ;; - 9) run_remote_command ;; - 10) copy_file_to_remote ;; - 11) copy_directory_to_remote ;; - 12) move_file_to_remote ;; - 13) move_directory_to_remote ;; - 14) remove_system ;; - 15) view_ssh_config ;; - 16) backup_files ;; - 17) sync_directories ;; - 18) exit ;; - *) printf "%b\n" "Invalid choice. Please try again." ;; - esac -done + show_menu + read -r choice + case $choice in + 1) ask_for_host_details ;; + 2) + show_available_hosts && printf "%b" "Enter the alias of the host to connect to: " && read -r host_alias + ssh "$host_alias" + ;; + 3) generate_ssh_key ;; + 4) share_ssh_key ;; + 5) disable_password_auth ;; + 6) enable_password_auth ;; + 7) check_password_auth ;; + 8) check_ssh_key_authentication ;; + 9) run_remote_command ;; + 10) copy_file_to_remote ;; + 11) copy_directory_to_remote ;; + 12) move_file_to_remote ;; + 13) move_directory_to_remote ;; + 14) remove_system ;; + 15) view_ssh_config ;; + 16) backup_files ;; + 17) sync_directories ;; + 18) exit ;; + *) printf "%b\n" "Invalid choice. Please try again." ;; + esac + done } checkEnv checkEscalationTool -main \ No newline at end of file +main diff --git a/core/tabs/utils/timeshift.sh b/core/tabs/utils/timeshift.sh index afe2c71d..0336aa9a 100644 --- a/core/tabs/utils/timeshift.sh +++ b/core/tabs/utils/timeshift.sh @@ -2,7 +2,6 @@ . ../common-script.sh -# Function to install Timeshift install_timeshift() { clear printf "%b\n" "${YELLOW}Checking if Timeshift is installed...${RC}" @@ -21,7 +20,6 @@ install_timeshift() { fi } -# Function to display the menu display_menu() { clear printf "%b\n" "${CYAN}Timeshift CLI Automation${RC}" @@ -34,19 +32,16 @@ display_menu() { printf "%b\n" "${CYAN}7) Exit${RC}" } -# Function to list snapshots list_snapshots() { printf "%b\n" "${CYAN}Listing snapshots...${RC}" "$ESCALATION_TOOL" timeshift --list-snapshots } -# Function to list devices list_devices() { printf "%b\n" "${CYAN}Listing available devices...${RC}" "$ESCALATION_TOOL" timeshift --list-devices } -# Function to create a new snapshot create_snapshot() { printf "%b" "${CYAN}Enter a comment for the snapshot (optional): ${RC}" read -r COMMENT @@ -64,14 +59,9 @@ create_snapshot() { "$ESCALATION_TOOL" timeshift --create --comments "$COMMENT" --tags "$TAG" fi - if [ $? -eq 0 ]; then - printf "%b\n" "${GREEN}Snapshot created successfully.${RC}" - else - printf "%b\n" "${RED}Snapshot creation failed.${RC}" - fi + printf "%b\n" "${GREEN}Snapshot created successfully.${RC}" } -# Function to restore a snapshot restore_snapshot() { list_snapshots @@ -90,14 +80,9 @@ restore_snapshot() { "$ESCALATION_TOOL" timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --grub-device "$GRUB_DEVICE" --yes fi - if [ $? -eq 0 ]; then - printf "%b\n" "${GREEN}Snapshot restored successfully.${RC}" - else - printf "%b\n" "${RED}Snapshot restore failed.${RC}" - fi + printf "%b\n" "${GREEN}Snapshot restored successfully.${RC}" } -# Function to delete a snapshot delete_snapshot() { list_snapshots @@ -107,14 +92,9 @@ delete_snapshot() { printf "%b\n" "${YELLOW}Deleting snapshot $SNAPSHOT...${RC}" "$ESCALATION_TOOL" timeshift --delete --snapshot "$SNAPSHOT" --yes - if [ $? -eq 0 ]; then - printf "%b\n" "${GREEN}Snapshot deleted successfully.${RC}" - else - printf "%b\n" "${RED}Snapshot deletion failed.${RC}" - fi + printf "%b\n" "${GREEN}Snapshot deleted successfully.${RC}" } -# Function to delete all snapshots delete_all_snapshots() { printf "%b\n" "${RED}WARNING: This will delete all snapshots!${RC}" printf "%b" "${CYAN}Are you sure? (y/N): ${RC}" @@ -123,11 +103,7 @@ delete_all_snapshots() { if [ "$CONFIRMATION" = "y" ] || [ "$CONFIRMATION" = "Y" ]; then printf "%b\n" "${CYAN}Deleting all snapshots...${RC}" "$ESCALATION_TOOL" timeshift --delete-all --yes - if [ $? -eq 0 ]; then - printf "%b\n" "${GREEN}All snapshots deleted successfully.${RC}" - else - printf "%b\n" "${RED}Failed to delete snapshots.${RC}" - fi + printf "%b\n" "${GREEN}All snapshots deleted successfully.${RC}" else printf "%b\n" "${RED}Operation cancelled.${RC}" fi @@ -146,15 +122,18 @@ main_menu() { 4) restore_snapshot ;; 5) delete_snapshot ;; 6) delete_all_snapshots ;; - 7) printf "%b\n" "${GREEN}Exiting...${RC}"; exit 0 ;; + 7) + printf "%b\n" "${GREEN}Exiting...${RC}" + exit 0 + ;; *) printf "%b\n" "${RED}Invalid option. Please try again.${RC}" ;; esac printf "%b\n" "${CYAN}Press Enter to continue...${RC}" - read -r dummy + read -r _ done } checkEnv checkEscalationTool -install_timeshift +install_timeshift main_menu diff --git a/core/tabs/utils/user-account-manager/add_to_group.sh b/core/tabs/utils/user-account-manager/add_to_group.sh index 665cf72a..07720505 100755 --- a/core/tabs/utils/user-account-manager/add_to_group.sh +++ b/core/tabs/utils/user-account-manager/add_to_group.sh @@ -33,7 +33,7 @@ addToGroup() { groups_to_add=$(echo "$groups" | tr ' ' ',') printf "%b" "${YELLOW}Are you sure you want to add user $username to $groups_to_add? [Y/n]: ${RC}" - read -r confirm + read -r _ confirmAction || exit 1 "$ESCALATION_TOOL" usermod -aG "$groups_to_add" "$username" @@ -44,4 +44,4 @@ addToGroup() { checkEnv checkEscalationTool checkGroups -addToGroup \ No newline at end of file +addToGroup diff --git a/core/tabs/utils/user-account-manager/add_user.sh b/core/tabs/utils/user-account-manager/add_user.sh index 26435f41..b3984fb3 100755 --- a/core/tabs/utils/user-account-manager/add_user.sh +++ b/core/tabs/utils/user-account-manager/add_user.sh @@ -11,7 +11,7 @@ createUser() { printf "%b" "${YELLOW}Enter the username: ${RC}" read -r username - if ! echo "$username" | grep '^[a-zA-Z]*$' > /dev/null; then + if ! echo "$username" | grep '^[a-zA-Z]*$' >/dev/null; then printf "%b\n" "${RED}Username must only contain letters and cannot contain spaces.${RC}" exit 1 fi diff --git a/core/tabs/utils/user-account-manager/change_password.sh b/core/tabs/utils/user-account-manager/change_password.sh index a909a5b2..4421db8e 100755 --- a/core/tabs/utils/user-account-manager/change_password.sh +++ b/core/tabs/utils/user-account-manager/change_password.sh @@ -12,12 +12,12 @@ changePassword() { printf "%b" "${YELLOW}Enter the username: ${RC}" read -r username - if id "$username" > /dev/null 2>&1; then + if id "$username" >/dev/null 2>&1; then printf "%b" "${YELLOW}Enter new password: ${RC}" read -r password printf "%b" "${YELLOW}Are you sure you want to change password for ""$username""? [Y/n]: ${RC}" - read -r confirm + read -r _ confirmAction || exit 1 echo "$username:$password" | "$ESCALATION_TOOL" chpasswd @@ -30,4 +30,4 @@ changePassword() { checkEnv checkEscalationTool -changePassword \ No newline at end of file +changePassword diff --git a/core/tabs/utils/user-account-manager/delete_user.sh b/core/tabs/utils/user-account-manager/delete_user.sh index aee9482e..c92b7a96 100755 --- a/core/tabs/utils/user-account-manager/delete_user.sh +++ b/core/tabs/utils/user-account-manager/delete_user.sh @@ -12,12 +12,12 @@ deleteUser() { printf "%b" "${YELLOW}Enter the username: ${RC}" read -r username - if id "$username" > /dev/null 2>&1; then + if id "$username" >/dev/null 2>&1; then printf "%b" "${YELLOW}Are you sure you want to delete user ""$username""? [Y/n]: ${RC}" - read -r confirm + read -r _ confirmAction || exit 1 - $ESCALATION_TOOL userdel --remove "$username" 2>/dev/null + "$ESCALATION_TOOL" userdel --remove "$username" 2>/dev/null printf "%b\n" "${GREEN}User $username deleted successfully${RC}" else printf "%b\n" "${RED}User $username does not exist.${RC}" @@ -27,4 +27,4 @@ deleteUser() { checkEnv checkEscalationTool -deleteUser \ No newline at end of file +deleteUser diff --git a/core/tabs/utils/user-account-manager/remove_from_group.sh b/core/tabs/utils/user-account-manager/remove_from_group.sh index 23935b5e..3d4067a8 100755 --- a/core/tabs/utils/user-account-manager/remove_from_group.sh +++ b/core/tabs/utils/user-account-manager/remove_from_group.sh @@ -12,7 +12,7 @@ removeFromGroup() { printf "%b" "${YELLOW}Enter the username: ${RC}" read -r username - if ! id "$username" > /dev/null 2>&1; then + if ! id "$username" >/dev/null 2>&1; then printf "%b\n" "${RED}User $username does not exist.${RC}" exit 1 fi @@ -34,14 +34,15 @@ removeFromGroup() { groups_to_remove=$(echo "$groups" | tr ' ' ',') printf "%b" "${YELLOW}Are you sure you want to remove user $username from $groups_to_remove? [Y/n]: ${RC}" - read -r confirm + read -r _ confirmAction || exit 1 - $ESCALATION_TOOL usermod -rG $groups_to_remove "$username" + # shellcheck disable=SC2086 + "$ESCALATION_TOOL" usermod -rG $groups_to_remove "$username" printf "%b\n" "${GREEN}User successfully removed from $groups_to_remove${RC}" } checkEnv checkEscalationTool -removeFromGroup \ No newline at end of file +removeFromGroup diff --git a/core/tabs/utils/utility_functions.sh b/core/tabs/utils/utility_functions.sh index b9ed3127..4f3bebd1 100755 --- a/core/tabs/utils/utility_functions.sh +++ b/core/tabs/utils/utility_functions.sh @@ -2,7 +2,6 @@ . ../../common-script.sh -# Function to check xrandr is installed setup_xrandr() { printf "%b\n" "${YELLOW}Installing xrandr...${RC}" if ! command_exists xrandr; then @@ -10,7 +9,7 @@ setup_xrandr() { pacman) "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm xorg-xrandr ;; - apt-get|nala) + apt-get | nala) "$ESCALATION_TOOL" "$PACKAGER" install -y x11-xserver-utils ;; *) @@ -22,56 +21,52 @@ setup_xrandr() { fi } -# Function to execute xrandr commands and handle errors execute_command() { command="$1" printf "Executing: %s\n" "$command" eval "$command" 2>&1 | tee /tmp/xrandr.log | tail -n 20 + #shellcheck disable=SC2181 if [ $? -ne 0 ]; then printf "%b\n" "${RED}An error occurred while executing the command. Check /tmp/xrandr.log for details.${RC}" fi } -# Function to detect connected monitors detect_connected_monitors() { xrandr_output=$(xrandr) printf "%b\n" "$xrandr_output" | grep " connected" | awk '{print $1}' } -# Function to get the current brightness for a monitor get_current_brightness() { monitor="$1" xrandr --verbose | grep -A 10 "^$monitor connected" | grep "Brightness:" | awk '{print $2}' } -# Function to get resolutions for a monitor get_unique_resolutions() { monitor="$1" xrandr_output=$(xrandr) available_resolutions=$(printf "%s" "$xrandr_output" | sed -n "/$monitor connected/,/^[^ ]/p" | grep -oP '\d+x\d+' | sort -u) - + standard_resolutions="1920x1080 1280x720 1600x900 2560x1440 3840x2160" - + temp_file=$(mktemp) - printf "%s" "$available_resolutions" > "$temp_file" - + printf "%s" "$available_resolutions" >"$temp_file" + filtered_standard_resolutions=$(printf "%s" "$standard_resolutions" | tr ' ' '\n' | grep -xF -f "$temp_file") - + rm "$temp_file" - + available_res_file=$(mktemp) filtered_standard_res_file=$(mktemp) - printf "%s" "$available_resolutions" | sort > "$available_res_file" - printf "%s" "$filtered_standard_resolutions" | sort > "$filtered_standard_res_file" - + printf "%s" "$available_resolutions" | sort >"$available_res_file" + printf "%s" "$filtered_standard_resolutions" | sort >"$filtered_standard_res_file" + remaining_resolutions=$(comm -23 "$available_res_file" "$filtered_standard_res_file") - + rm "$available_res_file" "$filtered_standard_res_file" - + printf "%b\n" "$filtered_standard_resolutions\n$remaining_resolutions" | head -n 10 } -# Function to prompt for confirmation confirm_action() { action="$1" printf "%b\n" "${CYAN}$action${RC}" diff --git a/core/tabs/utils/wifi-control.sh b/core/tabs/utils/wifi-control.sh index 14faec0a..8000b578 100755 --- a/core/tabs/utils/wifi-control.sh +++ b/core/tabs/utils/wifi-control.sh @@ -2,7 +2,6 @@ . ../common-script.sh -# Function to check if NetworkManager is installed setupNetworkManager() { printf "%b\n" "${YELLOW}Installing NetworkManager...${RC}" if ! command_exists nmcli; then @@ -20,19 +19,17 @@ setupNetworkManager() { else printf "%b\n" "${YELLOW}NetworkManager is already installed.${RC}" fi - - # Check if NetworkManager service is running + if ! systemctl is-active --quiet NetworkManager; then printf "%b\n" "${YELLOW}NetworkManager service is not running. Starting it now...${RC}" "$ESCALATION_TOOL" systemctl start NetworkManager - + if systemctl is-active --quiet NetworkManager; then printf "%b\n" "${GREEN}NetworkManager service started successfully.${RC}" fi fi } -# Function to display the main menu main_menu() { while true; do clear @@ -61,7 +58,6 @@ main_menu() { done } -# Function to scan for WiFi networks scan_networks() { clear printf "%b\n" "${YELLOW}Scanning for WiFi networks...${RC}" @@ -73,36 +69,33 @@ scan_networks() { echo "$networks" | awk -F: '{printf("%d. SSID: %-25s \n", NR, $1)}' fi printf "%b\n" "Press any key to return to the main menu..." - read -r dummy + read -r _ } -# Function to turn WiFi on wifi_on() { clear printf "%b\n" "${YELLOW}Turning WiFi on...${RC}" - nmcli radio wifi on && { + if nmcli radio wifi on; then printf "%b\n" "${GREEN}WiFi is now turned on.${RC}" - } || { + else printf "%b\n" "${RED}Failed to turn on WiFi.${RC}" - } + fi printf "%b\n" "Press any key to return to the main menu..." - read -r dummy + read -r _ } -# Function to turn WiFi off wifi_off() { clear printf "%b\n" "${YELLOW}Turning WiFi off...${RC}" - nmcli radio wifi off && { + if nmcli radio wifi off; then printf "%b\n" "${GREEN}WiFi is now turned off.${RC}" - } || { + else printf "%b\n" "${RED}Failed to turn off WiFi.${RC}" - } + fi printf "%b\n" "Press any key to return to the main menu..." - read -r dummy + read -r _ } -# Function to prompt for WiFi network selection prompt_for_network() { action=$1 prompt_msg=$2 @@ -116,19 +109,19 @@ prompt_for_network() { if [ -z "$networks" ]; then printf "%b\n" "${RED}No networks available. Please scan for networks first.${RC}" printf "%b\n" "Press any key to return to the main menu..." - read -r dummy + read -r _ rm -f "$temp_file" return fi - echo "$networks" > "$temp_file" + echo "$networks" >"$temp_file" i=1 while IFS= read -r network; do ssid=$(echo "$network" | awk -F: '{print $1}') printf "%b\n" "$i. SSID: " "$ssid" i=$((i + 1)) - done < "$temp_file" + done <"$temp_file" printf "%b\n" "0. Exit to main menu" printf "%b" "$prompt_msg" @@ -140,40 +133,36 @@ prompt_for_network() { printf "%b" "Enter password for SSID: " "$ssid" read -r password printf "\n" - nmcli dev wifi connect "$ssid" password "$password" && { - printf "%b\n" "${GREEN}$success_msg${RC}" - } || { - printf "%b\n" "${RED}$failure_msg${RC}" - } + if nmcli dev wifi connect "$ssid" password "$password"; then + printf "%b\n" "${GREEN}${success_msg}${RC}" + else + printf "%b\n" "${RED}${failure_msg}${RC}" + fi fi else printf "%b\n" "${RED}Invalid choice. Please try again.${RC}" fi printf "%b\n" "Press any key to return to the selection menu..." - read -r dummy + read -r _ done rm -f "$temp_file" } -# Function to connect to a WiFi network connect_network() { prompt_for_network "connect" "Enter the number of the network to connect: " "Connected to the network successfully." "Failed to connect to the network." } -# Function to disconnect from a WiFi network disconnect_network() { prompt_for_network "disconnect" "Enter the number of the network to disconnect: " "Disconnected from the network successfully." "Failed to disconnect from the network." } -# Function to remove a WiFi connection remove_network() { prompt_for_network "remove" "Enter the number of the network to remove: " "Network removed successfully." "Failed to remove the network." } -# Initialize checkEnv checkEscalationTool setupNetworkManager -main_menu \ No newline at end of file +main_menu diff --git a/start.sh b/start.sh index 3c412fb6..007e4585 100755 --- a/start.sh +++ b/start.sh @@ -2,50 +2,50 @@ # Prevent execution if this script was only partially downloaded { -rc='\033[0m' -red='\033[0;31m' + rc='\033[0m' + red='\033[0;31m' -check() { - exit_code=$1 - message=$2 + check() { + exit_code=$1 + message=$2 - if [ "$exit_code" -ne 0 ]; then - printf '%sERROR: %s%s\n' "$red" "$message" "$rc" - exit 1 - fi + if [ "$exit_code" -ne 0 ]; then + printf '%sERROR: %s%s\n' "$red" "$message" "$rc" + exit 1 + fi - unset exit_code - unset message -} + unset exit_code + unset message + } -findArch() { - case "$(uname -m)" in - x86_64|amd64) arch="x86_64" ;; - aarch64|arm64) arch="aarch64" ;; - *) check 1 "Unsupported architecture" - esac -} + findArch() { + case "$(uname -m)" in + x86_64 | amd64) arch="x86_64" ;; + aarch64 | arm64) arch="aarch64" ;; + *) check 1 "Unsupported architecture" ;; + esac + } -getUrl() { - case "${arch}" in - x86_64) echo "https://github.com/ChrisTitusTech/linutil/releases/latest/download/linutil";; - *) echo "https://github.com/ChrisTitusTech/linutil/releases/latest/download/linutil-${arch}";; - esac -} + getUrl() { + case "${arch}" in + x86_64) echo "https://github.com/ChrisTitusTech/linutil/releases/latest/download/linutil" ;; + *) echo "https://github.com/ChrisTitusTech/linutil/releases/latest/download/linutil-${arch}" ;; + esac + } -findArch -temp_file=$(mktemp) -check $? "Creating the temporary file" + findArch + temp_file=$(mktemp) + check $? "Creating the temporary file" -curl -fsL "$(getUrl)" -o "$temp_file" -check $? "Downloading linutil" + curl -fsL "$(getUrl)" -o "$temp_file" + check $? "Downloading linutil" -chmod +x "$temp_file" -check $? "Making linutil executable" + chmod +x "$temp_file" + check $? "Making linutil executable" -"$temp_file" -check $? "Executing linutil" + "$temp_file" + check $? "Executing linutil" -rm -f "$temp_file" -check $? "Deleting the temporary file" + rm -f "$temp_file" + check $? "Deleting the temporary file" } # End of wrapping diff --git a/startdev.sh b/startdev.sh index 5aad12ad..6070226a 100755 --- a/startdev.sh +++ b/startdev.sh @@ -2,76 +2,76 @@ # Prevent execution if this script was only partially downloaded { -RC='\033[0m' -RED='\033[0;31m' + RC='\033[0m' + RED='\033[0;31m' -# Function to fetch the latest release tag from the GitHub API -get_latest_release() { - latest_release=$(curl -s https://api.github.com/repos/ChrisTitusTech/linutil/releases | - grep -oP '"tag_name": "\K[^"]*' | - head -n 1) - if [ -z "$latest_release" ]; then - printf "%b\n" "Error fetching release data" >&2 - return 1 - fi - printf "%b\n" "$latest_release" -} + # Function to fetch the latest release tag from the GitHub API + get_latest_release() { + latest_release=$(curl -s https://api.github.com/repos/ChrisTitusTech/linutil/releases | + grep -oP '"tag_name": "\K[^"]*' | + head -n 1) + if [ -z "$latest_release" ]; then + printf "%b\n" "Error fetching release data" >&2 + return 1 + fi + printf "%b\n" "$latest_release" + } -# Function to redirect to the latest pre-release version -redirect_to_latest_pre_release() { - latest_release=$(get_latest_release) - if [ -n "$latest_release" ]; then - url="https://github.com/ChrisTitusTech/linutil/releases/download/$latest_release/linutil" - else - printf "%b\n" 'Unable to determine latest pre-release version.' >&2 - printf "%b\n" "Using latest Full Release" - url="https://github.com/ChrisTitusTech/linutil/releases/latest/download/linutil" - fi - addArch - printf "%b\n" "Using URL: $url" -} + # Function to redirect to the latest pre-release version + redirect_to_latest_pre_release() { + latest_release=$(get_latest_release) + if [ -n "$latest_release" ]; then + url="https://github.com/ChrisTitusTech/linutil/releases/download/$latest_release/linutil" + else + printf "%b\n" 'Unable to determine latest pre-release version.' >&2 + printf "%b\n" "Using latest Full Release" + url="https://github.com/ChrisTitusTech/linutil/releases/latest/download/linutil" + fi + addArch + printf "%b\n" "Using URL: $url" + } -check() { - exit_code=$1 - message=$2 + check() { + exit_code=$1 + message=$2 - if [ "$exit_code" -ne 0 ]; then - printf "%b\n" "${RED}ERROR: $message${RC}" - exit 1 - fi -} + if [ "$exit_code" -ne 0 ]; then + printf "%b\n" "${RED}ERROR: $message${RC}" + exit 1 + fi + } -addArch() { - case "${arch}" in - x86_64);; - *) url="${url}-${arch}";; - esac -} + addArch() { + case "${arch}" in + x86_64) ;; + *) url="${url}-${arch}" ;; + esac + } -findArch() { - case "$(uname -m)" in - x86_64|amd64) arch="x86_64" ;; - aarch64|arm64) arch="aarch64" ;; - *) check 1 "Unsupported architecture" - esac -} + findArch() { + case "$(uname -m)" in + x86_64 | amd64) arch="x86_64" ;; + aarch64 | arm64) arch="aarch64" ;; + *) check 1 "Unsupported architecture" ;; + esac + } -findArch -redirect_to_latest_pre_release + findArch + redirect_to_latest_pre_release -TMPFILE=$(mktemp) -check $? "Creating the temporary file" + TMPFILE=$(mktemp) + check $? "Creating the temporary file" -printf "%b\n" "Downloading linutil from $url" -curl -fsL "$url" -o "$TMPFILE" -check $? "Downloading linutil" + printf "%b\n" "Downloading linutil from $url" + curl -fsL "$url" -o "$TMPFILE" + check $? "Downloading linutil" -chmod +x "$TMPFILE" -check $? "Making linutil executable" + chmod +x "$TMPFILE" + check $? "Making linutil executable" -"$TMPFILE" -check $? "Executing linutil" + "$TMPFILE" + check $? "Executing linutil" -rm -f "$TMPFILE" -check $? "Deleting the temporary file" + rm -f "$TMPFILE" + check $? "Deleting the temporary file" } # End of wrapping