From c997a3d89e6908a6fb76d15da03ee43a6ed4fdda Mon Sep 17 00:00:00 2001 From: Jeevitha Kannan K S Date: Sun, 13 Oct 2024 18:37:30 +0530 Subject: [PATCH 1/6] Add root check --- Cargo.lock | 11 +++++++++++ tui/Cargo.toml | 1 + tui/src/main.rs | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 266ed837..9e1eefa6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -510,6 +510,7 @@ dependencies = [ "portable-pty", "rand", "ratatui", + "sudo", "temp-dir", "tree-sitter-bash", "tree-sitter-highlight", @@ -1006,6 +1007,16 @@ dependencies = [ "syn", ] +[[package]] +name = "sudo" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88bd84d4c082e18e37fef52c0088e4407dabcef19d23a607fb4b5ee03b7d5b83" +dependencies = [ + "libc", + "log", +] + [[package]] name = "syn" version = "2.0.77" diff --git a/tui/Cargo.toml b/tui/Cargo.toml index 40d3c357..d5532b11 100644 --- a/tui/Cargo.toml +++ b/tui/Cargo.toml @@ -30,6 +30,7 @@ tree-sitter-highlight = "0.24.2" tree-sitter-bash = "0.23.1" anstyle = "1.0.8" ansi-to-tui = "6.0.0" +sudo = "0.6.0" zips = "0.1.7" [build-dependencies] diff --git a/tui/src/main.rs b/tui/src/main.rs index 801e3b1d..2c309ee8 100644 --- a/tui/src/main.rs +++ b/tui/src/main.rs @@ -36,6 +36,12 @@ struct Args { } fn main() -> io::Result<()> { + if sudo::check() != sudo::RunningAs::User { + eprintln!("Error: This program is not intended to be run with elevated privileges."); + eprintln!("Please run this program as a regular user to ensure proper security and functionality."); + std::process::exit(1); + } + let args = Args::parse(); let mut state = AppState::new(args.theme, args.override_validation); From 937cf1522b3e1643a348365edd20c0c64b890bbf Mon Sep 17 00:00:00 2001 From: Carter Canedy Date: Sun, 13 Oct 2024 14:29:59 -0700 Subject: [PATCH 2/6] implement root check --- tui/src/main.rs | 79 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 71 insertions(+), 8 deletions(-) diff --git a/tui/src/main.rs b/tui/src/main.rs index 2c309ee8..8320cc6d 100644 --- a/tui/src/main.rs +++ b/tui/src/main.rs @@ -15,12 +15,18 @@ use std::{ use crate::theme::Theme; use clap::Parser; use crossterm::{ - event::{self, DisableMouseCapture, Event, KeyEventKind}, + event::{self, DisableMouseCapture, Event, KeyCode, KeyEvent, KeyEventKind}, style::ResetColor, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, ExecutableCommand, }; -use ratatui::{backend::CrosstermBackend, Terminal}; +use ratatui::{ + backend::CrosstermBackend, + layout::{Alignment, Constraint, Layout}, + style::Stylize, + widgets::{Paragraph, Wrap}, + Terminal, +}; use state::AppState; // Linux utility toolbox @@ -36,12 +42,6 @@ struct Args { } fn main() -> io::Result<()> { - if sudo::check() != sudo::RunningAs::User { - eprintln!("Error: This program is not intended to be run with elevated privileges."); - eprintln!("Please run this program as a regular user to ensure proper security and functionality."); - std::process::exit(1); - } - let args = Args::parse(); let mut state = AppState::new(args.theme, args.override_validation); @@ -67,6 +67,69 @@ fn run( terminal: &mut Terminal>, state: &mut AppState, ) -> io::Result<()> { + if sudo::check() == sudo::RunningAs::Root { + terminal.draw(|frame| { + let root_warn = Paragraph::new( + r#" +!!!!!!!!!!!!!! YOU ARE ABOUT TO RUN LINUTIL AS ROOT !!!!!!!!!!!!!! + +This utility prioritizes compatibility with non-root environments. +Some scripts may work without any issues, some may not. +You have been warned! + +!!!!!!!!!!!!!!!!!!!!!! PROCEED WITH CAUTION !!!!!!!!!!!!!!!!!!!!!! + +Press [y] to continue, [n] to abort +"#, + ) + .on_black() + .white() + .alignment(Alignment::Center) + .wrap(Wrap { trim: true }); + + let rects = Layout::vertical([ + Constraint::Fill(1), + Constraint::Length(10), + Constraint::Fill(1), + ]) + .split(frame.area()); + + let centered = rects[1]; + + frame.render_widget(root_warn, centered); + })?; + + loop { + match event::read()? { + Event::Key( + KeyEvent { + code: KeyCode::Char('y'), + .. + } + | KeyEvent { + code: KeyCode::Char('Y'), + .. + }, + ) => { + break; + } + Event::Key( + KeyEvent { + code: KeyCode::Char('n'), + .. + } + | KeyEvent { + code: KeyCode::Char('N'), + .. + }, + ) => { + return Ok(()); + } + _ => {} + } + } + } + loop { terminal.draw(|frame| state.draw(frame)).unwrap(); // Wait for an event From f472ab954424d783e6477a88ec95a6dfca8bd2ec Mon Sep 17 00:00:00 2001 From: Jeevitha Kannan K S Date: Mon, 14 Oct 2024 08:44:33 +0530 Subject: [PATCH 3/6] Implement escalation function and root checks --- .../Developer-tools/githubdesktop-setup.sh | 22 ++++----- .../Developer-tools/meld-setup.sh | 4 +- .../Developer-tools/neovim-setup.sh | 8 ++-- .../Developer-tools/ngrok-setup.sh | 10 +++- .../Developer-tools/sublime-setup.sh | 22 ++++----- .../Developer-tools/vscode-setup.sh | 22 ++++----- .../Developer-tools/vscodium-setup.sh | 22 ++++----- .../applications-setup/alacritty-setup.sh | 4 +- .../applications-setup/android-debloat.sh | 10 ++-- .../tabs/applications-setup/browsers/brave.sh | 28 +++++------ .../applications-setup/browsers/chromium.sh | 4 +- .../applications-setup/browsers/firefox.sh | 8 ++-- .../browsers/google-chrome.sh | 14 +++--- .../applications-setup/browsers/librewolf.sh | 20 ++++---- core/tabs/applications-setup/browsers/lynx.sh | 4 +- .../applications-setup/browsers/thorium.sh | 10 ++-- .../applications-setup/browsers/vivaldi.sh | 4 +- .../communication-apps/discord-setup.sh | 10 ++-- .../communication-apps/jitsi-setup.sh | 12 ++--- .../communication-apps/signal-setup.sh | 16 +++---- .../communication-apps/telegram-setup.sh | 4 +- .../communication-apps/thunderbird-setup.sh | 4 +- core/tabs/applications-setup/docker-setup.sh | 18 ++++---- .../tabs/applications-setup/dwmtitus-setup.sh | 26 +++++------ .../applications-setup/fastfetch-setup.sh | 6 +-- core/tabs/applications-setup/grub-theme.sh | 2 +- core/tabs/applications-setup/kitty-setup.sh | 4 +- .../applications-setup/linutil-installer.sh | 6 +-- .../applications-setup/linutil-updater.sh | 6 +-- core/tabs/applications-setup/mybash-setup.sh | 6 +-- .../office-suites/freeoffice.sh | 12 ++--- .../office-suites/libreoffice.sh | 4 +- .../office-suites/onlyoffice.sh | 2 +- .../applications-setup/pdf-suites/evince.sh | 4 +- .../applications-setup/pdf-suites/okular.sh | 4 +- .../pdf-suites/pdfstudio.sh | 2 +- .../pdf-suites/pdfstudioviewer.sh | 2 +- core/tabs/applications-setup/rofi-setup.sh | 4 +- core/tabs/applications-setup/setup-flatpak.sh | 12 ++--- .../tabs/applications-setup/waydroid-setup.sh | 40 ++++++++-------- core/tabs/applications-setup/zsh-setup.sh | 8 ++-- core/tabs/common-script.sh | 14 ++++++ core/tabs/security/firewall-baselines.sh | 18 ++++---- core/tabs/system-setup/arch/paru-setup.sh | 4 +- core/tabs/system-setup/arch/yay-setup.sh | 4 +- core/tabs/system-setup/compile-setup.sh | 30 ++++++------ .../tabs/system-setup/fedora/configure-dnf.sh | 8 ++-- .../system-setup/fedora/multimedia-codecs.sh | 6 +-- .../fedora/nvidia-proprietary-driver-setup.sh | 6 +-- .../system-setup/fedora/rpm-fusion-setup.sh | 8 ++-- .../system-setup/fedora/virtualization.sh | 2 +- core/tabs/system-setup/gaming-setup.sh | 46 +++++++++---------- core/tabs/system-setup/global-theme.sh | 10 ++-- core/tabs/system-setup/remove-snaps.sh | 8 ++-- core/tabs/system-setup/system-cleanup.sh | 32 ++++++------- core/tabs/system-setup/system-update.sh | 38 +++++++-------- core/tabs/system-setup/terminus-tty.sh | 24 +++++----- core/tabs/utils/auto-login.sh | 36 +++++++-------- core/tabs/utils/auto-mount.sh | 14 +++--- core/tabs/utils/bluetooth-control.sh | 6 +-- core/tabs/utils/create-bootable-usb.sh | 10 ++-- core/tabs/utils/encrypt_decrypt_tool.sh | 8 ++-- core/tabs/utils/numlock.sh | 10 ++-- core/tabs/utils/ollama.sh | 2 +- core/tabs/utils/power-profile.sh | 14 +++--- core/tabs/utils/samba-ssh-setup.sh | 28 +++++------ core/tabs/utils/service-control.sh | 46 +++++++++---------- core/tabs/utils/ssh.sh | 20 ++++---- core/tabs/utils/timeshift.sh | 22 ++++----- .../user-account-manager/add_to_group.sh | 2 +- .../utils/user-account-manager/add_user.sh | 4 +- .../user-account-manager/change_password.sh | 2 +- core/tabs/utils/utility_functions.sh | 6 +-- core/tabs/utils/wifi-control.sh | 8 ++-- tui/src/main.rs | 6 +++ 75 files changed, 479 insertions(+), 453 deletions(-) diff --git a/core/tabs/applications-setup/Developer-tools/githubdesktop-setup.sh b/core/tabs/applications-setup/Developer-tools/githubdesktop-setup.sh index 966cb914..73aee0d5 100644 --- a/core/tabs/applications-setup/Developer-tools/githubdesktop-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/githubdesktop-setup.sh @@ -7,24 +7,24 @@ installGithubDesktop() { printf "%b\n" "${YELLOW}Installing Github Desktop...${RC}" case "$PACKAGER" in apt-get|nala) - curl -fsSL https://apt.packages.shiftkey.dev/gpg.key | gpg --dearmor | "$ESCALATION_TOOL" tee /usr/share/keyrings/shiftkey-packages.gpg > /dev/null - printf "%b\n" 'deb [arch=amd64 signed-by=/usr/share/keyrings/shiftkey-packages.gpg] https://apt.packages.shiftkey.dev/ubuntu/ any main\n' | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/shiftkey-packages.list > /dev/null - "$ESCALATION_TOOL" "$PACKAGER" update - "$ESCALATION_TOOL" "$PACKAGER" install -y github-desktop + curl -fsSL https://apt.packages.shiftkey.dev/gpg.key | gpg --dearmor | elevated_execution 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' | elevated_execution tee /etc/apt/sources.list.d/shiftkey-packages.list > /dev/null + elevated_execution "$PACKAGER" update + elevated_execution "$PACKAGER" install -y github-desktop ;; zypper) - "$ESCALATION_TOOL" rpm --import https://rpm.packages.shiftkey.dev/gpg.key - printf "%b\n" '[shiftkey-packages]\nname=GitHub Desktop\nbaseurl=https://rpm.packages.shiftkey.dev/rpm/\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://rpm.packages.shiftkey.dev/gpg.key\n' | "$ESCALATION_TOOL" tee /etc/zypp/repos.d/shiftkey-packages.repo > /dev/null - "$ESCALATION_TOOL" "$PACKAGER" refresh - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install github-desktop + elevated_execution 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' | elevated_execution tee /etc/zypp/repos.d/shiftkey-packages.repo > /dev/null + elevated_execution "$PACKAGER" refresh + elevated_execution "$PACKAGER" --non-interactive install github-desktop ;; pacman) "$AUR_HELPER" -S --needed --noconfirm github-desktop-bin ;; dnf) - "$ESCALATION_TOOL" rpm --import https://rpm.packages.shiftkey.dev/gpg.key - printf "%b\n" '[shiftkey-packages]\nname=GitHub Desktop\nbaseurl=https://rpm.packages.shiftkey.dev/rpm/\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://rpm.packages.shiftkey.dev/gpg.key\n' | "$ESCALATION_TOOL" tee /etc/yum.repos.d/shiftkey-packages.repo > /dev/null - "$ESCALATION_TOOL" "$PACKAGER" install -y github-desktop + elevated_execution 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' | elevated_execution tee /etc/yum.repos.d/shiftkey-packages.repo > /dev/null + elevated_execution "$PACKAGER" install -y github-desktop ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/applications-setup/Developer-tools/meld-setup.sh b/core/tabs/applications-setup/Developer-tools/meld-setup.sh index bd0bb3c2..c35c43ce 100644 --- a/core/tabs/applications-setup/Developer-tools/meld-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/meld-setup.sh @@ -7,10 +7,10 @@ installMeld() { printf "%b\n" "${YELLOW}Installing Meld...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm meld + elevated_execution "$PACKAGER" -S --needed --noconfirm meld ;; apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" -y install meld + elevated_execution "$PACKAGER" -y install meld ;; *) . ../setup-flatpak.sh diff --git a/core/tabs/applications-setup/Developer-tools/neovim-setup.sh b/core/tabs/applications-setup/Developer-tools/neovim-setup.sh index ac0d2637..0147d638 100755 --- a/core/tabs/applications-setup/Developer-tools/neovim-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/neovim-setup.sh @@ -18,16 +18,16 @@ installNeovim() { 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 + elevated_execution "$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 + elevated_execution "$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 + elevated_execution mv /tmp/nvim.appimage /usr/local/bin/nvim ;; dnf|zypper) - "$ESCALATION_TOOL" "$PACKAGER" install -y neovim ripgrep fzf python3-virtualenv luarocks golang ShellCheck git + elevated_execution "$PACKAGER" install -y neovim ripgrep fzf python3-virtualenv luarocks golang ShellCheck git ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/applications-setup/Developer-tools/ngrok-setup.sh b/core/tabs/applications-setup/Developer-tools/ngrok-setup.sh index 1ba6ff66..47cfaa1e 100644 --- a/core/tabs/applications-setup/Developer-tools/ngrok-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/ngrok-setup.sh @@ -5,7 +5,13 @@ installNgrok() { if ! command_exists ngrok; then printf "%b\n" "${YELLOW}Installing Ngrok...${RC}" - curl -sSLO https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz | "$ESCALATION_TOOL" tar -xz -C /usr/local/bin + curl -sSLO https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz + if [ -f "ngrok-v3-stable-linux-amd64.tgz" ]; then + elevated_execution tar -xz -f ngrok-v3-stable-linux-amd64.tgz -C /usr/local/bin + else + printf "%b\n" "${RED}Error occurred when downloading.${RC}" + exit 1 + fi else printf "%b\n" "${GREEN}Ngrok is already installed.${RC}" fi @@ -13,4 +19,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..5eaad0ea 100644 --- a/core/tabs/applications-setup/Developer-tools/sublime-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/sublime-setup.sh @@ -7,24 +7,24 @@ installSublime() { printf "%b\n" "${YELLOW}Installing Sublime...${RC}" case "$PACKAGER" in 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 - "$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text + curl -fsSL https://download.sublimetext.com/sublimehq-pub.gpg | elevated_execution apt-key add - + echo "deb https://download.sublimetext.com/ apt/stable/" | elevated_execution tee /etc/apt/sources.list.d/sublime-text.list + elevated_execution "$PACKAGER" update + elevated_execution "$PACKAGER" install -y sublime-text ;; zypper) - "$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg - "$ESCALATION_TOOL" "$PACKAGER" addrepo -g -f https://download.sublimetext.com/rpm/dev/x86_64/sublime-text.repo - "$ESCALATION_TOOL" "$PACKAGER" refresh - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install sublime-text + elevated_execution rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg + elevated_execution "$PACKAGER" addrepo -g -f https://download.sublimetext.com/rpm/dev/x86_64/sublime-text.repo + elevated_execution "$PACKAGER" refresh + elevated_execution "$PACKAGER" --non-interactive install sublime-text ;; pacman) "$AUR_HELPER" -S --needed --noconfirm sublime-text-4 ;; dnf) - "$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg - "$ESCALATION_TOOL" "$PACKAGER" config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo - "$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text + elevated_execution rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg + elevated_execution "$PACKAGER" config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo + elevated_execution "$PACKAGER" install -y sublime-text ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/applications-setup/Developer-tools/vscode-setup.sh b/core/tabs/applications-setup/Developer-tools/vscode-setup.sh index 018616a6..7b1f36c8 100644 --- a/core/tabs/applications-setup/Developer-tools/vscode-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/vscode-setup.sh @@ -8,25 +8,25 @@ installVsCode() { case "$PACKAGER" in 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 + elevated_execution 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" | elevated_execution 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 + elevated_execution "$PACKAGER" update + elevated_execution "$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 - "$ESCALATION_TOOL" "$PACKAGER" refresh - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install code + elevated_execution 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' | elevated_execution tee /etc/zypp/repos.d/vscode.repo > /dev/null + elevated_execution "$PACKAGER" refresh + elevated_execution "$PACKAGER" --non-interactive install code ;; pacman) "$AUR_HELPER" -S --needed --noconfirm visual-studio-code-bin ;; 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 - "$ESCALATION_TOOL" "$PACKAGER" install -y code + elevated_execution 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' | elevated_execution tee /etc/yum.repos.d/vscode.repo > /dev/null + elevated_execution "$PACKAGER" install -y code ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/applications-setup/Developer-tools/vscodium-setup.sh b/core/tabs/applications-setup/Developer-tools/vscodium-setup.sh index 5b5615ca..6c04cb9b 100644 --- a/core/tabs/applications-setup/Developer-tools/vscodium-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/vscodium-setup.sh @@ -7,24 +7,24 @@ installVsCodium() { printf "%b\n" "${YELLOW}Installing VS Codium...${RC}" case "$PACKAGER" in 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 - "$ESCALATION_TOOL" "$PACKAGER" install -y codium + curl -fsSL https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg | gpg --dearmor | elevated_execution 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' | elevated_execution tee /etc/apt/sources.list.d/vscodium.list + elevated_execution "$PACKAGER" update + elevated_execution "$PACKAGER" install -y codium ;; zypper) - "$ESCALATION_TOOL" rpmkeys --import https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/-/raw/master/pub.gpg - printf "%b\n" "[gitlab.com_paulcarroty_vscodium_repo]\nname=gitlab.com_paulcarroty_vscodium_repo\nbaseurl=https://download.vscodium.com/rpms/\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/-/raw/master/pub.gpg\nmetadata_expire=1h" | "$ESCALATION_TOOL" tee -a /etc/zypp/repos.d/vscodium.repo - "$ESCALATION_TOOL" "$PACKAGER" refresh - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install codium + elevated_execution rpmkeys --import https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/-/raw/master/pub.gpg + printf "%b\n" "[gitlab.com_paulcarroty_vscodium_repo]\nname=gitlab.com_paulcarroty_vscodium_repo\nbaseurl=https://download.vscodium.com/rpms/\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/-/raw/master/pub.gpg\nmetadata_expire=1h" | elevated_execution tee -a /etc/zypp/repos.d/vscodium.repo + elevated_execution "$PACKAGER" refresh + elevated_execution "$PACKAGER" --non-interactive install codium ;; pacman) "$AUR_HELPER" -S --noconfirm vscodium-bin ;; dnf) - "$ESCALATION_TOOL" rpmkeys --import https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/-/raw/master/pub.gpg - printf "%b\n" "[gitlab.com_paulcarroty_vscodium_repo]\nname=download.vscodium.com\nbaseurl=https://download.vscodium.com/rpms/\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/-/raw/master/pub.gpg\nmetadata_expire=1h" | "$ESCALATION_TOOL" tee -a /etc/yum.repos.d/vscodium.repo - "$ESCALATION_TOOL" "$PACKAGER" install -y codium + elevated_execution rpmkeys --import https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/-/raw/master/pub.gpg + printf "%b\n" "[gitlab.com_paulcarroty_vscodium_repo]\nname=download.vscodium.com\nbaseurl=https://download.vscodium.com/rpms/\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/-/raw/master/pub.gpg\nmetadata_expire=1h" | elevated_execution tee -a /etc/yum.repos.d/vscodium.repo + elevated_execution "$PACKAGER" install -y codium ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/applications-setup/alacritty-setup.sh b/core/tabs/applications-setup/alacritty-setup.sh index 25558fed..fd980b72 100755 --- a/core/tabs/applications-setup/alacritty-setup.sh +++ b/core/tabs/applications-setup/alacritty-setup.sh @@ -7,10 +7,10 @@ installAlacritty() { printf "%b\n" "${YELLOW}Installing Alacritty...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm alacritty + elevated_execution "$PACKAGER" -S --needed --noconfirm alacritty ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y alacritty + elevated_execution "$PACKAGER" install -y alacritty ;; esac else diff --git a/core/tabs/applications-setup/android-debloat.sh b/core/tabs/applications-setup/android-debloat.sh index b4e1073a..4cfe1afa 100644 --- a/core/tabs/applications-setup/android-debloat.sh +++ b/core/tabs/applications-setup/android-debloat.sh @@ -7,13 +7,13 @@ install_adb() { printf "%b\n" "${YELLOW}Installing ADB...${RC}." case "$PACKAGER" in apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" install -y android-sdk-platform-tools + elevated_execution "$PACKAGER" install -y android-sdk-platform-tools ;; pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm android-tools + elevated_execution "$PACKAGER" -S --noconfirm android-tools ;; dnf|zypper) - "$ESCALATION_TOOL" "$PACKAGER" install -y android-tools + elevated_execution "$PACKAGER" install -y android-tools ;; *) printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" @@ -29,8 +29,8 @@ install_universal_android_debloater() { if ! command_exists uad; then printf "%b\n" "${YELLOW}Installing Universal Android Debloater...${RC}." curl -sSLo "${HOME}/uad" "https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/releases/download/v1.1.0/uad-ng-linux" - "$ESCALATION_TOOL" chmod +x "${HOME}/uad" - "$ESCALATION_TOOL" mv "${HOME}/uad" /usr/local/bin/uad + elevated_execution chmod +x "${HOME}/uad" + elevated_execution mv "${HOME}/uad" /usr/local/bin/uad else printf "%b\n" "${GREEN}Universal Android Debloater is already installed. Run 'uad' command to execute.${RC}" fi diff --git a/core/tabs/applications-setup/browsers/brave.sh b/core/tabs/applications-setup/browsers/brave.sh index 8a7eab40..6f97f56b 100644 --- a/core/tabs/applications-setup/browsers/brave.sh +++ b/core/tabs/applications-setup/browsers/brave.sh @@ -7,27 +7,27 @@ installBrave() { printf "%b\n" "${YELLOW}Installing Brave...${RC}" case "$PACKAGER" in 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 - "$ESCALATION_TOOL" "$PACKAGER" update - "$ESCALATION_TOOL" "$PACKAGER" install -y brave-browser + elevated_execution "$PACKAGER" install -y curl + elevated_execution 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" | elevated_execution tee /etc/apt/sources.list.d/brave-browser-release.list + elevated_execution "$PACKAGER" update + elevated_execution "$PACKAGER" install -y brave-browser ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" install -y curl - "$ESCALATION_TOOL" rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc - "$ESCALATION_TOOL" "$PACKAGER" addrepo https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo - "$ESCALATION_TOOL" "$PACKAGER" refresh - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install brave-browser + elevated_execution "$PACKAGER" install -y curl + elevated_execution rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc + elevated_execution "$PACKAGER" addrepo https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo + elevated_execution "$PACKAGER" refresh + elevated_execution "$PACKAGER" --non-interactive install brave-browser ;; pacman) "$AUR_HELPER" -S --needed --noconfirm brave-bin ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y dnf-plugins-core - "$ESCALATION_TOOL" "$PACKAGER" config-manager --add-repo https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo - "$ESCALATION_TOOL" rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc - "$ESCALATION_TOOL" "$PACKAGER" install -y brave-browser + elevated_execution "$PACKAGER" install -y dnf-plugins-core + elevated_execution "$PACKAGER" config-manager --add-repo https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo + elevated_execution rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc + elevated_execution "$PACKAGER" install -y brave-browser ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/applications-setup/browsers/chromium.sh b/core/tabs/applications-setup/browsers/chromium.sh index e929dbc9..91fd531c 100644 --- a/core/tabs/applications-setup/browsers/chromium.sh +++ b/core/tabs/applications-setup/browsers/chromium.sh @@ -7,10 +7,10 @@ if ! command_exists chromium; then printf "%b\n" "${YELLOW}Installing Chromium...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm chromium + elevated_execution "$PACKAGER" -S --needed --noconfirm chromium ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y chromium + elevated_execution "$PACKAGER" install -y chromium ;; esac else diff --git a/core/tabs/applications-setup/browsers/firefox.sh b/core/tabs/applications-setup/browsers/firefox.sh index 67980858..a86ee03e 100644 --- a/core/tabs/applications-setup/browsers/firefox.sh +++ b/core/tabs/applications-setup/browsers/firefox.sh @@ -7,16 +7,16 @@ installFirefox() { printf "%b\n" "${YELLOW}Installing Mozilla Firefox...${RC}" case "$PACKAGER" in apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" install -y firefox-esr + elevated_execution "$PACKAGER" install -y firefox-esr ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install MozillaFirefox + elevated_execution "$PACKAGER" --non-interactive install MozillaFirefox ;; pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm firefox + elevated_execution "$PACKAGER" -S --needed --noconfirm firefox ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y firefox + elevated_execution "$PACKAGER" install -y firefox ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/applications-setup/browsers/google-chrome.sh b/core/tabs/applications-setup/browsers/google-chrome.sh index d66ec9a5..b591b218 100644 --- a/core/tabs/applications-setup/browsers/google-chrome.sh +++ b/core/tabs/applications-setup/browsers/google-chrome.sh @@ -8,20 +8,20 @@ installChrome() { case "$PACKAGER" in 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 + elevated_execution "$PACKAGER" install -y ./google-chrome-stable_current_amd64.deb ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" addrepo http://dl.google.com/linux/chrome/rpm/stable/x86_64 Google-Chrome - "$ESCALATION_TOOL" "$PACKAGER" refresh - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install google-chrome-stable + elevated_execution "$PACKAGER" addrepo http://dl.google.com/linux/chrome/rpm/stable/x86_64 Google-Chrome + elevated_execution "$PACKAGER" refresh + elevated_execution "$PACKAGER" --non-interactive install google-chrome-stable ;; pacman) "$AUR_HELPER" -S --needed --noconfirm google-chrome ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y fedora-workstation-repositories - "$ESCALATION_TOOL" "$PACKAGER" config-manager --set-enabled google-chrome - "$ESCALATION_TOOL" "$PACKAGER" install -y google-chrome-stable + elevated_execution "$PACKAGER" install -y fedora-workstation-repositories + elevated_execution "$PACKAGER" config-manager --set-enabled google-chrome + elevated_execution "$PACKAGER" install -y google-chrome-stable ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/applications-setup/browsers/librewolf.sh b/core/tabs/applications-setup/browsers/librewolf.sh index a630b9c7..20ef4159 100644 --- a/core/tabs/applications-setup/browsers/librewolf.sh +++ b/core/tabs/applications-setup/browsers/librewolf.sh @@ -7,27 +7,27 @@ installLibreWolf() { printf "%b\n" "${YELLOW}Installing Librewolf...${RC}" case "$PACKAGER" in apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" install -y gnupg lsb-release apt-transport-https ca-certificates + elevated_execution "$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` - curl -fsSL https://deb.librewolf.net/keyring.gpg | "$ESCALATION_TOOL" gpg --dearmor -o /usr/share/keyrings/librewolf.gpg + curl -fsSL https://deb.librewolf.net/keyring.gpg | elevated_execution 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 - "$ESCALATION_TOOL" "$PACKAGER" update - "$ESCALATION_TOOL" "$PACKAGER" install -y librewolf +Signed-By: /usr/share/keyrings/librewolf.gpg" | elevated_execution tee /etc/apt/sources.list.d/librewolf.sources > /dev/null + elevated_execution "$PACKAGER" update + elevated_execution "$PACKAGER" install -y librewolf ;; dnf) 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 + elevated_execution "$PACKAGER" install -y librewolf ;; zypper) - "$ESCALATION_TOOL" rpm --import https://rpm.librewolf.net/pubkey.gpg - "$ESCALATION_TOOL" zypper ar -ef https://rpm.librewolf.net librewolf - "$ESCALATION_TOOL" zypper refresh - "$ESCALATION_TOOL" zypper --non-interactive install librewolf + elevated_execution rpm --import https://rpm.librewolf.net/pubkey.gpg + elevated_execution zypper ar -ef https://rpm.librewolf.net librewolf + elevated_execution zypper refresh + elevated_execution zypper --non-interactive install librewolf ;; pacman) "$AUR_HELPER" -S --needed --noconfirm librewolf-bin diff --git a/core/tabs/applications-setup/browsers/lynx.sh b/core/tabs/applications-setup/browsers/lynx.sh index 002ff7e3..f3c8cbe6 100644 --- a/core/tabs/applications-setup/browsers/lynx.sh +++ b/core/tabs/applications-setup/browsers/lynx.sh @@ -7,10 +7,10 @@ installLynx() { printf "%b\n" "${YELLOW}Installing Lynx...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm lynx + elevated_execution "$PACKAGER" -S --needed --noconfirm lynx ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y lynx + elevated_execution "$PACKAGER" install -y lynx ;; esac else diff --git a/core/tabs/applications-setup/browsers/thorium.sh b/core/tabs/applications-setup/browsers/thorium.sh index c45ebc80..d6e8dc0c 100644 --- a/core/tabs/applications-setup/browsers/thorium.sh +++ b/core/tabs/applications-setup/browsers/thorium.sh @@ -7,15 +7,15 @@ installThrorium() { printf "%b\n" "${YELLOW}Installing Thorium Browser...${RC}" case "$PACKAGER" in 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 + elevated_execution rm -fv /etc/apt/sources.list.d/thorium.list + elevated_execution curl http://dl.thorium.rocks/debian/dists/stable/thorium.list -o /etc/apt/sources.list.d/thorium.list + elevated_execution "$PACKAGER" update + elevated_execution "$PACKAGER" install -y thorium-browser ;; 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 + elevated_execution "$PACKAGER" install -y thorium-latest.rpm && rm thorium-latest.rpm ;; pacman) "$AUR_HELPER" -S --needed --noconfirm thorium-browser-bin diff --git a/core/tabs/applications-setup/browsers/vivaldi.sh b/core/tabs/applications-setup/browsers/vivaldi.sh index 002ff7e3..f3c8cbe6 100644 --- a/core/tabs/applications-setup/browsers/vivaldi.sh +++ b/core/tabs/applications-setup/browsers/vivaldi.sh @@ -7,10 +7,10 @@ installLynx() { printf "%b\n" "${YELLOW}Installing Lynx...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm lynx + elevated_execution "$PACKAGER" -S --needed --noconfirm lynx ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y lynx + elevated_execution "$PACKAGER" install -y lynx ;; esac else diff --git a/core/tabs/applications-setup/communication-apps/discord-setup.sh b/core/tabs/applications-setup/communication-apps/discord-setup.sh index 6c7a0a83..4778df1c 100644 --- a/core/tabs/applications-setup/communication-apps/discord-setup.sh +++ b/core/tabs/applications-setup/communication-apps/discord-setup.sh @@ -8,17 +8,17 @@ installDiscord() { case "$PACKAGER" in apt-get|nala) curl -Lo discord.deb "https://discord.com/api/download?platform=linux&format=deb" - "$ESCALATION_TOOL" "$PACKAGER" install -y discord.deb + elevated_execution "$PACKAGER" install -y discord.deb ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install discord + elevated_execution "$PACKAGER" --non-interactive install discord ;; pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm discord + elevated_execution "$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 discord + elevated_execution "$PACKAGER" install -y https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm + elevated_execution "$PACKAGER" install -y discord ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/applications-setup/communication-apps/jitsi-setup.sh b/core/tabs/applications-setup/communication-apps/jitsi-setup.sh index 2b6b4bbe..5ba2b94f 100644 --- a/core/tabs/applications-setup/communication-apps/jitsi-setup.sh +++ b/core/tabs/applications-setup/communication-apps/jitsi-setup.sh @@ -7,19 +7,19 @@ installJitsi() { 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 - "$ESCALATION_TOOL" "$PACKAGER" update - "$ESCALATION_TOOL" "$PACKAGER" -y install jitsi-meet + curl https://download.jitsi.org/jitsi-key.gpg.key | elevated_execution 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/' | elevated_execution tee /etc/apt/sources.list.d/jitsi-stable.list > /dev/null + elevated_execution "$PACKAGER" update + elevated_execution "$PACKAGER" -y install jitsi-meet ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install jitsi + elevated_execution "$PACKAGER" --non-interactive install jitsi ;; pacman) "$AUR_HELPER" -S --needed --noconfirm jitsi-meet-bin ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y jitsi-meet + elevated_execution "$PACKAGER" install -y jitsi-meet ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/applications-setup/communication-apps/signal-setup.sh b/core/tabs/applications-setup/communication-apps/signal-setup.sh index 7f5d70fc..67f7d228 100644 --- a/core/tabs/applications-setup/communication-apps/signal-setup.sh +++ b/core/tabs/applications-setup/communication-apps/signal-setup.sh @@ -8,20 +8,20 @@ installSignal() { 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 - 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 + cat signal-desktop-keyring.gpg | elevated_execution 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' | elevated_execution tee /etc/apt/sources.list.d/signal-xenial.list + elevated_execution "$PACKAGER" update + elevated_execution "$PACKAGER" -y install signal-desktop ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install signal-desktop + elevated_execution "$PACKAGER" --non-interactive install signal-desktop ;; pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm signal-desktop + elevated_execution "$PACKAGER" -S --noconfirm signal-desktop ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" copr enable luminoso/Signal-Desktop - "$ESCALATION_TOOL" "$PACKAGER" install -y signal-desktop + elevated_execution "$PACKAGER" copr enable luminoso/Signal-Desktop + elevated_execution "$PACKAGER" install -y signal-desktop ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/applications-setup/communication-apps/telegram-setup.sh b/core/tabs/applications-setup/communication-apps/telegram-setup.sh index a21b53e4..31901b77 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 + elevated_execution "$PACKAGER" -S --needed --noconfirm telegram-desktop ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y telegram-desktop + elevated_execution "$PACKAGER" install -y telegram-desktop ;; esac else diff --git a/core/tabs/applications-setup/communication-apps/thunderbird-setup.sh b/core/tabs/applications-setup/communication-apps/thunderbird-setup.sh index f49dcb78..182974aa 100644 --- a/core/tabs/applications-setup/communication-apps/thunderbird-setup.sh +++ b/core/tabs/applications-setup/communication-apps/thunderbird-setup.sh @@ -7,10 +7,10 @@ installThunderBird() { printf "%b\n" "${YELLOW}Installing Thunderbird...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm thunderbird + elevated_execution "$PACKAGER" -S --needed --noconfirm thunderbird ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y thunderbird + elevated_execution "$PACKAGER" install -y thunderbird ;; esac else diff --git a/core/tabs/applications-setup/docker-setup.sh b/core/tabs/applications-setup/docker-setup.sh index afcd1572..6b53f176 100755 --- a/core/tabs/applications-setup/docker-setup.sh +++ b/core/tabs/applications-setup/docker-setup.sh @@ -27,14 +27,14 @@ install_docker() { curl -fsSL https://get.docker.com | sh ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker - "$ESCALATION_TOOL" systemctl enable docker - "$ESCALATION_TOOL" systemctl start docker + elevated_execution "$PACKAGER" --non-interactive install docker + elevated_execution systemctl enable docker + elevated_execution systemctl start docker ;; pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm docker - "$ESCALATION_TOOL" systemctl enable docker - "$ESCALATION_TOOL" systemctl start docker + elevated_execution "$PACKAGER" -S --noconfirm docker + elevated_execution systemctl enable docker + elevated_execution systemctl start docker ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" @@ -47,13 +47,13 @@ install_docker_compose() { printf "%b\n" "${YELLOW}Installing Docker Compose...${RC}" case "$PACKAGER" in apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" install -y docker-compose-plugin + elevated_execution "$PACKAGER" install -y docker-compose-plugin ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker-compose + elevated_execution "$PACKAGER" --non-interactive install docker-compose ;; pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm docker-compose + elevated_execution "$PACKAGER" -S --needed --noconfirm docker-compose ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/applications-setup/dwmtitus-setup.sh b/core/tabs/applications-setup/dwmtitus-setup.sh index 01ec0ef1..9c0f41dc 100755 --- a/core/tabs/applications-setup/dwmtitus-setup.sh +++ b/core/tabs/applications-setup/dwmtitus-setup.sh @@ -6,14 +6,14 @@ setupDWM() { printf "%b\n" "${YELLOW}Installing DWM-Titus...${RC}" case "$PACKAGER" in # Install pre-Requisites pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm base-devel libx11 libxinerama libxft imlib2 libxcb git unzip flameshot lxappearance feh mate-polkit + elevated_execution "$PACKAGER" -S --needed --noconfirm base-devel libx11 libxinerama libxft imlib2 libxcb git unzip flameshot lxappearance feh mate-polkit ;; 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 + elevated_execution "$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) - "$ESCALATION_TOOL" "$PACKAGER" groupinstall -y "Development Tools" - "$ESCALATION_TOOL" "$PACKAGER" install -y libX11-devel libXinerama-devel libXft-devel imlib2-devel libxcb-devel unzip flameshot lxappearance feh mate-polkit # no need to include git here as it should be already installed via "Development Tools" + elevated_execution "$PACKAGER" groupinstall -y "Development Tools" + elevated_execution "$PACKAGER" install -y libX11-devel libXinerama-devel libXft-devel imlib2-devel libxcb-devel unzip flameshot lxappearance feh mate-polkit # no need to include git here as it should be already installed via "Development Tools" ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" @@ -26,7 +26,7 @@ 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. - "$ESCALATION_TOOL" make clean install # Run make clean install + elevated_execution make clean install # Run make clean install } install_nerd_font() { @@ -119,7 +119,7 @@ picom_animations() { fi # Install the built binary - if ! "$ESCALATION_TOOL" ninja -C build install; then + if ! elevated_execution ninja -C build install; then printf "%b\n" "${RED}Failed to install the built binary${RC}" return 1 fi @@ -183,13 +183,13 @@ setupDisplayManager() { printf "%b\n" "${YELLOW}Setting up Xorg${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm xorg-xinit xorg-server + elevated_execution "$PACKAGER" -S --needed --noconfirm xorg-xinit xorg-server ;; apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" install -y xorg xinit + elevated_execution "$PACKAGER" install -y xorg xinit ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y xorg-x11-xinit xorg-x11-server-Xorg + elevated_execution "$PACKAGER" install -y xorg-x11-xinit xorg-x11-server-Xorg ;; *) printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" @@ -217,13 +217,13 @@ setupDisplayManager() { read -r DM case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm "$DM" + elevated_execution "$PACKAGER" -S --needed --noconfirm "$DM" ;; apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" install -y "$DM" + elevated_execution "$PACKAGER" install -y "$DM" ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y "$DM" + elevated_execution "$PACKAGER" install -y "$DM" ;; *) printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" @@ -242,7 +242,7 @@ install_slstatus() { 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; } - if "$ESCALATION_TOOL" make clean install; then + if elevated_execution make clean install; then printf "%b\n" "${GREEN}slstatus installed successfully${RC}" else printf "%b\n" "${RED}Failed to install slstatus${RC}" diff --git a/core/tabs/applications-setup/fastfetch-setup.sh b/core/tabs/applications-setup/fastfetch-setup.sh index cb523441..d9f27376 100644 --- a/core/tabs/applications-setup/fastfetch-setup.sh +++ b/core/tabs/applications-setup/fastfetch-setup.sh @@ -7,15 +7,15 @@ installFastfetch() { printf "%b\n" "${YELLOW}Installing Fastfetch...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm fastfetch + elevated_execution "$PACKAGER" -S --needed --noconfirm fastfetch ;; apt-get|nala) curl -sSLo /tmp/fastfetch.deb https://github.com/fastfetch-cli/fastfetch/releases/latest/download/fastfetch-linux-amd64.deb - "$ESCALATION_TOOL" "$PACKAGER" install -y /tmp/fastfetch.deb + elevated_execution "$PACKAGER" install -y /tmp/fastfetch.deb rm /tmp/fastfetch.deb ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y fastfetch + elevated_execution "$PACKAGER" install -y fastfetch ;; esac else diff --git a/core/tabs/applications-setup/grub-theme.sh b/core/tabs/applications-setup/grub-theme.sh index 9b79b39b..6e27a735 100644 --- a/core/tabs/applications-setup/grub-theme.sh +++ b/core/tabs/applications-setup/grub-theme.sh @@ -10,7 +10,7 @@ themeinstall(){ fi git clone "https://github.com/ChrisTitusTech/Top-5-Bootloader-Themes" cd "Top-5-Bootloader-Themes" - "$ESCALATION_TOOL" ./install.sh + elevated_execution ./install.sh } checkEnv diff --git a/core/tabs/applications-setup/kitty-setup.sh b/core/tabs/applications-setup/kitty-setup.sh index 85ef129b..d2d468ae 100755 --- a/core/tabs/applications-setup/kitty-setup.sh +++ b/core/tabs/applications-setup/kitty-setup.sh @@ -7,10 +7,10 @@ installKitty() { printf "%b\n" "${YELLOW}Installing Kitty...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm kitty + elevated_execution "$PACKAGER" -S --needed --noconfirm kitty ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y kitty + elevated_execution "$PACKAGER" install -y kitty ;; esac else diff --git a/core/tabs/applications-setup/linutil-installer.sh b/core/tabs/applications-setup/linutil-installer.sh index 4bb241db..697fe4e0 100755 --- a/core/tabs/applications-setup/linutil-installer.sh +++ b/core/tabs/applications-setup/linutil-installer.sh @@ -35,13 +35,13 @@ installLinutil() { printf "%b\n" "${YELLOW}Installing rustup...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup + elevated_execution "$PACKAGER" -S --needed --noconfirm rustup ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y rustup + elevated_execution "$PACKAGER" install -y rustup ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make + elevated_execution "$PACKAGER" install -n curl gcc make curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y . $HOME/.cargo/env ;; diff --git a/core/tabs/applications-setup/linutil-updater.sh b/core/tabs/applications-setup/linutil-updater.sh index 8cf1762d..fe146f2a 100755 --- a/core/tabs/applications-setup/linutil-updater.sh +++ b/core/tabs/applications-setup/linutil-updater.sh @@ -12,15 +12,15 @@ updateLinutil() { printf "%b\n" "${YELLOW}Installing rustup...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup + elevated_execution "$PACKAGER" -S --needed --noconfirm rustup ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make + elevated_execution "$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 + elevated_execution "$PACKAGER" install -y rustup ;; esac fi diff --git a/core/tabs/applications-setup/mybash-setup.sh b/core/tabs/applications-setup/mybash-setup.sh index 7cda9942..3a092e90 100644 --- a/core/tabs/applications-setup/mybash-setup.sh +++ b/core/tabs/applications-setup/mybash-setup.sh @@ -9,10 +9,10 @@ installDepend() { printf "%b\n" "${YELLOW}Installing Bash...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm bash bash-completion tar bat tree unzip fontconfig git + elevated_execution "$PACKAGER" -S --needed --noconfirm bash bash-completion tar bat tree unzip fontconfig git ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y bash bash-completion tar bat tree unzip fontconfig git + elevated_execution "$PACKAGER" install -y bash bash-completion tar bat tree unzip fontconfig git ;; esac fi @@ -62,7 +62,7 @@ installStarshipAndFzf() { printf "%b\n" "${GREEN}Fzf already installed${RC}" else git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf - "$ESCALATION_TOOL" ~/.fzf/install + elevated_execution ~/.fzf/install fi } diff --git a/core/tabs/applications-setup/office-suites/freeoffice.sh b/core/tabs/applications-setup/office-suites/freeoffice.sh index 7effa3fb..13b3df42 100644 --- a/core/tabs/applications-setup/office-suites/freeoffice.sh +++ b/core/tabs/applications-setup/office-suites/freeoffice.sh @@ -8,19 +8,19 @@ installFreeOffice() { 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 + elevated_execution "$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 + elevated_execution "$PACKAGER" addrepo -f https://shop.softmaker.com/repo/rpm SoftMaker + elevated_execution "$PACKAGER" --gpg-auto-import-keys refresh + elevated_execution "$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 + elevated_execution curl -O -qO /etc/yum.repos.d/softmaker.repo https://shop.softmaker.com/repo/softmaker.repo + elevated_execution "$PACKAGER" install -y softmaker-freeoffice-2024 ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/applications-setup/office-suites/libreoffice.sh b/core/tabs/applications-setup/office-suites/libreoffice.sh index a9850fdc..0a52dfef 100644 --- a/core/tabs/applications-setup/office-suites/libreoffice.sh +++ b/core/tabs/applications-setup/office-suites/libreoffice.sh @@ -7,14 +7,14 @@ installLibreOffice() { printf "%b\n" "${YELLOW}Installing Libre Office...${RC}" case "$PACKAGER" in apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" install -y libreoffice-core + elevated_execution "$PACKAGER" install -y libreoffice-core ;; zypper|dnf) . ./setup-flatpak.sh flatpak install -y flathub org.libreoffice.LibreOffice ;; pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm libreoffice-fresh + elevated_execution "$PACKAGER" -S --needed --noconfirm libreoffice-fresh ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/applications-setup/office-suites/onlyoffice.sh b/core/tabs/applications-setup/office-suites/onlyoffice.sh index aaea7547..3a56edee 100644 --- a/core/tabs/applications-setup/office-suites/onlyoffice.sh +++ b/core/tabs/applications-setup/office-suites/onlyoffice.sh @@ -8,7 +8,7 @@ installOnlyOffice() { case "$PACKAGER" in 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 + elevated_execution "$PACKAGER" install -y ./onlyoffice-desktopeditors_amd64.deb ;; zypper|dnf) . ./setup-flatpak.sh diff --git a/core/tabs/applications-setup/pdf-suites/evince.sh b/core/tabs/applications-setup/pdf-suites/evince.sh index 9e0d8da0..11c8402c 100644 --- a/core/tabs/applications-setup/pdf-suites/evince.sh +++ b/core/tabs/applications-setup/pdf-suites/evince.sh @@ -7,10 +7,10 @@ installEvince() { printf "%b\n" "${YELLOW}Installing Evince...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm evince + elevated_execution "$PACKAGER" -S --needed --noconfirm evince ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y evince + elevated_execution "$PACKAGER" install -y evince ;; esac else diff --git a/core/tabs/applications-setup/pdf-suites/okular.sh b/core/tabs/applications-setup/pdf-suites/okular.sh index 6ed8d4d1..f6f035dd 100644 --- a/core/tabs/applications-setup/pdf-suites/okular.sh +++ b/core/tabs/applications-setup/pdf-suites/okular.sh @@ -7,10 +7,10 @@ installOkular() { printf "%b\n" "${YELLOW}Installing Okular...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm okular + elevated_execution "$PACKAGER" -S --needed --noconfirm okular ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y okular + elevated_execution "$PACKAGER" install -y okular ;; esac else diff --git a/core/tabs/applications-setup/pdf-suites/pdfstudio.sh b/core/tabs/applications-setup/pdf-suites/pdfstudio.sh index 03ba05f4..94dc0b34 100644 --- a/core/tabs/applications-setup/pdf-suites/pdfstudio.sh +++ b/core/tabs/applications-setup/pdf-suites/pdfstudio.sh @@ -6,7 +6,7 @@ installPdfstudio() { if ! command_exists pdfstudio2024; then printf "%b\n" "${YELLOW}Installing PDF Studio...${RC}" curl -O https://download.qoppa.com/pdfstudio/PDFStudio_linux64.sh - "$ESCALATION_TOOL" chmod +x PDFStudio_linux64.sh + elevated_execution chmod +x PDFStudio_linux64.sh if sh PDFStudio_linux64.sh; then printf "%b\n" "${GREEN}PDF Studio installed successfully!${RC}" else diff --git a/core/tabs/applications-setup/pdf-suites/pdfstudioviewer.sh b/core/tabs/applications-setup/pdf-suites/pdfstudioviewer.sh index 72013a11..4c7b2ded 100644 --- a/core/tabs/applications-setup/pdf-suites/pdfstudioviewer.sh +++ b/core/tabs/applications-setup/pdf-suites/pdfstudioviewer.sh @@ -6,7 +6,7 @@ installPdfstudioviewer() { if ! command_exists pdfstudioviewer2024; then printf "%b\n" "${YELLOW}Installing PDF Studio Viewer...${RC}" curl -O https://download.qoppa.com/pdfstudioviewer/PDFStudioViewer_linux64.sh - "$ESCALATION_TOOL" chmod +x PDFStudioViewer_linux64.sh + elevated_execution chmod +x PDFStudioViewer_linux64.sh if sh PDFStudioViewer_linux64.sh; then printf "%b\n" "${GREEN}PDF Studio Viewer installed successfully!${RC}" else diff --git a/core/tabs/applications-setup/rofi-setup.sh b/core/tabs/applications-setup/rofi-setup.sh index 24ce1a67..82eb1b0f 100755 --- a/core/tabs/applications-setup/rofi-setup.sh +++ b/core/tabs/applications-setup/rofi-setup.sh @@ -7,10 +7,10 @@ installRofi() { printf "%b\n" "${YELLOW}Installing Rofi...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rofi + elevated_execution "$PACKAGER" -S --needed --noconfirm rofi ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y rofi + elevated_execution "$PACKAGER" install -y rofi ;; esac else diff --git a/core/tabs/applications-setup/setup-flatpak.sh b/core/tabs/applications-setup/setup-flatpak.sh index 75da28af..53d8b7d9 100755 --- a/core/tabs/applications-setup/setup-flatpak.sh +++ b/core/tabs/applications-setup/setup-flatpak.sh @@ -23,14 +23,14 @@ setup_flatpak() { printf "%b\n" "${YELLOW}Installing Flatpak...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm flatpak + elevated_execution "$PACKAGER" -S --needed --noconfirm flatpak ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y flatpak + elevated_execution "$PACKAGER" install -y flatpak ;; esac printf "%b\n" "Adding Flathub remote..." - "$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + elevated_execution flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo else if command_exists flatpak; then if ! flatpak remotes | grep -q "flathub"; then @@ -39,7 +39,7 @@ setup_flatpak() { case "$add_remote" in [Yy]*) printf "%b\n" "Adding Flathub remote..." - "$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + elevated_execution flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo ;; esac else @@ -57,14 +57,14 @@ setup_flatpak() { printf "%b" "${YELLOW}Detected GNOME desktop environment. Would you like to install GNOME Software plugin for Flatpak? (y/N): ${RC}" read -r install_gnome if [ "$install_gnome" = "y" ] || [ "$install_gnome" = "Y" ]; then - "$ESCALATION_TOOL" "$PACKAGER" install -y gnome-software-plugin-flatpak + elevated_execution "$PACKAGER" install -y gnome-software-plugin-flatpak fi # Useful for Debian KDE spin as well elif [ "$DE" = "KDE" ]; then printf "%b" "${YELLOW}Detected KDE desktop environment. Would you like to install KDE Plasma Discover backend for Flatpak? (y/N): ${RC}" read -r install_kde if [ "$install_kde" = "y" ] || [ "$install_kde" = "Y" ]; then - "$ESCALATION_TOOL" "$PACKAGER" install -y plasma-discover-backend-flatpak + elevated_execution "$PACKAGER" install -y plasma-discover-backend-flatpak fi fi fi diff --git a/core/tabs/applications-setup/waydroid-setup.sh b/core/tabs/applications-setup/waydroid-setup.sh index 255a4cbe..e0f51dc4 100755 --- a/core/tabs/applications-setup/waydroid-setup.sh +++ b/core/tabs/applications-setup/waydroid-setup.sh @@ -17,38 +17,38 @@ installWaydroid() { "$AUR_HELPER" -S --needed --noconfirm waydroid if command_exists dkms; then "$AUR_HELPER" -S --needed --noconfirm binder_linux-dkms - "$ESCALATION_TOOL" modprobe binder-linux device=binder,hwbinder,vndbinder + elevated_execution modprobe binder-linux device=binder,hwbinder,vndbinder fi ;; apt-get|nala) - curl https://repo.waydro.id | "$ESCALATION_TOOL" sh - "$ESCALATION_TOOL" "$PACKAGER" install -y waydroid + curl https://repo.waydro.id | elevated_execution sh + elevated_execution "$PACKAGER" install -y waydroid if command_exists dkms; then - "$ESCALATION_TOOL" "$PACKAGER" install -y git + elevated_execution "$PACKAGER" install -y git mkdir -p "$HOME/.local/share/" # only create it if it doesnt exist git clone https://github.com/choff/anbox-modules.git "$HOME/.local/share/anbox-modules" cd "$HOME/.local/share/anbox-modules" - "$ESCALATION_TOOL" cp anbox.conf /etc/modules-load.d/ - "$ESCALATION_TOOL" cp 99-anbox.rules /lib/udev/rules.d/ - "$ESCALATION_TOOL" cp -rT ashmem /usr/src/anbox-ashmem-1 - "$ESCALATION_TOOL" cp -rT binder /usr/src/anbox-binder-1 - "$ESCALATION_TOOL" dkms install anbox-ashmem/1 - "$ESCALATION_TOOL" dkms install anbox-binder/1 + elevated_execution cp anbox.conf /etc/modules-load.d/ + elevated_execution cp 99-anbox.rules /lib/udev/rules.d/ + elevated_execution cp -rT ashmem /usr/src/anbox-ashmem-1 + elevated_execution cp -rT binder /usr/src/anbox-binder-1 + elevated_execution dkms install anbox-ashmem/1 + elevated_execution dkms install anbox-binder/1 fi ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y waydroid + elevated_execution "$PACKAGER" install -y waydroid if command_exists dkms; then - "$ESCALATION_TOOL" "$PACKAGER" install -y git + elevated_execution "$PACKAGER" install -y git mkdir -p "$HOME/.local/share/" # only create it if it doesnt exist git clone https://github.com/choff/anbox-modules.git "$HOME/.local/share/anbox-modules" cd "$HOME/.local/share/anbox-modules" - "$ESCALATION_TOOL" cp anbox.conf /etc/modules-load.d/ - "$ESCALATION_TOOL" cp 99-anbox.rules /lib/udev/rules.d/ - "$ESCALATION_TOOL" cp -rT ashmem /usr/src/anbox-ashmem-1 - "$ESCALATION_TOOL" cp -rT binder /usr/src/anbox-binder-1 - "$ESCALATION_TOOL" dkms install anbox-ashmem/1 - "$ESCALATION_TOOL" dkms install anbox-binder/1 + elevated_execution cp anbox.conf /etc/modules-load.d/ + elevated_execution cp 99-anbox.rules /lib/udev/rules.d/ + elevated_execution cp -rT ashmem /usr/src/anbox-ashmem-1 + elevated_execution cp -rT binder /usr/src/anbox-binder-1 + elevated_execution dkms install anbox-ashmem/1 + elevated_execution dkms install anbox-binder/1 fi ;; *) @@ -63,8 +63,8 @@ installWaydroid() { setupWaydroid() { printf "%b\n" "${YELLOW}Setting up Waydroid...${RC}" - "$ESCALATION_TOOL" systemctl enable --now waydroid-container - "$ESCALATION_TOOL" waydroid init + elevated_execution systemctl enable --now waydroid-container + elevated_execution waydroid init printf "%b\n" "${GREEN}Waydroid setup complete.${RC}" } diff --git a/core/tabs/applications-setup/zsh-setup.sh b/core/tabs/applications-setup/zsh-setup.sh index a85b9240..dde3ac5e 100644 --- a/core/tabs/applications-setup/zsh-setup.sh +++ b/core/tabs/applications-setup/zsh-setup.sh @@ -8,10 +8,10 @@ installZsh() { printf "%b\n" "${YELLOW}Installing Zsh...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm zsh + elevated_execution "$PACKAGER" -S --needed --noconfirm zsh ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y zsh + elevated_execution "$PACKAGER" install -y zsh ;; esac else @@ -44,8 +44,8 @@ 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 + [ ! -f /etc/zsh/zshenv ] && elevated_execution mkdir -p /etc/zsh && elevated_execution touch /etc/zsh/zshenv + echo "export ZDOTDIR=\"$HOME/.config/zsh\"" | elevated_execution tee -a /etc/zsh/zshenv } checkEnv diff --git a/core/tabs/common-script.sh b/core/tabs/common-script.sh index 12ab1146..2fe3896b 100644 --- a/core/tabs/common-script.sh +++ b/core/tabs/common-script.sh @@ -12,6 +12,14 @@ command_exists() { command -v "$1" >/dev/null 2>&1 } +elevated_execution() { + if [ -z "$ESCALATION_TOOL" ]; then + "$@" + else + "$ESCALATION_TOOL" "$@" + fi +} + checkAURHelper() { ## Check & Install AUR helper if [ "$PACKAGER" = "pacman" ]; then @@ -44,6 +52,12 @@ checkAURHelper() { checkEscalationTool() { ## Check for escalation tools. + if [ "$(id -u)" -eq 0 ]; then + printf "%b\n" "${CYAN}Running as root, no need for escalation tool.${RC}" + ESCALATION_TOOL_CHECKED=true + return 0 + fi + if [ -z "$ESCALATION_TOOL_CHECKED" ]; then ESCALATION_TOOLS='sudo doas' for tool in ${ESCALATION_TOOLS}; do diff --git a/core/tabs/security/firewall-baselines.sh b/core/tabs/security/firewall-baselines.sh index 9c0810f4..fd2fdb8d 100644 --- a/core/tabs/security/firewall-baselines.sh +++ b/core/tabs/security/firewall-baselines.sh @@ -7,10 +7,10 @@ installPkg() { printf "%b\n" "${YELLOW}Installing UFW...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm ufw + elevated_execution "$PACKAGER" -S --needed --noconfirm ufw ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y ufw + elevated_execution "$PACKAGER" install -y ufw ;; esac else @@ -22,24 +22,24 @@ configureUFW() { printf "%b\n" "${YELLOW}Using Chris Titus Recommended Firewall Rules${RC}" printf "%b\n" "${YELLOW}Disabling UFW${RC}" - "$ESCALATION_TOOL" ufw disable + elevated_execution ufw disable printf "%b\n" "${YELLOW}Limiting port 22/tcp (UFW)${RC}" - "$ESCALATION_TOOL" ufw limit 22/tcp + elevated_execution ufw limit 22/tcp printf "%b\n" "${YELLOW}Allowing port 80/tcp (UFW)${RC}" - "$ESCALATION_TOOL" ufw allow 80/tcp + elevated_execution ufw allow 80/tcp printf "%b\n" "${YELLOW}Allowing port 443/tcp (UFW)${RC}" - "$ESCALATION_TOOL" ufw allow 443/tcp + elevated_execution ufw allow 443/tcp printf "%b\n" "${YELLOW}Denying Incoming Packets by Default(UFW)${RC}" - "$ESCALATION_TOOL" ufw default deny incoming + elevated_execution ufw default deny incoming printf "%b\n" "${YELLOW}Allowing Outcoming Packets by Default(UFW)${RC}" - "$ESCALATION_TOOL" ufw default allow outgoing + elevated_execution ufw default allow outgoing - "$ESCALATION_TOOL" ufw enable + elevated_execution ufw enable printf "%b\n" "${GREEN}Enabled Firewall with Baselines!${RC}" } diff --git a/core/tabs/system-setup/arch/paru-setup.sh b/core/tabs/system-setup/arch/paru-setup.sh index fba445ef..bbc0548c 100755 --- a/core/tabs/system-setup/arch/paru-setup.sh +++ b/core/tabs/system-setup/arch/paru-setup.sh @@ -7,8 +7,8 @@ installDepend() { pacman) if ! command_exists paru; then printf "%b\n" "${YELLOW}Installing paru as AUR helper...${RC}" - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm base-devel git - cd /opt && "$ESCALATION_TOOL" git clone https://aur.archlinux.org/paru.git && "$ESCALATION_TOOL" chown -R "$USER": ./paru + elevated_execution "$PACKAGER" -S --needed --noconfirm base-devel git + cd /opt && elevated_execution git clone https://aur.archlinux.org/paru.git && elevated_execution chown -R "$USER": ./paru cd paru && makepkg --noconfirm -si printf "%b\n" "${GREEN}Paru installed${RC}" else diff --git a/core/tabs/system-setup/arch/yay-setup.sh b/core/tabs/system-setup/arch/yay-setup.sh index fd80f1f2..fe8c3e8f 100755 --- a/core/tabs/system-setup/arch/yay-setup.sh +++ b/core/tabs/system-setup/arch/yay-setup.sh @@ -7,8 +7,8 @@ installDepend() { pacman) if ! command_exists yay; then printf "%b\n" "${YELLOW}Installing yay as AUR helper...${RC}" - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm base-devel git - cd /opt && "$ESCALATION_TOOL" git clone https://aur.archlinux.org/yay-bin.git && "$ESCALATION_TOOL" chown -R "$USER": ./yay-bin + elevated_execution "$PACKAGER" -S --needed --noconfirm base-devel git + cd /opt && elevated_execution git clone https://aur.archlinux.org/yay-bin.git && elevated_execution chown -R "$USER": ./yay-bin cd yay-bin && makepkg --noconfirm -si printf "%b\n" "${GREEN}Yay installed${RC}" else diff --git a/core/tabs/system-setup/compile-setup.sh b/core/tabs/system-setup/compile-setup.sh index 74a96a41..20914202 100755 --- a/core/tabs/system-setup/compile-setup.sh +++ b/core/tabs/system-setup/compile-setup.sh @@ -9,9 +9,9 @@ installDepend() { case "$PACKAGER" in pacman) 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 - "$ESCALATION_TOOL" "$PACKAGER" -Syu + echo "[multilib]" | elevated_execution tee -a /etc/pacman.conf + echo "Include = /etc/pacman.d/mirrorlist" | elevated_execution tee -a /etc/pacman.conf + elevated_execution "$PACKAGER" -Syu else printf "%b\n" "${GREEN}Multilib is already enabled.${RC}" fi @@ -19,26 +19,26 @@ installDepend() { ;; apt-get|nala) COMPILEDEPS='build-essential' - "$ESCALATION_TOOL" "$PACKAGER" update - "$ESCALATION_TOOL" dpkg --add-architecture i386 - "$ESCALATION_TOOL" "$PACKAGER" update - "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS + elevated_execution "$PACKAGER" update + elevated_execution dpkg --add-architecture i386 + elevated_execution "$PACKAGER" update + elevated_execution "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS ;; dnf) COMPILEDEPS='@development-tools' - "$ESCALATION_TOOL" "$PACKAGER" update - "$ESCALATION_TOOL" "$PACKAGER" config-manager --set-enabled powertools - "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS - "$ESCALATION_TOOL" "$PACKAGER" install -y glibc-devel.i686 libgcc.i686 + elevated_execution "$PACKAGER" update + elevated_execution "$PACKAGER" config-manager --set-enabled powertools + elevated_execution "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS + elevated_execution "$PACKAGER" install -y glibc-devel.i686 libgcc.i686 ;; zypper) COMPILEDEPS='patterns-devel-base-devel_basis' - "$ESCALATION_TOOL" "$PACKAGER" refresh - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install $DEPENDENCIES $COMPILEDEPS - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install libgcc_s1-gcc7-32bit glibc-devel-32bit + elevated_execution "$PACKAGER" refresh + elevated_execution "$PACKAGER" --non-interactive install $DEPENDENCIES $COMPILEDEPS + elevated_execution "$PACKAGER" --non-interactive install libgcc_s1-gcc7-32bit glibc-devel-32bit ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES + elevated_execution "$PACKAGER" install -y $DEPENDENCIES ;; esac } diff --git a/core/tabs/system-setup/fedora/configure-dnf.sh b/core/tabs/system-setup/fedora/configure-dnf.sh index 977ea6d4..ff0e4cad 100644 --- a/core/tabs/system-setup/fedora/configure-dnf.sh +++ b/core/tabs/system-setup/fedora/configure-dnf.sh @@ -6,10 +6,10 @@ configureDNF() { case "$PACKAGER" in dnf) printf "%b\n" "${YELLOW}Configuring DNF...${RC}" - "$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 + elevated_execution 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" | elevated_execution tee -a /etc/dnf/dnf.conf > /dev/null + echo "defaultyes=True" | elevated_execution tee -a /etc/dnf/dnf.conf > /dev/null + elevated_execution "$PACKAGER" -y install dnf-plugins-core printf "%b\n" "${GREEN}DNF Configured Successfully.${RC}" ;; *) diff --git a/core/tabs/system-setup/fedora/multimedia-codecs.sh b/core/tabs/system-setup/fedora/multimedia-codecs.sh index 751e4547..b1022b80 100644 --- a/core/tabs/system-setup/fedora/multimedia-codecs.sh +++ b/core/tabs/system-setup/fedora/multimedia-codecs.sh @@ -7,9 +7,9 @@ multimedia() { dnf) if [ -e /etc/yum.repos.d/rpmfusion-free.repo ] && [ -e /etc/yum.repos.d/rpmfusion-nonfree.repo ]; then printf "%b\n" "${YELLOW}Installing Multimedia Codecs...${RC}" - "$ESCALATION_TOOL" "$PACKAGER" swap ffmpeg-free ffmpeg --allowerasing -y - "$ESCALATION_TOOL" "$PACKAGER" update @multimedia --setopt="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin -y - "$ESCALATION_TOOL" "$PACKAGER" update @sound-and-video -y + elevated_execution "$PACKAGER" swap ffmpeg-free ffmpeg --allowerasing -y + elevated_execution "$PACKAGER" update @multimedia --setopt="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin -y + elevated_execution "$PACKAGER" update @sound-and-video -y printf "%b\n" "${GREEN}Multimedia Codecs Installed...${RC}" else printf "%b\n" "${RED}RPM Fusion repositories not found. Please set up RPM Fusion first!${RC}" 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..75f004a9 100755 --- a/core/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh +++ b/core/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh @@ -18,10 +18,10 @@ checkRepo() { 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" + elevated_execution dnf config-manager --set-enabled "$REPO_ID" # Refreshing repository list - "$ESCALATION_TOOL" dnf makecache + elevated_execution dnf makecache # Verify if the repository is enabled if [ "$(dnf repolist enabled 2>/dev/null | grep -c "$REPO_ID")" -gt 0 ]; then @@ -49,7 +49,7 @@ installDriver() { fi # NOTE:: Installing graphics driver. - "$ESCALATION_TOOL" dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda -y + elevated_execution 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 diff --git a/core/tabs/system-setup/fedora/rpm-fusion-setup.sh b/core/tabs/system-setup/fedora/rpm-fusion-setup.sh index aeb7d24c..4388125c 100644 --- a/core/tabs/system-setup/fedora/rpm-fusion-setup.sh +++ b/core/tabs/system-setup/fedora/rpm-fusion-setup.sh @@ -9,10 +9,10 @@ installRPMFusion() { dnf) if [ ! -e /etc/yum.repos.d/rpmfusion-free.repo ] || [ ! -e /etc/yum.repos.d/rpmfusion-nonfree.repo ]; then printf "%b\n" "${YELLOW}Installing RPM Fusion...${RC}" - "$ESCALATION_TOOL" "$PACKAGER" install "https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora)".noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm - "$ESCALATION_TOOL" "$PACKAGER" config-manager --enable fedora-cisco-openh264 - "$ESCALATION_TOOL" "$PACKAGER" config-manager --set-enabled rpmfusion-nonfree-updates - "$ESCALATION_TOOL" "$PACKAGER" config-manager --set-enabled rpmfusion-free-updates + elevated_execution "$PACKAGER" install "https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora)".noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm + elevated_execution "$PACKAGER" config-manager --enable fedora-cisco-openh264 + elevated_execution "$PACKAGER" config-manager --set-enabled rpmfusion-nonfree-updates + elevated_execution "$PACKAGER" config-manager --set-enabled rpmfusion-free-updates printf "%b\n" "${GREEN}RPM Fusion installed and enabled${RC}" else printf "%b\n" "${GREEN}RPM Fusion already installed${RC}" diff --git a/core/tabs/system-setup/fedora/virtualization.sh b/core/tabs/system-setup/fedora/virtualization.sh index 3359efeb..3c1af7cf 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 + elevated_execution "$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..2d3f2e94 100755 --- a/core/tabs/system-setup/gaming-setup.sh +++ b/core/tabs/system-setup/gaming-setup.sh @@ -10,9 +10,9 @@ installDepend() { 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 - "$ESCALATION_TOOL" "$PACKAGER" -Syu + echo "[multilib]" | elevated_execution tee -a /etc/pacman.conf + echo "Include = /etc/pacman.d/mirrorlist" | elevated_execution tee -a /etc/pacman.conf + elevated_execution "$PACKAGER" -Syu else printf "%b\n" "${GREEN}Multilib is already enabled.${RC}" fi @@ -28,29 +28,29 @@ installDepend() { apt-get|nala) DISTRO_DEPS="libasound2 libsdl2 wine64 wine32" - "$ESCALATION_TOOL" "$PACKAGER" update - "$ESCALATION_TOOL" dpkg --add-architecture i386 - "$ESCALATION_TOOL" "$PACKAGER" install -y software-properties-common - "$ESCALATION_TOOL" apt-add-repository contrib -y - "$ESCALATION_TOOL" "$PACKAGER" update - "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $DISTRO_DEPS + elevated_execution "$PACKAGER" update + elevated_execution dpkg --add-architecture i386 + elevated_execution "$PACKAGER" install -y software-properties-common + elevated_execution apt-add-repository contrib -y + elevated_execution "$PACKAGER" update + elevated_execution "$PACKAGER" install -y $DEPENDENCIES $DISTRO_DEPS ;; dnf) if [ "$(rpm -E %fedora)" -le 41 ]; then - "$ESCALATION_TOOL" "$PACKAGER" install ffmpeg ffmpeg-libs -y - "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES + elevated_execution "$PACKAGER" install ffmpeg ffmpeg-libs -y + elevated_execution "$PACKAGER" install -y $DEPENDENCIES else printf "%b\n" "${CYAN}Fedora < 41 detected. Installing rpmfusion repos.${RC}" - "$ESCALATION_TOOL" "$PACKAGER" install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-"$(rpm -E %fedora)".noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm -y - "$ESCALATION_TOOL" "$PACKAGER" config-manager --enable fedora-cisco-openh264 -y - "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES + elevated_execution "$PACKAGER" install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-"$(rpm -E %fedora)".noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm -y + elevated_execution "$PACKAGER" config-manager --enable fedora-cisco-openh264 -y + elevated_execution "$PACKAGER" install -y $DEPENDENCIES fi ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" -n install $DEPENDENCIES + elevated_execution "$PACKAGER" -n install $DEPENDENCIES ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES + elevated_execution "$PACKAGER" install -y $DEPENDENCIES ;; esac } @@ -59,7 +59,7 @@ installAdditionalDepend() { case "$PACKAGER" in pacman) DISTRO_DEPS='steam lutris goverlay' - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm $DISTRO_DEPS + elevated_execution "$PACKAGER" -S --needed --noconfirm $DISTRO_DEPS ;; apt-get|nala) version=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/lutris/lutris | @@ -71,7 +71,7 @@ installAdditionalDepend() { 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 + elevated_execution "$PACKAGER" install ./lutris_"${version_no_v}"_all.deb rm lutris_"${version_no_v}"_all.deb @@ -79,20 +79,20 @@ installAdditionalDepend() { printf "%b\n" "${YELLOW}Installing steam...${RC}" if lsb_release -i | grep -qi Debian; then - "$ESCALATION_TOOL" apt-add-repository non-free -y - "$ESCALATION_TOOL" "$PACKAGER" install steam-installer -y + elevated_execution apt-add-repository non-free -y + elevated_execution "$PACKAGER" install steam-installer -y else - "$ESCALATION_TOOL" "$PACKAGER" install -y steam + elevated_execution "$PACKAGER" install -y steam fi ;; dnf) DISTRO_DEPS='steam lutris' - "$ESCALATION_TOOL" "$PACKAGER" install -y $DISTRO_DEPS + elevated_execution "$PACKAGER" install -y $DISTRO_DEPS ;; zypper) # Flatpak DISTRO_DEPS='lutris' - "$ESCALATION_TOOL" "$PACKAGER" -n install $DISTRO_DEPS + elevated_execution "$PACKAGER" -n install $DISTRO_DEPS ;; *) ;; diff --git a/core/tabs/system-setup/global-theme.sh b/core/tabs/system-setup/global-theme.sh index 07f9d4b2..3cf24581 100755 --- a/core/tabs/system-setup/global-theme.sh +++ b/core/tabs/system-setup/global-theme.sh @@ -6,16 +6,16 @@ install_theme_tools() { printf "%b\n" "${YELLOW}Installing theme tools (qt6ct and kvantum)...${RC}" case "$PACKAGER" in apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" install -y qt6ct kvantum + elevated_execution "$PACKAGER" install -y qt6ct kvantum ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install qt6ct kvantum + elevated_execution "$PACKAGER" --non-interactive install qt6ct kvantum ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y qt6ct kvantum + elevated_execution "$PACKAGER" install -y qt6ct kvantum ;; pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm qt6ct kvantum + elevated_execution "$PACKAGER" -S --needed --noconfirm qt6ct kvantum ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" @@ -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" | elevated_execution 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}" diff --git a/core/tabs/system-setup/remove-snaps.sh b/core/tabs/system-setup/remove-snaps.sh index a46ef323..dde5b7d0 100644 --- a/core/tabs/system-setup/remove-snaps.sh +++ b/core/tabs/system-setup/remove-snaps.sh @@ -6,16 +6,16 @@ removeSnaps() { if command_exists snap; then case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -Rns snapd + elevated_execution "$PACKAGER" -Rns snapd ;; apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" autoremove --purge snapd + elevated_execution "$PACKAGER" autoremove --purge snapd if [ "$ID" = ubuntu ]; then - "$ESCALATION_TOOL" apt-mark hold snapd + elevated_execution apt-mark hold snapd fi ;; dnf|zypper) - "$ESCALATION_TOOL" "$PACKAGER" remove snapd + elevated_execution "$PACKAGER" remove snapd ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/system-setup/system-cleanup.sh b/core/tabs/system-setup/system-cleanup.sh index 0a625913..2bcf3f7e 100644 --- a/core/tabs/system-setup/system-cleanup.sh +++ b/core/tabs/system-setup/system-cleanup.sh @@ -6,24 +6,24 @@ cleanup_system() { printf "%b\n" "${YELLOW}Performing system cleanup...${RC}" case "$PACKAGER" in apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" clean - "$ESCALATION_TOOL" "$PACKAGER" autoremove -y - "$ESCALATION_TOOL" "$PACKAGER" autoclean - "$ESCALATION_TOOL" du -h /var/cache/apt - "$ESCALATION_TOOL" "$PACKAGER" clean + elevated_execution "$PACKAGER" clean + elevated_execution "$PACKAGER" autoremove -y + elevated_execution "$PACKAGER" autoclean + elevated_execution du -h /var/cache/apt + elevated_execution "$PACKAGER" clean ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" clean -a - "$ESCALATION_TOOL" "$PACKAGER" tidy - "$ESCALATION_TOOL" "$PACKAGER" cc -a + elevated_execution "$PACKAGER" clean -a + elevated_execution "$PACKAGER" tidy + elevated_execution "$PACKAGER" cc -a ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" clean all - "$ESCALATION_TOOL" "$PACKAGER" autoremove -y + elevated_execution "$PACKAGER" clean all + elevated_execution "$PACKAGER" autoremove -y ;; pacman) - "$ESCALATION_TOOL" "$PACKAGER" -Sc --noconfirm - "$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null 2>&1 + elevated_execution "$PACKAGER" -Sc --noconfirm + elevated_execution "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null 2>&1 ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" @@ -33,10 +33,10 @@ cleanup_system() { } common_cleanup() { - "$ESCALATION_TOOL" find /var/tmp -type f -atime +5 -delete - "$ESCALATION_TOOL" find /tmp -type f -atime +5 -delete - "$ESCALATION_TOOL" find /var/log -type f -name "*.log" -exec truncate -s 0 {} \; - "$ESCALATION_TOOL" journalctl --vacuum-time=3d + elevated_execution find /var/tmp -type f -atime +5 -delete + elevated_execution find /tmp -type f -atime +5 -delete + elevated_execution find /var/log -type f -name "*.log" -exec truncate -s 0 {} \; + elevated_execution journalctl --vacuum-time=3d } clean_data() { diff --git a/core/tabs/system-setup/system-update.sh b/core/tabs/system-setup/system-update.sh index c213156a..73a9ec7a 100755 --- a/core/tabs/system-setup/system-update.sh +++ b/core/tabs/system-setup/system-update.sh @@ -11,7 +11,7 @@ fastUpdate() { printf "%b\n" "${YELLOW}Generating a new list of mirrors using rate-mirrors. This process may take a few seconds...${RC}" if [ -s /etc/pacman.d/mirrorlist ]; then - "$ESCALATION_TOOL" cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak + elevated_execution cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak fi # If for some reason DTYPE is still unknown use always arch so the rate-mirrors does not fail @@ -20,33 +20,33 @@ 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} + elevated_execution 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 printf "%b\n" "${RED}Rate-mirrors failed, restoring backup.${RC}" - "$ESCALATION_TOOL" cp /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist + elevated_execution cp /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist fi ;; apt-get|nala) - "$ESCALATION_TOOL" apt-get update + elevated_execution 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"; } + elevated_execution apt-get install -y nala || { printf "%b\n" "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; } fi if [ "$PACKAGER" = "nala" ]; then - "$ESCALATION_TOOL" cp /etc/apt/sources.list /etc/apt/sources.list.bak - "$ESCALATION_TOOL" nala update + elevated_execution cp /etc/apt/sources.list /etc/apt/sources.list.bak + elevated_execution nala update PACKAGER="nala" fi - "$ESCALATION_TOOL" "$PACKAGER" upgrade -y + elevated_execution "$PACKAGER" upgrade -y ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" update -y + elevated_execution "$PACKAGER" update -y ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" ref - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive dup + elevated_execution "$PACKAGER" ref + elevated_execution "$PACKAGER" --non-interactive dup ;; *) printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" @@ -59,20 +59,20 @@ updateSystem() { printf "%b\n" "${GREEN}Updating system${RC}" case "$PACKAGER" in apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" update - "$ESCALATION_TOOL" "$PACKAGER" upgrade -y + elevated_execution "$PACKAGER" update + elevated_execution "$PACKAGER" upgrade -y ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" update -y - "$ESCALATION_TOOL" "$PACKAGER" upgrade -y + elevated_execution "$PACKAGER" update -y + elevated_execution "$PACKAGER" upgrade -y ;; pacman) - "$ESCALATION_TOOL" "$PACKAGER" -Sy --noconfirm --needed archlinux-keyring - "$ESCALATION_TOOL" "$PACKAGER" -Su --noconfirm + elevated_execution "$PACKAGER" -Sy --noconfirm --needed archlinux-keyring + elevated_execution "$PACKAGER" -Su --noconfirm ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" ref - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive dup + elevated_execution "$PACKAGER" ref + elevated_execution "$PACKAGER" --non-interactive dup ;; *) printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" diff --git a/core/tabs/system-setup/terminus-tty.sh b/core/tabs/system-setup/terminus-tty.sh index 2c1deaa0..d422d5c2 100755 --- a/core/tabs/system-setup/terminus-tty.sh +++ b/core/tabs/system-setup/terminus-tty.sh @@ -8,13 +8,13 @@ InstallTermiusFonts() { printf "%b\n" "${YELLOW}Installing Terminus Fonts...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm terminus-font + elevated_execution "$PACKAGER" -S --needed --noconfirm terminus-font ;; apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" install -y fonts-terminus + elevated_execution "$PACKAGER" install -y fonts-terminus ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y terminus-fonts-console + elevated_execution "$PACKAGER" install -y terminus-fonts-console ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" @@ -30,31 +30,31 @@ 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 + elevated_execution 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 + elevated_execution 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 + elevated_execution sed -i 's/^CODESET=.*/CODESET="guess"/' /etc/default/console-setup + elevated_execution sed -i 's/^FONTFACE=.*/FONTFACE="TerminusBold"/' /etc/default/console-setup + elevated_execution 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 + elevated_execution update-initramfs -u if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then - "$ESCALATION_TOOL" setfont -C /dev/tty1 /usr/share/consolefonts/Uni3-TerminusBold32x16.psf.gz + elevated_execution 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 + elevated_execution 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 + elevated_execution setfont -C /dev/tty1 ter-v32b fi printf "%b\n" "${GREEN}Terminus font has been set for TTY.${RC}" ;; diff --git a/core/tabs/utils/auto-login.sh b/core/tabs/utils/auto-login.sh index 561250d5..fefadaf1 100644 --- a/core/tabs/utils/auto-login.sh +++ b/core/tabs/utils/auto-login.sh @@ -43,9 +43,9 @@ configure_lightdm() { printf "%b" "Enter username for LightDM autologin: " read -r user - printf "%b\n" '[Seat:*]' | "$ESCALATION_TOOL" tee -a /etc/lightdm/lightdm.conf - printf "%s\n" "autologin-user=$user" | "$ESCALATION_TOOL" tee -a /etc/lightdm/lightdm.conf - printf "%b\n" 'autologin-user-timeout=0' | "$ESCALATION_TOOL" tee -a /etc/lightdm/lightdm.conf + printf "%b\n" '[Seat:*]' | elevated_execution tee -a /etc/lightdm/lightdm.conf + printf "%s\n" "autologin-user=$user" | elevated_execution tee -a /etc/lightdm/lightdm.conf + printf "%b\n" 'autologin-user-timeout=0' | elevated_execution tee -a /etc/lightdm/lightdm.conf printf "%b\n" "LightDM has been configured for autologin." } @@ -53,8 +53,8 @@ configure_lightdm() { # Function to remove LightDM autologin remove_lightdm_autologin() { printf "%b\n" "Removing LightDM autologin configuration..." - "$ESCALATION_TOOL" sed -i'' '/^\[Seat:\*]/d' /etc/lightdm/lightdm.conf - "$ESCALATION_TOOL" sed -i'' '/^autologin-/d' /etc/lightdm/lightdm.conf + elevated_execution sed -i'' '/^\[Seat:\*]/d' /etc/lightdm/lightdm.conf + elevated_execution sed -i'' '/^autologin-/d' /etc/lightdm/lightdm.conf printf "%b\n" "LightDM autologin configuration has been removed." } @@ -64,9 +64,9 @@ configure_gdm() { printf "%b" "Enter username for GDM autologin: " read -r user - printf "%b\n" '[daemon]' | "$ESCALATION_TOOL" tee -a /etc/gdm/custom.conf - printf "%b\n" 'AutomaticLoginEnable = true' | "$ESCALATION_TOOL" tee -a /etc/gdm/custom.conf - printf "%s\n" "AutomaticLogin = $user" | "$ESCALATION_TOOL" tee -a /etc/gdm/custom.conf + printf "%b\n" '[daemon]' | elevated_execution tee -a /etc/gdm/custom.conf + printf "%b\n" 'AutomaticLoginEnable = true' | elevated_execution tee -a /etc/gdm/custom.conf + printf "%s\n" "AutomaticLogin = $user" | elevated_execution tee -a /etc/gdm/custom.conf printf "%b\n" "GDM has been configured for autologin." } @@ -74,8 +74,8 @@ configure_gdm() { # Function to remove GDM autologin remove_gdm_autologin() { printf "%b\n" "Removing GDM autologin configuration..." - "$ESCALATION_TOOL" sed -i'' '/AutomaticLoginEnable/d' /etc/gdm/custom.conf - "$ESCALATION_TOOL" sed -i'' '/AutomaticLogin/d' /etc/gdm/custom.conf + elevated_execution sed -i'' '/AutomaticLoginEnable/d' /etc/gdm/custom.conf + elevated_execution sed -i'' '/AutomaticLogin/d' /etc/gdm/custom.conf printf "%b\n" "GDM autologin configuration has been removed." } @@ -86,9 +86,9 @@ configure_sddm() { read -r user 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 - printf "%s\n" "Session=$session" | "$ESCALATION_TOOL" tee -a /etc/sddm.conf + printf "%b\n" '[Autologin]' | elevated_execution tee -a /etc/sddm.conf + printf "%s\n" "User=$user" | elevated_execution tee -a /etc/sddm.conf + printf "%s\n" "Session=$session" | elevated_execution tee -a /etc/sddm.conf printf "%b\n" "SDDM has been configured for autologin." } @@ -96,7 +96,7 @@ configure_sddm() { # Function to remove SDDM autologin remove_sddm_autologin() { printf "%b\n" "Removing SDDM autologin configuration..." - "$ESCALATION_TOOL" sed -i'' '/\[Autologin\]/,+2d' /etc/sddm.conf + elevated_execution sed -i'' '/\[Autologin\]/,+2d' /etc/sddm.conf printf "%b\n" "SDDM autologin configuration has been removed." } @@ -107,8 +107,8 @@ configure_lxdm() { read -r user 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 + elevated_execution sed -i'' "s/^#.*autologin=.*$/autologin=${user}/" /etc/lxdm/lxdm.conf + elevated_execution sed -i'' "s|^#.*session=.*$|session=/usr/bin/${session}|; s|^session=.*$|session=/usr/bin/${session}|" /etc/lxdm/lxdm.conf printf "%b\n" "LXDM has been configured for autologin." } @@ -116,8 +116,8 @@ configure_lxdm() { # Function to remove LXDM autologin remove_lxdm_autologin() { printf "%b\n" "Removing LXDM autologin configuration..." - "$ESCALATION_TOOL" sed -i'' "s/^autologin=.*$/#autologin=/" /etc/lxdm/lxdm.conf - "$ESCALATION_TOOL" sed -i'' "s/^session=.*$/#session=/" /etc/lxdm/lxdm.conf + elevated_execution sed -i'' "s/^autologin=.*$/#autologin=/" /etc/lxdm/lxdm.conf + elevated_execution sed -i'' "s/^session=.*$/#session=/" /etc/lxdm/lxdm.conf printf "%b\n" "LXDM autologin configuration has been removed." } diff --git a/core/tabs/utils/auto-mount.sh b/core/tabs/utils/auto-mount.sh index f4eb59b2..64d12ccf 100644 --- a/core/tabs/utils/auto-mount.sh +++ b/core/tabs/utils/auto-mount.sh @@ -21,7 +21,7 @@ select_drive() { # Function to get UUID and FSTYPE of the selected drive get_uuid_fstype() { - UUID=$("$ESCALATION_TOOL" blkid -s UUID -o value "${partition}") + UUID=$(elevated_execution blkid -s UUID -o value "${partition}") FSTYPE=$(lsblk -no FSTYPE "${partition}") NAME=$(lsblk -no NAME "${partition}") @@ -42,7 +42,7 @@ create_mount_point() { read -r mount_point if [ ! -d "$mount_point" ]; then printf "%b\n" "${YELLOW}Mount point doesn't exist. Creating it..${RC}." - "$ESCALATION_TOOL" mkdir -p "$mount_point" + elevated_execution mkdir -p "$mount_point" else printf "%b\n" "${RED}Mount point already exists.${RC}" fi @@ -51,16 +51,16 @@ create_mount_point() { # Function to update /etc/fstab with a comment on the first line and the actual entry on the second line update_fstab() { printf "%b\n" "${YELLOW}Adding entry to /etc/fstab...${RC}" - "$ESCALATION_TOOL" cp /etc/fstab /etc/fstab.bak # Backup fstab + elevated_execution cp /etc/fstab /etc/fstab.bak # Backup fstab # Prepare the comment and the fstab entry comment="# Mount for /dev/$NAME" 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" | elevated_execution tee -a /etc/fstab > /dev/null + printf "%b\n" "$fstab_entry" | elevated_execution tee -a /etc/fstab > /dev/null + printf "%b\n" "" | elevated_execution tee -a /etc/fstab > /dev/null printf "%b\n" "Entry added to /etc/fstab:" printf "%b\n" "$comment" @@ -71,7 +71,7 @@ update_fstab() { # Function to mount the drive mount_drive() { printf "%b\n" "Mounting the drive..." - "$ESCALATION_TOOL" mount -a + elevated_execution mount -a if mount | grep "$mount_point" > /dev/null; then printf "%b\n" "${GREEN}Drive mounted successfully at $mount_point${RC}." else diff --git a/core/tabs/utils/bluetooth-control.sh b/core/tabs/utils/bluetooth-control.sh index da7ee23d..dd57709a 100644 --- a/core/tabs/utils/bluetooth-control.sh +++ b/core/tabs/utils/bluetooth-control.sh @@ -8,10 +8,10 @@ setupBluetooth() { if ! command_exists bluetoothctl; then case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm bluez-utils + elevated_execution "$PACKAGER" -S --noconfirm bluez-utils ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y bluez + elevated_execution "$PACKAGER" install -y bluez ;; esac else @@ -21,7 +21,7 @@ setupBluetooth() { # 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 + elevated_execution systemctl start bluetooth if systemctl is-active --quiet bluetooth; then printf "%b\n" "${GREEN}Bluetooth service started successfully.${RC}" diff --git a/core/tabs/utils/create-bootable-usb.sh b/core/tabs/utils/create-bootable-usb.sh index 0e59440d..574f0b06 100644 --- a/core/tabs/utils/create-bootable-usb.sh +++ b/core/tabs/utils/create-bootable-usb.sh @@ -13,7 +13,7 @@ usage() { list_devices() { printf "%b\n" "${YELLOW} Available devices and partitions: ${RC}" printf "\n" - "$ESCALATION_TOOL" lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL + elevated_execution lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL printf "\n" } @@ -164,13 +164,13 @@ write_iso(){ # 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 + if ! elevated_execution 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 + if ! elevated_execution sync; then printf "%b\n" "${RED}Failed to sync data${RC}" exit 1 fi @@ -179,10 +179,10 @@ write_iso(){ # Eject the USB device printf "%b\n" "${YELLOW}Ejecting ${USB_DEVICE}...${RC}" - if ! "$ESCALATION_TOOL" umount "${USB_DEVICE}"* 2>/dev/null; then + if ! elevated_execution umount "${USB_DEVICE}"* 2>/dev/null; then printf "%b\n" "${RED}Failed to unmount ${USB_DEVICE}${RC}" fi - if ! "$ESCALATION_TOOL" eject "$USB_DEVICE"; then + if ! elevated_execution eject "$USB_DEVICE"; then printf "%b\n" "${RED}Failed to eject ${USB_DEVICE}${RC}" fi diff --git a/core/tabs/utils/encrypt_decrypt_tool.sh b/core/tabs/utils/encrypt_decrypt_tool.sh index 0db4a49b..3db9aff0 100644 --- a/core/tabs/utils/encrypt_decrypt_tool.sh +++ b/core/tabs/utils/encrypt_decrypt_tool.sh @@ -8,16 +8,16 @@ printf "%b\n" "${YELLOW}Ensuring OpenSSL is installed...${RC}" if ! command_exists openssl; then case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -Syu --noconfirm openssl + elevated_execution "$PACKAGER" -Syu --noconfirm openssl ;; apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" install -y openssl + elevated_execution "$PACKAGER" install -y openssl ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y openssl + elevated_execution "$PACKAGER" install -y openssl ;; zypper) - "$ESCALATION_TOOL" "$PACKAGER" install openssl + elevated_execution "$PACKAGER" install openssl ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" diff --git a/core/tabs/utils/numlock.sh b/core/tabs/utils/numlock.sh index 742ceeb7..9d112bff 100755 --- a/core/tabs/utils/numlock.sh +++ b/core/tabs/utils/numlock.sh @@ -9,7 +9,7 @@ create_file() { printf "%b\n" "Creating script..." - "$ESCALATION_TOOL" tee "/usr/local/bin/numlock" >/dev/null <<'EOF' + elevated_execution 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 + elevated_execution 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' + elevated_execution tee "/etc/systemd/system/numlock.service" >/dev/null <<'EOF' [Unit] Description=numlock @@ -51,10 +51,10 @@ numlockSetup() { 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 + elevated_execution systemctl enable numlock.service --quiet printf "%b\n" "Numlock will be enabled on boot" else - "$ESCALATION_TOOL" systemctl disable numlock.service --quiet + elevated_execution systemctl disable numlock.service --quiet printf "%b\n" "Numlock will not be enabled on boot" fi } diff --git a/core/tabs/utils/ollama.sh b/core/tabs/utils/ollama.sh index 35453ba3..4659e084 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 + elevated_execution systemctl start ollama fi } diff --git a/core/tabs/utils/power-profile.sh b/core/tabs/utils/power-profile.sh index 536f7c69..085a272c 100644 --- a/core/tabs/utils/power-profile.sh +++ b/core/tabs/utils/power-profile.sh @@ -17,10 +17,10 @@ installAutoCpufreq() { printf "%b\n" "${YELLOW}git not found. Installing git...${RC}" case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm git + elevated_execution "$PACKAGER" -S --needed --noconfirm git ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y git + elevated_execution "$PACKAGER" install -y git ;; esac fi @@ -33,8 +33,8 @@ installAutoCpufreq() { cd auto-cpufreq printf "%b\n" "${YELLOW}Running auto-cpufreq installer...${RC}" - "$ESCALATION_TOOL" ./auto-cpufreq-installer - "$ESCALATION_TOOL" auto-cpufreq --install + elevated_execution ./auto-cpufreq-installer + elevated_execution auto-cpufreq --install cd .. fi @@ -47,10 +47,10 @@ configureAutoCpufreq() { # Check if the system has a battery to determine if it's a laptop if [ -d /sys/class/power_supply/BAT0 ]; then printf "%b\n" "${GREEN}System detected as laptop. Updating auto-cpufreq for laptop...${RC}" - "$ESCALATION_TOOL" auto-cpufreq --force powersave + elevated_execution auto-cpufreq --force powersave else printf "%b\n" "${GREEN}System detected as desktop. Updating auto-cpufreq for desktop...${RC}" - "$ESCALATION_TOOL" auto-cpufreq --force performance + elevated_execution auto-cpufreq --force performance fi else printf "%b\n" "${RED}auto-cpufreq is not installed, skipping configuration.${RC}" @@ -62,7 +62,7 @@ removeAutoCpufreqTweak() { if command_exists auto-cpufreq; then printf "%b\n" "${YELLOW}Resetting auto-cpufreq configuration...${RC}" - "$ESCALATION_TOOL" auto-cpufreq --force reset + elevated_execution auto-cpufreq --force reset else printf "%b\n" "${RED}auto-cpufreq is not installed, skipping removal.${RC}" fi diff --git a/core/tabs/utils/samba-ssh-setup.sh b/core/tabs/utils/samba-ssh-setup.sh index 52004a27..f95ae9a3 100755 --- a/core/tabs/utils/samba-ssh-setup.sh +++ b/core/tabs/utils/samba-ssh-setup.sh @@ -9,10 +9,10 @@ install_package() { if ! command_exists "$PACKAGE"; then case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm "$PACKAGE" + elevated_execution "$PACKAGER" -S --needed --noconfirm "$PACKAGE" ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y "$PACKAGE" + elevated_execution "$PACKAGER" install -y "$PACKAGE" ;; esac else @@ -41,8 +41,8 @@ setup_ssh() { esac # Enable and start the appropriate SSH service - "$ESCALATION_TOOL" systemctl enable "$SSH_SERVICE" - "$ESCALATION_TOOL" systemctl start "$SSH_SERVICE" + elevated_execution systemctl enable "$SSH_SERVICE" + elevated_execution systemctl start "$SSH_SERVICE" # Get the local IP address LOCAL_IP=$(ip -4 addr show | awk '/inet / {print $2}' | tail -n 1) @@ -71,7 +71,7 @@ setup_samba() { printf "%b" "Do you want to modify the existing Samba configuration? (Y/n): " read -r MODIFY_SAMBA if [ "$MODIFY_SAMBA" = "Y" ] || [ "$MODIFY_SAMBA" = "y" ]; then - "$ESCALATION_TOOL" "$EDITOR" "$SAMBA_CONFIG" + elevated_execution "$EDITOR" "$SAMBA_CONFIG" fi else printf "%b\n" "${YELLOW}No existing Samba configuration found. Setting up a new one...${RC}" @@ -82,8 +82,8 @@ setup_samba() { SHARED_DIR=${SHARED_DIR:-/srv/samba/share} # Create the shared directory if it doesn't exist - "$ESCALATION_TOOL" mkdir -p "$SHARED_DIR" - "$ESCALATION_TOOL" chmod -R 0777 "$SHARED_DIR" + elevated_execution mkdir -p "$SHARED_DIR" + elevated_execution chmod -R 0777 "$SHARED_DIR" # Add a new Samba user printf "%b" "Enter Samba username: " @@ -109,10 +109,10 @@ setup_samba() { done # Add the user and set the password - "$ESCALATION_TOOL" smbpasswd -a "$SAMBA_USER" + elevated_execution smbpasswd -a "$SAMBA_USER" # Configure Samba settings - "$ESCALATION_TOOL" tee "$SAMBA_CONFIG" > /dev/null < /dev/null <1 {print $1}' | more + elevated_execution systemctl list-units --type=service --state=running --no-pager | head -n -6 | awk 'NR>1 {print $1}' | more } # Function to add a new service @@ -55,7 +55,7 @@ add_service() { while [ -z "$SERVICE_NAME" ]; do printf "%b" "Enter the name of the new service (e.g., my_service): " read -r SERVICE_NAME - if "$ESCALATION_TOOL" systemctl list-units --type=service --all --no-legend | grep -q "$SERVICE_NAME.service"; then + if elevated_execution systemctl list-units --type=service --all --no-legend | grep -q "$SERVICE_NAME.service"; then printf "%b\n" "${GREEN}Service already exists.${RC}" SERVICE_NAME="" fi @@ -92,11 +92,11 @@ add_service() { printf "\n" printf "%b\n" "[Install]" printf "%b\n" "WantedBy=multi-user.target" - } | "$ESCALATION_TOOL" tee "$SERVICE_FILE" > /dev/null + } | elevated_execution tee "$SERVICE_FILE" > /dev/null # Set permissions and reload systemd - "$ESCALATION_TOOL" chmod 644 "$SERVICE_FILE" - "$ESCALATION_TOOL" systemctl daemon-reload + elevated_execution chmod 644 "$SERVICE_FILE" + elevated_execution systemctl daemon-reload printf "%b\n" "Service $SERVICE_NAME has been created and is ready to be started." # Optionally, enable and start the service @@ -104,8 +104,8 @@ add_service() { read -r START_ENABLE if [ "$START_ENABLE" = "y" ] || [ "$START_ENABLE" = "Y" ]; then - "$ESCALATION_TOOL" systemctl start "$SERVICE_NAME" - "$ESCALATION_TOOL" systemctl enable "$SERVICE_NAME" + elevated_execution systemctl start "$SERVICE_NAME" + elevated_execution systemctl enable "$SERVICE_NAME" printf "%b\n" "Service $SERVICE_NAME has been started and enabled." else printf "%b\n" "Service $SERVICE_NAME has been created but not started." @@ -121,12 +121,12 @@ remove_service() { if [ -f "$SERVICE_FILE" ]; then printf "%b\n" "Stopping and disabling the service..." - "$ESCALATION_TOOL" systemctl stop "$SERVICE_NAME" - "$ESCALATION_TOOL" systemctl disable "$SERVICE_NAME" + elevated_execution systemctl stop "$SERVICE_NAME" + elevated_execution systemctl disable "$SERVICE_NAME" printf "%b\n" "Removing the service file..." - "$ESCALATION_TOOL" rm -f "$SERVICE_FILE" - "$ESCALATION_TOOL" systemctl daemon-reload + elevated_execution rm -f "$SERVICE_FILE" + elevated_execution systemctl daemon-reload printf "%b\n" "Service $SERVICE_NAME has been removed." else printf "%b\n" "Service $SERVICE_NAME does not exist." @@ -139,7 +139,7 @@ start_service() { printf "%b" "Enter the name of the service to start (e.g., my_service): " read -r SERVICE_NAME - if "$ESCALATION_TOOL" systemctl start "$SERVICE_NAME"; then + if elevated_execution systemctl start "$SERVICE_NAME"; then printf "%b\n" "Service $SERVICE_NAME has been started." else printf "%b\n" "Failed to start service: $SERVICE_NAME." @@ -152,7 +152,7 @@ stop_service() { printf "%b" "Enter the name of the service to stop (e.g., my_service): " read -r SERVICE_NAME - if "$ESCALATION_TOOL" systemctl stop "$SERVICE_NAME"; then + if elevated_execution systemctl stop "$SERVICE_NAME"; then printf "%b\n" "Service $SERVICE_NAME has been stopped." else printf "%b\n" "Failed to stop service: $SERVICE_NAME." @@ -165,7 +165,7 @@ enable_service() { printf "%b" "Enter the name of the service to enable (e.g., my_service): " read -r SERVICE_NAME - if "$ESCALATION_TOOL" systemctl enable "$SERVICE_NAME"; then + if elevated_execution systemctl enable "$SERVICE_NAME"; then printf "%b\n" "Service $SERVICE_NAME has been enabled." else printf "%b\n" "Failed to enable service: $SERVICE_NAME." @@ -178,7 +178,7 @@ disable_service() { printf "%b" "Enter the name of the service to disable (e.g., my_service): " read -r SERVICE_NAME - if "$ESCALATION_TOOL" systemctl disable "$SERVICE_NAME"; then + if elevated_execution systemctl disable "$SERVICE_NAME"; then printf "%b\n" "Service $SERVICE_NAME has been enabled." else printf "%b\n" "Failed to enable service: $SERVICE_NAME." @@ -225,11 +225,11 @@ create_service_from_external() { fi # Copy the modified service file to /etc/systemd/system/ - "$ESCALATION_TOOL" cp "$SERVICE_FILE" "$SYSTEMD_SERVICE_FILE" + elevated_execution cp "$SERVICE_FILE" "$SYSTEMD_SERVICE_FILE" # Set permissions and reload systemd - "$ESCALATION_TOOL" chmod 644 "$SYSTEMD_SERVICE_FILE" - "$ESCALATION_TOOL" systemctl daemon-reload + elevated_execution chmod 644 "$SYSTEMD_SERVICE_FILE" + elevated_execution systemctl daemon-reload printf "%b\n" "Service $SERVICE_NAME has been created and is ready to be started." # Optionally, enable and start the service @@ -237,8 +237,8 @@ create_service_from_external() { read -r START_ENABLE if [ "$START_ENABLE" = "y" ]; then - "$ESCALATION_TOOL" systemctl start "$SERVICE_NAME" - "$ESCALATION_TOOL" systemctl enable "$SERVICE_NAME" + elevated_execution systemctl start "$SERVICE_NAME" + elevated_execution systemctl enable "$SERVICE_NAME" printf "%b\n" "Service $SERVICE_NAME has been started and enabled." else printf "%b\n" "Service $SERVICE_NAME has been created but not started." diff --git a/core/tabs/utils/ssh.sh b/core/tabs/utils/ssh.sh index 1e402546..74ba825b 100644 --- a/core/tabs/utils/ssh.sh +++ b/core/tabs/utils/ssh.sh @@ -61,11 +61,11 @@ disable_password_auth() { read -r host_alias printf "\n" 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 + elevated_execution -S sed -i 's/^#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config && + elevated_execution -S sed -i 's/^PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config && + elevated_execution -S sed -i 's/^#PubkeyAuthentication no/PubkeyAuthentication yes/' /etc/ssh/sshd_config && + elevated_execution -S sed -i 's/^PubkeyAuthentication no/PubkeyAuthentication yes/' /etc/ssh/sshd_config && + elevated_execution -S systemctl restart sshd " printf "%b\n" "PasswordAuthentication set to no and PubkeyAuthentication set to yes." } @@ -76,11 +76,11 @@ enable_password_auth() { read -r host_alias printf "\n" 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 + elevated_execution -S sed -i 's/^#PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config && + elevated_execution -S sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config && + elevated_execution -S sed -i 's/^#PubkeyAuthentication yes/PubkeyAuthentication no/' /etc/ssh/sshd_config && + elevated_execution -S sed -i 's/^PubkeyAuthentication yes/PubkeyAuthentication no/' /etc/ssh/sshd_config && + elevated_execution -S systemctl restart sshd " printf "%b\n" "PasswordAuthentication set to yes and PubkeyAuthentication set to no." } diff --git a/core/tabs/utils/timeshift.sh b/core/tabs/utils/timeshift.sh index afe2c71d..fbc05744 100644 --- a/core/tabs/utils/timeshift.sh +++ b/core/tabs/utils/timeshift.sh @@ -10,10 +10,10 @@ install_timeshift() { if ! command_exists timeshift; then case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "${PACKAGER}" -S --noconfirm timeshift + elevated_execution "${PACKAGER}" -S --noconfirm timeshift ;; *) - "$ESCALATION_TOOL" "${PACKAGER}" install -y timeshift + elevated_execution "${PACKAGER}" install -y timeshift ;; esac else @@ -37,13 +37,13 @@ display_menu() { # Function to list snapshots list_snapshots() { printf "%b\n" "${CYAN}Listing snapshots...${RC}" - "$ESCALATION_TOOL" timeshift --list-snapshots + elevated_execution timeshift --list-snapshots } # Function to list devices list_devices() { printf "%b\n" "${CYAN}Listing available devices...${RC}" - "$ESCALATION_TOOL" timeshift --list-devices + elevated_execution timeshift --list-devices } # Function to create a new snapshot @@ -55,13 +55,13 @@ create_snapshot() { if [ -z "$COMMENT" ] && [ -z "$TAG" ]; then printf "%b\n" "${CYAN}Creating snapshot with no comment or tag...${RC}" - "$ESCALATION_TOOL" timeshift --create + elevated_execution timeshift --create elif [ -z "$TAG" ]; then printf "%b\n" "${CYAN}Creating snapshot with no tag...${RC}" - "$ESCALATION_TOOL" timeshift --create --comments "$COMMENT" + elevated_execution timeshift --create --comments "$COMMENT" else printf "%b\n" "${CYAN}Creating snapshot with tag: $TAG...${RC}" - "$ESCALATION_TOOL" timeshift --create --comments "$COMMENT" --tags "$TAG" + elevated_execution timeshift --create --comments "$COMMENT" --tags "$TAG" fi if [ $? -eq 0 ]; then @@ -83,11 +83,11 @@ restore_snapshot() { read -r SKIP_GRUB if [ "$SKIP_GRUB" = "y" ] || [ "$SKIP_GRUB" = "Y" ]; then - "$ESCALATION_TOOL" timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --skip-grub --yes + elevated_execution timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --skip-grub --yes else printf "%b\n" "${CYAN}Enter GRUB device (e.g., /dev/sda): ${RC}" read -r GRUB_DEVICE - "$ESCALATION_TOOL" timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --grub-device "$GRUB_DEVICE" --yes + elevated_execution timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --grub-device "$GRUB_DEVICE" --yes fi if [ $? -eq 0 ]; then @@ -105,7 +105,7 @@ delete_snapshot() { read -r SNAPSHOT printf "%b\n" "${YELLOW}Deleting snapshot $SNAPSHOT...${RC}" - "$ESCALATION_TOOL" timeshift --delete --snapshot "$SNAPSHOT" --yes + elevated_execution timeshift --delete --snapshot "$SNAPSHOT" --yes if [ $? -eq 0 ]; then printf "%b\n" "${GREEN}Snapshot deleted successfully.${RC}" @@ -122,7 +122,7 @@ delete_all_snapshots() { if [ "$CONFIRMATION" = "y" ] || [ "$CONFIRMATION" = "Y" ]; then printf "%b\n" "${CYAN}Deleting all snapshots...${RC}" - "$ESCALATION_TOOL" timeshift --delete-all --yes + elevated_execution timeshift --delete-all --yes if [ $? -eq 0 ]; then printf "%b\n" "${GREEN}All snapshots deleted successfully.${RC}" else 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..3eee3306 100755 --- a/core/tabs/utils/user-account-manager/add_to_group.sh +++ b/core/tabs/utils/user-account-manager/add_to_group.sh @@ -36,7 +36,7 @@ addToGroup() { read -r confirm confirmAction || exit 1 - "$ESCALATION_TOOL" usermod -aG "$groups_to_add" "$username" + elevated_execution usermod -aG "$groups_to_add" "$username" printf "%b\n" "${GREEN}User successfully added to the $groups_to_add${RC}" } diff --git a/core/tabs/utils/user-account-manager/add_user.sh b/core/tabs/utils/user-account-manager/add_user.sh index 26435f41..643fcdcb 100755 --- a/core/tabs/utils/user-account-manager/add_user.sh +++ b/core/tabs/utils/user-account-manager/add_user.sh @@ -26,8 +26,8 @@ createUser() { exit 1 fi - "$ESCALATION_TOOL" useradd -m "$username" -g users -s /bin/bash - echo "$username:$password" | "$ESCALATION_TOOL" chpasswd + elevated_execution useradd -m "$username" -g users -s /bin/bash + echo "$username:$password" | elevated_execution chpasswd printf "%b\n" "${GREEN}User $username created successfully${RC}" printf "%b\n" "${GREEN}To add additional groups use Add User To Groups${RC}" diff --git a/core/tabs/utils/user-account-manager/change_password.sh b/core/tabs/utils/user-account-manager/change_password.sh index a909a5b2..f61096dd 100755 --- a/core/tabs/utils/user-account-manager/change_password.sh +++ b/core/tabs/utils/user-account-manager/change_password.sh @@ -20,7 +20,7 @@ changePassword() { read -r confirm confirmAction || exit 1 - echo "$username:$password" | "$ESCALATION_TOOL" chpasswd + echo "$username:$password" | elevated_execution chpasswd printf "%b\n" "${GREEN}Password changed successfully${RC}" else printf "%b\n" "${RED}User $username does not exist.${RC}" diff --git a/core/tabs/utils/utility_functions.sh b/core/tabs/utils/utility_functions.sh index b9ed3127..5c2a7c69 100755 --- a/core/tabs/utils/utility_functions.sh +++ b/core/tabs/utils/utility_functions.sh @@ -8,13 +8,13 @@ setup_xrandr() { if ! command_exists xrandr; then case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm xorg-xrandr + elevated_execution "$PACKAGER" -S --noconfirm xorg-xrandr ;; apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" install -y x11-xserver-utils + elevated_execution "$PACKAGER" install -y x11-xserver-utils ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y xorg-x11-server-utils + elevated_execution "$PACKAGER" install -y xorg-x11-server-utils ;; esac else diff --git a/core/tabs/utils/wifi-control.sh b/core/tabs/utils/wifi-control.sh index 14faec0a..681548b4 100755 --- a/core/tabs/utils/wifi-control.sh +++ b/core/tabs/utils/wifi-control.sh @@ -8,13 +8,13 @@ setupNetworkManager() { if ! command_exists nmcli; then case "$PACKAGER" in pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm networkmanager + elevated_execution "$PACKAGER" -S --noconfirm networkmanager ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y NetworkManager-1 + elevated_execution "$PACKAGER" install -y NetworkManager-1 ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y network-manager + elevated_execution "$PACKAGER" install -y network-manager ;; esac else @@ -24,7 +24,7 @@ setupNetworkManager() { # 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 + elevated_execution systemctl start NetworkManager if systemctl is-active --quiet NetworkManager; then printf "%b\n" "${GREEN}NetworkManager service started successfully.${RC}" diff --git a/tui/src/main.rs b/tui/src/main.rs index 8320cc6d..1433ddca 100644 --- a/tui/src/main.rs +++ b/tui/src/main.rs @@ -42,6 +42,12 @@ struct Args { } fn main() -> io::Result<()> { + if sudo::check() != sudo::RunningAs::User && !Args::parse().allow_root { + eprintln!("Error: This program is not intended to be run with elevated privileges."); + eprintln!("To bypass this restriction, use the '--allow-root' flag."); + std::process::exit(1); + } + let args = Args::parse(); let mut state = AppState::new(args.theme, args.override_validation); From f6314414fe88b7e2276f041972b83bd768282d99 Mon Sep 17 00:00:00 2001 From: Jeevitha Kannan K S Date: Mon, 14 Oct 2024 11:05:15 +0530 Subject: [PATCH 4/6] Seperate root check logic --- Cargo.lock | 32 ++++++++++++-------- tui/Cargo.toml | 2 +- tui/src/main.rs | 80 ++++--------------------------------------------- tui/src/root.rs | 69 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 88 deletions(-) create mode 100644 tui/src/root.rs diff --git a/Cargo.lock b/Cargo.lock index 9e1eefa6..86a8cbe5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -178,6 +178,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "chrono" version = "0.4.38" @@ -506,11 +512,11 @@ dependencies = [ "crossterm", "ego-tree", "linutil_core", + "nix 0.29.0", "oneshot", "portable-pty", "rand", "ratatui", - "sudo", "temp-dir", "tree-sitter-bash", "tree-sitter-highlight", @@ -598,6 +604,18 @@ dependencies = [ "pin-utils", ] +[[package]] +name = "nix" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "cfg_aliases", + "libc", +] + [[package]] name = "nom" version = "7.1.3" @@ -677,7 +695,7 @@ dependencies = [ "lazy_static", "libc", "log", - "nix", + "nix 0.25.1", "serial", "shared_library", "shell-words", @@ -1007,16 +1025,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sudo" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88bd84d4c082e18e37fef52c0088e4407dabcef19d23a607fb4b5ee03b7d5b83" -dependencies = [ - "libc", - "log", -] - [[package]] name = "syn" version = "2.0.77" diff --git a/tui/Cargo.toml b/tui/Cargo.toml index d5532b11..f1f596bf 100644 --- a/tui/Cargo.toml +++ b/tui/Cargo.toml @@ -30,8 +30,8 @@ tree-sitter-highlight = "0.24.2" tree-sitter-bash = "0.23.1" anstyle = "1.0.8" ansi-to-tui = "6.0.0" -sudo = "0.6.0" zips = "0.1.7" +nix = { version = "0.29.0", features = [ "user" ] } [build-dependencies] chrono = "0.4.33" diff --git a/tui/src/main.rs b/tui/src/main.rs index 1433ddca..db0d3e27 100644 --- a/tui/src/main.rs +++ b/tui/src/main.rs @@ -3,6 +3,7 @@ mod filter; mod float; mod floating_text; mod hint; +mod root; mod running_command; pub mod state; mod theme; @@ -15,18 +16,12 @@ use std::{ use crate::theme::Theme; use clap::Parser; use crossterm::{ - event::{self, DisableMouseCapture, Event, KeyCode, KeyEvent, KeyEventKind}, + event::{self, DisableMouseCapture, Event, KeyEventKind}, style::ResetColor, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, ExecutableCommand, }; -use ratatui::{ - backend::CrosstermBackend, - layout::{Alignment, Constraint, Layout}, - style::Stylize, - widgets::{Paragraph, Wrap}, - Terminal, -}; +use ratatui::{backend::CrosstermBackend, Terminal}; use state::AppState; // Linux utility toolbox @@ -42,12 +37,6 @@ struct Args { } fn main() -> io::Result<()> { - if sudo::check() != sudo::RunningAs::User && !Args::parse().allow_root { - eprintln!("Error: This program is not intended to be run with elevated privileges."); - eprintln!("To bypass this restriction, use the '--allow-root' flag."); - std::process::exit(1); - } - let args = Args::parse(); let mut state = AppState::new(args.theme, args.override_validation); @@ -73,67 +62,8 @@ fn run( terminal: &mut Terminal>, state: &mut AppState, ) -> io::Result<()> { - if sudo::check() == sudo::RunningAs::Root { - terminal.draw(|frame| { - let root_warn = Paragraph::new( - r#" -!!!!!!!!!!!!!! YOU ARE ABOUT TO RUN LINUTIL AS ROOT !!!!!!!!!!!!!! - -This utility prioritizes compatibility with non-root environments. -Some scripts may work without any issues, some may not. -You have been warned! - -!!!!!!!!!!!!!!!!!!!!!! PROCEED WITH CAUTION !!!!!!!!!!!!!!!!!!!!!! - -Press [y] to continue, [n] to abort -"#, - ) - .on_black() - .white() - .alignment(Alignment::Center) - .wrap(Wrap { trim: true }); - - let rects = Layout::vertical([ - Constraint::Fill(1), - Constraint::Length(10), - Constraint::Fill(1), - ]) - .split(frame.area()); - - let centered = rects[1]; - - frame.render_widget(root_warn, centered); - })?; - - loop { - match event::read()? { - Event::Key( - KeyEvent { - code: KeyCode::Char('y'), - .. - } - | KeyEvent { - code: KeyCode::Char('Y'), - .. - }, - ) => { - break; - } - Event::Key( - KeyEvent { - code: KeyCode::Char('n'), - .. - } - | KeyEvent { - code: KeyCode::Char('N'), - .. - }, - ) => { - return Ok(()); - } - _ => {} - } - } + if !root::check_root(terminal)? { + return Ok(()); } loop { diff --git a/tui/src/root.rs b/tui/src/root.rs new file mode 100644 index 00000000..c8ba0b48 --- /dev/null +++ b/tui/src/root.rs @@ -0,0 +1,69 @@ +use ratatui::{ + backend::CrosstermBackend, + crossterm::event::{self, Event, KeyCode, KeyEvent}, + layout::{Alignment, Constraint, Layout}, + style::{Style, Stylize}, + widgets::{Paragraph, Wrap}, + Terminal, +}; +use std::io; + +pub fn check_root(terminal: &mut Terminal>) -> io::Result { + if nix::unistd::geteuid().is_root() { + terminal.draw(|frame| { + let root_warn = Paragraph::new( + r#" +!!!!!!!!!!!!!! YOU ARE ABOUT TO RUN LINUTIL AS ROOT !!!!!!!!!!!!!! +This utility prioritizes compatibility with non-root environments. +Some scripts may work without any issues, some may not. +You have been warned! +!!!!!!!!!!!!!!!!!!!!!! PROCEED WITH CAUTION !!!!!!!!!!!!!!!!!!!!!! +Press [y] to continue, [n] to abort +"#, + ) + .white() + .on_black() + .alignment(Alignment::Center) + .style(Style::default().bold()) + .wrap(Wrap { trim: true }); + + let rects = Layout::vertical([ + Constraint::Fill(1), + Constraint::Length(10), + Constraint::Fill(1), + ]) + .split(frame.area()); + + let centered = rects[1]; + + frame.render_widget(root_warn, centered); + })?; + + loop { + match event::read()? { + Event::Key( + KeyEvent { + code: KeyCode::Char('y'), + .. + } + | KeyEvent { + code: KeyCode::Char('Y'), + .. + }, + ) => break, + Event::Key( + KeyEvent { + code: KeyCode::Char('n'), + .. + } + | KeyEvent { + code: KeyCode::Char('N'), + .. + }, + ) => return Ok(false), + _ => {} + } + } + } + Ok(true) +} From ef59216d12e7dfce6054739678560da9c0fc50aa Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Mon, 14 Oct 2024 20:04:09 +0530 Subject: [PATCH 5/6] Update core/tabs/common-script.sh Co-authored-by: Adam Perkowski --- core/tabs/common-script.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/tabs/common-script.sh b/core/tabs/common-script.sh index 2fe3896b..a6c23b3d 100644 --- a/core/tabs/common-script.sh +++ b/core/tabs/common-script.sh @@ -51,9 +51,8 @@ checkAURHelper() { } checkEscalationTool() { - ## Check for escalation tools. if [ "$(id -u)" -eq 0 ]; then - printf "%b\n" "${CYAN}Running as root, no need for escalation tool.${RC}" + printf "%b\n" "${CYAN}Running as root. Skipping escalation tool check.${RC}" ESCALATION_TOOL_CHECKED=true return 0 fi From 8eb3ba88b45a9adbd3bd07d9560ed9fe8dc70506 Mon Sep 17 00:00:00 2001 From: Liam <33645555+lj3954@users.noreply.github.com> Date: Mon, 21 Oct 2024 23:24:51 -0700 Subject: [PATCH 6/6] refactor: Reduce nesting in root module --- tui/src/root.rs | 66 ++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 39 deletions(-) diff --git a/tui/src/root.rs b/tui/src/root.rs index c8ba0b48..638f0c51 100644 --- a/tui/src/root.rs +++ b/tui/src/root.rs @@ -8,62 +8,50 @@ use ratatui::{ }; use std::io; -pub fn check_root(terminal: &mut Terminal>) -> io::Result { - if nix::unistd::geteuid().is_root() { - terminal.draw(|frame| { - let root_warn = Paragraph::new( - r#" +const ROOT_WARNING: &str = r#" !!!!!!!!!!!!!! YOU ARE ABOUT TO RUN LINUTIL AS ROOT !!!!!!!!!!!!!! This utility prioritizes compatibility with non-root environments. Some scripts may work without any issues, some may not. You have been warned! !!!!!!!!!!!!!!!!!!!!!! PROCEED WITH CAUTION !!!!!!!!!!!!!!!!!!!!!! Press [y] to continue, [n] to abort -"#, - ) +"#; + +pub fn check_root(terminal: &mut Terminal>) -> io::Result { + if !nix::unistd::geteuid().is_root() { + return Ok(true); + } + terminal.draw(|frame| { + let root_warn = Paragraph::new(ROOT_WARNING) .white() .on_black() .alignment(Alignment::Center) .style(Style::default().bold()) .wrap(Wrap { trim: true }); - let rects = Layout::vertical([ - Constraint::Fill(1), - Constraint::Length(10), - Constraint::Fill(1), - ]) - .split(frame.area()); + let rects = Layout::vertical([ + Constraint::Fill(1), + Constraint::Length(10), + Constraint::Fill(1), + ]) + .split(frame.area()); - let centered = rects[1]; + let centered = rects[1]; - frame.render_widget(root_warn, centered); - })?; + frame.render_widget(root_warn, centered); + })?; - loop { - match event::read()? { - Event::Key( - KeyEvent { - code: KeyCode::Char('y'), - .. - } - | KeyEvent { - code: KeyCode::Char('Y'), - .. - }, - ) => break, - Event::Key( - KeyEvent { - code: KeyCode::Char('n'), - .. - } - | KeyEvent { - code: KeyCode::Char('N'), - .. - }, - ) => return Ok(false), + loop { + if let Event::Key(KeyEvent { + code: KeyCode::Char(ch), + .. + }) = event::read()? + { + match ch.to_ascii_lowercase() { + 'y' => return Ok(true), + 'n' => return Ok(false), _ => {} } } } - Ok(true) }