diff --git a/.github/workflows/bashisms.yml b/.github/workflows/bashisms.yml index cffacb04..d4d1490f 100644 --- a/.github/workflows/bashisms.yml +++ b/.github/workflows/bashisms.yml @@ -3,11 +3,11 @@ name: Check for bashisms on: # push: # paths: - # - tabs/** + # - core/tabs/** # branches: [ "main" ] pull_request: paths: - - tabs/** + - core/tabs/** merge_group: workflow_dispatch: @@ -24,8 +24,8 @@ jobs: - name: Check for bashisms in changed files run: | - for file in $(git diff --name-only origin/${{ github.base_ref }} HEAD tabs); do - if [[ "$file" == *.sh ]]; then + for file in $(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs); do + if [[ "$file" == *.sh ]] && [[ -f "$file" ]]; then checkbashisms "$file" fi done diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index adcd8048..e91ad941 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -3,7 +3,7 @@ name: ShellCheck on: pull_request: paths: - - 'tabs/**/*.sh' + - 'core/tabs/**/*.sh' workflow_dispatch: jobs: @@ -11,9 +11,20 @@ jobs: name: Shellcheck runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Run ShellCheck - uses: ludeeus/action-shellcheck@master - with: - scandir: 'tabs' - severity: error \ No newline at end of file + - uses: actions/checkout@v4 + - run: git fetch origin ${{ github.base_ref }} + + - name: Download and set up shellcheck + run : | + wget https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.x86_64.tar.xz + tar -xf shellcheck-v0.10.0.linux.x86_64.tar.xz + cd shellcheck-v0.10.0 + chmod +x shellcheck + + - name: Run shellcheck + run: | + for file in $(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs); do + if [[ "$file" == *.sh ]] && [[ -f "$file" ]]; then + ./shellcheck-v0.10.0/shellcheck -S error "$file" + fi + done diff --git a/Cargo.lock b/Cargo.lock index c3798ede..a558b3ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -452,7 +452,7 @@ checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "linutil_core" -version = "0.1.0" +version = "24.9.19" dependencies = [ "ego-tree", "include_dir", @@ -464,7 +464,7 @@ dependencies = [ [[package]] name = "linutil_tui" -version = "0.1.0" +version = "24.9.19" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 551f0bc4..ebb3544d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace.package] license = "MIT" -version = "0.1.0" +version = "24.9.19" [workspace.dependencies] ego-tree = "0.6.2" @@ -16,4 +16,4 @@ lto = true codegen-units = 1 panic = "abort" strip = true -incremental = false +incremental = false \ No newline at end of file diff --git a/README.md b/README.md index 9892d5aa..a924e7f1 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![](https://dcbadge.limes.pink/api/server/https://discord.gg/bujFYKAHSp)](https://discord.gg/bujFYKAHSp) -[![linutil AUR Version](https://img.shields.io/aur/version/linutil?style=for-the-badge&label=%5BAUR%5D%20linutil&color=%23230567ff)](https://aur.archlinux.org/packages/linutil) [![linutil-bin AUR Version](https://img.shields.io/aur/version/linutil-bin?style=for-the-badge&label=%5BAUR%5D%20linutil-bin&color=%23230567ff)](https://aur.archlinux.org/packages/linutil-bin) +[![Crates.io Version](https://img.shields.io/crates/v/linutil_tui?style=for-the-badge&color=%23af3a03)](https://crates.io/crates/linutil_tui) [![linutil AUR Version](https://img.shields.io/aur/version/linutil?style=for-the-badge&label=%5BAUR%5D%20linutil&color=%23230567ff)](https://aur.archlinux.org/packages/linutil) [![linutil-bin AUR Version](https://img.shields.io/aur/version/linutil-bin?style=for-the-badge&label=%5BAUR%5D%20linutil-bin&color=%23230567ff)](https://aur.archlinux.org/packages/linutil-bin) ![Preview](docs/assets/preview.png) @@ -44,6 +44,11 @@ Thank you to everyone who has contributed to the development of Linutil. Your ef [![Contributors](https://contrib.rocks/image?repo=ChrisTitusTech/linutil)](https://github.com/ChrisTitusTech/linutil/graphs/contributors) -## 📜 Credits +## 📜 Contributor Milestones -Linutil’s Rust shell was developed by [@JustLinuxUser](https://github.com/JustLinuxUser). +- 2024/07 - Original Linutil Rust TUI was developed by [@JustLinuxUser](https://github.com/JustLinuxUser). +- 2024/09 - TabList (Left Column) and various Rust Core/TUI Improvements developed by [@lj3954](https://github.com/lj3954) +- 2024/09 - Cargo Publish, AUR, Rust, and Bash additions done by [@adamperkowski](https://github.com/adamperkowski) +- 2024/09 - Rust TUI Min/Max, MultiSelection, and Bash additions done by [@jeevithakannan2](https://github.com/jeevithakannan2) +- 2024/09 - Various bash updates and standardization done by [@nnyyxxxx](https://github.com/nnyyxxxx) +- 2024/09 - Multiple bash script additions done by [@guruswarupa](https://github.com/guruswarupa) diff --git a/core/Cargo.toml b/core/Cargo.toml index fdabe609..8605c94c 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,8 +1,15 @@ [package] name = "linutil_core" +description = "The backend of Linutil." +repository = "https://github.com/ChrisTitusTech/linutil/tree/main/core" edition = "2021" version.workspace = true license.workspace = true +include = [ + "src/*.rs", + "Cargo.toml", + "tabs/**", +] [dependencies] include_dir = "0.7.4" diff --git a/core/src/inner.rs b/core/src/inner.rs index f936e3b2..00761c2d 100644 --- a/core/src/inner.rs +++ b/core/src/inner.rs @@ -5,7 +5,7 @@ use serde::Deserialize; use std::path::{Path, PathBuf}; use tempdir::TempDir; -const TAB_DATA: Dir = include_dir!("$CARGO_MANIFEST_DIR/../tabs"); +const TAB_DATA: Dir = include_dir!("$CARGO_MANIFEST_DIR/tabs"); pub fn get_tabs(validate: bool) -> Vec { let tab_files = TabList::get_tabs(); diff --git a/tabs/applications-setup/alacritty-setup.sh b/core/tabs/applications-setup/alacritty-setup.sh similarity index 100% rename from tabs/applications-setup/alacritty-setup.sh rename to core/tabs/applications-setup/alacritty-setup.sh diff --git a/tabs/applications-setup/bottles-setup.sh b/core/tabs/applications-setup/bottles-setup.sh similarity index 100% rename from tabs/applications-setup/bottles-setup.sh rename to core/tabs/applications-setup/bottles-setup.sh diff --git a/tabs/applications-setup/browser-setup.sh b/core/tabs/applications-setup/browser-setup.sh similarity index 100% rename from tabs/applications-setup/browser-setup.sh rename to core/tabs/applications-setup/browser-setup.sh diff --git a/tabs/applications-setup/dwmtitus-setup.sh b/core/tabs/applications-setup/dwmtitus-setup.sh similarity index 100% rename from tabs/applications-setup/dwmtitus-setup.sh rename to core/tabs/applications-setup/dwmtitus-setup.sh diff --git a/tabs/applications-setup/fastfetch-setup.sh b/core/tabs/applications-setup/fastfetch-setup.sh similarity index 100% rename from tabs/applications-setup/fastfetch-setup.sh rename to core/tabs/applications-setup/fastfetch-setup.sh diff --git a/tabs/applications-setup/kitty-setup.sh b/core/tabs/applications-setup/kitty-setup.sh similarity index 100% rename from tabs/applications-setup/kitty-setup.sh rename to core/tabs/applications-setup/kitty-setup.sh diff --git a/core/tabs/applications-setup/linutil-installer.sh b/core/tabs/applications-setup/linutil-installer.sh new file mode 100755 index 00000000..7fbb09a6 --- /dev/null +++ b/core/tabs/applications-setup/linutil-installer.sh @@ -0,0 +1,62 @@ +#!/bin/sh -e + +. ../common-script.sh + +installLinutil() { + printf "%b\n" "${YELLOW}Installing Linutil...${RC}" + case "$PACKAGER" in + pacman) + printf "%b\n" "-----------------------------------------------------" + printf "%b\n" "Select the package to install:" + printf "%b\n" "1. ${CYAN}linutil${RC} (stable release compiled from source)" + printf "%b\n" "2. ${CYAN}linutil-bin${RC} (stable release pre-compiled)" + printf "%b\n" "3. ${CYAN}linutil-git${RC} (compiled from the latest commit)" + printf "%b\n" "-----------------------------------------------------" + printf "%b" "Enter your choice: " + read -r choice + case $choice in + 1) "$AUR_HELPER" -S --noconfirm linutil ;; + 2) "$AUR_HELPER" -S --noconfirm linutil-bin ;; + 3) "$AUR_HELPER" -S --noconfirm linutil-git ;; + *) + printf "%b\n" "${RED}Invalid choice:${RC} $choice" + exit 1 + ;; + esac + printf "%b\n" "${GREEN}Installed successfully.${RC}" + ;; + *) + printf "%b\n" "${RED}There are no official packages for your distro.${RC}" + printf "%b" "${YELLOW}Do you want to install the crates.io package? (y/N) ${RC}" + read -r choice + case $choice in + y|Y) + if ! command_exists cargo; then + printf "%b\n" "${YELLOW}Installing rustup...${RC}" + case "$PACKAGER" in + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup + ;; + zypper) + "$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + . $HOME/.cargo/env + ;; + *) + "$ESCALATION_TOOL" "$PACKAGER" install -y rustup + ;; + esac + fi + rustup default stable + cargo install --force linutil_tui + printf "%b\n" "${GREEN}Installed successfully.${RC}" + ;; + *) printf "%b\n" "${RED}Linutil not installed.${RC}" ;; + esac + esac +} + +checkEnv +checkEscalationTool +checkAURHelper +installLinutil diff --git a/core/tabs/applications-setup/linutil-updater.sh b/core/tabs/applications-setup/linutil-updater.sh new file mode 100755 index 00000000..8cf1762d --- /dev/null +++ b/core/tabs/applications-setup/linutil-updater.sh @@ -0,0 +1,45 @@ +#!/bin/sh -e + +. ../common-script.sh + +updateLinutil() { + if [ ! -e "$HOME/.cargo/bin/linutil" ]; then + printf "%b\n" "${RED}This script only updates the binary installed through cargo.\nlinutil_tui is not installed.${RC}" + exit 1 + fi + + if ! command_exists cargo; then + printf "%b\n" "${YELLOW}Installing rustup...${RC}" + case "$PACKAGER" in + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup + ;; + zypper) + "$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + . $HOME/.cargo/env + ;; + *) + "$ESCALATION_TOOL" "$PACKAGER" install -y rustup + ;; + esac + fi + + INSTALLED_VERSION=$(cargo install --list | grep "linutil_tui" | awk '{print $2}' | tr -d 'v:') + LATEST_VERSION=$(curl -s https://crates.io/api/v1/crates/linutil_tui | grep -oP '"max_version":\s*"\K[^"]+') + + if [ "$INSTALLED_VERSION" = "$LATEST_VERSION" ]; then + printf "%b\n" "${GREEN}linutil_tui is up to date.${RC}" + exit 0 + fi + + printf "%b\n" "${YELLOW}Updating linutil_tui...${RC}" + rustup default stable + cargo install --force linutil_tui + printf "%b\n" "${GREEN}Updated successfully.${RC}" +} + +checkEnv +checkEscalationTool +checkAURHelper +updateLinutil diff --git a/tabs/applications-setup/mybash-setup.sh b/core/tabs/applications-setup/mybash-setup.sh similarity index 100% rename from tabs/applications-setup/mybash-setup.sh rename to core/tabs/applications-setup/mybash-setup.sh diff --git a/tabs/applications-setup/neovim-setup.sh b/core/tabs/applications-setup/neovim-setup.sh similarity index 100% rename from tabs/applications-setup/neovim-setup.sh rename to core/tabs/applications-setup/neovim-setup.sh diff --git a/tabs/applications-setup/rofi-setup.sh b/core/tabs/applications-setup/rofi-setup.sh similarity index 100% rename from tabs/applications-setup/rofi-setup.sh rename to core/tabs/applications-setup/rofi-setup.sh diff --git a/tabs/applications-setup/setup-flatpak.sh b/core/tabs/applications-setup/setup-flatpak.sh similarity index 100% rename from tabs/applications-setup/setup-flatpak.sh rename to core/tabs/applications-setup/setup-flatpak.sh diff --git a/tabs/applications-setup/tab_data.toml b/core/tabs/applications-setup/tab_data.toml similarity index 89% rename from tabs/applications-setup/tab_data.toml rename to core/tabs/applications-setup/tab_data.toml index 0a8633b1..c0480ef7 100644 --- a/tabs/applications-setup/tab_data.toml +++ b/core/tabs/applications-setup/tab_data.toml @@ -53,3 +53,23 @@ script = "rofi-setup.sh" name = "ZSH Prompt" description = "The Z shell is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.\nThis command installs ZSH prompt and provides basic configuration." script = "zsh-setup.sh" + +[[data]] +name = "Install Linutil" +description = "Installs a distro-specific Linutil package locally." +script = "linutil-installer.sh" + +[[data.preconditions]] +matches = false +data = "command_exists" +values = [ "linutil" ] + +[[data]] +name = "Update Linutil" +description = "Updates your local Linutil crate installation." +script = "linutil-updater.sh" + +[[data.preconditions]] +matches = true +data = "command_exists" +values = [ "linutil" ] diff --git a/tabs/applications-setup/zsh-setup.sh b/core/tabs/applications-setup/zsh-setup.sh similarity index 100% rename from tabs/applications-setup/zsh-setup.sh rename to core/tabs/applications-setup/zsh-setup.sh diff --git a/tabs/common-script.sh b/core/tabs/common-script.sh similarity index 100% rename from tabs/common-script.sh rename to core/tabs/common-script.sh diff --git a/tabs/gaming/diablo-ii/d2r-loot-filters.sh b/core/tabs/gaming/diablo-ii/d2r-loot-filters.sh similarity index 100% rename from tabs/gaming/diablo-ii/d2r-loot-filters.sh rename to core/tabs/gaming/diablo-ii/d2r-loot-filters.sh diff --git a/tabs/gaming/tab_data.toml b/core/tabs/gaming/tab_data.toml similarity index 100% rename from tabs/gaming/tab_data.toml rename to core/tabs/gaming/tab_data.toml diff --git a/tabs/security/firewall-baselines.sh b/core/tabs/security/firewall-baselines.sh similarity index 100% rename from tabs/security/firewall-baselines.sh rename to core/tabs/security/firewall-baselines.sh diff --git a/tabs/security/tab_data.toml b/core/tabs/security/tab_data.toml similarity index 100% rename from tabs/security/tab_data.toml rename to core/tabs/security/tab_data.toml diff --git a/tabs/system-setup/arch/paru-setup.sh b/core/tabs/system-setup/arch/paru-setup.sh similarity index 100% rename from tabs/system-setup/arch/paru-setup.sh rename to core/tabs/system-setup/arch/paru-setup.sh diff --git a/tabs/system-setup/arch/server-setup.sh b/core/tabs/system-setup/arch/server-setup.sh similarity index 100% rename from tabs/system-setup/arch/server-setup.sh rename to core/tabs/system-setup/arch/server-setup.sh diff --git a/tabs/system-setup/arch/yay-setup.sh b/core/tabs/system-setup/arch/yay-setup.sh similarity index 100% rename from tabs/system-setup/arch/yay-setup.sh rename to core/tabs/system-setup/arch/yay-setup.sh diff --git a/tabs/system-setup/auto-mount.sh b/core/tabs/system-setup/auto-mount.sh similarity index 100% rename from tabs/system-setup/auto-mount.sh rename to core/tabs/system-setup/auto-mount.sh diff --git a/tabs/system-setup/compile-setup.sh b/core/tabs/system-setup/compile-setup.sh similarity index 100% rename from tabs/system-setup/compile-setup.sh rename to core/tabs/system-setup/compile-setup.sh diff --git a/tabs/system-setup/docker-setup.sh b/core/tabs/system-setup/docker-setup.sh similarity index 100% rename from tabs/system-setup/docker-setup.sh rename to core/tabs/system-setup/docker-setup.sh diff --git a/tabs/system-setup/fedora/configure-dnf.sh b/core/tabs/system-setup/fedora/configure-dnf.sh similarity index 100% rename from tabs/system-setup/fedora/configure-dnf.sh rename to core/tabs/system-setup/fedora/configure-dnf.sh diff --git a/tabs/system-setup/fedora/multimedia-codecs.sh b/core/tabs/system-setup/fedora/multimedia-codecs.sh similarity index 100% rename from tabs/system-setup/fedora/multimedia-codecs.sh rename to core/tabs/system-setup/fedora/multimedia-codecs.sh diff --git a/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh b/core/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh similarity index 100% rename from tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh rename to core/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh diff --git a/tabs/system-setup/fedora/rpm-fusion-setup.sh b/core/tabs/system-setup/fedora/rpm-fusion-setup.sh similarity index 100% rename from tabs/system-setup/fedora/rpm-fusion-setup.sh rename to core/tabs/system-setup/fedora/rpm-fusion-setup.sh diff --git a/tabs/system-setup/fedora/virtualization.sh b/core/tabs/system-setup/fedora/virtualization.sh similarity index 100% rename from tabs/system-setup/fedora/virtualization.sh rename to core/tabs/system-setup/fedora/virtualization.sh diff --git a/tabs/system-setup/gaming-setup.sh b/core/tabs/system-setup/gaming-setup.sh similarity index 100% rename from tabs/system-setup/gaming-setup.sh rename to core/tabs/system-setup/gaming-setup.sh diff --git a/tabs/system-setup/global-theme.sh b/core/tabs/system-setup/global-theme.sh similarity index 100% rename from tabs/system-setup/global-theme.sh rename to core/tabs/system-setup/global-theme.sh diff --git a/tabs/system-setup/grub-theme.sh b/core/tabs/system-setup/grub-theme.sh similarity index 99% rename from tabs/system-setup/grub-theme.sh rename to core/tabs/system-setup/grub-theme.sh index 1e860576..d0b35420 100644 --- a/tabs/system-setup/grub-theme.sh +++ b/core/tabs/system-setup/grub-theme.sh @@ -1,4 +1,5 @@ #!/bin/sh -e + . ../common-script.sh themeinstall(){ diff --git a/tabs/system-setup/remove-snaps.sh b/core/tabs/system-setup/remove-snaps.sh similarity index 100% rename from tabs/system-setup/remove-snaps.sh rename to core/tabs/system-setup/remove-snaps.sh diff --git a/tabs/system-setup/samba-ssh-setup.sh b/core/tabs/system-setup/samba-ssh-setup.sh similarity index 98% rename from tabs/system-setup/samba-ssh-setup.sh rename to core/tabs/system-setup/samba-ssh-setup.sh index b130b290..027fe588 100755 --- a/tabs/system-setup/samba-ssh-setup.sh +++ b/core/tabs/system-setup/samba-ssh-setup.sh @@ -157,8 +157,8 @@ configure_firewall() { } setup_ssh_samba(){ - printf "Samba and SSH Setup Script\n" - printf "----------------------------\n" + printf "%b\n" "Samba and SSH Setup Script" + printf "%b\n" "--------------------------" clear # Display menu diff --git a/tabs/system-setup/system-cleanup.sh b/core/tabs/system-setup/system-cleanup.sh similarity index 100% rename from tabs/system-setup/system-cleanup.sh rename to core/tabs/system-setup/system-cleanup.sh diff --git a/tabs/system-setup/system-update.sh b/core/tabs/system-setup/system-update.sh similarity index 100% rename from tabs/system-setup/system-update.sh rename to core/tabs/system-setup/system-update.sh diff --git a/tabs/system-setup/tab_data.toml b/core/tabs/system-setup/tab_data.toml similarity index 100% rename from tabs/system-setup/tab_data.toml rename to core/tabs/system-setup/tab_data.toml diff --git a/tabs/tabs.toml b/core/tabs/tabs.toml similarity index 100% rename from tabs/tabs.toml rename to core/tabs/tabs.toml diff --git a/tabs/utils/auto-login.sh b/core/tabs/utils/auto-login.sh similarity index 54% rename from tabs/utils/auto-login.sh rename to core/tabs/utils/auto-login.sh index 80fee2df..5437c4f8 100644 --- a/tabs/utils/auto-login.sh +++ b/core/tabs/utils/auto-login.sh @@ -4,18 +4,18 @@ # Function to list common session options list_sessions() { - printf "Select the session:\n" - printf "1) GNOME (gnome.desktop)\n" - printf "2) KDE Plasma (plasma.desktop)\n" - printf "3) XFCE (xfce.desktop)\n" - printf "4) LXDE (LXDE.desktop)\n" - printf "5) LXQt (lxqt.desktop)\n" - printf "6) Cinnamon (cinnamon.desktop)\n" - printf "7) MATE (mate.desktop)\n" - printf "8) Openbox (openbox.desktop)\n" - printf "9) i3 (i3.desktop)\n" - printf "10) Custom session\n" - printf "Enter your choice [1-10]: " + printf "%b\n" "Select the session:" + printf "%b\n" "1) GNOME (gnome.desktop)" + printf "%b\n" "2) KDE Plasma (plasma.desktop)" + printf "%b\n" "3) XFCE (xfce.desktop)" + printf "%b\n" "4) LXDE (LXDE.desktop)" + printf "%b\n" "5) LXQt (lxqt.desktop)" + printf "%b\n" "6) Cinnamon (cinnamon.desktop)" + printf "%b\n" "7) MATE (mate.desktop)" + printf "%b\n" "8) Openbox (openbox.desktop)" + printf "%b\n" "9) i3 (i3.desktop)" + printf "%b\n" "10) Custom session" + printf "%b\n" "Enter your choice [1-10]: " read -r session_choice case "$session_choice" in @@ -29,62 +29,59 @@ list_sessions() { 8) session="openbox.desktop" ;; 9) session="i3.desktop" ;; 10) - printf "Enter custom session name (e.g., mysession.desktop): " + printf "%b\n" "Enter custom session name (e.g., mysession.desktop): " read -r session ;; *) - printf "Invalid option selected.\n" + printf "%b\n" "Invalid option selected." exit 1 ;; esac } # Function to configure LightDM configure_lightdm() { - printf "Configuring LightDM for autologin...\n" - - printf "Enter username for LightDM autologin: " + printf "%b\n" "Configuring LightDM for autologin..." + printf "%b\n" "Enter username for LightDM autologin: " read -r user "$ESCALATION_TOOL" "printf '[Seat:*]' > /etc/lightdm/lightdm.conf.d/50-autologin.conf" "$ESCALATION_TOOL" "printf 'autologin-user=$user' >> /etc/lightdm/lightdm.conf.d/50-autologin.conf" "$ESCALATION_TOOL" "printf 'autologin-user-timeout=0' >> /etc/lightdm/lightdm.conf.d/50-autologin.conf" - printf "LightDM has been configured for autologin.\n" + printf "%b\n" "LightDM has been configured for autologin." } # Function to remove LightDM autologin remove_lightdm_autologin() { - printf "Removing LightDM autologin configuration...\n" + printf "%b\n" "Removing LightDM autologin configuration..." "$ESCALATION_TOOL" rm -f /etc/lightdm/lightdm.conf.d/50-autologin.conf - printf "LightDM autologin configuration has been removed.\n" + printf "%b\n" "LightDM autologin configuration has been removed." } # Function to configure GDM configure_gdm() { - printf "Configuring GDM for autologin...\n" - - printf "Enter username for GDM autologin: " + printf "%b\n" "Configuring GDM for autologin..." + printf "%b\n" "Enter username for GDM autologin: " read -r user "$ESCALATION_TOOL" "printf '[daemon]' > /etc/gdm/custom.conf" "$ESCALATION_TOOL" "printf 'AutomaticLoginEnable = true' >> /etc/gdm/custom.conf" "$ESCALATION_TOOL" "printf 'AutomaticLogin = $user' >> /etc/gdm/custom.conf" - printf "GDM has been configured for autologin.\n" + printf "%b\n" "GDM has been configured for autologin." } # Function to remove GDM autologin remove_gdm_autologin() { - printf "Removing GDM autologin configuration...\n" + 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 - printf "GDM autologin configuration has been removed.\n" + printf "%b\n" "GDM autologin configuration has been removed." } # Function to configure SDDM configure_sddm() { - printf "Configuring SDDM for autologin...\n" - - printf "Enter username for SDDM autologin: " + printf "%b\n" "Configuring SDDM for autologin..." + printf "%b\n" "Enter username for SDDM autologin: " read -r user list_sessions # Show session options @@ -92,53 +89,52 @@ configure_sddm() { "$ESCALATION_TOOL" "printf 'User=$user' >> /etc/sddm.conf" "$ESCALATION_TOOL" "printf 'Session=$session' >> /etc/sddm.conf" - printf "SDDM has been configured for autologin.\n" + printf "%b\n" "SDDM has been configured for autologin." } # Function to remove SDDM autologin remove_sddm_autologin() { - printf "Removing SDDM autologin configuration...\n" + printf "%b\n" "Removing SDDM autologin configuration..." "$ESCALATION_TOOL" sed -i '/\[Autologin\]/,+2d' /etc/sddm.conf - printf "SDDM autologin configuration has been removed.\n" + printf "%b\n" "SDDM autologin configuration has been removed." } # Function to configure LXDM configure_lxdm() { - printf "Configuring LXDM for autologin...\n" - - printf "Enter username for LXDM autologin: " + printf "%b\n" "Configuring LXDM for autologin..." + printf "%b\n" "Enter username for LXDM autologin: " 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 - printf "LXDM has been configured for autologin.\n" + printf "%b\n" "LXDM has been configured for autologin." } # Function to remove LXDM autologin remove_lxdm_autologin() { - printf "Removing LXDM autologin configuration...\n" + 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 - printf "LXDM autologin configuration has been removed.\n" + printf "%b\n" "LXDM autologin configuration has been removed." } # Function to configure or remove autologin based on user choice configure_or_remove_autologin() { - printf "Do you want to add or remove autologin?\n" - printf "1) Add autologin\n" - printf "2) Remove autologin\n" - printf "Enter your choice [1-2]: " + printf "%b\n" "Do you want to add or remove autologin?" + printf "%b\n" "1) Add autologin" + printf "%b\n" "2) Remove autologin" + printf "%b\n" "Enter your choice [1-2]: " read -r action_choice if [ "$action_choice" = "1" ]; then - printf "Choose the display manager to configure:\n" - printf "1) LightDM\n" - printf "2) GDM\n" - printf "3) SDDM\n" - printf "4) LXDM\n" - printf "Enter your choice [1-4]: " + printf "%b\n" "Choose the display manager to configure:" + printf "%b\n" "1) LightDM" + printf "%b\n" "2) GDM" + printf "%b\n" "3) SDDM" + printf "%b\n" "4) LXDM" + printf "%b\n" "Enter your choice [1-4]: " read -r choice case "$choice" in @@ -146,15 +142,15 @@ configure_or_remove_autologin() { 2) configure_gdm ;; 3) configure_sddm ;; 4) configure_lxdm ;; - *) printf "Invalid option selected.\n" ;; + *) printf "%b\n" "Invalid option selected." ;; esac elif [ "$action_choice" = "2" ]; then - printf "Choose the display manager to remove autologin:\n" - printf "1) LightDM\n" - printf "2) GDM\n" - printf "3) SDDM\n" - printf "4) LXDM\n" - printf "Enter your choice [1-4]: " + printf "%b\n" "Choose the display manager to remove autologin:" + printf "%b\n" "1) LightDM" + printf "%b\n" "2) GDM" + printf "%b\n" "3) SDDM" + printf "%b\n" "4) LXDM" + printf "%b\n" "Enter your choice [1-4]: " read -r choice case "$choice" in @@ -162,14 +158,14 @@ configure_or_remove_autologin() { 2) remove_gdm_autologin ;; 3) remove_sddm_autologin ;; 4) remove_lxdm_autologin ;; - *) printf "Invalid option selected.\n" ;; + *) printf "%b\n" "Invalid option selected." ;; esac else - printf "Invalid choice. Exiting...\n" + printf "%b\n" "Invalid choice. Exiting..." exit 1 fi - printf "Action completed. Exiting...\n" + printf "%b\n" "Action completed. Exiting..." exit 0 } diff --git a/tabs/utils/bluetooth-control.sh b/core/tabs/utils/bluetooth-control.sh similarity index 100% rename from tabs/utils/bluetooth-control.sh rename to core/tabs/utils/bluetooth-control.sh diff --git a/tabs/utils/create-bootable-usb.sh b/core/tabs/utils/create-bootable-usb.sh similarity index 96% rename from tabs/utils/create-bootable-usb.sh rename to core/tabs/utils/create-bootable-usb.sh index 17e422c2..30bf1bfa 100644 --- a/tabs/utils/create-bootable-usb.sh +++ b/core/tabs/utils/create-bootable-usb.sh @@ -5,7 +5,7 @@ # Function to display usage instructions usage() { printf "%b\n" "${RED} Usage: $0 ${RC}" - printf "No arguments needed. The script will prompt for ISO path and USB device.\n" + printf "%b\n" "No arguments needed. The script will prompt for ISO path and USB device." exit 1 } @@ -98,9 +98,9 @@ choose_iso_source() { fetch_iso_urls() { clear printf "%b\n" "${YELLOW}Available ISOs for download:${RC}" - printf "1) Arch Linux (latest)\n" - printf "2) Arch Linux (older versions)\n" - printf "3) Debian Linux (latest)\n" + printf "%b\n" "1) Arch Linux (latest)" + printf "%b\n" "2) Arch Linux (older versions)" + printf "%b\n" "3) Debian Linux (latest)" printf "\n" printf "Select the ISO you want to download (1-3): " read -r ISO_OPTION diff --git a/tabs/utils/encrypt_decrypt_tool.sh b/core/tabs/utils/encrypt_decrypt_tool.sh similarity index 58% rename from tabs/utils/encrypt_decrypt_tool.sh rename to core/tabs/utils/encrypt_decrypt_tool.sh index 8a4f033f..4c2818f5 100644 --- a/tabs/utils/encrypt_decrypt_tool.sh +++ b/core/tabs/utils/encrypt_decrypt_tool.sh @@ -22,39 +22,39 @@ if ! command_exists openssl; then *) printf "%b\n" "${RED}Your Linux distribution is not supported by this script.${RC}" printf "%b\n" "${YELLOW}You can try installing OpenSSL manually:${RC}" - echo "1. Refer to your distribution's documentation." + printf "%b\n" "1. Refer to your distribution's documentation." ;; esac fi show_menu() { - echo "========================================================" - echo " File/Directory Encryption/Decryption" - echo "========================================================" - echo "How to use:-" - echo "if you encrypt or decrypt a file include new file name for successful operation" - echo "if you encrypt or decrypt a folder include new directory name for successful operation" - echo "========================================================" - echo "1. Encrypt a file or directory" - echo "2. Decrypt a file or directory" - echo "3. Exit" - echo "========================================================" + printf "%b\n" "========================================================" + printf "%b\n" " File/Directory Encryption/Decryption" + printf "%b\n" "========================================================" + printf "%b\n" "How to use:-" + printf "%b\n" "if you encrypt or decrypt a file include new file name for successful operation" + printf "%b\n" "if you encrypt or decrypt a folder include new directory name for successful operation" + printf "%b\n" "========================================================" + printf "%b\n" "1. Encrypt a file or directory" + printf "%b\n" "2. Decrypt a file or directory" + printf "%b\n" "3. Exit" + printf "%b\n" "========================================================" } # Function to encrypt a file encrypt_file() { - echo "Enter the path to the file or directory to encrypt:" + printf "%b\n" "Enter the path to the file or directory to encrypt:" read -r INPUT_PATH if [ ! -e "$INPUT_PATH" ]; then - echo "Path does not exist!" + printf "%b\n" "Path does not exist!" return fi - - echo "Enter the path for the encrypted file or directory:" + + printf "%b\n" "Enter the path for the encrypted file or directory:" read -r OUTPUT_PATH - printf "Enter the encryption password: " + printf "%b\n" "Enter the encryption password: " read -r PASSWORD if [ -d "$INPUT_PATH" ]; then @@ -65,41 +65,41 @@ encrypt_file() { mkdir -p "$(dirname "$OUTPUT_FILE")" openssl enc -aes-256-cbc -salt -pbkdf2 -in "$FILE" -out "$OUTPUT_FILE" -k "$PASSWORD" if [ $? -eq 0 ]; then - echo "Encrypted: $OUTPUT_FILE" + printf "%b\n" "Encrypted: $OUTPUT_FILE" else - echo "Failed to encrypt: $FILE" + printf "%b\n" "Failed to encrypt: $FILE" fi done else # Encrypt a single file if [ -d "$OUTPUT_PATH" ]; then - echo "Output path must be a file for single file encryption." + printf "%b\n" "Output path must be a file for single file encryption." return fi mkdir -p "$(dirname "$OUTPUT_PATH")" openssl enc -aes-256-cbc -salt -pbkdf2 -in "$INPUT_PATH" -out "$OUTPUT_PATH" -k "$PASSWORD" if [ $? -eq 0 ]; then - echo "Encrypted: $OUTPUT_PATH" + printf "%b\n" "Encrypted: $OUTPUT_PATH" else - echo "Failed to encrypt: $INPUT_PATH" + printf "%b\n" "Failed to encrypt: $INPUT_PATH" fi fi } # Function to decrypt a file decrypt_file() { - echo "Enter the path to the file or directory to decrypt:" + printf "%b\n" "Enter the path to the file or directory to decrypt:" read -r INPUT_PATH if [ ! -e "$INPUT_PATH" ]; then - echo "Path does not exist!" + printf "%b\n" "Path does not exist!" return fi - echo "Enter the path for the decrypted file or directory:" + printf "%b\n" "Enter the path for the decrypted file or directory:" read -r OUTPUT_PATH - printf "Enter the decryption password: " + printf "%b\n" "Enter the decryption password: " read -r PASSWORD if [ -d "$INPUT_PATH" ]; then @@ -110,23 +110,23 @@ decrypt_file() { mkdir -p "$(dirname "$OUTPUT_FILE")" openssl enc -aes-256-cbc -d -pbkdf2 -in "$FILE" -out "$OUTPUT_FILE" -k "$PASSWORD" if [ $? -eq 0 ]; then - echo "Decrypted: $OUTPUT_FILE" + printf "%b\n" "Decrypted: $OUTPUT_FILE" else - echo "Failed to decrypt: $FILE" + printf "%b\n" "Failed to decrypt: $FILE" fi done else # Decrypt a single file if [ -d "$OUTPUT_PATH" ]; then - echo "Output path must be a file for single file decryption." + printf "%b\n" "Output path must be a file for single file decryption." return fi mkdir -p "$(dirname "$OUTPUT_PATH")" openssl enc -aes-256-cbc -d -pbkdf2 -in "$INPUT_PATH" -out "$OUTPUT_PATH" -k "$PASSWORD" if [ $? -eq 0 ]; then - echo "Decrypted: $OUTPUT_PATH" + printf "%b\n" "Decrypted: $OUTPUT_PATH" else - echo "Failed to decrypt: $INPUT_PATH" + printf "%b\n" "Failed to decrypt: $INPUT_PATH" fi fi } @@ -135,17 +135,17 @@ main(){ clear while true; do show_menu - echo "Enter your choice:" + printf "%b\n" "Enter your choice:" read -r CHOICE case $CHOICE in 1) encrypt_file ;; 2) decrypt_file ;; - 3) echo "Exiting..."; exit 0 ;; - *) echo "Invalid choice. Please try again." ;; + 3) printf "%b\n" "Exiting..."; exit 0 ;; + *) printf "%b\n" "Invalid choice. Please try again." ;; esac - printf "Press [Enter] to continue..." + printf "%b\n" "Press [Enter] to continue..." read -r dummy done } diff --git a/tabs/utils/monitor-control/auto_detect_displays.sh b/core/tabs/utils/monitor-control/auto_detect_displays.sh similarity index 98% rename from tabs/utils/monitor-control/auto_detect_displays.sh rename to core/tabs/utils/monitor-control/auto_detect_displays.sh index 44352f6e..51af3b08 100755 --- a/tabs/utils/monitor-control/auto_detect_displays.sh +++ b/core/tabs/utils/monitor-control/auto_detect_displays.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./utility_functions.sh +. ../utility_functions.sh . ../../common-script.sh diff --git a/tabs/utils/monitor-control/change_orientation.sh b/core/tabs/utils/monitor-control/change_orientation.sh similarity index 98% rename from tabs/utils/monitor-control/change_orientation.sh rename to core/tabs/utils/monitor-control/change_orientation.sh index 19e085f4..f9f047fc 100755 --- a/tabs/utils/monitor-control/change_orientation.sh +++ b/core/tabs/utils/monitor-control/change_orientation.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./utility_functions.sh +. ../utility_functions.sh . ../../common-script.sh diff --git a/tabs/utils/monitor-control/disable_monitor.sh b/core/tabs/utils/monitor-control/disable_monitor.sh similarity index 98% rename from tabs/utils/monitor-control/disable_monitor.sh rename to core/tabs/utils/monitor-control/disable_monitor.sh index 8a400701..03c5297f 100755 --- a/tabs/utils/monitor-control/disable_monitor.sh +++ b/core/tabs/utils/monitor-control/disable_monitor.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./utility_functions.sh +. ../utility_functions.sh . ../../common-script.sh diff --git a/tabs/utils/monitor-control/duplicate_displays.sh b/core/tabs/utils/monitor-control/duplicate_displays.sh similarity index 94% rename from tabs/utils/monitor-control/duplicate_displays.sh rename to core/tabs/utils/monitor-control/duplicate_displays.sh index aee3a15f..53aa260d 100755 --- a/tabs/utils/monitor-control/duplicate_displays.sh +++ b/core/tabs/utils/monitor-control/duplicate_displays.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./utility_functions.sh +. ../utility_functions.sh . ../../common-script.sh diff --git a/tabs/utils/monitor-control/enable_monitor.sh b/core/tabs/utils/monitor-control/enable_monitor.sh similarity index 98% rename from tabs/utils/monitor-control/enable_monitor.sh rename to core/tabs/utils/monitor-control/enable_monitor.sh index 2173f7f1..c2121b2c 100755 --- a/tabs/utils/monitor-control/enable_monitor.sh +++ b/core/tabs/utils/monitor-control/enable_monitor.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./utility_functions.sh +. ../utility_functions.sh . ../../common-script.sh diff --git a/tabs/utils/monitor-control/extend_displays.sh b/core/tabs/utils/monitor-control/extend_displays.sh similarity index 100% rename from tabs/utils/monitor-control/extend_displays.sh rename to core/tabs/utils/monitor-control/extend_displays.sh diff --git a/tabs/utils/monitor-control/manage_arrangement.sh b/core/tabs/utils/monitor-control/manage_arrangement.sh similarity index 99% rename from tabs/utils/monitor-control/manage_arrangement.sh rename to core/tabs/utils/monitor-control/manage_arrangement.sh index 684dbfd4..9820b78e 100755 --- a/tabs/utils/monitor-control/manage_arrangement.sh +++ b/core/tabs/utils/monitor-control/manage_arrangement.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./utility_functions.sh +. ../utility_functions.sh . ../../common-script.sh diff --git a/tabs/utils/monitor-control/reset_scaling.sh b/core/tabs/utils/monitor-control/reset_scaling.sh similarity index 96% rename from tabs/utils/monitor-control/reset_scaling.sh rename to core/tabs/utils/monitor-control/reset_scaling.sh index ffca6c1b..63eac1d7 100755 --- a/tabs/utils/monitor-control/reset_scaling.sh +++ b/core/tabs/utils/monitor-control/reset_scaling.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./utility_functions.sh +. ../utility_functions.sh . ../../common-script.sh diff --git a/tabs/utils/monitor-control/scale_monitor.sh b/core/tabs/utils/monitor-control/scale_monitor.sh similarity index 98% rename from tabs/utils/monitor-control/scale_monitor.sh rename to core/tabs/utils/monitor-control/scale_monitor.sh index ac386d77..1817f0f0 100755 --- a/tabs/utils/monitor-control/scale_monitor.sh +++ b/core/tabs/utils/monitor-control/scale_monitor.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./utility_functions.sh +. ../utility_functions.sh . ../../common-script.sh diff --git a/tabs/utils/monitor-control/set_brightness.sh b/core/tabs/utils/monitor-control/set_brightness.sh similarity index 99% rename from tabs/utils/monitor-control/set_brightness.sh rename to core/tabs/utils/monitor-control/set_brightness.sh index bd3b3d55..0e20fa67 100644 --- a/tabs/utils/monitor-control/set_brightness.sh +++ b/core/tabs/utils/monitor-control/set_brightness.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./utility_functions.sh +. ../utility_functions.sh # Function to adjust brightness for a selected monitor adjust_monitor_brightness() { diff --git a/tabs/utils/monitor-control/set_primary_monitor.sh b/core/tabs/utils/monitor-control/set_primary_monitor.sh similarity index 98% rename from tabs/utils/monitor-control/set_primary_monitor.sh rename to core/tabs/utils/monitor-control/set_primary_monitor.sh index c1a70416..173fff59 100755 --- a/tabs/utils/monitor-control/set_primary_monitor.sh +++ b/core/tabs/utils/monitor-control/set_primary_monitor.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./utility_functions.sh +. ../utility_functions.sh . ../../common-script.sh diff --git a/tabs/utils/monitor-control/set_resolutions.sh b/core/tabs/utils/monitor-control/set_resolutions.sh similarity index 99% rename from tabs/utils/monitor-control/set_resolutions.sh rename to core/tabs/utils/monitor-control/set_resolutions.sh index 85d7e0cb..3bd95836 100755 --- a/tabs/utils/monitor-control/set_resolutions.sh +++ b/core/tabs/utils/monitor-control/set_resolutions.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./utility_functions.sh +. ../utility_functions.sh . ../../common-script.sh diff --git a/tabs/utils/numlock.sh b/core/tabs/utils/numlock.sh similarity index 82% rename from tabs/utils/numlock.sh rename to core/tabs/utils/numlock.sh index cbae21f3..0f06bdf8 100755 --- a/tabs/utils/numlock.sh +++ b/core/tabs/utils/numlock.sh @@ -8,7 +8,7 @@ # Create a script to toggle numlock create_file() { - printf "Creating script...\n" + printf "%b\n" "Creating script..." "$ESCALATION_TOOL" tee "/usr/local/bin/numlock" >/dev/null <<'EOF' #!/bin/bash @@ -23,7 +23,7 @@ EOF # Create a systemd service to run the script on boot create_service() { - printf "Creating service...\n" + printf "%b\n" "Creating service..." "$ESCALATION_TOOL" tee "/etc/systemd/system/numlock.service" >/dev/null <<'EOF' [Unit] Description=numlock @@ -48,14 +48,14 @@ numlockSetup() { create_service fi - printf "Do you want to enable Numlock on boot? (y/n): " + printf "%b\n" "Do you want to enable Numlock on boot? (y/n): " read -r confirm if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then "$ESCALATION_TOOL" systemctl enable numlock.service --quiet - printf "Numlock will be enabled on boot\n" + printf "%b\n" "Numlock will be enabled on boot" else "$ESCALATION_TOOL" systemctl disable numlock.service --quiet - printf "Numlock will not be enabled on boot\n" + printf "%b\n" "Numlock will not be enabled on boot" fi } diff --git a/tabs/utils/ollama.sh b/core/tabs/utils/ollama.sh similarity index 100% rename from tabs/utils/ollama.sh rename to core/tabs/utils/ollama.sh diff --git a/tabs/utils/power-profile.sh b/core/tabs/utils/power-profile.sh similarity index 100% rename from tabs/utils/power-profile.sh rename to core/tabs/utils/power-profile.sh diff --git a/tabs/utils/service-control.sh b/core/tabs/utils/service-control.sh similarity index 80% rename from tabs/utils/service-control.sh rename to core/tabs/utils/service-control.sh index 4539f444..b968b27b 100644 --- a/tabs/utils/service-control.sh +++ b/core/tabs/utils/service-control.sh @@ -28,25 +28,25 @@ show_menu() { # Function to view all services view_all_services() { - printf "Listing all services...\n" + printf "%b\n" "Listing all services..." "$ESCALATION_TOOL" systemctl list-units --type=service --all --no-legend | awk '{print $1}' | sed 's/\.service//' | more } # Function to view enabled services view_enabled_services() { - printf "Listing enabled services...\n" + printf "%b\n" "Listing enabled services..." "$ESCALATION_TOOL" systemctl list-unit-files --type=service --state=enabled --no-legend | awk '{print $1}' | sed 's/\.service//' | more } # Function to view disabled services view_disabled_services() { - printf "Listing disabled services...\n" + printf "%b\n" "Listing disabled services..." "$ESCALATION_TOOL" systemctl list-unit-files --type=service --state=disabled --no-legend | awk '{print $1}' | sed 's/\.service//' | more } # Function to view started services view_started_services() { - printf "Listing started services:\n" + printf "%b\n" "Listing started services: " "$ESCALATION_TOOL" systemctl list-units --type=service --state=running --no-pager | head -n -6 | awk 'NR>1 {print $1}' | more } @@ -86,9 +86,9 @@ add_service() { printf "\n" printf "[Service]\n" printf "ExecStart=$EXEC_START\n" - [ -n "$SERVICE_USER" ] && printf "User=$SERVICE_USER\n" - [ -n "$WORKING_DIRECTORY" ] && printf "WorkingDirectory=$WORKING_DIRECTORY\n" - [ -n "$RESTART_POLICY" ] && printf "Restart=$RESTART_POLICY\n" + [ -n "$SERVICE_USER" ] && printf "%b\n" "User=$SERVICE_USER" + [ -n "$WORKING_DIRECTORY" ] && printf "%b\n" "WorkingDirectory=$WORKING_DIRECTORY" + [ -n "$RESTART_POLICY" ] && printf "%b\n" "Restart=$RESTART_POLICY" printf "\n" printf "[Install]\n" printf "WantedBy=multi-user.target\n" @@ -97,7 +97,7 @@ add_service() { # Set permissions and reload systemd "$ESCALATION_TOOL" chmod 644 "$SERVICE_FILE" "$ESCALATION_TOOL" systemctl daemon-reload - printf "Service $SERVICE_NAME has been created and is ready to be started.\n" + printf "%b\n" "Service $SERVICE_NAME has been created and is ready to be started." # Optionally, enable and start the service printf "Do you want to start and enable the service now? (y/n)\n" @@ -106,9 +106,9 @@ add_service() { if [ "$START_ENABLE" = "y" ]; then "$ESCALATION_TOOL" systemctl start "$SERVICE_NAME" "$ESCALATION_TOOL" systemctl enable "$SERVICE_NAME" - printf "Service $SERVICE_NAME has been started and enabled.\n" + printf "%b\n" "Service $SERVICE_NAME has been started and enabled." else - printf "Service $SERVICE_NAME has been created but not started.\n" + printf "%b\n" "Service $SERVICE_NAME has been created but not started." fi } @@ -120,29 +120,29 @@ remove_service() { SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME.service" if [ -f "$SERVICE_FILE" ]; then - printf "Stopping and disabling the service...\n" + printf "%b\n" "Stopping and disabling the service..." "$ESCALATION_TOOL" systemctl stop "$SERVICE_NAME" "$ESCALATION_TOOL" systemctl disable "$SERVICE_NAME" - printf "Removing the service file...\n" + printf "%b\n" "Removing the service file...\n" "$ESCALATION_TOOL" rm -f "$SERVICE_FILE" "$ESCALATION_TOOL" systemctl daemon-reload - printf "Service $SERVICE_NAME has been removed.\n" + printf "%b\n" "Service $SERVICE_NAME has been removed." else - printf "Service $SERVICE_NAME does not exist.\n" + printf "%b\n" "Service $SERVICE_NAME does not exist." fi } # Function to start a service start_service() { view_disabled_services - printf "Enter the name of the service to start (e.g., my_service):\n" + printf "%b\n" "Enter the name of the service to start (e.g., my_service): " read -r SERVICE_NAME if "$ESCALATION_TOOL" systemctl start "$SERVICE_NAME"; then - printf "Service $SERVICE_NAME has been started.\n" + printf "%b\n" "Service $SERVICE_NAME has been started." else - printf "Failed to start service: $SERVICE_NAME.\n" + printf "%b\n" "Failed to start service: $SERVICE_NAME." fi } @@ -153,9 +153,9 @@ stop_service() { read -r SERVICE_NAME if "$ESCALATION_TOOL" systemctl stop "$SERVICE_NAME"; then - printf "Service $SERVICE_NAME has been stopped.\n" + printf "%b\n" "Service $SERVICE_NAME has been stopped." else - printf "Failed to stop service: $SERVICE_NAME.\n" + printf "%b\n" "Failed to stop service: $SERVICE_NAME." fi } @@ -166,9 +166,9 @@ enable_service() { read -r SERVICE_NAME if "$ESCALATION_TOOL" systemctl enable "$SERVICE_NAME"; then - printf "Service $SERVICE_NAME has been enabled.\n" + printf "%b\n" "Service $SERVICE_NAME has been enabled." else - printf "Failed to enable service: $SERVICE_NAME.\n" + printf "%b\n" "Failed to enable service: $SERVICE_NAME." fi } @@ -179,9 +179,9 @@ disable_service() { read -r SERVICE_NAME if "$ESCALATION_TOOL" systemctl disable "$SERVICE_NAME"; then - printf "Service $SERVICE_NAME has been enabled.\n" + printf "%b\n" "Service $SERVICE_NAME has been enabled." else - printf "Failed to enable service: $SERVICE_NAME.\n" + printf "%b\n" "Failed to enable service: $SERVICE_NAME." fi } @@ -202,7 +202,7 @@ create_service_from_external() { SERVICE_FILE="$SCRIPT_DIR/$SERVICE_NAME.service" if [ ! -f "$SERVICE_FILE" ]; then - printf "Service file $SERVICE_FILE does not exist.\n" + printf "%b\n" "Service file $SERVICE_FILE does not exist." return fi @@ -230,7 +230,7 @@ create_service_from_external() { # Set permissions and reload systemd "$ESCALATION_TOOL" chmod 644 "$SYSTEMD_SERVICE_FILE" "$ESCALATION_TOOL" systemctl daemon-reload - printf "Service $SERVICE_NAME has been created and is ready to be started.\n" + printf "%b\n" "Service $SERVICE_NAME has been created and is ready to be started." # Optionally, enable and start the service printf "Do you want to start and enable the service now? (y/n)\n" @@ -239,9 +239,9 @@ create_service_from_external() { if [ "$START_ENABLE" = "y" ]; then "$ESCALATION_TOOL" systemctl start "$SERVICE_NAME" "$ESCALATION_TOOL" systemctl enable "$SERVICE_NAME" - printf "Service $SERVICE_NAME has been started and enabled.\n" + printf "%b\n" "Service $SERVICE_NAME has been started and enabled." else - printf "Service $SERVICE_NAME has been created but not started.\n" + printf "%b\n" "Service $SERVICE_NAME has been created but not started." fi } diff --git a/tabs/utils/services/i3lock-on-lid-close.service b/core/tabs/utils/services/i3lock-on-lid-close.service similarity index 100% rename from tabs/utils/services/i3lock-on-lid-close.service rename to core/tabs/utils/services/i3lock-on-lid-close.service diff --git a/tabs/utils/ssh.sh b/core/tabs/utils/ssh.sh similarity index 95% rename from tabs/utils/ssh.sh rename to core/tabs/utils/ssh.sh index 17cac929..a1f96e59 100644 --- a/tabs/utils/ssh.sh +++ b/core/tabs/utils/ssh.sh @@ -23,12 +23,14 @@ ask_for_host_details() { read -r host printf "%b\n" "Enter Remote User: " read -r user - printf "%b\n" "Host $host_alias" >> ~/.ssh/config - printf "%b\n" " HostName $host" >> ~/.ssh/config - printf "%b\n" " User $user" >> ~/.ssh/config - printf "%b\n" " IdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config - printf "%b\n" " StrictHostKeyChecking no" >> ~/.ssh/config - printf "%b\n" " UserKnownHostsFile=/dev/null" >> ~/.ssh/config + { + printf "%b\n" "Host $host_alias" + printf "%b\n" " HostName $host" + printf "%b\n" " User $user" + printf "%b\n" " IdentityFile ~/.ssh/id_rsa" + printf "%b\n" " StrictHostKeyChecking no" + printf "%b\n" " UserKnownHostsFile=/dev/null" + } >> ~/.ssh/config printf "%b\n" "Host $host_alias added successfully." } @@ -187,7 +189,7 @@ sync_directories() { # Function to check SSH key authentication status check_ssh_key_authentication() { - printf "%b\n""Enter the alias of the host: " + printf "%b\n" "Enter the alias of the host: " read -r host_alias ssh $host_alias "grep '^PubkeyAuthentication' /etc/ssh/sshd_config" } @@ -247,4 +249,4 @@ done checkEnv checkEscalationTool -main \ No newline at end of file +main diff --git a/tabs/utils/tab_data.toml b/core/tabs/utils/tab_data.toml similarity index 100% rename from tabs/utils/tab_data.toml rename to core/tabs/utils/tab_data.toml diff --git a/tabs/utils/timeshift.sh b/core/tabs/utils/timeshift.sh similarity index 100% rename from tabs/utils/timeshift.sh rename to core/tabs/utils/timeshift.sh diff --git a/core/tabs/utils/user-account-manager/add_to_group.sh b/core/tabs/utils/user-account-manager/add_to_group.sh new file mode 100755 index 00000000..665cf72a --- /dev/null +++ b/core/tabs/utils/user-account-manager/add_to_group.sh @@ -0,0 +1,47 @@ +#!/bin/sh -e + +. ../../common-script.sh + +. ../utility_functions.sh + +addToGroup() { + clear + printf "%b\n" "${YELLOW}Add to group${RC}" + printf "%b\n" "${YELLOW}=================${RC}" + + printf "%b" "${YELLOW}Enter the username: ${RC}" + read -r username + user_groups=$(groups "$username" | cut -d: -f2 | sort | tr '\n' ' ') + + printf "%b\n" "${YELLOW}Groups user $username is in:${RC} $user_groups" + printf "%b\n" "${YELLOW}=================${RC}" + + available_groups=$(cut -d: -f1 /etc/group | sort | tr '\n' ' ') + + printf "%b\n" "${YELLOW}Available groups:${RC} $available_groups" + printf "%b\n" "${YELLOW}=================${RC}" + + printf "%b" "${YELLOW}Enter the groups you want to add user $username to (space-separated): ${RC}" + read -r groups + + checkEmpty "$groups" || exit 1 + if ! checkGroups "$groups" "$available_groups"; then + printf "%b\n" "${RED}One or more groups are not available.${RC}" + exit 1 + fi + + groups_to_add=$(echo "$groups" | tr ' ' ',') + + printf "%b" "${YELLOW}Are you sure you want to add user $username to $groups_to_add? [Y/n]: ${RC}" + read -r confirm + confirmAction || exit 1 + + "$ESCALATION_TOOL" usermod -aG "$groups_to_add" "$username" + + printf "%b\n" "${GREEN}User successfully added to the $groups_to_add${RC}" +} + +checkEnv +checkEscalationTool +checkGroups +addToGroup \ No newline at end of file diff --git a/core/tabs/utils/user-account-manager/add_user.sh b/core/tabs/utils/user-account-manager/add_user.sh new file mode 100755 index 00000000..26435f41 --- /dev/null +++ b/core/tabs/utils/user-account-manager/add_user.sh @@ -0,0 +1,38 @@ +#!/bin/sh -e + +. ../../common-script.sh + +. ../utility_functions.sh + +createUser() { + clear + printf "%b\n" "${YELLOW}Create a new user${RC}" + printf "%b\n" "${YELLOW}=================${RC}" + printf "%b" "${YELLOW}Enter the username: ${RC}" + read -r username + + if ! echo "$username" | grep '^[a-zA-Z]*$' > /dev/null; then + printf "%b\n" "${RED}Username must only contain letters and cannot contain spaces.${RC}" + exit 1 + fi + + printf "%b" "${YELLOW}Enter the password: ${RC}" + read -r password + printf "%b" "${YELLOW}Enter the password again: ${RC}" + read -r password_confirmation + + if [ "$password" != "$password_confirmation" ]; then + printf "%b\n" "${RED}Passwords do not match${RC}" + exit 1 + fi + + "$ESCALATION_TOOL" useradd -m "$username" -g users -s /bin/bash + echo "$username:$password" | "$ESCALATION_TOOL" chpasswd + + printf "%b\n" "${GREEN}User $username created successfully${RC}" + printf "%b\n" "${GREEN}To add additional groups use Add User To Groups${RC}" +} + +checkEnv +checkEscalationTool +createUser diff --git a/core/tabs/utils/user-account-manager/change_password.sh b/core/tabs/utils/user-account-manager/change_password.sh new file mode 100755 index 00000000..a909a5b2 --- /dev/null +++ b/core/tabs/utils/user-account-manager/change_password.sh @@ -0,0 +1,33 @@ +#!/bin/sh -e + +. ../../common-script.sh + +. ../utility_functions.sh + +changePassword() { + clear + printf "%b\n" "${YELLOW}Change password${RC}" + printf "%b\n" "${YELLOW}=================${RC}" + + printf "%b" "${YELLOW}Enter the username: ${RC}" + read -r username + + if id "$username" > /dev/null 2>&1; then + printf "%b" "${YELLOW}Enter new password: ${RC}" + read -r password + + printf "%b" "${YELLOW}Are you sure you want to change password for ""$username""? [Y/n]: ${RC}" + read -r confirm + confirmAction || exit 1 + + echo "$username:$password" | "$ESCALATION_TOOL" chpasswd + printf "%b\n" "${GREEN}Password changed successfully${RC}" + else + printf "%b\n" "${RED}User $username does not exist.${RC}" + exit 1 + fi +} + +checkEnv +checkEscalationTool +changePassword \ No newline at end of file diff --git a/core/tabs/utils/user-account-manager/delete_user.sh b/core/tabs/utils/user-account-manager/delete_user.sh new file mode 100755 index 00000000..aee9482e --- /dev/null +++ b/core/tabs/utils/user-account-manager/delete_user.sh @@ -0,0 +1,30 @@ +#!/bin/sh -e + +. ../../common-script.sh + +. ../utility_functions.sh + +deleteUser() { + clear + printf "%b\n" "${YELLOW}Delete a user${RC}" + printf "%b\n" "${YELLOW}=================${RC}" + + printf "%b" "${YELLOW}Enter the username: ${RC}" + read -r username + + if id "$username" > /dev/null 2>&1; then + printf "%b" "${YELLOW}Are you sure you want to delete user ""$username""? [Y/n]: ${RC}" + read -r confirm + confirmAction || exit 1 + + $ESCALATION_TOOL userdel --remove "$username" 2>/dev/null + printf "%b\n" "${GREEN}User $username deleted successfully${RC}" + else + printf "%b\n" "${RED}User $username does not exist.${RC}" + exit 1 + fi +} + +checkEnv +checkEscalationTool +deleteUser \ No newline at end of file diff --git a/core/tabs/utils/user-account-manager/remove_from_group.sh b/core/tabs/utils/user-account-manager/remove_from_group.sh new file mode 100755 index 00000000..23935b5e --- /dev/null +++ b/core/tabs/utils/user-account-manager/remove_from_group.sh @@ -0,0 +1,47 @@ +#!/bin/sh -e + +. ../../common-script.sh + +. ../utility_functions.sh + +removeFromGroup() { + clear + printf "%b\n" "${YELLOW}Remove from group${RC}" + printf "%b\n" "${YELLOW}=================${RC}" + + printf "%b" "${YELLOW}Enter the username: ${RC}" + read -r username + + if ! id "$username" > /dev/null 2>&1; then + printf "%b\n" "${RED}User $username does not exist.${RC}" + exit 1 + fi + + user_groups=$(groups "$username" | cut -d: -f2 | sort | tr '\n' ' ') + + printf "%b\n" "${YELLOW}Groups user $username is in:${RC} $user_groups" + printf "%b\n" "${YELLOW}=================${RC}" + + printf "%b" "${YELLOW}Enter the groups you want to remove user $username from (space-separated): ${RC} " + read -r groups + + checkEmpty "$groups" || exit 1 + if ! checkGroups "$groups" "$user_groups"; then + printf "%b\n" "${RED}One or more specified groups do not exist.${RC}" + exit 1 + fi + + groups_to_remove=$(echo "$groups" | tr ' ' ',') + + printf "%b" "${YELLOW}Are you sure you want to remove user $username from $groups_to_remove? [Y/n]: ${RC}" + read -r confirm + confirmAction || exit 1 + + $ESCALATION_TOOL usermod -rG $groups_to_remove "$username" + + printf "%b\n" "${GREEN}User successfully removed from $groups_to_remove${RC}" +} + +checkEnv +checkEscalationTool +removeFromGroup \ No newline at end of file diff --git a/tabs/utils/monitor-control/utility_functions.sh b/core/tabs/utils/utility_functions.sh similarity index 84% rename from tabs/utils/monitor-control/utility_functions.sh rename to core/tabs/utils/utility_functions.sh index 5bccd94d..523fb7a2 100755 --- a/tabs/utils/monitor-control/utility_functions.sh +++ b/core/tabs/utils/utility_functions.sh @@ -84,6 +84,31 @@ confirm_action() { fi } +checkEmpty() { + if [ -z "$1" ]; then + printf "%b\n" "${RED}Empty value is not allowed${RC}" >&2 + exit 1 + fi +} + +checkGroups() { + groups="$1" + available_groups="$2" + for group in $groups; do + if ! echo "$available_groups" | grep -q -w "$group"; then + return 1 + fi + done + return 0 +} + +confirmAction() { + if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then + printf "%b\n" "${RED}Cancelled operation...${RC}" >&2 + exit 1 + fi +} + checkEnv checkEscalationTool setup_xrandr diff --git a/tabs/utils/wifi-control.sh b/core/tabs/utils/wifi-control.sh similarity index 100% rename from tabs/utils/wifi-control.sh rename to core/tabs/utils/wifi-control.sh diff --git a/tabs/utils/user-account-manager/add_to_group.sh b/tabs/utils/user-account-manager/add_to_group.sh deleted file mode 100755 index bc66da1b..00000000 --- a/tabs/utils/user-account-manager/add_to_group.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -e - -. ../../common-script.sh -. ./utility_functions.sh - -clear -printf "%b\n" "${YELLOW}Add to group${RC}" -printf "%b\n" "${YELLOW}=================${RC}" - -username=$(promptUsername "" "non-root") || exit 1 -user_groups=$(groups "$username" | cut -d: -f2 | sort | tr '\n' ' ') - -printf "%b\n" "${YELLOW}Groups user $username is in:${RC} $user_groups" -printf "%b\n" "${YELLOW}=================${RC}" - -available_groups=$(cut -d: -f1 /etc/group | sort | tr '\n' ' ') - -printf "%b\n" "${YELLOW}Available groups:${RC} $available_groups" -printf "%b\n" "${YELLOW}=================${RC}" - -printf "%b\n" "${YELLOW}Enter the groups you want to add user $username to (space-separated):${RC} " -read -r groups - -checkEmpty "$groups" || exit 1 -checkGroupAvailabe "$groups" "$available_groups" || exit 1 - -groups_to_add=$(echo "$groups" | tr ' ' ',') - -printf "Are you sure you want to add user $username to $groups_to_add? [Y/N]: " -read -r confirm -confirmAction || exit 1 - -$ESCALATION_TOOL usermod -aG $groups_to_add "$username" - -printf "%b\n" "${GREEN}User successfully added to the $groups_to_add${RC}" - -checkEnv \ No newline at end of file diff --git a/tabs/utils/user-account-manager/add_user.sh b/tabs/utils/user-account-manager/add_user.sh deleted file mode 100755 index d26dbfc6..00000000 --- a/tabs/utils/user-account-manager/add_user.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -e - -. ../../common-script.sh -. ./utility_functions.sh - -clear -printf "%b\n" "${YELLOW}Create a new user${RC}" -printf "%b\n" "${YELLOW}=================${RC}" - -username=$(promptUsername "add" "non-root") || exit 1 - -# Check if username is valid -if ! echo "$username" | grep '^[a-z][-a-z0-9_]*$' > /dev/null; then - printf "%b\n" "${RED}Username must only contain letters, numbers, hyphens, and underscores. It cannot start with a number or contain spaces.${RC}" - exit 1 -fi - -password=$(promptPassword) || exit 1 - -$ESCALATION_TOOL useradd -m "$username" -g users -s /bin/bash -echo "$username:$password" | "$ESCALATION_TOOL" chpasswd - -printf "%b\n" "${GREEN}User $username created successfully${RC}" -printf "%b\n" "${GREEN}To add additional groups use Add User To Groups${RC}" - -checkEnv diff --git a/tabs/utils/user-account-manager/change_password.sh b/tabs/utils/user-account-manager/change_password.sh deleted file mode 100755 index 677dcd75..00000000 --- a/tabs/utils/user-account-manager/change_password.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -e - -. ../../common-script.sh -. ./utility_functions.sh - -clear -printf "%b\n" "${YELLOW}Change password${RC}" -printf "%b\n" "${YELLOW}=================${RC}" - -username=$(promptUsername "" "root") || exit 1 -password=$(promptPassword) || exit 1 - -printf "Are you sure you want to change password for $username? [Y/N]: " -read -r confirm -confirmAction || exit 1 - -echo "$username:$password" | "$ESCALATION_TOOL" chpasswd -printf "%b\n" "${GREEN}Password changed successfully${RC}" - -checkEnv \ No newline at end of file diff --git a/tabs/utils/user-account-manager/delete_user.sh b/tabs/utils/user-account-manager/delete_user.sh deleted file mode 100755 index e776a063..00000000 --- a/tabs/utils/user-account-manager/delete_user.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -e - -. ../../common-script.sh -. ./utility_functions.sh - -clear -printf "%b\n" "${YELLOW}Delete a user${RC}" -printf "%b\n" "${YELLOW}=================${RC}" - -username=$(promptUsername "" "non-root") || exit 1 - -# Check if current user -if [ "$username" = "$USER" ]; then - printf "%b\n" "${RED}Cannot delete the current user${RC}" - printf "%b\n" "${RED}Press [Enter] to continue...${RC}" - read -r dummy - return -fi - -printf "Are you sure you want to delete user $username? [Y/N]: " -read -r confirm -confirmAction || exit 1 - -$ESCALATION_TOOL userdel --remove "$username" 2>/dev/null -printf "%b\n" "${GREEN}User $username deleted successfully${RC}" - -checkEnv \ No newline at end of file diff --git a/tabs/utils/user-account-manager/remove_from_group.sh b/tabs/utils/user-account-manager/remove_from_group.sh deleted file mode 100755 index f56a5d9e..00000000 --- a/tabs/utils/user-account-manager/remove_from_group.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -e - -. ../../common-script.sh -. ./utility_functions.sh - -clear -printf "%b\n" "${YELLOW}Remove from group${RC}" -printf "%b\n" "${YELLOW}=================${RC}" - -username=$(promptUsername "" "non-root") || exit 1 -user_groups=$(groups "$username" | cut -d: -f2 | sort | tr '\n' ' ') - -printf "%b\n" "${YELLOW}Groups user $username is in:${RC} $user_groups" -printf "%b\n" "${YELLOW}=================${RC}" - -printf "%b\n" "${YELLOW}Enter the groups you want to remove user $username from (space-separated):${RC} " -read -r groups - -checkEmpty "$groups" || exit 1 -checkGroupAvailabe "$groups" "$user_groups" || exit 1 - -groups_to_remove=$(echo "$groups" | tr ' ' ',') - -printf "Are you sure you want to remove user $username from $groups_to_remove? [Y/N]: " -read -r confirm -confirmAction || exit 1 - -$ESCALATION_TOOL usermod -rG $groups_to_remove "$username" - -printf "%b\n" "${GREEN}User successfully removed from $groups_to_remove${RC}" - -checkEnv \ No newline at end of file diff --git a/tabs/utils/user-account-manager/utility_functions.sh b/tabs/utils/user-account-manager/utility_functions.sh deleted file mode 100755 index b6af5f53..00000000 --- a/tabs/utils/user-account-manager/utility_functions.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/sh -e - -. ../../common-script.sh - -# Prompt for username -promptUsername() { - printf "Enter the username: " - read -r username - - checkEmpty "$username"; - - if [ "$1" = "add" ]; then - checkUserExistence "$username" "$1" - else - checkUserExistence "$username" "$1" - checkReservedUsername "$username" "$2" - fi - echo "$username" -} - - -# Prompt for password -promptPassword() { - stty -echo - printf "Enter the password (PASSWORD IS HIDDEN): " - read -r password1 - echo >&2 - printf "Re-enter the password (PASSWORD IS HIDDEN): " - read -r password2 - echo >&2 - stty echo - - if ! checkEmpty "$password1"; then - promptPassword - fi - - if [ "$password1" != "$password2" ]; then - printf "%b\n" "${RED}Passwords do not match${RC}" >&2 - promptPassword - else - echo $password1 - fi -} - -# Check if input is empty -checkEmpty() { - if [ -z "$1" ]; then - printf "%b\n" "${RED}Empty value is not allowed${RC}" >&2 - exit 1 - fi -} - -# Check if user exists -checkUserExistence() { - if [ "$2" = "add" ]; then - if id "$1" > /dev/null 2>&1; then - printf "%b\n" "${RED}User already exists${RC}" >&2 - exit 1 - fi - else - if ! id "$1" > /dev/null 2>&1; then - printf "%b\n" "${RED}User does not exist${RC}" >&2 - exit 1 - fi - fi -} - -# Check if user is reserved -checkReservedUsername() { - uid=$(id -u "$1") - if [ "$2" = "root" ]; then - if [ "$uid" -le 999 ] && [ "$uid" -ne 0 ]; then - printf "%b\n" "${RED}Cannot modify system users${RC}" >&2 - exit 1 - fi - else - if [ "$(id -u "$1")" -le 999 ]; then - printf "%b\n" "${RED}Cannot modify system users${RC}" >&2 - exit 1 - fi - fi -} - -# Check if user is reserved -confirmAction() { - if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then - printf "%b\n" "${RED}Cancelled operation...${RC}" >&2 - exit 1 - fi -} - -# Check if group is available -checkGroupAvailabe() { - for group in $1; do - if ! echo "$2" | grep -wq "$group"; then - printf "%b\n" "${RED}Group $group not avaiable${RC}" >&2 - exit 1 - fi - done -} - -checkEnv -checkEscalationTool \ No newline at end of file diff --git a/tui/Cargo.toml b/tui/Cargo.toml index 383dd154..c8802be4 100644 --- a/tui/Cargo.toml +++ b/tui/Cargo.toml @@ -1,8 +1,18 @@ [package] name = "linutil_tui" +description = "Chris Titus Tech's Linux Toolbox - Linutil is a distro-agnostic toolbox designed to simplify everyday Linux tasks." +documentation = "https://christitustech.github.io/linutil" +readme = "../README.md" edition = "2021" -version.workspace = true license.workspace = true +repository = "https://github.com/ChrisTitusTech/linutil/tree/main/tui" +version.workspace = true +include = [ + "src/*.rs", + "Cargo.toml", + "build.rs", +] +build = "build.rs" [dependencies] clap = { version = "4.5.16", features = ["derive"] } @@ -13,11 +23,11 @@ portable-pty = "0.8.1" ratatui = "0.28.1" tui-term = "0.1.12" unicode-width = "0.1.13" -linutil_core = { path = "../core" } +linutil_core = { path = "../core", version = "24.9.19" } [build-dependencies] chrono = "0.4.33" [[bin]] name = "linutil" -path = "src/main.rs" +path = "src/main.rs" \ No newline at end of file