From 5b415b656750395b3bc8115423dd0124044c64ae Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Thu, 5 Sep 2024 22:28:45 -0400 Subject: [PATCH 01/37] Reduce redundancy --- .github/PULL_REQUEST_TEMPLATE.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 3b61761b..093357d2 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,8 +1,3 @@ -# Pull Request - -## Title - - ## Type of Change - [ ] New feature - [ ] Bug fix From fcc5a5fc0fc5a4d21cca66fb990b68d4b03383d0 Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Tue, 10 Sep 2024 07:21:00 -0400 Subject: [PATCH 02/37] Remove unneeded scripts --- src/commands/test/lib.sh | 5 ----- src/commands/test/main.sh | 6 ------ 2 files changed, 11 deletions(-) delete mode 100755 src/commands/test/lib.sh delete mode 100755 src/commands/test/main.sh diff --git a/src/commands/test/lib.sh b/src/commands/test/lib.sh deleted file mode 100755 index 45e08b7a..00000000 --- a/src/commands/test/lib.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -say_hello () { - echo Hi -} diff --git a/src/commands/test/main.sh b/src/commands/test/main.sh deleted file mode 100755 index 7af16b96..00000000 --- a/src/commands/test/main.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -# The current working directory will always be inside "commands" -. test/lib.sh - -say_hello From 8235a36d4b43e209724de479d638f2f499a21b04 Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Thu, 12 Sep 2024 15:50:29 -0400 Subject: [PATCH 03/37] Remove unneeded scripts --- tabs/test/lib.sh | 5 ----- tabs/test/main.sh | 6 ------ 2 files changed, 11 deletions(-) delete mode 100755 tabs/test/lib.sh delete mode 100755 tabs/test/main.sh diff --git a/tabs/test/lib.sh b/tabs/test/lib.sh deleted file mode 100755 index 45e08b7a..00000000 --- a/tabs/test/lib.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -say_hello () { - echo Hi -} diff --git a/tabs/test/main.sh b/tabs/test/main.sh deleted file mode 100755 index 7af16b96..00000000 --- a/tabs/test/main.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -# The current working directory will always be inside "commands" -. test/lib.sh - -say_hello From 725e22ff67e6311a1dea18d698425c0af283fd27 Mon Sep 17 00:00:00 2001 From: Rory Dunne Date: Sat, 7 Sep 2024 11:52:41 -0400 Subject: [PATCH 04/37] fix: Correctly Detect Pictures Directory and Clone Path for Background --- tabs/applications-setup/dwmtitus-setup.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tabs/applications-setup/dwmtitus-setup.sh b/tabs/applications-setup/dwmtitus-setup.sh index 8c0fc97a..7d6398b4 100644 --- a/tabs/applications-setup/dwmtitus-setup.sh +++ b/tabs/applications-setup/dwmtitus-setup.sh @@ -142,29 +142,32 @@ clone_config_folders() { } configure_backgrounds() { + # Set the variable PIC_DIR which stores the path for images + PIC_DIR="$HOME/Pictures" + # Set the variable BG_DIR to the path where backgrounds will be stored - BG_DIR="$HOME/Pictures/backgrounds" + BG_DIR="$PIC_DIR/backgrounds" # Check if the ~/Pictures directory exists - if [ ! -d "~/Pictures" ]; then + if [ ! -d "$PIC_DIR" ]; then # If it doesn't exist, print an error message and return with a status of 1 (indicating failure) echo "Pictures directory does not exist" - mkdir ~/Pictures + mkdir "$PIC_DIR" echo "Directory was created in Home folder" fi - + # Check if the backgrounds directory (BG_DIR) exists if [ ! -d "$BG_DIR" ]; then # If the backgrounds directory doesn't exist, attempt to clone a repository containing backgrounds - if ! git clone https://github.com/ChrisTitusTech/nord-background.git ~/Pictures; then + if ! git clone https://github.com/ChrisTitusTech/nord-background.git "$PIC_DIR/nord-background"; then # If the git clone command fails, print an error message and return with a status of 1 echo "Failed to clone the repository" return 1 fi # Rename the cloned directory to 'backgrounds' - mv ~/Pictures/nord-background ~/Pictures/backgrounds + mv "$PIC_DIR/nord-background" "$PIC_DIR/backgrounds" # Print a success message indicating that the backgrounds have been downloaded - echo "Downloaded desktop backgrounds to $BG_DIR" + echo "Downloaded desktop backgrounds to $BG_DIR" else # If the backgrounds directory already exists, print a message indicating that the download is being skipped echo "Path $BG_DIR exists for desktop backgrounds, skipping download of backgrounds" @@ -290,9 +293,6 @@ setupDisplayManager() { echo "Auto-login configuration skipped" fi fi - - - } checkEnv From d560acac3ab89ce76a0fda5095eb6e8914f9be30 Mon Sep 17 00:00:00 2001 From: guruswarupa Date: Fri, 13 Sep 2024 14:08:30 +0530 Subject: [PATCH 05/37] docker setup added --- tabs/system-setup/6-docker-setup.sh | 87 +++++++++++++++++++++++++++++ tabs/system-setup/tab_data.toml | 4 ++ 2 files changed, 91 insertions(+) create mode 100755 tabs/system-setup/6-docker-setup.sh diff --git a/tabs/system-setup/6-docker-setup.sh b/tabs/system-setup/6-docker-setup.sh new file mode 100755 index 00000000..7f2a0b3f --- /dev/null +++ b/tabs/system-setup/6-docker-setup.sh @@ -0,0 +1,87 @@ +#!/bin/sh -e + +. ../common-script.sh + +# Function to prompt the user for installation choice +choose_installation() { + clear + printf "%b\n" "${YELLOW}Choose what to install:${RC}" + printf "%b\n" "1. ${YELLOW}Docker${RC}" + printf "%b\n" "2. ${YELLOW}Docker Compose${RC}" + printf "%b\n" "3. ${YELLOW}Both${RC}" + read -p "Enter your choice [1-3]: " CHOICE + + case "$CHOICE" in + 1) INSTALL_DOCKER=1; INSTALL_COMPOSE=0 ;; + 2) INSTALL_DOCKER=0; INSTALL_COMPOSE=1 ;; + 3) INSTALL_DOCKER=1; INSTALL_COMPOSE=1 ;; + *) echo "Invalid choice. Exiting."; exit 1 ;; + esac +} + +install_docker() { + printf "%b\n" "${YELLOW}Installing Docker...${RC}" + case $PACKAGER in + apt-get | yum) + curl -fsSL https://get.docker.com | sh + ;; + zypper) + $ESCALATION_TOOL ${PACKAGER} --non-interactive install docker + $ESCALATION_TOOL systemctl enable docker + $ESCALATION_TOOL systemctl start docker + ;; + pacman) + $ESCALATION_TOOL ${PACKAGER} -S --noconfirm docker + $ESCALATION_TOOL systemctl enable docker + $ESCALATION_TOOL systemctl start docker + ;; + *) + printf "${RED}Unsupported package manager. Please install Docker manually.${RC}\n" + exit 1 + ;; + esac +} + +install_docker_compose() { + printf "%b\n" "${YELLOW}Installing Docker Compose...${RC}" + case $PACKAGER in + apt-get | yum) + $ESCALATION_TOOL ${PACKAGER} update + $ESCALATION_TOOL ${PACKAGER} install -y docker-compose-plugin + ;; + zypper) + $ESCALATION_TOOL ${PACKAGER} --non-interactive install docker-compose + ;; + pacman) + $ESCALATION_TOOL ${PACKAGER} -S --noconfirm docker-compose + ;; + *) + printf "${RED}Unsupported package manager. Please install Docker Compose manually.${RC}\n" + exit 1 + ;; + esac +} + +install_components() { + choose_installation + + if [ "$INSTALL_DOCKER" -eq 1 ]; then + if ! command_exists docker; then + install_docker + else + printf "%b\n" "${GREEN}Docker is already installed.${RC}" + fi + fi + + if [ "$INSTALL_COMPOSE" -eq 1 ]; then + if ! command_exists docker-compose || ! command_exists docker compose version; then + install_docker_compose + else + printf "%b\n" "${GREEN}Docker Compose is already installed.${RC}" + fi + fi +} + +checkEnv +checkEscalationTool +install_components diff --git a/tabs/system-setup/tab_data.toml b/tabs/system-setup/tab_data.toml index 6743da3c..c1c8f02b 100644 --- a/tabs/system-setup/tab_data.toml +++ b/tabs/system-setup/tab_data.toml @@ -51,3 +51,7 @@ script = "3-global-theme.sh" [[data]] name = "Remove Snaps" script = "4-remove-snaps.sh" + +[[data]] +name = "Docker Setup" +script = "6-docker-setup.sh" From c3abd7e38ef3101dedf9742d52e0135ebc871a92 Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Sat, 14 Sep 2024 07:36:35 -0400 Subject: [PATCH 06/37] Increase Partition size --- tabs/system-setup/arch/server-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/system-setup/arch/server-setup.sh b/tabs/system-setup/arch/server-setup.sh index 87400b22..a0a78cc4 100755 --- a/tabs/system-setup/arch/server-setup.sh +++ b/tabs/system-setup/arch/server-setup.sh @@ -336,7 +336,7 @@ sgdisk -a 2048 -o ${DISK} # new gpt disk 2048 alignment # create partitions sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:'BIOSBOOT' ${DISK} # partition 1 (BIOS Boot Partition) -sgdisk -n 2::+300M --typecode=2:ef00 --change-name=2:'EFIBOOT' ${DISK} # partition 2 (UEFI Boot Partition) +sgdisk -n 2::+1GiB --typecode=2:ef00 --change-name=2:'EFIBOOT' ${DISK} # partition 2 (UEFI Boot Partition) sgdisk -n 3::-0 --typecode=3:8300 --change-name=3:'ROOT' ${DISK} # partition 3 (Root), default start, remaining if [[ ! -d "/sys/firmware/efi" ]]; then # Checking for bios system sgdisk -A 1:set:2 ${DISK} From 3f67abc9186e2fcbd06a602fa2cc2b6ce037a2d8 Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Sat, 14 Sep 2024 11:30:03 -0400 Subject: [PATCH 07/37] fix typos --- tui/src/hint.rs | 10 +++++----- tui/src/state.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tui/src/hint.rs b/tui/src/hint.rs index 27474ea9..37947159 100644 --- a/tui/src/hint.rs +++ b/tui/src/hint.rs @@ -16,7 +16,7 @@ pub struct ShortcutList { } pub struct Shortcut { - pub key_sequenses: Vec>, + pub key_sequences: Vec>, pub desc: &'static str, } @@ -75,7 +75,7 @@ impl ShortcutList { impl Shortcut { pub fn new(key_sequences: Vec<&'static str>, desc: &'static str) -> Self { Self { - key_sequenses: key_sequences + key_sequences: key_sequences .iter() .map(|s| Span::styled(*s, Style::default().bold())) .collect(), @@ -85,7 +85,7 @@ impl Shortcut { fn to_spans(&self) -> Vec { let mut ret: Vec<_> = self - .key_sequenses + .key_sequences .iter() .flat_map(|seq| { [ @@ -124,10 +124,10 @@ pub fn draw_shortcuts(state: &AppState, frame: &mut Frame, area: Rect) { if state.selected_item_is_up_dir() { hints.push(Shortcut::new( vec!["l", "Right", "Enter", "h", "Left"], - "Go to parrent directory", + "Go to parent directory", )); } else { - hints.push(Shortcut::new(vec!["h", "Left"], "Go to parrent directory")); + hints.push(Shortcut::new(vec!["h", "Left"], "Go to parent directory")); hints.push(get_list_item_shortcut(state)); if state.selected_item_is_cmd() { hints.push(Shortcut::new(vec!["p"], "Enable preview")); diff --git a/tui/src/state.rs b/tui/src/state.rs index 267e6769..8d1e1d7b 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -26,7 +26,7 @@ pub struct AppState { tabs: Vec, /// Current tab current_tab: ListState, - /// This stack keeps track of our "current dirrectory". You can think of it as `pwd`. but not + /// This stack keeps track of our "current directory". You can think of it as `pwd`. but not /// just the current directory, all paths that took us here, so we can "cd .." visit_stack: Vec, /// This is the state asociated with the list widget, used to display the selection in the @@ -246,7 +246,7 @@ impl AppState { *self.visit_stack.last().unwrap(), ); } - /// Checks ehther the current tree node is the root node (can we go up the tree or no) + /// Checks either the current tree node is the root node (can we go up the tree or no) /// Returns `true` if we can't go up the tree (we are at the tree root) /// else returns `false` pub fn at_root(&self) -> bool { From 4fa0079cb786c4ece1cf1349d3258fe649c654b3 Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Sun, 15 Sep 2024 20:32:37 -0400 Subject: [PATCH 08/37] Fix last bashism --- startdev.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/startdev.sh b/startdev.sh index 1070ea42..b58dc8f5 100755 --- a/startdev.sh +++ b/startdev.sh @@ -35,7 +35,7 @@ check() { local message=$2 if [ $exit_code -ne 0 ]; then - echo -e "${RED}ERROR: $message${RC}" + printf "%b\n" "${RED}ERROR: $message${RC}" exit 1 fi } From 6753c80b06584b48394859eb7bef7dfa6bc0513a Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Sun, 15 Sep 2024 21:23:53 -0400 Subject: [PATCH 09/37] Use -e & Keep synergy with every other script --- start.sh | 2 +- startdev.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/start.sh b/start.sh index d1e7658a..b6fe4fdc 100755 --- a/start.sh +++ b/start.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -e rc='\033[0m' red='\033[0;31m' diff --git a/startdev.sh b/startdev.sh index 1070ea42..301eb798 100755 --- a/startdev.sh +++ b/startdev.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -e RC='\033[0m' RED='\033[0;31m' From 2c447f74913b6cc4c421e6480531c9f4e5990fd3 Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Mon, 16 Sep 2024 22:10:02 -0400 Subject: [PATCH 10/37] Fix grammatical errors --- tabs/applications-setup/alacritty-setup.sh | 10 +++++----- tabs/applications-setup/fastfetch-setup.sh | 6 +++--- tabs/applications-setup/kitty-setup.sh | 8 ++++---- tabs/applications-setup/mybash-setup.sh | 2 +- tabs/applications-setup/neovim-setup.sh | 8 +++++--- tabs/applications-setup/rofi-setup.sh | 8 ++++---- tabs/applications-setup/zsh-setup.sh | 11 ++++++----- tabs/security/firewall-baselines.sh | 4 ++-- tabs/system-setup/system-update.sh | 2 +- 9 files changed, 31 insertions(+), 28 deletions(-) diff --git a/tabs/applications-setup/alacritty-setup.sh b/tabs/applications-setup/alacritty-setup.sh index 92e49d33..c808ce46 100755 --- a/tabs/applications-setup/alacritty-setup.sh +++ b/tabs/applications-setup/alacritty-setup.sh @@ -2,8 +2,8 @@ . ../common-script.sh -setupAlacritty() { - echo "Install Alacritty if not already installed..." +installAlacritty() { + echo "Installing Alacritty..." if ! command_exists alacritty; then case ${PACKAGER} in pacman) @@ -14,12 +14,12 @@ setupAlacritty() { ;; esac else - echo "alacritty is already installed." + echo "Alacritty is already installed." fi } setupAlacrittyConfig() { - echo "Copy alacritty config files" + echo "Copying Alacritty configuration files..." if [ -d "${HOME}/.config/alacritty" ] && [ ! -d "${HOME}/.config/alacritty-bak" ]; then cp -r "${HOME}/.config/alacritty" "${HOME}/.config/alacritty-bak" fi @@ -30,5 +30,5 @@ setupAlacrittyConfig() { checkEnv checkEscalationTool -setupAlacritty +installAlacritty setupAlacrittyConfig \ No newline at end of file diff --git a/tabs/applications-setup/fastfetch-setup.sh b/tabs/applications-setup/fastfetch-setup.sh index e3f9a4f7..1fbe7472 100644 --- a/tabs/applications-setup/fastfetch-setup.sh +++ b/tabs/applications-setup/fastfetch-setup.sh @@ -2,8 +2,8 @@ . ../common-script.sh -setupFastfetch() { - echo "Installing Fastfetch if not already installed..." +installFastfetch() { + echo "Installing Fastfetch..." if ! command_exists fastfetch; then case ${PACKAGER} in pacman) @@ -29,5 +29,5 @@ setupFastfetchConfig() { checkEnv checkEscalationTool -setupFastfetch +installFastfetch setupFastfetchConfig \ No newline at end of file diff --git a/tabs/applications-setup/kitty-setup.sh b/tabs/applications-setup/kitty-setup.sh index 7afbbe5d..ab3f3e00 100755 --- a/tabs/applications-setup/kitty-setup.sh +++ b/tabs/applications-setup/kitty-setup.sh @@ -2,8 +2,8 @@ . ../common-script.sh -setupKitty() { - echo "Install Kitty if not already installed..." +installKitty() { + echo "Installing Kitty..." if ! command_exists kitty; then case ${PACKAGER} in pacman) @@ -19,7 +19,7 @@ setupKitty() { } setupKittyConfig() { - echo "Copy Kitty config files" + echo "Copying Kitty configuration files..." if [ -d "${HOME}/.config/kitty" ] && [ ! -d "${HOME}/.config/kitty-bak" ]; then cp -r "${HOME}/.config/kitty" "${HOME}/.config/kitty-bak" fi @@ -30,5 +30,5 @@ setupKittyConfig() { checkEnv checkEscalationTool -setupKitty +installKitty setupKittyConfig \ No newline at end of file diff --git a/tabs/applications-setup/mybash-setup.sh b/tabs/applications-setup/mybash-setup.sh index 7bca14e2..ad1e9c4e 100644 --- a/tabs/applications-setup/mybash-setup.sh +++ b/tabs/applications-setup/mybash-setup.sh @@ -14,7 +14,7 @@ cloneMyBash() { } installDepend() { - echo "Install mybash if not already installed" + echo "Installing Bash..." case "$PACKAGER" in pacman) $ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm bash bash-completion tar bat tree unzip fontconfig diff --git a/tabs/applications-setup/neovim-setup.sh b/tabs/applications-setup/neovim-setup.sh index 0d3a2578..6d1cf5af 100755 --- a/tabs/applications-setup/neovim-setup.sh +++ b/tabs/applications-setup/neovim-setup.sh @@ -13,8 +13,8 @@ cloneNeovim() { cd "$HOME" && git clone https://github.com/ChrisTitusTech/neovim.git "$HOME/.local/share/neovim" } -setupNeovim() { - echo "Install Neovim if not already installed" +installNeovim() { + echo "Installing Neovim..." case "$PACKAGER" in pacman) $ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm neovim ripgrep fzf python-virtualenv luarocks go shellcheck @@ -36,6 +36,7 @@ setupNeovim() { } backupNeovimConfig() { + echo "Backing up existing configuration files..." if [ -d "$HOME/.config/nvim" ] && [ ! -d "$HOME/.config/nvim-backup" ]; then cp -r "$HOME/.config/nvim" "$HOME/.config/nvim-backup" fi @@ -43,6 +44,7 @@ backupNeovimConfig() { } linkNeovimConfig() { + echo "Linking Neovim configuration files..." mkdir -p "$HOME/.config/nvim" ln -s "$gitpath/titus-kickstart/"* "$HOME/.config/nvim/" # Wild card is used here to link all contents of titus-kickstart. } @@ -50,6 +52,6 @@ linkNeovimConfig() { checkEnv checkEscalationTool cloneNeovim -setupNeovim +installNeovim backupNeovimConfig linkNeovimConfig \ No newline at end of file diff --git a/tabs/applications-setup/rofi-setup.sh b/tabs/applications-setup/rofi-setup.sh index c5874517..c2e1ff37 100755 --- a/tabs/applications-setup/rofi-setup.sh +++ b/tabs/applications-setup/rofi-setup.sh @@ -2,8 +2,8 @@ . ../common-script.sh -setupRofi() { - echo "Install Rofi if not already installed..." +installRofi() { + echo "Installing Rofi..." if ! command_exists rofi; then case "$PACKAGER" in pacman) @@ -19,7 +19,7 @@ setupRofi() { } setupRofiConfig() { - echo "Copy Rofi config files" + echo "Copying Rofi configuration files..." if [ -d "$HOME/.config/rofi" ] && [ ! -d "$HOME/.config/rofi-bak" ]; then cp -r "$HOME/.config/rofi" "$HOME/.config/rofi-bak" fi @@ -35,5 +35,5 @@ setupRofiConfig() { checkEnv checkEscalationTool -setupRofi +installRofi setupRofiConfig diff --git a/tabs/applications-setup/zsh-setup.sh b/tabs/applications-setup/zsh-setup.sh index eaa608b5..16423cf7 100644 --- a/tabs/applications-setup/zsh-setup.sh +++ b/tabs/applications-setup/zsh-setup.sh @@ -3,8 +3,8 @@ . ../common-script.sh # Function to install zsh -install_zsh() { - echo "Install ZSH if not already installed..." +installZsh() { + echo "Installing Zsh..." if ! command_exists zsh; then case "$PACKAGER" in pacman) @@ -20,7 +20,8 @@ install_zsh() { } # Function to setup zsh configuration -setup_zsh_config() { +setupZshConfig() { + echo "Setting up Zsh configuration..." CONFIG_DIR="$HOME/.config/zsh" ZSHRC_FILE="$CONFIG_DIR/.zshrc" @@ -48,5 +49,5 @@ EOL checkEnv checkEscalationTool -install_zsh -setup_zsh_config +installZsh +setupZshConfig diff --git a/tabs/security/firewall-baselines.sh b/tabs/security/firewall-baselines.sh index 5abb0c76..1ed974cc 100644 --- a/tabs/security/firewall-baselines.sh +++ b/tabs/security/firewall-baselines.sh @@ -3,7 +3,7 @@ . ../common-script.sh installPkg() { - echo "Install UFW if not already installed..." + echo "Installing UFW..." if ! command_exists ufw; then case ${PACKAGER} in pacman) @@ -19,7 +19,7 @@ installPkg() { } configureUFW() { - printf "%b\n" "${GREEN}Using Chris Titus Recommended Firewall Rules${RC}" + printf "%b\n" "${YELLOW}Using Chris Titus Recommended Firewall Rules${RC}" echo "Disabling UFW" $ESCALATION_TOOL ufw disable diff --git a/tabs/system-setup/system-update.sh b/tabs/system-setup/system-update.sh index e6b32af6..4529befe 100755 --- a/tabs/system-setup/system-update.sh +++ b/tabs/system-setup/system-update.sh @@ -61,7 +61,7 @@ fastUpdate() { } updateSystem() { - printf "%b\n" "${GREEN}Updating system${RC}" + printf "%b\n" "${YELLOW}Updating system${RC}" case ${PACKAGER} in nala|apt-get) $ESCALATION_TOOL "${PACKAGER}" update -y From c1c60aae7b9b64ce92db2ac5221141f69bb895e7 Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Mon, 16 Sep 2024 22:44:20 -0400 Subject: [PATCH 11/37] Incorporate colors into current scripts --- tabs/applications-setup/alacritty-setup.sh | 7 +- tabs/applications-setup/dwmtitus-setup.sh | 94 +++++++++++----------- tabs/applications-setup/fastfetch-setup.sh | 6 +- tabs/applications-setup/kitty-setup.sh | 6 +- tabs/applications-setup/mybash-setup.sh | 14 ++-- tabs/applications-setup/neovim-setup.sh | 2 +- tabs/applications-setup/rofi-setup.sh | 6 +- tabs/applications-setup/zsh-setup.sh | 4 +- tabs/gaming/diablo-ii/d2r-loot-filters.sh | 12 +-- tabs/security/firewall-baselines.sh | 12 +-- tabs/system-setup/1-compile-setup.sh | 2 +- tabs/system-setup/4-remove-snaps.sh | 2 +- 12 files changed, 84 insertions(+), 83 deletions(-) diff --git a/tabs/applications-setup/alacritty-setup.sh b/tabs/applications-setup/alacritty-setup.sh index 92e49d33..796315d2 100755 --- a/tabs/applications-setup/alacritty-setup.sh +++ b/tabs/applications-setup/alacritty-setup.sh @@ -3,7 +3,7 @@ . ../common-script.sh setupAlacritty() { - echo "Install Alacritty if not already installed..." + printf "%b\n" "${YELLOW}Install Alacritty if not already installed...${RC}" if ! command_exists alacritty; then case ${PACKAGER} in pacman) @@ -14,18 +14,19 @@ setupAlacritty() { ;; esac else - echo "alacritty is already installed." + printf "%b\n" "${RED}alacritty is already installed.${RC}" fi } setupAlacrittyConfig() { - echo "Copy alacritty config files" + printf "%b\n" "${YELLOW}Copy alacritty config files${RC}" if [ -d "${HOME}/.config/alacritty" ] && [ ! -d "${HOME}/.config/alacritty-bak" ]; then cp -r "${HOME}/.config/alacritty" "${HOME}/.config/alacritty-bak" fi mkdir -p "${HOME}/.config/alacritty/" curl -sSLo "${HOME}/.config/alacritty/alacritty.toml" "https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/alacritty/alacritty.toml" curl -sSLo "${HOME}/.config/alacritty/nordic.toml" "https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/alacritty/nordic.toml" + printf "%b\n" "${GREEN}Alacritty configuration files copied.${RC}" } checkEnv diff --git a/tabs/applications-setup/dwmtitus-setup.sh b/tabs/applications-setup/dwmtitus-setup.sh index acc56c0e..58b22fe1 100755 --- a/tabs/applications-setup/dwmtitus-setup.sh +++ b/tabs/applications-setup/dwmtitus-setup.sh @@ -10,7 +10,7 @@ makeDWM() { } setupDWM() { - echo "Installing DWM-Titus if not already installed" + printf "%b\n" "${YELLOW}Installing DWM-Titus if not already installed${RC}" case "$PACKAGER" in # Install pre-Requisites pacman) $ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm base-devel libx11 libxinerama libxft imlib2 libxcb @@ -23,7 +23,7 @@ setupDWM() { $ESCALATION_TOOL "$PACKAGER" install -y libX11-devel libXinerama-devel libXft-devel imlib2-devel libxcb-devel ;; *) - echo "Unsupported package manager: $PACKAGER" + printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}" exit 1 ;; esac @@ -37,56 +37,56 @@ install_nerd_font() { # Check if Meslo Nerd-font is already installed if [ -n "$FONT_INSTALLED" ]; then - echo "Meslo Nerd-fonts are already installed." + printf "%b\n" "${RED}Meslo Nerd-fonts are already installed.${RC}" return 0 fi - echo "Installing Meslo Nerd-fonts" + printf "%b\n" "${YELLOW}Installing Meslo Nerd-fonts${RC}" # Create the fonts directory if it doesn't exist if [ ! -d "$FONT_DIR" ]; then mkdir -p "$FONT_DIR" || { - echo "Failed to create directory: $FONT_DIR" + printf "%b\n" "${RED}Failed to create directory: $FONT_DIR${RC}" return 1 } else - echo "$FONT_DIR exists, skipping creation." + printf "%b\n" "${GREEN}$FONT_DIR exists, skipping creation.${RC}" fi # Check if the font zip file already exists if [ ! -f "$FONT_ZIP" ]; then # Download the font zip file curl -sSLo "$FONT_ZIP" "$FONT_URL" || { - echo "Failed to download Meslo Nerd-fonts from $FONT_URL" + printf "%b\n" "${RED}Failed to download Meslo Nerd-fonts from $FONT_URL${RC}" return 1 } else - echo "Meslo.zip already exists in $FONT_DIR, skipping download." + printf "%b\n" "${GREEN}Meslo.zip already exists in $FONT_DIR, skipping download.${RC}" fi # Unzip the font file if it hasn't been unzipped yet if [ ! -d "$FONT_DIR/Meslo" ]; then unzip "$FONT_ZIP" -d "$FONT_DIR" || { - echo "Failed to unzip $FONT_ZIP" + printf "%b\n" "${RED}Failed to unzip $FONT_ZIP${RC}" return 1 } else - echo "Meslo font files already unzipped in $FONT_DIR, skipping unzip." + printf "%b\n" "${GREEN}Meslo font files already unzipped in $FONT_DIR, skipping unzip.${RC}" fi # Remove the zip file rm "$FONT_ZIP" || { - echo "Failed to remove $FONT_ZIP" + printf "%b\n" "${RED}Failed to remove $FONT_ZIP${RC}" return 1 } # Rebuild the font cache fc-cache -fv || { - echo "Failed to rebuild font cache" + printf "%b\n" "${RED}Failed to rebuild font cache${RC}" return 1 } - echo "Meslo Nerd-fonts installed successfully" + printf "%b\n" "${GREEN}Meslo Nerd-fonts installed successfully${RC}" } picom_animations() { @@ -94,33 +94,33 @@ picom_animations() { mkdir -p ~/build if [ ! -d ~/build/picom ]; then if ! git clone https://github.com/FT-Labs/picom.git ~/build/picom; then - echo "Failed to clone the repository" + printf "%b\n" "${RED}Failed to clone the repository${RC}" return 1 fi else - echo "Repository already exists, skipping clone" + printf "%b\n" "${GREEN}Repository already exists, skipping clone${RC}" fi - cd ~/build/picom || { echo "Failed to change directory to picom"; return 1; } + cd ~/build/picom || { printf "%b\n" "${RED}Failed to change directory to picom${RC}"; return 1; } # Build the project if ! meson setup --buildtype=release build; then - echo "Meson setup failed" + printf "%b\n" "${RED}Meson setup failed${RC}" return 1 fi if ! ninja -C build; then - echo "Ninja build failed" + printf "%b\n" "${RED}Ninja build failed${RC}" return 1 fi # Install the built binary if ! $ESCALATION_TOOL ninja -C build install; then - echo "Failed to install the built binary" + printf "%b\n" "${RED}Failed to install the built binary${RC}" return 1 fi - echo "Picom animations installed successfully" + printf "%b\n" "${GREEN}Picom animations installed successfully${RC}" } clone_config_folders() { @@ -135,9 +135,9 @@ clone_config_folders() { # Clone the directory to ~/.config/ if [ -d "$dir" ]; then cp -r "$dir" ~/.config/ - echo "Cloned $dir_name to ~/.config/" + printf "%b\n" "${GREEN}Cloned $dir_name to ~/.config/${RC}" else - echo "Directory $dir_name does not exist, skipping" + printf "%b\n" "${RED}Directory $dir_name does not exist, skipping${RC}" fi done } @@ -149,9 +149,9 @@ configure_backgrounds() { # Check if the ~/Pictures directory exists if [ ! -d "~/Pictures" ]; then # If it doesn't exist, print an error message and return with a status of 1 (indicating failure) - echo "Pictures directory does not exist" + printf "%b\n" "${RED}Pictures directory does not exist${RC}" mkdir ~/Pictures - echo "Directory was created in Home folder" + printf "%b\n" "${GREEN}Directory was created in Home folder${RC}" fi # Check if the backgrounds directory (BG_DIR) exists @@ -159,21 +159,21 @@ configure_backgrounds() { # If the backgrounds directory doesn't exist, attempt to clone a repository containing backgrounds if ! git clone https://github.com/ChrisTitusTech/nord-background.git ~/Pictures; then # If the git clone command fails, print an error message and return with a status of 1 - echo "Failed to clone the repository" + printf "%b\n" "${RED}Failed to clone the repository${RC}" return 1 fi # Rename the cloned directory to 'backgrounds' mv ~/Pictures/nord-background ~/Pictures/backgrounds # Print a success message indicating that the backgrounds have been downloaded - echo "Downloaded desktop backgrounds to $BG_DIR" + printf "%b\n" "${GREEN}Downloaded desktop backgrounds to $BG_DIR${RC}" else # If the backgrounds directory already exists, print a message indicating that the download is being skipped - echo "Path $BG_DIR exists for desktop backgrounds, skipping download of backgrounds" + printf "%b\n" "${RED}Path $BG_DIR exists for desktop backgrounds, skipping download of backgrounds${RC}" fi } setupDisplayManager() { - echo "Setting up Xorg" + printf "%b\n" "${YELLOW}Setting up Xorg${RC}" case "$PACKAGER" in pacman) $ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm xorg-xinit xorg-server @@ -185,12 +185,12 @@ setupDisplayManager() { $ESCALATION_TOOL "$PACKAGER" install -y xorg-x11-xinit xorg-x11-server-Xorg ;; *) - echo "Unsupported package manager: $PACKAGER" + printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}" exit 1 ;; esac - echo "Xorg installed successfully" - echo "Setting up Display Manager" + printf "%b\n" "${GREEN}Xorg installed successfully${RC}" + printf "%b\n" "${YELLOW}Setting up Display Manager${RC}" currentdm="none" for dm in gdm sddm lightdm; do if systemctl is-active --quiet "$dm.service"; then @@ -198,10 +198,10 @@ setupDisplayManager() { break fi done - echo "Current display manager: $currentdm" + printf "%b\n" "${GREEN}Current display manager: $currentdm${RC}" if [ "$currentdm" = "none" ]; then DM="sddm" - echo "No display manager found, installing $DM" + printf "%b\n" "${YELLOW}No display manager found, installing $DM${RC}" case "$PACKAGER" in pacman) $ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm "$DM" @@ -213,11 +213,11 @@ setupDisplayManager() { $ESCALATION_TOOL "$PACKAGER" install -y "$DM" ;; *) - echo "Unsupported package manager: $PACKAGER" + printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}" exit 1 ;; esac - echo "$DM installed successfully" + printf "%b\n" "${GREEN}$DM installed successfully${RC}" systemctl enable "$DM" # Prompt user for auto-login @@ -226,7 +226,7 @@ setupDisplayManager() { read -r answer case "$answer" in [Yy]*) - echo "Configuring SDDM for autologin" + printf "%b\n" "${YELLOW}Configuring SDDM for autologin${RC}" SDDM_CONF="/etc/sddm.conf" if [ ! -f "$SDDM_CONF" ]; then echo "[Autologin]" | $ESCALATION_TOOL tee -a "$SDDM_CONF" @@ -240,24 +240,24 @@ setupDisplayManager() { echo "User=$USER" | $ESCALATION_TOOL tee -a "$SDDM_CONF" echo "Session=dwm" | $ESCALATION_TOOL tee -a "$SDDM_CONF" fi - echo "Checking if autologin group exists" + printf "%b\n" "{YELLOW}Checking if autologin group exists${RC}" if ! getent group autologin > /dev/null; then - echo "Creating autologin group" + printf "%b\n" "${YELLOW}Creating autologin group${RC}" $ESCALATION_TOOL groupadd autologin else - echo "Autologin group already exists" + printf "%b\n" "${RED}Autologin group already exists${RC}" fi - echo "Adding user with UID 1000 to autologin group" + printf "%b\n" "${YELLOW}Adding user with UID 1000 to autologin group${RC}" USER_UID_1000=$(getent passwd 1000 | cut -d: -f1) if [ -n "$USER_UID_1000" ]; then $ESCALATION_TOOL usermod -aG autologin "$USER_UID_1000" - echo "User $USER_UID_1000 added to autologin group" + printf "%b\n" "${GREEN}User $USER_UID_1000 added to autologin group${RC}" else - echo "No user with UID 1000 found - Auto login not possible" + printf "%b\n" "${RED}No user with UID 1000 found - Auto login not possible${RC}" fi ;; *) - echo "Auto-login configuration skipped" + printf "%b\n" "${GREEN}Auto-login configuration skipped${RC}" ;; esac fi @@ -270,16 +270,16 @@ install_slstatus() { printf "Do you want to install slstatus? (y/N): " # using printf instead of 'echo' to avoid newline, -n flag for 'echo' is not supported in POSIX read -r response # -r flag to prevent backslashes from being interpreted if [ "$response" = "y" ] || [ "$response" = "Y" ]; then - echo "Installing slstatus" + printf "%b\n" "${YELLOW}Installing slstatus${RC}" cd "$HOME/dwm-titus/slstatus" || { echo "Failed to change directory to slstatus"; return 1; } if $ESCALATION_TOOL make clean install; then - echo "slstatus installed successfully" + printf "%b\n" "${GREEN}slstatus installed successfully${RC}" else - echo "Failed to install slstatus" + printf "%b\n" "${RED}Failed to install slstatus${RC}" return 1 fi else - echo "Skipping slstatus installation" + printf "%b\n" "${GREEN}Skipping slstatus installation${RC}" fi cd "$HOME" } diff --git a/tabs/applications-setup/fastfetch-setup.sh b/tabs/applications-setup/fastfetch-setup.sh index e3f9a4f7..20d756e2 100644 --- a/tabs/applications-setup/fastfetch-setup.sh +++ b/tabs/applications-setup/fastfetch-setup.sh @@ -3,7 +3,7 @@ . ../common-script.sh setupFastfetch() { - echo "Installing Fastfetch if not already installed..." + printf "%b\n" "${YELLOW}Installing Fastfetch if not already installed...${RC}" if ! command_exists fastfetch; then case ${PACKAGER} in pacman) @@ -14,12 +14,12 @@ setupFastfetch() { ;; esac else - echo "Fastfetch is already installed." + printf "%b\n" "${GREEN}Fastfetch is already installed.${RC}" fi } setupFastfetchConfig() { - echo "Copying Fastfetch config files..." + printf "%b\n" "${YELLOW}Copying Fastfetch config files...${RC}" if [ -d "${HOME}/.config/fastfetch" ] && [ ! -d "${HOME}/.config/fastfetch-bak" ]; then cp -r "${HOME}/.config/fastfetch" "${HOME}/.config/fastfetch-bak" fi diff --git a/tabs/applications-setup/kitty-setup.sh b/tabs/applications-setup/kitty-setup.sh index 7afbbe5d..b5b3bca9 100755 --- a/tabs/applications-setup/kitty-setup.sh +++ b/tabs/applications-setup/kitty-setup.sh @@ -3,7 +3,7 @@ . ../common-script.sh setupKitty() { - echo "Install Kitty if not already installed..." + printf "%b\n" "${YELLOW}Install Kitty if not already installed...${RC}" if ! command_exists kitty; then case ${PACKAGER} in pacman) @@ -14,12 +14,12 @@ setupKitty() { ;; esac else - echo "Kitty is already installed." + printf "%b\n" "${GREEN}Kitty is already installed.${RC}" fi } setupKittyConfig() { - echo "Copy Kitty config files" + printf "%b\n" "${YELLOW}Copy Kitty config files${RC}" if [ -d "${HOME}/.config/kitty" ] && [ ! -d "${HOME}/.config/kitty-bak" ]; then cp -r "${HOME}/.config/kitty" "${HOME}/.config/kitty-bak" fi diff --git a/tabs/applications-setup/mybash-setup.sh b/tabs/applications-setup/mybash-setup.sh index 7bca14e2..526b3e8e 100644 --- a/tabs/applications-setup/mybash-setup.sh +++ b/tabs/applications-setup/mybash-setup.sh @@ -14,7 +14,7 @@ cloneMyBash() { } installDepend() { - echo "Install mybash if not already installed" + printf "%b\n" "${YELLOW}Install mybash if not already installed${RC}" case "$PACKAGER" in pacman) $ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm bash bash-completion tar bat tree unzip fontconfig @@ -39,9 +39,9 @@ installFont() { # Check to see if the MesloLGS Nerd Font is installed (Change this to whatever font you would like) FONT_NAME="MesloLGS Nerd Font Mono" if fc-list :family | grep -iq "$FONT_NAME"; then - echo "Font '$FONT_NAME' is installed." + printf "%b\n" "${GREEN}Font '$FONT_NAME' is installed.${RC}" else - echo "Installing font '$FONT_NAME'" + printf "%b\n" "${YELLOW}Installing font '$FONT_NAME'${RC}" # Change this URL to correspond with the correct font FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Meslo.zip" FONT_DIR="$HOME/.local/share/fonts" @@ -52,13 +52,13 @@ installFont() { mv "${TEMP_DIR}"/*.ttf "$FONT_DIR"/"$FONT_NAME" fc-cache -fv rm -rf "${TEMP_DIR}" - echo "'$FONT_NAME' installed successfully." + printf "%b\n" "${GREEN}'$FONT_NAME' installed successfully.${RC}" fi } installStarshipAndFzf() { if command_exists starship; then - echo "Starship already installed" + printf "%b\n" "${GREEN}Starship already installed${RC}" return fi @@ -67,7 +67,7 @@ installStarshipAndFzf() { exit 1 fi if command_exists fzf; then - echo "Fzf already installed" + printf "%b\n" "${GREEN}Fzf already installed${RC}" else git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf $ESCALATION_TOOL ~/.fzf/install @@ -76,7 +76,7 @@ installStarshipAndFzf() { installZoxide() { if command_exists zoxide; then - echo "Zoxide already installed" + printf "%b\n" "${GREEN}Zoxide already installed${RC}" return fi diff --git a/tabs/applications-setup/neovim-setup.sh b/tabs/applications-setup/neovim-setup.sh index 0d3a2578..042eea3d 100755 --- a/tabs/applications-setup/neovim-setup.sh +++ b/tabs/applications-setup/neovim-setup.sh @@ -14,7 +14,7 @@ cloneNeovim() { } setupNeovim() { - echo "Install Neovim if not already installed" + printf "%b\n" "${YELLOW}Install Neovim if not already installed${RC}" case "$PACKAGER" in pacman) $ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm neovim ripgrep fzf python-virtualenv luarocks go shellcheck diff --git a/tabs/applications-setup/rofi-setup.sh b/tabs/applications-setup/rofi-setup.sh index c5874517..58c46325 100755 --- a/tabs/applications-setup/rofi-setup.sh +++ b/tabs/applications-setup/rofi-setup.sh @@ -3,7 +3,7 @@ . ../common-script.sh setupRofi() { - echo "Install Rofi if not already installed..." + printf "%b\n" "${YELLOW}Install Rofi if not already installed...${RC}" if ! command_exists rofi; then case "$PACKAGER" in pacman) @@ -14,12 +14,12 @@ setupRofi() { ;; esac else - echo "Rofi is already installed." + printf "%b\n" "${GREEN}Rofi is already installed.${RC}" fi } setupRofiConfig() { - echo "Copy Rofi config files" + printf "%b\n" "${YELLOW}Copy Rofi config files${RC}" if [ -d "$HOME/.config/rofi" ] && [ ! -d "$HOME/.config/rofi-bak" ]; then cp -r "$HOME/.config/rofi" "$HOME/.config/rofi-bak" fi diff --git a/tabs/applications-setup/zsh-setup.sh b/tabs/applications-setup/zsh-setup.sh index eaa608b5..991c3849 100644 --- a/tabs/applications-setup/zsh-setup.sh +++ b/tabs/applications-setup/zsh-setup.sh @@ -4,7 +4,7 @@ # Function to install zsh install_zsh() { - echo "Install ZSH if not already installed..." + printf "%b\n" "${YELLOW}Install ZSH if not already installed...${RC}" if ! command_exists zsh; then case "$PACKAGER" in pacman) @@ -15,7 +15,7 @@ install_zsh() { ;; esac else - echo "ZSH is already installed." + printf "%b\n" "${GREEN}ZSH is already installed.${RC}" fi } diff --git a/tabs/gaming/diablo-ii/d2r-loot-filters.sh b/tabs/gaming/diablo-ii/d2r-loot-filters.sh index 1fa43fab..a7cd7694 100755 --- a/tabs/gaming/diablo-ii/d2r-loot-filters.sh +++ b/tabs/gaming/diablo-ii/d2r-loot-filters.sh @@ -1,11 +1,11 @@ #!/bin/bash # Search for possible Diablo II Resurrected folder locations -echo "Searching for Diablo II Resurrected folders..." +printf "%b\n" "${YELLOW}Searching for Diablo II Resurrected folders...${RC}" possible_paths=$(find $HOME -type d -path "*/drive_c/Program Files (x86)/Diablo II Resurrected" 2>/dev/null) if [ -z "$possible_paths" ]; then - echo "Error: No Diablo II Resurrected folders found." + printf "%b\n" "${RED}Error: No Diablo II Resurrected folders found.${RC}" exit 1 fi @@ -23,7 +23,7 @@ print_menu() { if ((start + max_display > total)); then start=$((total - max_display)); fi if ((start < 0)); then start=0; fi - echo "Please select the Diablo II: Resurrected installation path:" + printf "%b\n" "${YELLOW}Please select the Diablo II: Resurrected installation path:${RC}" for i in $(seq 0 $((max_display - 1))); do if ((i + start >= total)); then break; fi if [ $((i + start)) -eq $selected ]; then @@ -84,17 +84,17 @@ mods_path="$d2r_path/mods" mkdir -p "$mods_path" # Download the latest release -echo "Downloading the latest loot filter..." +printf "%b\n" "${YELLOW}Downloading the latest loot filter...${RC}" curl -sSLo /tmp/lootfilter.zip https://github.com/ChrisTitusTech/d2r-loot-filter/releases/latest/download/lootfilter.zip # Extract the contents to the mods folder -echo "Extracting loot filter to $mods_path..." +printf "%b\n" "${YELLOW}Extracting loot filter to $mods_path...${RC}" unzip -q -o /tmp/lootfilter.zip -d "$mods_path" # Clean up rm /tmp/lootfilter.zip -echo "Loot filter installed successfully in $mods_path" +printf "%b\n" "${GREEN}Loot filter installed successfully in $mods_path${RC}" # Add instructions for setting launch options echo diff --git a/tabs/security/firewall-baselines.sh b/tabs/security/firewall-baselines.sh index 5abb0c76..0c73d08b 100644 --- a/tabs/security/firewall-baselines.sh +++ b/tabs/security/firewall-baselines.sh @@ -21,22 +21,22 @@ installPkg() { configureUFW() { printf "%b\n" "${GREEN}Using Chris Titus Recommended Firewall Rules${RC}" - echo "Disabling UFW" + printf "%b\n" "${YELLOW}Disabling UFW${RC}" $ESCALATION_TOOL ufw disable - echo "Limiting port 22/tcp (UFW)" + printf "%b\n" "${YELLOW}Limiting port 22/tcp (UFW)${RC}" $ESCALATION_TOOL ufw limit 22/tcp - echo "Allowing port 80/tcp (UFW)" + printf "%b\n" "${YELLOW}Allowing port 80/tcp (UFW)${RC}" $ESCALATION_TOOL ufw allow 80/tcp - echo "Allowing port 443/tcp (UFW)" + printf "%b\n" "${YELLO}Allowing port 443/tcp (UFW)${RC}" $ESCALATION_TOOL ufw allow 443/tcp - echo "Denying Incoming Packets by Default(UFW)" + printf "%b\n" "${YELLOW}Denying Incoming Packets by Default(UFW)${RC}" $ESCALATION_TOOL ufw default deny incoming - echo "Allowing Outcoming Packets by Default(UFW)" + printf "%b\n" "${YELLOW}Allowing Outcoming Packets by Default(UFW)${RC}" $ESCALATION_TOOL ufw default allow outgoing $ESCALATION_TOOL ufw enable diff --git a/tabs/system-setup/1-compile-setup.sh b/tabs/system-setup/1-compile-setup.sh index a9d21890..0ed8f05c 100755 --- a/tabs/system-setup/1-compile-setup.sh +++ b/tabs/system-setup/1-compile-setup.sh @@ -13,7 +13,7 @@ installDepend() { echo "Include = /etc/pacman.d/mirrorlist" | $ESCALATION_TOOL tee -a /etc/pacman.conf $ESCALATION_TOOL "$PACKAGER" -Syu else - echo "Multilib is already enabled." + printf "%b\n" "${GREEN}Multilib is already enabled.${RC}" fi $AUR_HELPER -S --needed --noconfirm "$DEPENDENCIES" ;; diff --git a/tabs/system-setup/4-remove-snaps.sh b/tabs/system-setup/4-remove-snaps.sh index f804aa5b..f72fd658 100644 --- a/tabs/system-setup/4-remove-snaps.sh +++ b/tabs/system-setup/4-remove-snaps.sh @@ -20,7 +20,7 @@ removeSnaps() { $ESCALATION_TOOL ${PACKAGER} remove snapd ;; *) - echo "Removing snapd not implemented for this package manager" + printf "%b\n" "${RED}Removing snapd not implemented for this package manager${RC}" ;; esac } From fd126fbb5f56ca7d31e5447292d421b53c7ba701 Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Mon, 16 Sep 2024 22:58:17 -0400 Subject: [PATCH 12/37] Fix minor inconsistencies --- tabs/applications-setup/alacritty-setup.sh | 2 +- tabs/applications-setup/dwmtitus-setup.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tabs/applications-setup/alacritty-setup.sh b/tabs/applications-setup/alacritty-setup.sh index 796315d2..61922a15 100755 --- a/tabs/applications-setup/alacritty-setup.sh +++ b/tabs/applications-setup/alacritty-setup.sh @@ -14,7 +14,7 @@ setupAlacritty() { ;; esac else - printf "%b\n" "${RED}alacritty is already installed.${RC}" + printf "%b\n" "${GREEN}alacritty is already installed.${RC}" fi } diff --git a/tabs/applications-setup/dwmtitus-setup.sh b/tabs/applications-setup/dwmtitus-setup.sh index 58b22fe1..cf2f66ef 100755 --- a/tabs/applications-setup/dwmtitus-setup.sh +++ b/tabs/applications-setup/dwmtitus-setup.sh @@ -37,7 +37,7 @@ install_nerd_font() { # Check if Meslo Nerd-font is already installed if [ -n "$FONT_INSTALLED" ]; then - printf "%b\n" "${RED}Meslo Nerd-fonts are already installed.${RC}" + printf "%b\n" "${GREEN}Meslo Nerd-fonts are already installed.${RC}" return 0 fi @@ -168,7 +168,7 @@ configure_backgrounds() { printf "%b\n" "${GREEN}Downloaded desktop backgrounds to $BG_DIR${RC}" else # If the backgrounds directory already exists, print a message indicating that the download is being skipped - printf "%b\n" "${RED}Path $BG_DIR exists for desktop backgrounds, skipping download of backgrounds${RC}" + printf "%b\n" "${GREEN}Path $BG_DIR exists for desktop backgrounds, skipping download of backgrounds${RC}" fi } @@ -245,7 +245,7 @@ setupDisplayManager() { printf "%b\n" "${YELLOW}Creating autologin group${RC}" $ESCALATION_TOOL groupadd autologin else - printf "%b\n" "${RED}Autologin group already exists${RC}" + printf "%b\n" "${GREEN}Autologin group already exists${RC}" fi printf "%b\n" "${YELLOW}Adding user with UID 1000 to autologin group${RC}" USER_UID_1000=$(getent passwd 1000 | cut -d: -f1) From b329b572ae1c52f6a1adc212266cf1db0688083c Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Mon, 16 Sep 2024 23:11:04 -0400 Subject: [PATCH 13/37] Incorporate colors into added echo statements & replace those echo statements with printf %bn statements --- tabs/applications-setup/neovim-setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tabs/applications-setup/neovim-setup.sh b/tabs/applications-setup/neovim-setup.sh index 6d1cf5af..826fd538 100755 --- a/tabs/applications-setup/neovim-setup.sh +++ b/tabs/applications-setup/neovim-setup.sh @@ -14,7 +14,7 @@ cloneNeovim() { } installNeovim() { - echo "Installing Neovim..." + 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 @@ -36,7 +36,7 @@ installNeovim() { } backupNeovimConfig() { - echo "Backing up existing configuration files..." + printf "%b\n" "${YELLOW}Backing up existing configuration files...${RC}" if [ -d "$HOME/.config/nvim" ] && [ ! -d "$HOME/.config/nvim-backup" ]; then cp -r "$HOME/.config/nvim" "$HOME/.config/nvim-backup" fi @@ -44,7 +44,7 @@ backupNeovimConfig() { } linkNeovimConfig() { - echo "Linking Neovim configuration files..." + printf "%b\n" "${YELLOW}Linking Neovim configuration files...${RC}" mkdir -p "$HOME/.config/nvim" ln -s "$gitpath/titus-kickstart/"* "$HOME/.config/nvim/" # Wild card is used here to link all contents of titus-kickstart. } From 7c491bde98b0f22958226de741939c67c5eb73ac Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Mon, 16 Sep 2024 23:14:49 -0400 Subject: [PATCH 14/37] Revert one of the changes in the last commit --- tabs/applications-setup/neovim-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/applications-setup/neovim-setup.sh b/tabs/applications-setup/neovim-setup.sh index 826fd538..6c2a20bf 100755 --- a/tabs/applications-setup/neovim-setup.sh +++ b/tabs/applications-setup/neovim-setup.sh @@ -14,7 +14,7 @@ cloneNeovim() { } installNeovim() { - printf "%b\n" "${YELLOW}Installing Neovim...${RC}" + echo "Installing Neovim..." case "$PACKAGER" in pacman) $ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm neovim ripgrep fzf python-virtualenv luarocks go shellcheck From 5e83ca55e7ddc11cd9ab6af523e92b40b998d2a3 Mon Sep 17 00:00:00 2001 From: MyDrift Date: Tue, 17 Sep 2024 12:43:39 +0200 Subject: [PATCH 15/37] fix stuff - enhance logic - fix logic to get PR body as plain text --- .github/workflows/pr-labels.yaml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr-labels.yaml b/.github/workflows/pr-labels.yaml index eab956f4..a5f1840e 100644 --- a/.github/workflows/pr-labels.yaml +++ b/.github/workflows/pr-labels.yaml @@ -9,8 +9,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Analyze PR Body and manage labels + shell: bash run: | - body="${{ github.event.pull_request.body }}" + body=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH") labels_to_add=() labels_to_remove=() declare -A label_checks=( @@ -20,19 +21,23 @@ jobs: ["Refactoring"]="refactor" ["UI/UX improvement"]="UI/UX" ) - for key in "${!label_checks[@]}"; do - if echo "$body" | grep -q "\- \[x\] $key"; then - labels_to_add+=("${label_checks[$key]}") + for pattern in "${!label_checks[@]}"; do + label="${label_checks[$pattern]}" + if echo "$body" | grep -Eq "\- \[x\] ($pattern)"; then + labels_to_add+=("$label") else - labels_to_remove+=("${label_checks[$key]}") + labels_to_remove+=("$label") fi done - echo "LABELS_TO_ADD=${labels_to_add[*]}" >> $GITHUB_ENV - echo "LABELS_TO_REMOVE=${labels_to_remove[*]}" >> $GITHUB_ENV + + echo "LABELS_TO_ADD=$(IFS=,; echo "${labels_to_add[*]}")" >> $GITHUB_ENV + echo "LABELS_TO_REMOVE=$(IFS=,; echo "${labels_to_remove[*]}")" >> $GITHUB_ENV + - name: Add labels if necessary if: env.LABELS_TO_ADD != '' run: | - for label in ${{ env.LABELS_TO_ADD }}; do + IFS=',' read -ra labels <<< "${LABELS_TO_ADD}" + for label in "${labels[@]}"; do curl -s -X POST \ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ -H "Accept: application/vnd.github.v3+json" \ @@ -42,7 +47,8 @@ jobs: - name: Remove labels if necessary if: env.LABELS_TO_REMOVE != '' run: | - for label in ${{ env.LABELS_TO_REMOVE }}; do + IFS=',' read -ra labels <<< "${LABELS_TO_REMOVE}" + for label in "${labels[@]}"; do curl -s -X DELETE \ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ -H "Accept: application/vnd.github.v3+json" \ From 63b7da40a41f500d879aacd5e625982da33e8b27 Mon Sep 17 00:00:00 2001 From: MyDrift Date: Tue, 17 Sep 2024 12:52:36 +0200 Subject: [PATCH 16/37] add _target for forked repo support --- .github/workflows/pr-labels.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-labels.yaml b/.github/workflows/pr-labels.yaml index a5f1840e..82f9ac97 100644 --- a/.github/workflows/pr-labels.yaml +++ b/.github/workflows/pr-labels.yaml @@ -1,7 +1,7 @@ name: Manage labels based on PR body on: - pull_request: + pull_request_target: types: [opened, edited, reopened, synchronize] jobs: @@ -53,4 +53,4 @@ jobs: -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/$label - done \ No newline at end of file + done From 418cb9db44eed260e5c2d9fe2e3ed9a96a34fed5 Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 19:43:33 +0530 Subject: [PATCH 17/37] added auto-login --- tabs/utils/auto-login.sh | 179 +++++++++++++++++++++++++++++++++++++++ tabs/utils/tab_data.toml | 9 ++ 2 files changed, 188 insertions(+) create mode 100644 tabs/utils/auto-login.sh diff --git a/tabs/utils/auto-login.sh b/tabs/utils/auto-login.sh new file mode 100644 index 00000000..69bd8611 --- /dev/null +++ b/tabs/utils/auto-login.sh @@ -0,0 +1,179 @@ +#!/bin/sh -e + +. ../common-script.sh + +# Function to list common session options +list_sessions() { + echo "Select the session:" + echo "1) GNOME (gnome.desktop)" + echo "2) KDE Plasma (plasma.desktop)" + echo "3) XFCE (xfce.desktop)" + echo "4) LXDE (LXDE.desktop)" + echo "5) LXQt (lxqt.desktop)" + echo "6) Cinnamon (cinnamon.desktop)" + echo "7) MATE (mate.desktop)" + echo "8) Openbox (openbox.desktop)" + echo "9) i3 (i3.desktop)" + echo "10) Custom session" + echo "Enter your choice [1-10]: " + read session_choice + + case "$session_choice" in + 1) session="gnome.desktop" ;; + 2) session="plasma.desktop" ;; + 3) session="xfce.desktop" ;; + 4) session="LXDE.desktop" ;; + 5) session="lxqt.desktop" ;; + 6) session="cinnamon.desktop" ;; + 7) session="mate.desktop" ;; + 8) session="openbox.desktop" ;; + 9) session="i3.desktop" ;; + 10) + echo "Enter custom session name (e.g., mysession.desktop): " + read session ;; + *) + echo "Invalid option selected." + exit 1 ;; + esac +} + +# Function to configure LightDM +configure_lightdm() { + echo "Configuring LightDM for autologin..." + + echo "Enter username for LightDM autologin: " + read user + + $ESCALATION_TOOL "echo '[Seat:*]' > /etc/lightdm/lightdm.conf.d/50-autologin.conf" + $ESCALATION_TOOL "echo 'autologin-user=$user' >> /etc/lightdm/lightdm.conf.d/50-autologin.conf" + $ESCALATION_TOOL "echo 'autologin-user-timeout=0' >> /etc/lightdm/lightdm.conf.d/50-autologin.conf" + + echo "LightDM has been configured for autologin." +} + +# Function to remove LightDM autologin +remove_lightdm_autologin() { + echo "Removing LightDM autologin configuration..." + $ESCALATION_TOOL rm -f /etc/lightdm/lightdm.conf.d/50-autologin.conf + echo "LightDM autologin configuration has been removed." +} + +# Function to configure GDM +configure_gdm() { + echo "Configuring GDM for autologin..." + + echo "Enter username for GDM autologin: " + read user + + $ESCALATION_TOOL "echo '[daemon]' > /etc/gdm/custom.conf" + $ESCALATION_TOOL "echo 'AutomaticLoginEnable = true' >> /etc/gdm/custom.conf" + $ESCALATION_TOOL "echo 'AutomaticLogin = $user' >> /etc/gdm/custom.conf" + + echo "GDM has been configured for autologin." +} + +# Function to remove GDM autologin +remove_gdm_autologin() { + echo "Removing GDM autologin configuration..." + $ESCALATION_TOOL sed -i '/AutomaticLoginEnable/d' /etc/gdm/custom.conf + $ESCALATION_TOOL sed -i '/AutomaticLogin/d' /etc/gdm/custom.conf + echo "GDM autologin configuration has been removed." +} + +# Function to configure SDDM +configure_sddm() { + echo "Configuring SDDM for autologin..." + + echo "Enter username for SDDM autologin: " + read user + list_sessions # Show session options + + $ESCALATION_TOOL "echo '[Autologin]' > /etc/sddm.conf" + $ESCALATION_TOOL "echo 'User=$user' >> /etc/sddm.conf" + $ESCALATION_TOOL "echo 'Session=$session' >> /etc/sddm.conf" + + echo "SDDM has been configured for autologin." +} + +# Function to remove SDDM autologin +remove_sddm_autologin() { + echo "Removing SDDM autologin configuration..." + $ESCALATION_TOOL sed -i '/\[Autologin\]/,+2d' /etc/sddm.conf + echo "SDDM autologin configuration has been removed." +} + +# Function to configure LXDM +configure_lxdm() { + echo "Configuring LXDM for autologin..." + + echo "Enter username for LXDM autologin: " + read 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 + + echo "LXDM has been configured for autologin." +} + +# Function to remove LXDM autologin +remove_lxdm_autologin() { + echo "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 + echo "LXDM autologin configuration has been removed." +} + +# Function to configure or remove autologin based on user choice +configure_or_remove_autologin() { + echo "Do you want to add or remove autologin?" + echo "1) Add autologin" + echo "2) Remove autologin" + echo "Enter your choice [1-2]: " + read action_choice + + if [ "$action_choice" = "1" ]; then + echo "Choose the display manager to configure:" + echo "1) LightDM" + echo "2) GDM" + echo "3) SDDM" + echo "4) LXDM" + echo "Enter your choice [1-4]: " + read choice + + case "$choice" in + 1) configure_lightdm ;; + 2) configure_gdm ;; + 3) configure_sddm ;; + 4) configure_lxdm ;; + *) echo "Invalid option selected." ;; + esac + elif [ "$action_choice" = "2" ]; then + echo "Choose the display manager to remove autologin:" + echo "1) LightDM" + echo "2) GDM" + echo "3) SDDM" + echo "4) LXDM" + echo "Enter your choice [1-4]: " + read choice + + case "$choice" in + 1) remove_lightdm_autologin ;; + 2) remove_gdm_autologin ;; + 3) remove_sddm_autologin ;; + 4) remove_lxdm_autologin ;; + *) echo "Invalid option selected." ;; + esac + else + echo "Invalid choice. Exiting..." + exit 1 + fi + + echo "Action completed. Exiting..." + exit 0 +} + + +checkEnv +checkEscalationTool +configure_or_remove_autologin diff --git a/tabs/utils/tab_data.toml b/tabs/utils/tab_data.toml index bf05a1b3..53224c52 100644 --- a/tabs/utils/tab_data.toml +++ b/tabs/utils/tab_data.toml @@ -20,6 +20,10 @@ script = "ollama.sh" name = "Service Manager" script = "service-control.sh" +[[data]] +name = "Auto Login" +script = "auto-login.sh" + [[data]] name = "Monitor Control" @@ -73,3 +77,8 @@ script = "monitor-control/scale_monitor.sh" name = "Reset Scaling" script = "monitor-control/reset_scaling.sh" matches = true + +[[data.entries]] +name = "Set Brightness" +script = "monitor-control/set_brightness.sh" +matches = true \ No newline at end of file From 0b8a649d07b9a01a01e0e461fe632342cb7e6c75 Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 19:44:52 +0530 Subject: [PATCH 18/37] added pendrive maker script --- tabs/utils/create-bootable-usb.sh | 191 ++++++++++++++++++++++++++++++ tabs/utils/tab_data.toml | 4 + 2 files changed, 195 insertions(+) create mode 100644 tabs/utils/create-bootable-usb.sh diff --git a/tabs/utils/create-bootable-usb.sh b/tabs/utils/create-bootable-usb.sh new file mode 100644 index 00000000..80dab102 --- /dev/null +++ b/tabs/utils/create-bootable-usb.sh @@ -0,0 +1,191 @@ +#!/bin/sh -e + +. ../common-script.sh + +# Function to display usage instructions +usage() { + printf "%b\n" "${RED} Usage: $0 ${RC}" + echo "No arguments needed. The script will prompt for ISO path and USB device." + exit 1 +} + +# Function to display all available block devices +list_devices() { + printf "%b\n" "${YELLOW} Available devices and partitions: ${RC}" + echo "" + $ESCALATION_TOOL lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL + echo "" +} + +# Function to fetch the latest Arch Linux ISO +fetch_arch_latest_iso() { + ARCH_BASE_URL="https://archive.archlinux.org/iso/" + ARCH_LATEST=$(curl -s "$ARCH_BASE_URL" | grep -oP '(?<=href=")[0-9]{4}\.[0-9]{2}\.[0-9]{2}(?=/)' | sort -V | tail -1) + ARCH_URL="${ARCH_BASE_URL}${ARCH_LATEST}/archlinux-${ARCH_LATEST}-x86_64.iso" + printf "%b\n" "${GREEN} Selected Arch Linux (latest) ISO URL: ${RC} $ARCH_URL" +} + +# Function to fetch older Arch Linux ISOs and display in a table format +fetch_arch_older_isos() { + ARCH_BASE_URL="https://archive.archlinux.org/iso/" + ARCH_VERSIONS=$(curl -s "$ARCH_BASE_URL" | grep -oP '(?<=href=")[0-9]{4}\.[0-9]{2}\.[0-9]{2}(?=/)' | sort -V) + + # Filter versions to include only those from 2017-04-01 and later + MIN_DATE="2017.04.01" + ARCH_VERSIONS=$(echo "$ARCH_VERSIONS" | awk -v min_date="$MIN_DATE" '$0 >= min_date') + + if [ -z "$ARCH_VERSIONS" ]; then + printf "%b\n" "${RED}No Arch Linux versions found from ${MIN_DATE} onwards.${RC}" + exit 1 + fi + + printf "%b\n" "${YELLOW}Available Arch Linux versions from ${MIN_DATE} onwards:${RC}" + + COUNTER=1 + ROW_ITEMS=6 # Number of versions to show per row + for VERSION in $ARCH_VERSIONS; do + printf "%-5s${YELLOW}%-15s ${RC}" "$COUNTER)" "$VERSION" + + if [ $(( COUNTER % ROW_ITEMS )) -eq 0 ]; then + echo "" # New line after every 6 versions + fi + + COUNTER=$((COUNTER + 1)) + done + echo "" # New line after the last row + + read -p "Select an Arch Linux version (1-$((COUNTER - 1))): " ARCH_OPTION + ARCH_DIR=$(echo "$ARCH_VERSIONS" | sed -n "${ARCH_OPTION}p") + ARCH_URL="${ARCH_BASE_URL}${ARCH_DIR}/archlinux-${ARCH_DIR}-x86_64.iso" + printf "%b\n" "${GREEN}Selected Arch Linux (older) ISO URL: $ARCH_URL${RC}" +} + + +# Function to fetch the latest Debian Linux ISO +fetch_debian_latest_iso() { + DEBIAN_URL=$(curl -s https://www.debian.org/distrib/netinst | grep -oP '(?<=href=")[^"]+debian-[0-9.]+-amd64-netinst.iso(?=")' | head -1) + printf "%b\n" "${GREEN} Selected Debian Linux (latest) ISO URL: ${RC} $DEBIAN_URL" +} + +# Function to ask whether to use local or online ISO +choose_iso_source() { + printf "%b\n" "${YELLOW} Do you want to use a local ISO or download online? ${RC}" + echo "1) Download online" + echo "2) Use local ISO" + echo "" + read -p "Select option (1-2): " ISO_SOURCE_OPTION + + case $ISO_SOURCE_OPTION in + 1) + fetch_iso_urls # Call the function to fetch online ISO URLs + ;; + 2) + read -p "Enter the path to the already downloaded ISO file: " ISO_PATH + if [ ! -f "$ISO_PATH" ]; then + printf "%b\n" "${RED} ISO file not found: $ISO_PATH ${RC}" + exit 1 + fi + ;; + *) + printf "%b\n" "${RED}Invalid option selected. ${RC}" + exit 1 + ;; + esac +} + +# Function to fetch ISO URLs +fetch_iso_urls() { + clear + printf "%b\n" "${YELLOW}Available ISOs for download:${RC}" + echo "1) Arch Linux (latest)" + echo "2) Arch Linux (older versions)" + echo "3) Debian Linux (latest)" + echo "" + read -p "Select the ISO you want to download (1-3): " ISO_OPTION + + case $ISO_OPTION in + 1) + fetch_arch_latest_iso + ISO_URL=$ARCH_URL + ;; + 2) + fetch_arch_older_isos + ISO_URL=$ARCH_URL + ;; + 3) + fetch_debian_latest_iso + ISO_URL=$DEBIAN_URL + ;; + *) + printf "%b\n" "${RED}Invalid option selected.${RC}" + exit 1 + ;; + esac + + ISO_PATH=$(basename "$ISO_URL") + printf "%b\n" "${YELLOW}Downloading ISO...${RC}" + curl -L -o "$ISO_PATH" "$ISO_URL" + if [ $? -ne 0 ]; then + printf "%b\n" "${RED}Failed to download the ISO file.${RC}" + exit 1 + fi +} + +write_iso(){ + clear + + # Ask whether to use a local or online ISO + choose_iso_source + + clear + # Display all available devices + list_devices + + # Prompt user for USB device + read -p "Enter the USB device (e.g., /dev/sdX): " USB_DEVICE + + # Verify that the USB device exists + if [ ! -b "$USB_DEVICE" ]; then + printf "%b\n" "${RED}USB device not found: $USB_DEVICE${RC}" + exit 1 + fi + + # Confirm the device selection with the user + printf "%b\n" "${RED}WARNING: This will erase all data on ${USB_DEVICE}. Are you sure you want to continue? (yes/no)${RC}" + read -r CONFIRMATION + + if [ "$CONFIRMATION" != "yes" ]; then + printf "%b\n" "${YELLOW}Operation cancelled.${RC}" + exit 1 + fi + + # Display progress and create the bootable USB drive + printf "%b\n" "${YELLOW}Creating bootable USB drive...${RC}" + if ! $ESCALATION_TOOL dd if="$ISO_PATH" of="$USB_DEVICE" bs=4M status=progress oflag=sync; then + printf "%b\n" "${RED}Failed to create bootable USB drive${RC}" + exit 1 + fi + + # Sync to ensure all data is written + if ! $ESCALATION_TOOL sync; then + printf "%b\n" "${RED}Failed to sync data${RC}" + exit 1 + fi + + printf "%b\n" "${GREEN}Bootable USB drive created successfully!${RC}" + + # Eject the USB device + printf "%b\n" "${YELLOW}Ejecting ${USB_DEVICE}...${RC}" + if ! $ESCALATION_TOOL umount "${USB_DEVICE}"* 2>/dev/null; then + printf "%b\n" "${RED}Failed to unmount ${USB_DEVICE}${RC}" + fi + if ! $ESCALATION_TOOL eject "$USB_DEVICE"; then + printf "%b\n" "${RED}Failed to eject ${USB_DEVICE}${RC}" + fi + + printf "%b\n" "${GREEN}You can safely remove your USB drive. Reinsert the drive to be detected.${RC}" +} + +checkEnv +checkEscalationTool +write_iso \ No newline at end of file diff --git a/tabs/utils/tab_data.toml b/tabs/utils/tab_data.toml index 53224c52..8ed1779c 100644 --- a/tabs/utils/tab_data.toml +++ b/tabs/utils/tab_data.toml @@ -24,6 +24,10 @@ script = "service-control.sh" name = "Auto Login" script = "auto-login.sh" +[[data]] +name = "Bootable Pendrive Maker" +script = "create-bootable-usb.sh" + [[data]] name = "Monitor Control" From 4bb3ba545881ba3f4f12c9d0a78b96683ca9f6c0 Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 19:45:29 +0530 Subject: [PATCH 19/37] added power profile script --- tabs/utils/power-profile.sh | 99 +++++++++++++++++++++++++++++++++++++ tabs/utils/tab_data.toml | 4 ++ 2 files changed, 103 insertions(+) create mode 100644 tabs/utils/power-profile.sh diff --git a/tabs/utils/power-profile.sh b/tabs/utils/power-profile.sh new file mode 100644 index 00000000..5c614d3f --- /dev/null +++ b/tabs/utils/power-profile.sh @@ -0,0 +1,99 @@ +#!/bin/sh -e + +. ../common-script.sh + +installAutoCpufreq() { + clear + printf "%b\n" "${YELLOW}Checking if auto-cpufreq is already installed...${RC}" + + # Check if auto-cpufreq is already installed + if command_exists auto-cpufreq; then + printf "%b\n" "${GREEN}auto-cpufreq is already installed.${RC}" + else + printf "%b\n" "${YELLOW}Installing auto-cpufreq...${RC}" + + # Install git if not already installed + if ! command_exists git; then + printf "%b\n" "${YELLOW}git not found. Installing git...${RC}" + case ${PACKAGER} in + pacman) + $ESCALATION_TOOL ${PACKAGER} -S --needed --noconfirm git + ;; + *) + $ESCALATION_TOOL ${PACKAGER} install -y git + ;; + esac + fi + + # Clone the auto-cpufreq repository and run the installer + if [ ! -d "auto-cpufreq" ]; then + printf "%b\n" "${YELLOW}Cloning auto-cpufreq repository...${RC}" + git clone https://github.com/AdnanHodzic/auto-cpufreq.git + fi + + case ${PACKAGER} in + *) + cd auto-cpufreq + printf "%b\n" "${YELLOW}Running auto-cpufreq installer...${RC}" + $ESCALATION_TOOL ./auto-cpufreq-installer + ;; + esac + cd .. + fi +} + +configureAutoCpufreq() { + printf "%b\n" "${YELLOW}Configuring auto-cpufreq...${RC}" + + if command_exists auto-cpufreq; then + # 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 + else + printf "%b\n" "${GREEN}System detected as desktop. Updating auto-cpufreq for desktop...${RC}" + $ESCALATION_TOOL auto-cpufreq --force performance + fi + else + printf "%b\n" "${RED}auto-cpufreq is not installed, skipping configuration.${RC}" + fi +} + +removeAutoCpufreqTweak() { + printf "%b\n" "${YELLOW}Removing auto-cpufreq tweak...${RC}" + + if command_exists auto-cpufreq; then + printf "%b\n" "${YELLOW}Resetting auto-cpufreq configuration...${RC}" + $ESCALATION_TOOL auto-cpufreq --force reset + else + printf "%b\n" "${RED}auto-cpufreq is not installed, skipping removal.${RC}" + fi +} + +apply_or_remove_auto_cpufreq() { + # Prompt user for action + printf "%b\n" "${YELLOW}Do you want to apply the auto-cpufreq tweak or remove it?${RC}" + printf "%b\n" "${YELLOW}1) Apply tweak${RC}" + printf "%b\n" "${YELLOW}2) Remove tweak${RC}" + read -rp "Enter your choice [1/2]: " choice + + case $choice in + 1) + configureAutoCpufreq + ;; + 2) + removeAutoCpufreqTweak + ;; + *) + printf "%b\n" "${RED}Invalid choice. Exiting.${RC}" + exit 1 + ;; + esac + + printf "%b\n" "${GREEN}auto-cpufreq setup complete.${RC}" +} + +checkEnv +checkEscalationTool +installAutoCpufreq +apply_or_remove_auto_cpufreq \ No newline at end of file diff --git a/tabs/utils/tab_data.toml b/tabs/utils/tab_data.toml index 8ed1779c..9efd0aa0 100644 --- a/tabs/utils/tab_data.toml +++ b/tabs/utils/tab_data.toml @@ -28,6 +28,10 @@ script = "auto-login.sh" name = "Bootable Pendrive Maker" script = "create-bootable-usb.sh" +[[data]] +name = "Auto Power Profiling" +script = "power-profile.sh" + [[data]] name = "Monitor Control" From d99d26d910385d756c58e3a04ebc0559278cee39 Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 19:45:57 +0530 Subject: [PATCH 20/37] added timeshift backup script --- tabs/utils/tab_data.toml | 4 + tabs/utils/timeshift.sh | 153 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 tabs/utils/timeshift.sh diff --git a/tabs/utils/tab_data.toml b/tabs/utils/tab_data.toml index 9efd0aa0..2559d5dc 100644 --- a/tabs/utils/tab_data.toml +++ b/tabs/utils/tab_data.toml @@ -32,6 +32,10 @@ script = "create-bootable-usb.sh" name = "Auto Power Profiling" script = "power-profile.sh" +[[data]] +name = "Timeshift Backup" +script = "timeshift.sh" + [[data]] name = "Monitor Control" diff --git a/tabs/utils/timeshift.sh b/tabs/utils/timeshift.sh new file mode 100644 index 00000000..9ff18892 --- /dev/null +++ b/tabs/utils/timeshift.sh @@ -0,0 +1,153 @@ +#!/bin/sh -e + +. ../common-script.sh + +# Function to install Timeshift +install_timeshift() { + clear + printf "%b\n" "${YELLOW}Checking if Timeshift is installed...${RC}" + + if ! command_exists timeshift; then + case ${PACKAGER} in + pacman) + $ESCALATION_TOOL "${PACKAGER}" -S --noconfirm timeshift + ;; + *) + $ESCALATION_TOOL "${PACKAGER}" install -y timeshift + ;; + esac + else + echo "Timeshift is already installed." + fi +} + +# Function to display the menu +display_menu() { + clear + echo "Timeshift CLI Automation" + echo "-------------------------" + echo "1) List Snapshots" + echo "2) List Devices" + echo "3) Create Snapshot" + echo "4) Restore Snapshot" + echo "5) Delete Snapshot" + echo "6) Delete All Snapshots" + echo "7) Exit" + echo "" +} + +# Function to list snapshots +list_snapshots() { + echo "Listing snapshots..." + $ESCALATION_TOOL timeshift --list-snapshots +} + +# Function to list devices +list_devices() { + echo "Listing available devices..." + $ESCALATION_TOOL timeshift --list-devices +} + +# Function to create a new snapshot +create_snapshot() { + read -p "Enter a comment for the snapshot (optional): " COMMENT + read -p "Enter snapshot tag (O,B,H,D,W,M) (leave empty for no tag): " TAG + + if [ -z "$COMMENT" ] && [ -z "$TAG" ]; then + echo "Creating snapshot with no comment or tag..." + $ESCALATION_TOOL timeshift --create + elif [ -z "$TAG" ]; then + echo "Creating snapshot with no tag..." + $ESCALATION_TOOL timeshift --create --comments "$COMMENT" + else + echo "Creating snapshot with tag: $TAG..." + $ESCALATION_TOOL timeshift --create --comments "$COMMENT" --tags "$TAG" + fi + + if [ $? -eq 0 ]; then + echo "Snapshot created successfully." + else + echo "Snapshot creation failed." + fi +} + +# Function to restore a snapshot +restore_snapshot() { + list_snapshots + + read -p "Enter the snapshot name you want to restore: " SNAPSHOT + read -p "Enter the target device (e.g., /dev/sda1): " TARGET_DEVICE + read -p "Do you want to skip GRUB reinstall? (yes/no): " SKIP_GRUB + + if [ "$SKIP_GRUB" = "yes" ]; then + $ESCALATION_TOOL timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --skip-grub --yes + else + read -p "Enter GRUB device (e.g., /dev/sda): " GRUB_DEVICE + $ESCALATION_TOOL timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --grub-device "$GRUB_DEVICE" --yes + fi + + if [ $? -eq 0 ]; then + echo "Snapshot restored successfully." + else + echo "Snapshot restore failed." + fi +} + +# Function to delete a snapshot +delete_snapshot() { + list_snapshots + + read -p "Enter the snapshot name you want to delete: " SNAPSHOT + + echo "Deleting snapshot $SNAPSHOT..." + $ESCALATION_TOOL timeshift --delete --snapshot "$SNAPSHOT" --yes + + if [ $? -eq 0 ]; then + echo "Snapshot deleted successfully." + else + echo "Snapshot deletion failed." + fi +} + +# Function to delete all snapshots +delete_all_snapshots() { + echo "WARNING: This will delete all snapshots!" + read -p "Are you sure? (yes/no): " CONFIRMATION + + if [ "$CONFIRMATION" = "yes" ]; then + echo "Deleting all snapshots..." + $ESCALATION_TOOL timeshift --delete-all --yes + if [ $? -eq 0 ]; then + printf "%b\n" "${GREEN}All snapshots deleted successfully.${RC}" + else + printf "%b\n" "${RED}Failed to delete snapshots.${RC}" + fi + else + printf "%b\n" "${RED}Operation cancelled.${RC}" + fi +} + +main_menu() { +while true; do + display_menu + read -p "Select an option (1-7): " OPTION + + case $OPTION in + 1) list_snapshots ;; + 2) list_devices ;; + 3) create_snapshot ;; + 4) restore_snapshot ;; + 5) delete_snapshot ;; + 6) delete_all_snapshots ;; + 7) echo "Exiting..."; exit 0 ;; + *) echo "Invalid option. Please try again." ;; + esac + + read -p "Press Enter to continue..." +done +} + +checkEnv +checkEscalationTool +install_timeshift +main_menu From 71beabd6d6d3b7c4bcbf4223856bf7730c7bbce3 Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 19:50:52 +0530 Subject: [PATCH 21/37] set brightness monitor scontrol script --- tabs/utils/monitor-control/set_brightness.sh | 85 +++++++++++++++++++ .../monitor-control/utility_functions.sh | 6 ++ 2 files changed, 91 insertions(+) create mode 100644 tabs/utils/monitor-control/set_brightness.sh diff --git a/tabs/utils/monitor-control/set_brightness.sh b/tabs/utils/monitor-control/set_brightness.sh new file mode 100644 index 00000000..8265ded7 --- /dev/null +++ b/tabs/utils/monitor-control/set_brightness.sh @@ -0,0 +1,85 @@ +#!/bin/sh -e + +. ./utility_functions.sh + +# Function to adjust brightness for a selected monitor +adjust_monitor_brightness() { + while true; do + monitor_list=$(detect_connected_monitors) + monitor_array=$(echo "$monitor_list" | tr '\n' ' ') + set -- $monitor_array + count=1 + + clear + printf "%b\n" "${YELLOW}=========================================${RC}" + printf "%b\n" "${YELLOW} Adjust Monitor Brightness${RC}" + printf "%b\n" "${YELLOW}=========================================${RC}" + printf "%b\n" "${YELLOW}Choose a monitor to adjust brightness:${RC}" + for monitor in "$@"; do + echo "$count. $monitor" + count=$((count + 1)) + done + + echo "Enter the number of the monitor (or 'q' to quit): " + read monitor_choice + + if [ "$monitor_choice" = "q" ]; then + printf "%b\n" "${RED}Exiting...${RC}" + return + fi + + if ! echo "$monitor_choice" | grep -qE '^[0-9]+$'; then + echo "Invalid selection. Please try again." + echo "Press [Enter] to continue..." + read + continue + fi + + if [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$#" ]; then + printf "%b\n" "${RED}Invalid selection. Please try again.${RC}" + echo "Press [Enter] to continue..." + read + continue + fi + + monitor_name=$(eval echo "\${$monitor_choice}") + current_brightness=$(get_current_brightness "$monitor_name") + + # Correctly calculate the brightness percentage + current_brightness_percentage=$(awk "BEGIN {printf \"%.0f\", $current_brightness * 100}") + printf "%b\n" "${YELLOW}Current brightness for $monitor_name${RC}: ${GREEN}$current_brightness_percentage%${RC}" + + while true; do + echo "Enter the new brightness value as a percentage (10 to 100, or 'q' to quit): " + read new_brightness_percentage + + if [ "$new_brightness_percentage" = "q" ]; then + printf "%b\n" "${RED}Exiting...${RC}" + return + fi + + # Validate brightness input: accept only values above 10 + if ! echo "$new_brightness_percentage" | grep -qE '^[0-9]+$' || [ "$new_brightness_percentage" -lt 10 ] || [ "$new_brightness_percentage" -gt 100 ]; then + printf "%b\n" "${RED}Invalid brightness value. Please enter a value between 10 and 100.${RC}" + continue + fi + + # Convert percentage to xrandr brightness value (10% to 0.10) + new_brightness=$(awk "BEGIN {printf \"%.2f\", $new_brightness_percentage / 100}") + + echo "Set brightness for $monitor_name to $new_brightness_percentage%? (y/n): " + read confirm + if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then + printf "%b\n" "${GREEN}Setting brightness for $monitor_name to $new_brightness_percentage%${RC}" + execute_command "xrandr --output $monitor_name --brightness $new_brightness" + printf "%b\n" "${GREEN}Brightness for $monitor_name set to $new_brightness_percentage% successfully.${RC}" + break + else + printf "%b\n" "${RED}Action canceled. Please choose a different brightness value.${RC}" + fi + done + done +} + +# Call the adjust_monitor_brightness function +adjust_monitor_brightness diff --git a/tabs/utils/monitor-control/utility_functions.sh b/tabs/utils/monitor-control/utility_functions.sh index 48b4c8da..00e01af0 100755 --- a/tabs/utils/monitor-control/utility_functions.sh +++ b/tabs/utils/monitor-control/utility_functions.sh @@ -38,6 +38,12 @@ detect_connected_monitors() { echo "$xrandr_output" | grep " connected" | awk '{print $1}' } +# Function to get the current brightness for a monitor +get_current_brightness() { + monitor="$1" + xrandr --verbose | grep -A 10 "^$monitor connected" | grep "Brightness:" | awk '{print $2}' +} + # Function to get resolutions for a monitor get_unique_resolutions() { monitor="$1" From ea9d6d7ddc04297d69e268ebd40f1a1416c11207 Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 19:52:10 +0530 Subject: [PATCH 22/37] samba ssh setup script added --- tabs/system-setup/5-samba-ssh-setup.sh | 201 +++++++++++++++++++++++++ tabs/system-setup/tab_data.toml | 4 + 2 files changed, 205 insertions(+) create mode 100755 tabs/system-setup/5-samba-ssh-setup.sh diff --git a/tabs/system-setup/5-samba-ssh-setup.sh b/tabs/system-setup/5-samba-ssh-setup.sh new file mode 100755 index 00000000..d9f7855c --- /dev/null +++ b/tabs/system-setup/5-samba-ssh-setup.sh @@ -0,0 +1,201 @@ +#!/bin/sh -e + +# Load common script functions +. ../common-script.sh + +# Function to install packages based on the package manager +install_package() { + PACKAGE=$1 + if ! command_exists "$PACKAGE"; then + case "$PACKAGER" in + pacman) + $ESCALATION_TOOL "$PACKAGER" -S --noconfirm "$PACKAGE" + ;; + *) + $ESCALATION_TOOL "$PACKAGER" install -y "$PACKAGE" + ;; + esac + else + echo "$PACKAGE is already installed." + fi +} + +# Function to setup and configure SSH +setup_ssh() { + printf "%b\n" "${YELLOW}Setting up SSH...${RC}" + + # Detect package manager and install appropriate SSH package + if [ "$PACKAGER" = "apt-get" ]; then + install_package openssh-server + SSH_SERVICE="ssh" + elif [ "$PACKAGER" = "pacman" ]; then + install_package openssh + SSH_SERVICE="sshd" + else + install_package openssh-server + SSH_SERVICE="sshd" + fi + + # Enable and start the appropriate SSH service + $ESCALATION_TOOL systemctl enable "$SSH_SERVICE" + $ESCALATION_TOOL systemctl start "$SSH_SERVICE" + + # Get the local IP address + LOCAL_IP=$(ip -4 addr show | awk '/inet / {print $2}' | tail -n 1) + + printf "%b\n" "${GREEN}Your local IP address is: $LOCAL_IP${RC}" + + # Check if SSH is running + if systemctl is-active --quiet "$SSH_SERVICE"; then + printf "%b\n" "${GREEN}SSH is up and running.${RC}" + else + printf "%b\n" "${RED}Failed to start SSH.${RC}" + fi +} + +# Function to setup and configure Samba +setup_samba() { + printf "%b\n" "${YELLOW}Setting up Samba...${RC}" + + # Install Samba if not installed + install_package samba + + SAMBA_CONFIG="/etc/samba/smb.conf" + + if [ -f "$SAMBA_CONFIG" ]; then + printf "%b\n" "${YELLOW}Samba configuration file already exists at $SAMBA_CONFIG.${RC}" + echo "Do you want to modify the existing Samba configuration? (yes/no): " + read MODIFY_SAMBA + if [ "$MODIFY_SAMBA" = "yes" ]; then + $ESCALATION_TOOL nano "$SAMBA_CONFIG" + fi + else + printf "%b\n" "${YELLOW}No existing Samba configuration found. Setting up a new one...${RC}" + + # Prompt user for shared directory path + echo "Enter the path for the Samba share (default: /srv/samba/share): " + read SHARED_DIR + 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" + + # Add a new Samba user + echo "Enter Samba username: " + read SAMBA_USER + + # Loop until the passwords match + while true; do + echo "Enter Samba password: " + stty -echo + read SAMBA_PASSWORD + stty echo + echo "Confirm Samba password: " + stty -echo + read SAMBA_PASSWORD_CONFIRM + stty echo + echo "" + if [ "$SAMBA_PASSWORD" = "$SAMBA_PASSWORD_CONFIRM" ]; then + printf "%b\n" "${GREEN}Passwords match.${RC}" + break + else + printf "%b\n" "${RED}Passwords do not match. Please try again.${RC}" + fi + done + + # Add the user and set the password + $ESCALATION_TOOL smbpasswd -a "$SAMBA_USER" + + # Configure Samba settings + $ESCALATION_TOOL sh -c "cat > $SAMBA_CONFIG" < Date: Wed, 18 Sep 2024 21:54:48 +0530 Subject: [PATCH 23/37] Update tabs/utils/tab_data.toml Co-authored-by: Adam Perkowski --- tabs/utils/tab_data.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/utils/tab_data.toml b/tabs/utils/tab_data.toml index 2559d5dc..d5783fc0 100644 --- a/tabs/utils/tab_data.toml +++ b/tabs/utils/tab_data.toml @@ -25,7 +25,7 @@ name = "Auto Login" script = "auto-login.sh" [[data]] -name = "Bootable Pendrive Maker" +name = "Bootable USB Creator" script = "create-bootable-usb.sh" [[data]] From 60405aae80fe9d24badcc1c8c4899c667e8f817f Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 21:55:55 +0530 Subject: [PATCH 24/37] Update tabs/system-setup/5-samba-ssh-setup.sh Co-authored-by: Adam Perkowski --- tabs/system-setup/5-samba-ssh-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/system-setup/5-samba-ssh-setup.sh b/tabs/system-setup/5-samba-ssh-setup.sh index d9f7855c..81d081b8 100755 --- a/tabs/system-setup/5-samba-ssh-setup.sh +++ b/tabs/system-setup/5-samba-ssh-setup.sh @@ -63,7 +63,7 @@ setup_samba() { SAMBA_CONFIG="/etc/samba/smb.conf" if [ -f "$SAMBA_CONFIG" ]; then - printf "%b\n" "${YELLOW}Samba configuration file already exists at $SAMBA_CONFIG.${RC}" + printf "%b\n" "${YELLOW}Samba configuration file already exists in $SAMBA_CONFIG.${RC}" echo "Do you want to modify the existing Samba configuration? (yes/no): " read MODIFY_SAMBA if [ "$MODIFY_SAMBA" = "yes" ]; then From 1d59a555bfa67bec3a9606ff7b7e6a76152e47a7 Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 21:56:45 +0530 Subject: [PATCH 25/37] Update tabs/utils/auto-login.sh Co-authored-by: Adam Perkowski --- tabs/utils/auto-login.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/utils/auto-login.sh b/tabs/utils/auto-login.sh index 69bd8611..e73c4100 100644 --- a/tabs/utils/auto-login.sh +++ b/tabs/utils/auto-login.sh @@ -107,7 +107,7 @@ configure_lxdm() { echo "Configuring LXDM for autologin..." echo "Enter username for LXDM autologin: " - read user + read -r user list_sessions # Show session options $ESCALATION_TOOL sed -i "s/^#.*autologin=.*$/autologin=${user}/" /etc/lxdm/lxdm.conf From 1b0b9bbf12646adc259960cdc9b8780c30a8605b Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 21:58:56 +0530 Subject: [PATCH 26/37] Update tabs/system-setup/5-samba-ssh-setup.sh Co-authored-by: Adam Perkowski --- tabs/system-setup/5-samba-ssh-setup.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tabs/system-setup/5-samba-ssh-setup.sh b/tabs/system-setup/5-samba-ssh-setup.sh index 81d081b8..c540e6b3 100755 --- a/tabs/system-setup/5-samba-ssh-setup.sh +++ b/tabs/system-setup/5-samba-ssh-setup.sh @@ -25,16 +25,20 @@ setup_ssh() { printf "%b\n" "${YELLOW}Setting up SSH...${RC}" # Detect package manager and install appropriate SSH package - if [ "$PACKAGER" = "apt-get" ]; then + case "$PACKAGER" in + "apt-get") install_package openssh-server SSH_SERVICE="ssh" - elif [ "$PACKAGER" = "pacman" ]; then + ;; + "pacman") install_package openssh SSH_SERVICE="sshd" - else + ;; + *) install_package openssh-server SSH_SERVICE="sshd" - fi + ;; + esac # Enable and start the appropriate SSH service $ESCALATION_TOOL systemctl enable "$SSH_SERVICE" From 0d7213d36adc0e2eb20f687d555b4e47475cee87 Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:04:10 +0530 Subject: [PATCH 27/37] Update tabs/utils/auto-login.sh Co-authored-by: Adam Perkowski --- tabs/utils/auto-login.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/utils/auto-login.sh b/tabs/utils/auto-login.sh index e73c4100..9b88dd99 100644 --- a/tabs/utils/auto-login.sh +++ b/tabs/utils/auto-login.sh @@ -85,7 +85,7 @@ configure_sddm() { echo "Configuring SDDM for autologin..." echo "Enter username for SDDM autologin: " - read user + read -r user list_sessions # Show session options $ESCALATION_TOOL "echo '[Autologin]' > /etc/sddm.conf" From 8fdb1050785e0dd91ba1eef829b87ebf3bf63e2e Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:04:19 +0530 Subject: [PATCH 28/37] Update tabs/utils/auto-login.sh Co-authored-by: Adam Perkowski --- tabs/utils/auto-login.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/utils/auto-login.sh b/tabs/utils/auto-login.sh index 9b88dd99..21299210 100644 --- a/tabs/utils/auto-login.sh +++ b/tabs/utils/auto-login.sh @@ -63,7 +63,7 @@ configure_gdm() { echo "Configuring GDM for autologin..." echo "Enter username for GDM autologin: " - read user + read -r user $ESCALATION_TOOL "echo '[daemon]' > /etc/gdm/custom.conf" $ESCALATION_TOOL "echo 'AutomaticLoginEnable = true' >> /etc/gdm/custom.conf" From 6646c4d81cf25df880fca4cf50d3ac5d776a0824 Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:04:30 +0530 Subject: [PATCH 29/37] Update tabs/utils/auto-login.sh Co-authored-by: Adam Perkowski --- tabs/utils/auto-login.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/utils/auto-login.sh b/tabs/utils/auto-login.sh index 21299210..9fa28bf5 100644 --- a/tabs/utils/auto-login.sh +++ b/tabs/utils/auto-login.sh @@ -42,7 +42,7 @@ configure_lightdm() { echo "Configuring LightDM for autologin..." echo "Enter username for LightDM autologin: " - read user + read -r user $ESCALATION_TOOL "echo '[Seat:*]' > /etc/lightdm/lightdm.conf.d/50-autologin.conf" $ESCALATION_TOOL "echo 'autologin-user=$user' >> /etc/lightdm/lightdm.conf.d/50-autologin.conf" From d0ccb236875478a5085397416fe5707438b15e6f Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:04:43 +0530 Subject: [PATCH 30/37] Update tabs/utils/auto-login.sh Co-authored-by: Adam Perkowski --- tabs/utils/auto-login.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/utils/auto-login.sh b/tabs/utils/auto-login.sh index 9fa28bf5..835ca746 100644 --- a/tabs/utils/auto-login.sh +++ b/tabs/utils/auto-login.sh @@ -30,7 +30,7 @@ list_sessions() { 9) session="i3.desktop" ;; 10) echo "Enter custom session name (e.g., mysession.desktop): " - read session ;; + read -r session ;; *) echo "Invalid option selected." exit 1 ;; From dc268906b8b483ae3d97d277a416811765200c97 Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:05:24 +0530 Subject: [PATCH 31/37] Update tabs/system-setup/5-samba-ssh-setup.sh Co-authored-by: Adam Perkowski --- tabs/system-setup/5-samba-ssh-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/system-setup/5-samba-ssh-setup.sh b/tabs/system-setup/5-samba-ssh-setup.sh index c540e6b3..677cadb7 100755 --- a/tabs/system-setup/5-samba-ssh-setup.sh +++ b/tabs/system-setup/5-samba-ssh-setup.sh @@ -93,7 +93,7 @@ setup_samba() { while true; do echo "Enter Samba password: " stty -echo - read SAMBA_PASSWORD + read -r SAMBA_PASSWORD stty echo echo "Confirm Samba password: " stty -echo From d30ba118858e16e9ebeb400760d74864b0247ce8 Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:05:42 +0530 Subject: [PATCH 32/37] Update tabs/system-setup/5-samba-ssh-setup.sh Co-authored-by: Adam Perkowski --- tabs/system-setup/5-samba-ssh-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/system-setup/5-samba-ssh-setup.sh b/tabs/system-setup/5-samba-ssh-setup.sh index 677cadb7..317b59e3 100755 --- a/tabs/system-setup/5-samba-ssh-setup.sh +++ b/tabs/system-setup/5-samba-ssh-setup.sh @@ -87,7 +87,7 @@ setup_samba() { # Add a new Samba user echo "Enter Samba username: " - read SAMBA_USER + read -r SAMBA_USER # Loop until the passwords match while true; do From 59fafbbc2e24d6c7b10635af99dd1952b73be4a7 Mon Sep 17 00:00:00 2001 From: Guru Swarupa <112751363+guruswarupa@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:05:56 +0530 Subject: [PATCH 33/37] Update tabs/system-setup/5-samba-ssh-setup.sh Co-authored-by: Adam Perkowski --- tabs/system-setup/5-samba-ssh-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/system-setup/5-samba-ssh-setup.sh b/tabs/system-setup/5-samba-ssh-setup.sh index 317b59e3..c8a4d69e 100755 --- a/tabs/system-setup/5-samba-ssh-setup.sh +++ b/tabs/system-setup/5-samba-ssh-setup.sh @@ -78,7 +78,7 @@ setup_samba() { # Prompt user for shared directory path echo "Enter the path for the Samba share (default: /srv/samba/share): " - read SHARED_DIR + read -r SHARED_DIR SHARED_DIR=${SHARED_DIR:-/srv/samba/share} # Create the shared directory if it doesn't exist From 28ee76b9b0e51d00a178ee82c5d7ff855ba3f745 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Wed, 18 Sep 2024 11:57:44 -0500 Subject: [PATCH 34/37] Update tabs/system-setup/5-samba-ssh-setup.sh Co-authored-by: Adam Perkowski --- tabs/system-setup/5-samba-ssh-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/system-setup/5-samba-ssh-setup.sh b/tabs/system-setup/5-samba-ssh-setup.sh index c8a4d69e..94de1e0d 100755 --- a/tabs/system-setup/5-samba-ssh-setup.sh +++ b/tabs/system-setup/5-samba-ssh-setup.sh @@ -71,7 +71,7 @@ setup_samba() { echo "Do you want to modify the existing Samba configuration? (yes/no): " read MODIFY_SAMBA if [ "$MODIFY_SAMBA" = "yes" ]; then - $ESCALATION_TOOL nano "$SAMBA_CONFIG" + "$ESCALATION_TOOL" "$EDITOR" "$SAMBA_CONFIG" fi else printf "%b\n" "${YELLOW}No existing Samba configuration found. Setting up a new one...${RC}" From 7f286461b11d2b1952c28d7621e781bc73f390a7 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Wed, 18 Sep 2024 12:03:04 -0500 Subject: [PATCH 35/37] Update tabs/utils/monitor-control/set_brightness.sh Co-authored-by: Adam Perkowski --- tabs/utils/monitor-control/set_brightness.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/utils/monitor-control/set_brightness.sh b/tabs/utils/monitor-control/set_brightness.sh index 8265ded7..bcb8c104 100644 --- a/tabs/utils/monitor-control/set_brightness.sh +++ b/tabs/utils/monitor-control/set_brightness.sh @@ -31,7 +31,7 @@ adjust_monitor_brightness() { if ! echo "$monitor_choice" | grep -qE '^[0-9]+$'; then echo "Invalid selection. Please try again." echo "Press [Enter] to continue..." - read + read dummy continue fi From 3f6209e7f6c7007e26fd1ffc2765e7441eab4748 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Wed, 18 Sep 2024 12:04:37 -0500 Subject: [PATCH 36/37] Update tabs/utils/monitor-control/set_brightness.sh Co-authored-by: Adam Perkowski --- tabs/utils/monitor-control/set_brightness.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/utils/monitor-control/set_brightness.sh b/tabs/utils/monitor-control/set_brightness.sh index bcb8c104..16f3da3b 100644 --- a/tabs/utils/monitor-control/set_brightness.sh +++ b/tabs/utils/monitor-control/set_brightness.sh @@ -38,7 +38,7 @@ adjust_monitor_brightness() { if [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$#" ]; then printf "%b\n" "${RED}Invalid selection. Please try again.${RC}" echo "Press [Enter] to continue..." - read + read dummy continue fi From 60d4d4b380cf1a0188cf16da2bb45483bda82e85 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Wed, 18 Sep 2024 12:53:47 -0500 Subject: [PATCH 37/37] Remove bashisms --- tabs/common-script.sh | 1 + tabs/system-setup/5-samba-ssh-setup.sh | 24 +++---- tabs/utils/create-bootable-usb.sh | 18 ++--- .../monitor-control/utility_functions.sh | 5 +- tabs/utils/power-profile.sh | 3 +- tabs/utils/timeshift.sh | 71 +++++++++++-------- 6 files changed, 68 insertions(+), 54 deletions(-) diff --git a/tabs/common-script.sh b/tabs/common-script.sh index aa4deae9..678a4516 100644 --- a/tabs/common-script.sh +++ b/tabs/common-script.sh @@ -5,6 +5,7 @@ RC='\033[0m' RED='\033[31m' YELLOW='\033[33m' +CYAN='\033[36m' GREEN='\033[32m' command_exists() { diff --git a/tabs/system-setup/5-samba-ssh-setup.sh b/tabs/system-setup/5-samba-ssh-setup.sh index 94de1e0d..ddd43c99 100755 --- a/tabs/system-setup/5-samba-ssh-setup.sh +++ b/tabs/system-setup/5-samba-ssh-setup.sh @@ -68,8 +68,8 @@ setup_samba() { if [ -f "$SAMBA_CONFIG" ]; then printf "%b\n" "${YELLOW}Samba configuration file already exists in $SAMBA_CONFIG.${RC}" - echo "Do you want to modify the existing Samba configuration? (yes/no): " - read MODIFY_SAMBA + printf "Do you want to modify the existing Samba configuration? (yes/no): " + read -r MODIFY_SAMBA if [ "$MODIFY_SAMBA" = "yes" ]; then "$ESCALATION_TOOL" "$EDITOR" "$SAMBA_CONFIG" fi @@ -77,7 +77,7 @@ setup_samba() { printf "%b\n" "${YELLOW}No existing Samba configuration found. Setting up a new one...${RC}" # Prompt user for shared directory path - echo "Enter the path for the Samba share (default: /srv/samba/share): " + printf "Enter the path for the Samba share (default: /srv/samba/share): " read -r SHARED_DIR SHARED_DIR=${SHARED_DIR:-/srv/samba/share} @@ -157,19 +157,19 @@ configure_firewall() { } setup_ssh_samba(){ - echo "Samba and SSH Setup Script" - echo "----------------------------" + printf "Samba and SSH Setup Script\n" + printf "----------------------------\n" clear # Display menu - echo "Select an option:" - echo "1. Setup SSH" - echo "2. Setup Samba" - echo "3. Configure Firewall" - echo "4. Setup All" - echo "5. Exit" + printf "Select an option:\n" + printf "1. Setup SSH\n" + printf "2. Setup Samba\n" + printf "3. Configure Firewall\n" + printf "4. Setup All\n" + printf "5. Exit\n" - echo "Enter your choice [1-5]: " + printf "Enter your choice [1-5]: " read CHOICE case "$CHOICE" in diff --git a/tabs/utils/create-bootable-usb.sh b/tabs/utils/create-bootable-usb.sh index 80dab102..6feae2da 100644 --- a/tabs/utils/create-bootable-usb.sh +++ b/tabs/utils/create-bootable-usb.sh @@ -52,9 +52,9 @@ fetch_arch_older_isos() { COUNTER=$((COUNTER + 1)) done - echo "" # New line after the last row - - read -p "Select an Arch Linux version (1-$((COUNTER - 1))): " ARCH_OPTION + printf "\n" # New line after the last row + printf "Select an Arch Linux version (1-%d): " "$((COUNTER - 1))" + read -r ARCH_OPTION ARCH_DIR=$(echo "$ARCH_VERSIONS" | sed -n "${ARCH_OPTION}p") ARCH_URL="${ARCH_BASE_URL}${ARCH_DIR}/archlinux-${ARCH_DIR}-x86_64.iso" printf "%b\n" "${GREEN}Selected Arch Linux (older) ISO URL: $ARCH_URL${RC}" @@ -70,17 +70,19 @@ fetch_debian_latest_iso() { # Function to ask whether to use local or online ISO choose_iso_source() { printf "%b\n" "${YELLOW} Do you want to use a local ISO or download online? ${RC}" - echo "1) Download online" - echo "2) Use local ISO" - echo "" - read -p "Select option (1-2): " ISO_SOURCE_OPTION + printf "1) Download online\n" + printf "2) Use local ISO\n" + printf "\n" + printf "Select option (1-2): " + read -r ISO_SOURCE_OPTION case $ISO_SOURCE_OPTION in 1) fetch_iso_urls # Call the function to fetch online ISO URLs ;; 2) - read -p "Enter the path to the already downloaded ISO file: " ISO_PATH + printf "Enter the path to the already downloaded ISO file: " + read -r ISO_PATH if [ ! -f "$ISO_PATH" ]; then printf "%b\n" "${RED} ISO file not found: $ISO_PATH ${RC}" exit 1 diff --git a/tabs/utils/monitor-control/utility_functions.sh b/tabs/utils/monitor-control/utility_functions.sh index 00e01af0..6c811a84 100755 --- a/tabs/utils/monitor-control/utility_functions.sh +++ b/tabs/utils/monitor-control/utility_functions.sh @@ -79,8 +79,9 @@ get_unique_resolutions() { # Function to prompt for confirmation confirm_action() { action="$1" - echo "$action" - read -p "Are you sure? (y/n): " confirm + printf "%b\n" "${CYAN}$action${RC}" + printf "%b" "${CYAN}Are you sure? (y/n): ${RC}" + read -r confirm if echo "$confirm" | grep -qE '^[Yy]$'; then return 0 else diff --git a/tabs/utils/power-profile.sh b/tabs/utils/power-profile.sh index 5c614d3f..3cc1823f 100644 --- a/tabs/utils/power-profile.sh +++ b/tabs/utils/power-profile.sh @@ -75,7 +75,8 @@ apply_or_remove_auto_cpufreq() { printf "%b\n" "${YELLOW}Do you want to apply the auto-cpufreq tweak or remove it?${RC}" printf "%b\n" "${YELLOW}1) Apply tweak${RC}" printf "%b\n" "${YELLOW}2) Remove tweak${RC}" - read -rp "Enter your choice [1/2]: " choice + printf "%b" "Enter your choice [1/2]: " + read -r choice case $choice in 1) diff --git a/tabs/utils/timeshift.sh b/tabs/utils/timeshift.sh index 9ff18892..2d4a5a78 100644 --- a/tabs/utils/timeshift.sh +++ b/tabs/utils/timeshift.sh @@ -24,34 +24,36 @@ install_timeshift() { # Function to display the menu display_menu() { clear - echo "Timeshift CLI Automation" - echo "-------------------------" - echo "1) List Snapshots" - echo "2) List Devices" - echo "3) Create Snapshot" - echo "4) Restore Snapshot" - echo "5) Delete Snapshot" - echo "6) Delete All Snapshots" - echo "7) Exit" - echo "" + printf "%b\n" "${CYAN}Timeshift CLI Automation${RC}" + printf "%b\n" "${CYAN}\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-" + printf "%b\n" "${CYAN}1) List Snapshots${RC}" + printf "%b\n" "${CYAN}2) List Devices${RC}" + printf "%b\n" "${CYAN}3) Create Snapshot${RC}" + printf "%b\n" "${CYAN}4) Restore Snapshot${RC}" + printf "%b\n" "${CYAN}5) Delete Snapshot${RC}" + printf "%b\n" "${CYAN}6) Delete All Snapshots${RC}" + printf "%b\n" "${CYAN}7) Exit${RC}" + printf "%b\n" "${CYAN}\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-" } # Function to list snapshots list_snapshots() { - echo "Listing snapshots..." + printf "%b\n" "${CYAN}Listing snapshots...${RC}" $ESCALATION_TOOL timeshift --list-snapshots } # Function to list devices list_devices() { - echo "Listing available devices..." + printf "%b\n" "${CYAN}Listing available devices...${RC}" $ESCALATION_TOOL timeshift --list-devices } # Function to create a new snapshot create_snapshot() { - read -p "Enter a comment for the snapshot (optional): " COMMENT - read -p "Enter snapshot tag (O,B,H,D,W,M) (leave empty for no tag): " TAG + printf "%b" "${CYAN}Enter a comment for the snapshot (optional): ${RC}" + read -r COMMENT + printf "%b" "${CYAN}Enter snapshot tag (O,B,H,D,W,M) (leave empty for no tag): ${RC}" + read -r TAG if [ -z "$COMMENT" ] && [ -z "$TAG" ]; then echo "Creating snapshot with no comment or tag..." @@ -75,21 +77,25 @@ create_snapshot() { restore_snapshot() { list_snapshots - read -p "Enter the snapshot name you want to restore: " SNAPSHOT - read -p "Enter the target device (e.g., /dev/sda1): " TARGET_DEVICE - read -p "Do you want to skip GRUB reinstall? (yes/no): " SKIP_GRUB + printf "%b" "${CYAN}Enter the snapshot name you want to restore: ${RC}" + read -r SNAPSHOT + printf "%b" "${CYAN}Enter the target device (e.g., /dev/sda1): ${RC}" + read -r TARGET_DEVICE + printf "%b" "${CYAN}Do you want to skip GRUB reinstall? (yes/no): ${RC}" + read -r SKIP_GRUB if [ "$SKIP_GRUB" = "yes" ]; then $ESCALATION_TOOL timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --skip-grub --yes else - read -p "Enter GRUB device (e.g., /dev/sda): " GRUB_DEVICE + printf "%b" "${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 fi if [ $? -eq 0 ]; then - echo "Snapshot restored successfully." + printf "%b\n" "${GREEN}Snapshot restored successfully.${RC}" else - echo "Snapshot restore failed." + printf "%b\n" "${RED}Snapshot restore failed.${RC}" fi } @@ -97,22 +103,24 @@ restore_snapshot() { delete_snapshot() { list_snapshots - read -p "Enter the snapshot name you want to delete: " SNAPSHOT + printf "%b" "${CYAN}Enter the snapshot name you want to delete: ${RC}" + read -r SNAPSHOT - echo "Deleting snapshot $SNAPSHOT..." + printf "%b\n" "${YELLOW}Deleting snapshot $SNAPSHOT...${RC}" $ESCALATION_TOOL timeshift --delete --snapshot "$SNAPSHOT" --yes if [ $? -eq 0 ]; then - echo "Snapshot deleted successfully." + printf "%b\n" "${GREEN}Snapshot deleted successfully.${RC}" else - echo "Snapshot deletion failed." + printf "%b\n" "${RED}Snapshot deletion failed.${RC}" fi } # Function to delete all snapshots delete_all_snapshots() { - echo "WARNING: This will delete all snapshots!" - read -p "Are you sure? (yes/no): " CONFIRMATION + printf "%b\n" "${RED}WARNING: This will delete all snapshots!${RC}" + printf "%b" "${CYAN}Are you sure? (yes/no): ${RC}" + read -r CONFIRMATION if [ "$CONFIRMATION" = "yes" ]; then echo "Deleting all snapshots..." @@ -130,7 +138,8 @@ delete_all_snapshots() { main_menu() { while true; do display_menu - read -p "Select an option (1-7): " OPTION + printf "%b" "${CYAN}Select an option (1-7): ${RC}" + read -r OPTION case $OPTION in 1) list_snapshots ;; @@ -139,11 +148,11 @@ while true; do 4) restore_snapshot ;; 5) delete_snapshot ;; 6) delete_all_snapshots ;; - 7) echo "Exiting..."; exit 0 ;; - *) echo "Invalid option. Please try again." ;; + 7) printf "%b\n" "${GREEN}Exiting...${RC}"; exit 0 ;; + *) printf "%b\n" "${RED}Invalid option. Please try again.${RC}" ;; esac - - read -p "Press Enter to continue..." + printf "%b" "${CYAN}Press Enter to continue...${RC}" + read -r dummy done }