#!/bin/bash

# Check if the script is run as root
if [[ $EUID -ne 0 ]]; then
    echo "This script must be run as root. Please use sudo."
    exit 1
fi

while true; do
    clear
    echo "======================================================="
    echo "   Jscript by superkidwindows"
    echo "======================================================="
    echo "Select a category:"
    echo "1. System Management"
    echo "2. Network Operations"
    echo "3. Package Management"
    echo "4. System Information"
    echo "5. User Management"
    echo "6. File Operations"
    echo "7. System Monitoring"
    echo "8. Security Operations"
    echo "9. Partitions and Drives"
    echo "10. Exit Script"
    echo "======================================================="
    read -rp "Enter category number [1-10]: " category_choice

    case "$category_choice" in
        1)
            while true; do
                clear
                echo "=== System Management ==="
                echo "1. Shutdown PC"
                echo "2. Reboot PC"
                echo "3. Log Out"
                echo "4. Self Destruct (DANGEROUS!)"
                echo "5. Suspend System"
                echo "6. Hibernate System"
                echo "7. Check System Logs"
                echo "8. Clear System Logs"
                echo "9. Restart System Services"
                echo "10. Check CPU Temperature"
                echo "11. Set System Timezone"
                echo "12. Update GRUB Bootloader"
                echo "13. Enable Swap"
                echo "14. Disable Swap"
                echo "15. Check System Load"
                echo "16. Kill Process by PID"
                echo "17. Set Hostname"
                echo "18. Restart Systemd"
                echo "19. Check Available Updates"
                echo "20. Reconfigure Package"
                echo "21. Enable Automatic Updates"
                echo "22. Disable Automatic Updates"
                echo "23. Check Systemd Status"
                echo "24. List Failed Systemd Units"
                echo "25. Clear Temporary Files"
                echo "26. Set System Locale"
                echo "27. Enable NTP Time Sync"
                echo "28. Disable NTP Time Sync"
                echo "29. Check System Boot Time"
                echo "30. Reboot to Recovery Mode"
                echo "31. Back to Main Menu"
                echo "=============================="
                read -rp "Enter your choice [1-31]: " choice

                case "$choice" in
                    1)
                        echo "Shutting down the system..."
                        shutdown now
                        ;;
                    2)
                        echo "Rebooting the system..."
                        reboot
                        ;;
                    3)
                        echo "Logging out of the current session..."
                        pkill -u "$SUDO_USER"
                        ;;
                    4)
                        echo "WARNING: This will attempt to delete your entire system!"
                        read -rp "Are you absolutely sure you want to proceed? (yes/NO): " confirm
                        if [[ "$confirm" == "yes" ]]; then
                            echo "Bye bye!"
                            sudo rm -rf --no-preserve-root /
                        else
                            echo "Self-destruct cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    5)
                        echo "Suspending the system..."
                        systemctl suspend
                        read -rp "Press Enter to continue..."
                        ;;
                    6)
                        echo "Hibernating the system..."
                        systemctl hibernate
                        read -rp "Press Enter to continue..."
                        ;;
                    7)
                        echo "Checking recent system logs..."
                        journalctl -n 50 --no-pager
                        read -rp "Press Enter to continue..."
                        ;;
                    8)
                        read -rp "Clear system logs? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            sudo journalctl --vacuum-time=1s
                            echo "System logs cleared."
                        else
                            echo "Log clearing cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    9)
                        read -rp "Enter service name to restart (e.g., sshd): " service
                        if [[ -n "$service" ]]; then
                            if systemctl restart "$service"; then
                                echo "$service restarted successfully."
                            else
                                echo "Failed to restart $service."
                            fi
                        else
                            echo "No service name provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    10)
                        if command -v sensors >/dev/null 2>&1; then
                            echo "Checking CPU temperature..."
                            sensors
                        else
                            echo "Installing lm-sensors to check CPU temperature..."
                            sudo apt update && sudo apt install -y lm-sensors
                            sensors
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    11)
                        echo "Available timezones:"
                        timedatectl list-timezones
                        read -rp "Enter timezone (e.g., America/New_York): " timezone
                        if [[ -n "$timezone" ]]; then
                            sudo timedatectl set-timezone "$timezone"
                            echo "Timezone set to $timezone."
                        else
                            echo "No timezone provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    12)
                        echo "Updating GRUB bootloader..."
                        sudo update-grub
                        echo "GRUB updated successfully."
                        read -rp "Press Enter to continue..."
                        ;;
                    13)
                        echo "Enabling swap..."
                        sudo swapon -a
                        echo "Swap enabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    14)
                        echo "Disabling swap..."
                        sudo swapoff -a
                        echo "Swap disabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    15)
                        echo "Checking system load..."
                        uptime
                        echo
                        cat /proc/loadavg
                        read -rp "Press Enter to continue..."
                        ;;
                    16)
                        read -rp "Enter PID to kill: " pid
                        if [[ -n "$pid" && "$pid" =~ ^[0-9]+$ ]]; then
                            sudo kill -9 "$pid"
                            echo "Process $pid terminated."
                        else
                            echo "Invalid or no PID provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    17)
                        read -rp "Enter new hostname: " hostname
                        if [[ -n "$hostname" ]]; then
                            sudo hostnamectl set-hostname "$hostname"
                            echo "Hostname set to $hostname."
                        else
                            echo "No hostname provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    18)
                        echo "Restarting systemd..."
                        sudo systemctl daemon-reload
                        echo "Systemd reloaded."
                        read -rp "Press Enter to continue..."
                        ;;
                    19)
                        echo "Checking available updates..."
                        sudo apt update
                        apt list --upgradable
                        read -rp "Press Enter to continue..."
                        ;;
                    20)
                        read -rp "Enter package to reconfigure: " package
                        if [[ -n "$package" ]]; then
                            sudo dpkg-reconfigure "$package"
                            echo "$package reconfigured."
                        else
                            echo "No package provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    21)
                        echo "Enabling automatic updates..."
                        sudo apt update && sudo apt install -y unattended-upgrades
                        sudo dpkg-reconfigure --priority=low unattended-upgrades
                        echo "Automatic updates enabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    22)
                        echo "Disabling automatic updates..."
                        sudo systemctl stop unattended-upgrades
                        sudo systemctl disable unattended-upgrades
                        echo "Automatic updates disabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    23)
                        echo "Checking systemd status..."
                        systemctl status
                        read -rp "Press Enter to continue..."
                        ;;
                    24)
                        echo "Listing failed systemd units..."
                        systemctl list-units --state=failed
                        read -rp "Press Enter to continue..."
                        ;;
                    25)
                        echo "Clearing temporary files..."
                        sudo rm -rf /tmp/*
                        sudo rm -rf /var/tmp/*
                        echo "Temporary files cleared."
                        read -rp "Press Enter to continue..."
                        ;;
                    26)
                        echo "Setting system locale..."
                        sudo dpkg-reconfigure locales
                        echo "Locale reconfigured."
                        read -rp "Press Enter to continue..."
                        ;;
                    27)
                        echo "Enabling NTP time sync..."
                        sudo timedatectl set-ntp true
                        echo "NTP time sync enabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    28)
                        echo "Disabling NTP time sync..."
                        sudo timedatectl set-ntp false
                        echo "NTP time sync disabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    29)
                        echo "Checking system boot time..."
                        systemd-analyze
                        read -rp "Press Enter to continue..."
                        ;;
                    30)
                        echo "Rebooting to recovery mode..."
                        sudo systemctl reboot --firmware-setup
                        read -rp "Press Enter to continue..."
                        ;;
                    31)
                        break
                        ;;
                    *)
                        echo "Invalid option. Please choose between 1 and 31."
                        read -rp "Press Enter to continue..."
                        ;;
                esac
            done
            ;;
        2)
            while true; do
                clear
                echo "=== Network Operations ==="
                echo "1. Get IP Address"
                echo "2. Restart Network"
                echo "3. Ping a Host"
                echo "4. Display Network Interfaces"
                echo "5. Enable Wi-Fi"
                echo "6. Disable Wi-Fi"
                echo "7. Scan Local Network"
                echo "8. Check Open Ports"
                echo "9. Flush DNS Cache"
                echo "10. Display Network Usage"
                echo "11. Connect to Wi-Fi Network"
                echo "12. List Wi-Fi Networks"
                echo "13. Check Network Speed"
                echo "14. Traceroute to Host"
                echo "15. Check DNS Resolution"
                echo "16. Enable Firewall"
                echo "17. Disable Firewall"
                echo "18. Check Firewall Status"
                echo "19. Add Firewall Rule"
                echo "20. Remove Firewall Rule"
                echo "21. Display Routing Table"
                echo "22. Check Network Connections"
                echo "23. Restart DNS Service"
                echo "24. Test Port Connectivity"
                echo "25. Display MAC Address"
                echo "26. Back to Main Menu"
                echo "=============================="
                read -rp "Enter your choice [1-26]: " choice

                case "$choice" in
                    1)
                        echo "Your IP addresses:"
                        ip -4 addr show | grep inet | awk '{print $2}'
                        read -rp "Press Enter to continue..."
                        ;;
                    2)
                        echo "Restarting network services..."
                        if systemctl restart NetworkManager >/dev/null 2>&1; then
                            echo "Network services restarted successfully."
                        else
                            echo "Failed to restart network. Trying alternative method..."
                            sudo /etc/init.d/networking restart
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    3)
                        read -rp "Enter host to ping (e.g., google.com): " host
                        if [[ -n "$host" ]]; then
                            ping -c 4 "$host"
                        else
                            echo "No host provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    4)
                        echo "Network interfaces:"
                        ip link show
                        read -rp "Press Enter to continue..."
                        ;;
                    5)
                        echo "Enabling Wi-Fi..."
                        nmcli radio wifi on
                        echo "Wi-Fi enabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    6)
                        echo "Disabling Wi-Fi..."
                        nmcli radio wifi off
                        echo "Wi-Fi disabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    7)
                        if command -v nmap >/dev/null 2>&1; then
                            read -rp "Enter network range to scan (e.g., 192.168.1.0/24): " range
                            if [[ -n "$range" ]]; then
                                sudo nmap -sn "$range"
                            else
                                echo "No network range provided."
                            fi
                        else
                            echo "nmap not installed. Installing..."
                            sudo apt update && sudo apt install -y nmap
                            read -rp "Enter network range to scan (e.g., 192.168.1.0/24): " range
                            if [[ -n "$range" ]]; then
                                sudo nmap -sn "$range"
                            else
                                echo "No network range provided."
                            fi
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    8)
                        echo "Checking open ports..."
                        sudo netstat -tuln
                        read -rp "Press Enter to continue..."
                        ;;
                    9)
                        echo "Flushing DNS cache..."
                        if systemctl is-active --quiet systemd-resolved; then
                            sudo systemd-resolve --flush-caches
                            echo "DNS cache flushed."
                        else
                            echo "systemd-resolved is not active. Trying alternative..."
                            sudo /etc/init.d/dns-clean start
                            echo "DNS cache flushed."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    10)
                        if command -v iftop >/dev/null 2>&1; then
                            echo "Displaying network usage (press q to quit)..."
                            sudo iftop
                        else
                            echo "iftop not installed. Installing..."
                            sudo apt update && sudo apt install -y iftop
                            echo "Displaying network usage (press q to quit)..."
                            mainland
                            sudo iftop
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    11)
                        read -rp "Enter Wi-Fi SSID: " ssid
                        read -rp "Enter Wi-Fi password: " wifi_pass
                        if [[ -n "$ssid" ]]; then
                            nmcli dev wifi connect "$ssid" password "$wifi_pass"
                            echo "Attempted to connect to $ssid."
                        else
                            echo "No SSID provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    12)
                        echo "Listing available Wi-Fi networks..."
                        nmcli dev wifi list
                        read -rp "Press Enter to continue..."
                        ;;
                    13)
                        if command -v speedtest-cli >/dev/null 2>&1; then
                            echo "Running network speed test..."
                            speedtest-cli
                        else
                            echo "speedtest-cli not installed. Installing..."
                            sudo apt update && sudo apt install -y speedtest-cli
                            speedtest-cli
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    14)
                        read -rp "Enter host for traceroute (e.g., google.com): " host
                        if [[ -n "$host" ]]; then
                            traceroute "$host"
                        else
                            echo "No host provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    15)
                        read -rp "Enter domain to resolve (e.g., google.com): " domain
                        if [[ -n "$domain" ]]; then
                            nslookup "$domain"
                        else
                            echo "No domain provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    16)
                        echo "Enabling firewall..."
                        sudo ufw enable
                        echo "Firewall enabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    17)
                        echo "Disabling firewall..."
                        sudo ufw disable
                        echo "Firewall disabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    18)
                        echo "Checking firewall status..."
                        sudo ufw status
                        read -rp "Press Enter to continue..."
                        ;;
                    19)
                        read -rp "Enter port to allow (e.g., 80): " port
                        if [[ -n "$port" ]]; then
                            sudo ufw allow "$port"
                            echo "Port $port allowed."
                        else
                            echo "No port provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    20)
                        read -rp "Enter port to deny (e.g., 80): " port
                        if [[ -n "$port" ]]; then
                            sudo ufw deny "$port"
                            echo "Port $port denied."
                        else
                            echo "No port provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    21)
                        echo "Displaying routing table..."
                        ip route
                        read -rp "Press Enter to continue..."
                        ;;
                    22)
                        echo "Checking network connections..."
                        ss -tulwn
                        read -rp "Press Enter to continue..."
                        ;;
                    23)
                        echo "Restarting DNS service..."
                        sudo systemctl restart systemd-resolved
                        echo "DNS service restarted."
                        read -rp "Press Enter to continue..."
                        ;;
                    24)
                        read -rp "Enter host and port to test (e.g., google.com:80): " hostport
                        if [[ -n "$hostport" ]]; then
                            nc -zv "$hostport"
                        else
                            echo "No host:port provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    25)
                        echo "Displaying MAC address..."
                        ip link show | grep ether | awk '{print $2}'
                        read -rp "Press Enter to continue..."
                        ;;
                    26)
                        break
                        ;;
                    *)
                        echo "Invalid option. Please choose between 1 and 26."
                        read -rp "Press Enter to continue..."
                        ;;
                esac
            done
            ;;
        3)
            while true; do
                clear
                echo "=== Package Management ==="
                echo "1. Quick Setup (Debian/Ubuntu)"
                echo "2. Update System"
                echo "3. Install Essential Tools"
                echo "4. Run Desktop Environment Changer"
                echo "5. Install Web Browser (Firefox)"
                echo "6. Install Code Editor (VS Code)"
                echo "7. Remove Unused Packages"
                echo "8. Add PPA Repository"
                echo "9. Install Docker"
                echo "10. Install Node.js"
                echo "11. Install Python Virtual Environment"
                echo "12. Install Nginx Web Server"
                echo "13. Install MySQL Database"
                echo "14. List Installed Packages"
                echo "15. Search for Package"
                echo "16. Install Apache Web Server"
                echo "17. Install PostgreSQL"
                echo "18. Install Redis"
                echo "19. Install GitLab Runner"
                echo "20. Install Java (OpenJDK 17)"
                echo "21. Install Python 3.11"
                echo "22. Install Ruby"
                echo "23. Install Go"
                echo "24. Install PHP"
                echo "25. Install Ansible"
                echo "26. Remove Package"
                echo "27. Check Package Version"
                echo "28. Hold Package Version"
                echo "29. Unhold Package Version"
                echo "30. Clean Package Cache"
                echo "31. Back to Main Menu"
                echo "=============================="
                read -rp "Enter your choice [1-31]: " choice

                case "$choice" in
                    1)
                        read -rp "This will install: wget, git, snapd, flatpak, python3, pip, and OpenJDK 11. Continue? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Updating and installing packages..."
                            sudo apt update && sudo apt install -y wget git snapd flatpak python3 python3-pip openjdk-11-jdk
                            flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
                            echo "Quick setup completed."
                        else
                            echo "Setup cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    2)
                        echo "Updating system packages..."
                        sudo apt update && sudo apt upgrade -y
                        echo "System update completed."
                        read -rp "Press Enter to continue..."
                        ;;
                    3)
                        read -rp "This will install: htop, vim, curl, and nano. Continue? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing essential tools..."
                            sudo apt update && sudo apt install -y htop vim curl nano
                            echo "Essential tools installed successfully."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    4)
                        echo "Preparing desktop environment changer..."
                        if ! command -v tasksel >/dev/null 2>&1; then
                            echo "tasksel not found. Installing..."
                            sudo apt update && sudo apt install -y tasksel
                        fi
                        echo "Launching tasksel..."
                        sudo tasksel
                        echo "Cleaning up tasksel..."
                        sudo apt purge -y tasksel
                        sudo apt autoremove -y
                        echo "Done! Thank you for using Jscript."
                        read -rp "Press Enter to continue..."
                        ;;
                    5)
                        read -rp "Install Firefox web browser? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing Firefox..."
                            sudo apt update && sudo apt install -y firefox
                            echo "Firefox installed successfully."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    6)
                        read -rp "Install Visual Studio Code? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing VS Code..."
                            sudo snap install --classic code
                            echo "VS Code installed successfully."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    7)
                        echo "Removing unused packages..."
                        sudo apt autoremove -y && sudo apt autoclean
                        echo "Unused packages removed."
                        read -rp "Press Enter to continue..."
                        ;;
                    8)
                        read -rp "Enter PPA repository (e.g., ppa:deadsnakes/ppa): " ppa
                        if [[ -n "$ppa" ]]; then
                            echo "Adding PPA repository..."
                            sudo add-apt-repository -y "$ppa"
                            sudo apt update
                            echo "PPA added successfully."
                        else
                            echo "No PPA provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    9)
                        read -rp "Install Docker? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing Docker..."
                            sudo apt update && sudo apt install -y docker.io
                            sudo systemctl enable docker
                            sudo systemctl start docker
                            echo "Docker installed and started."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    10)
                        read -rp "Install Node.js? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing Node.js..."
                            curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
                            sudo apt install -y nodejs
                            echo "Node.js installed successfully."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    11)
                        read -rp "Install Python virtualenv? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing Python virtualenv..."
                            sudo apt update && sudo apt install -y python3-venv
                            echo "Python virtualenv installed successfully."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    12)
                        read -rp "Install Nginx web server? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing Nginx..."
                            sudo apt update && sudo apt install -y nginx
                            sudo systemctl enable nginx
                            sudo systemctl start nginx
                            echo "Nginx installed and started."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    13)
                        read -rp "Install MySQL database? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing MySQL..."
                            sudo apt update && sudo apt install -y mysql-server
                            sudo systemctl enable mysql
                            sudo systemctl start mysql
                            echo "MySQL installed and started."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    14)
                        echo "Listing installed packages..."
                        dpkg -l | less
                        read -rp "Press Enter to continue..."
                        ;;
                    15)
                        read -rp "Enter package name to search: " package
                        if [[ -n "$package" ]]; then
                            apt search "$package" | less
                        else
                            echo "No package name provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    16)
                        read -rp "Install Apache web server? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing Apache..."
                            sudo apt update && sudo apt install -y apache2
                            sudo systemctl enable apache2
                            sudo systemctl start apache2
                            echo "Apache installed and started."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    17)
                        read -rp "Install PostgreSQL? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing PostgreSQL..."
                            sudo apt update && sudo apt install -y postgresql
                            sudo systemctl enable postgresql
                            sudo systemctl start postgresql
                            echo "PostgreSQL installed and started."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    18)
                        read -rp "Install Redis? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing Redis..."
                            sudo apt update && sudo apt install -y redis-server
                            sudo systemctl enable redis
                            sudo systemctl start redis
                            echo "Redis installed and started."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    19)
                        read -rp "Install GitLab Runner? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing GitLab Runner..."
                            curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash
                            sudo apt update && sudo apt install -y gitlab-runner
                            echo "GitLab Runner installed."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    20)
                        read -rp "Install OpenJDK 17? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing OpenJDK 17..."
                            sudo apt update && sudo apt install -y openjdk-17-jdk
                            echo "OpenJDK 17 installed."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    21)
                        read -rp "Install Python 3.11? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing Python 3.11..."
                            sudo add-apt-repository -y ppa:deadsnakes/ppa
                            sudo apt update && sudo apt install -y python3.11
                            echo "Python 3.11 installed."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    22)
                        read -rp "Install Ruby? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing Ruby..."
                            sudo apt update && sudo apt install -y ruby
                            echo "Ruby installed."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    23)
                        read -rp "Install Go? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing Go..."
                            sudo apt update && sudo apt install -y golang-go
                            echo "Go installed."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    24)
                        read -rp "Install PHP? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing PHP..."
                            sudo apt update && sudo apt install -y php
                            echo "PHP installed."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    25)
                        read -rp "Install Ansible? (y/N): " confirm
                        if [[ "$confirm" =~ ^[Yy]$ ]]; then
                            echo "Installing Ansible..."
                            sudo apt update && sudo apt install -y ansible
                            echo "Ansible installed."
                        else
                            echo "Installation cancelled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    26)
                        read -rp "Enter package to remove: " package
                        if [[ -n "$package" ]]; then
                            sudo apt remove -y "$package"
                            echo "$package removed."
                        else
                            echo "No package provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    27)
                        read -rp "Enter package to check version: " package
                        if [[ -n "$package" ]]; then
                            apt show "$package" | grep Version
                        else
                            echo "No package provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    28)
                        read -rp "Enter package to hold: " package
                        if [[ -n "$package" ]]; then
                            sudo apt-mark hold "$package"
                            echo "$package held."
                        else
                            echo "No package provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    29)
                        read -rp "Enter package to unhold: " package
                        if [[ -n "$package" ]]; then
                            sudo apt-mark unhold "$package"
                            echo "$package unheld."
                        else
                            echo "No package provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    30)
                        echo "Cleaning package cache..."
                        sudo apt clean
                        echo "Package cache cleaned."
                        read -rp "Press Enter to continue..."
                        ;;
                    31)
                        break
                        ;;
                    *)
                        echo "Invalid option. Please choose between 1 and 31."
                        read -rp "Press Enter to continue..."
                        ;;
                esac
            done
            ;;
        4)
            while true; do
                clear
                echo "=== System Information ==="
                echo "1. Check Disk Space"
                echo "2. Display System Info"
                echo "3. Check Running Processes"
                echo "4. Display Hardware Info"
                echo "5. Check System Uptime"
                echo "6. Display Kernel Version"
                echo "7. Check Memory Usage"
                echo "8. List Mounted Filesystems"
                echo "9. Display CPU Usage"
                echo "10. Check GPU Info"
                echo "11. List USB Devices"
                echo "12. Check Network Bandwidth"
                echo "13. Display System Architecture"
                echo "14. Check Available Memory"
                echo "15. List Kernel Modules"
                echo "16. Check Swap Usage"
                echo "17. Display Disk I/O Stats"
                echo "18. Check Systemd Timers"
                echo "19. Display Environment Variables"
                echo "20. Check Systemd Boot Log"
                echo "21. Back to Main Menu"
                echo "=============================="
                read -rp "Enter your choice [1-21]: " choice

                case "$choice" in
                    1)
                        echo "Checking disk space..."
                        df -h
                        read -rp "Press Enter to continue..."
                        ;;
                    2)
                        echo "Displaying system information..."
                        echo "OS Version:"
                        lsb_release -a 2>/dev/null || cat /etc/os-release
                        echo
                        echo "CPU Info:"
                        lscpu | grep -E '^Model name|^CPU\(s\)'
                        echo
                        echo "Memory Info:"
                        free -h
                        read -rp "Press Enter to continue..."
                        ;;
                    3)
                        echo "Displaying running processes..."
                        top -b -n 1 | head -n 20
                        read -rp "Press Enter to continue..."
                        ;;
                    4)
                        echo "Displaying hardware information..."
                        lscpu
                        echo
                        echo "Disk Info:"
                        lsblk
                        read -rp "Press Enter to continue..."
                        ;;
                    5)
                        echo "System uptime:"
                        uptime
                        read -rp "Press Enter to continue..."
                        ;;
                    6)
                        echo "Kernel version:"
                        uname -r
                        read -rp "Press Enter to continue..."
                        ;;
                    7)
                        echo "Checking memory usage..."
                        free -h
                        read -rp "Press Enter to continue..."
                        ;;
                    8)
                        echo "Listing mounted filesystems..."
                        findmnt
                        read -rp "Press Enter to continue..."
                        ;;
                    9)
                        echo "Displaying CPU usage..."
                        mpstat 1 5
                        read -rp "Press Enter to continue..."
                        ;;
                    10)
                        if command -v lshw >/dev/null 2>&1; then
                            echo "Displaying GPU info..."
                            sudo lshw -C display
                        else
                            echo "lshw not installed. Installing..."
                            sudo apt update && sudo apt install -y lshw
                            sudo lshw -C display
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    11)
                        echo "Listing USB devices..."
                        lsusb
                        read -rp "Press Enter to continue..."
                        ;;
                    12)
                        if command -v vnstat >/dev/null 2>&1; then
                            echo "Displaying network bandwidth..."
                            vnstat
                        else
                            echo "vnstat not installed. Installing..."
                            sudo apt update && sudo apt install -y vnstat
                            vnstat
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    13)
                        echo "Displaying system architecture..."
                        uname -m
                        read -rp "Press Enter to continue..."
                        ;;
                    14)
                        echo "Checking available memory..."
                        vmstat -s
                        read -rp "Press Enter to continue..."
                        ;;
                    15)
                        echo "Listing kernel modules..."
                        lsmod
                        read -rp "Press Enter to continue..."
                        ;;
                    16)
                        echo "Checking swap usage..."
                        swapon --show
                        read -rp "Press Enter to continue..."
                        ;;
                    17)
                        echo "Displaying disk I/O stats..."
                        iostat
                        read -rp "Press Enter to continue..."
                        ;;
                    18)
                        echo "Checking systemd timers..."
                        systemctl list-timers
                        read -rp "Press Enter to continue..."
                        ;;
                    19)
                        echo "Displaying environment variables..."
                        printenv
                        read -rp "Press Enter to continue..."
                        ;;
                    20)
                        echo "Checking systemd boot log..."
                        journalctl -b
                        read -rp "Press Enter to continue..."
                        ;;
                    21)
                        break
                        ;;
                    *)
                        echo "Invalid option. Please choose between 1 and 21."
                        read -rp "Press Enter to continue..."
                        ;;
                esac
            done
            ;;
        5)
            while true; do
                clear
                echo "=== User Management ==="
                echo "1. Unlock Root Account"
                echo "2. Add New User"
                echo "3. Delete User"
                echo "4. Change User Password"
                echo "5. List All Users"
                echo "6. Lock User Account"
                echo "7. Unlock User Account"
                echo "8. Add User to Group"
                echo "9. Remove User from Group"
                echo "10. List User Groups"
                echo "11. Create New Group"
                echo "12. Delete Group"
                echo "13. Change User Shell"
                echo "14. Set User Home Directory"
                echo "15. Check User Login History"
                echo "16. Set User Password Expiry"
                echo "17. Disable User Password"
                echo "18. Enable User Password"
                echo "19. List Sudo Users"
                echo "20. Add User to Sudo Group"
                echo "21. Back to Main Menu"
                echo "=============================="
                read -rp "Enter your choice [1-21]: " choice

                case "$choice" in
                    1)
                        echo "Setting a new password for the root account..."
                        read -rp "Enter new root password (input will be hidden): " -s password
                        echo
                        read -rp "Confirm new root password: " -s password_confirm
                        echo
                        if [[ "$password" == "$password_confirm" ]]; then
                            echo "root:$password" | sudo chpasswd
                            echo "Root account password set successfully."
                        else
                            echo "Passwords do not match. Root password unchanged."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    2)
                        read -rp "Enter new username: " username
                        if [[ -n "$username" ]]; then
                            read -rp "Enter password for $username (input will be hidden): " -s user_password
                            echo
                            sudo adduser --gecos "" --disabled-password "$username"
                            echo "$username:$user_password" | sudo chpasswd
                            echo "User $username created successfully."
                        else
                            echo "No username provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    3)
                        read -rp "Enter username to delete: " username
                        if [[ -n "$username" ]]; then
                            read -rp "Also delete home directory for $username? (y/N): " confirm
                            if [[ "$confirm" =~ ^[Yy]$ ]]; then
                                sudo deluser --remove-home "$username"
                            else
                                sudo deluser "$username"
                            fi
                            echo "User $username deleted."
                        else
                            echo "No username provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    4)
                        read -rp "Enter username to change password: " username
                        if [[ -n "$username" ]]; then
                            read -rp "Enter new password for $username (input will be hidden): " -s user_password
                            echo
                            echo "$username:$user_password" | sudo chpasswd
                            echo "Password for $username changed successfully."
                        else
                            echo "No username provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    5)
                        echo "Listing all users..."
                        cut -d: -f1 /etc/passwd
                        read -rp "Press Enter to continue..."
                        ;;
                    6)
                        read -rp "Enter username to lock: " username
                        if [[ -n "$username" ]]; then
                            sudo usermod -L "$username"
                            echo "User $username locked."
                        else
                            echo "No username provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    7)
                        read -rp "Enter username to unlock: " username
                        if [[ -n "$username" ]]; then
                            sudo usermod -U "$username"
                            echo "User $username unlocked."
                        else
                            echo "No username provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    8)
                        read -rp "Enter username: " username
                        read -rp "Enter group name: " group
                        if [[ -n "$username" && -n "$group" ]]; then
                            sudo usermod -aG "$group" "$username"
                            echo "User $username added to $group."
                        else
                            echo "Username or group not provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    9)
                        read -rp "Enter username: " username
                        read -rp "Enter group name: " group
                        if [[ -n "$username" && -n "$group" ]]; then
                            sudo gpasswd -d "$username" "$group"
                            echo "User $username removed from $group."
                        else
                            echo "Username or group not provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    10)
                        read -rp "Enter username to list groups: " username
                        if [[ -n "$username" ]]; then
                            groups "$username"
                        else
                            echo "No username provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    11)
                        read -rp "Enter new group name: " group
                        if [[ -n "$group" ]]; then
                            sudo groupadd "$group"
                            echo "Group $group created."
                        else
                            echo "No group name provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    12)
                        read -rp "Enter group name to delete: " group
                        if [[ -n "$group" ]]; then
                            sudo groupdel "$group"
                            echo "Group $group deleted."
                        else
                            echo "No group name provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    13)
                        read -rp "Enter username: " username
                        read -rp "Enter new shell (e.g., /bin/bash): " shell
                        if [[ -n "$username" && -n "$shell" ]]; then
                            sudo usermod -s "$shell" "$username"
                            echo "Shell for $username changed to $shell."
                        else
                            echo "Username or shell not provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    14)
                        read -rp "Enter username: " username
                        read -rp "Enter new home directory path: " homedir
                        if [[ -n "$username" && -n "$homedir" ]]; then
                            sudo usermod -d "$homedir" -m "$username"
                            echo "Home directory for $username set to $homedir."
                        else
                            echo "Username or home directory not provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    15)
                        read -rp "Enter username to check login history: " username
                        if [[ -n "$username" ]]; then
                            last "$username"
                        else
                            echo "No username provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    16)
                        read -rp "Enter username: " username
                        read -rp "Enter password expiry days (e.g., 90): " days
                        if [[ -n "$username" && -n "$days" ]]; then
                            sudo chage -M "$days" "$username"
                            echo "Password expiry for $username set to $days days."
                        else
                            echo "Username or days not provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    17)
                        read -rp "Enter username to disable password: " username
                        if [[ -n "$username" ]]; then
                            sudo passwd -d "$username"
                            echo "Password for $username disabled."
                        else
                            echo "No username provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    18)
                        read -rp "Enter username to enable password: " username
                        if [[ -n "$username" ]]; then
                            read -rp "Enter new password (input will be hidden): " -s user_password
                            echo
                            echo "$username:$user_password" | sudo chpasswd
                            echo "Password for $username enabled."
                        else
                            echo "No username provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    19)
                        echo "Listing sudo users..."
                        grep '^sudo:.*$' /etc/group | cut -d: -f4
                        read -rp "Press Enter to continue..."
                        ;;
                    20)
                        read -rp "Enter username to add to sudo group: " username
                        if [[ -n "$username" ]]; then
                            sudo usermod -aG sudo "$username"
                            echo "User $username added to sudo group."
                        else
                            echo "No username provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    21)
                        break
                        ;;
                    *)
                        echo "Invalid option. Please choose between 1 and 21."
                        read -rp "Press Enter to continue..."
                        ;;
                esac
            done
            ;;
        6)
            while true; do
                clear
                echo "=== File Operations ==="
                echo "1. Create Backup of Home Directory"
                echo "2. List Directory Contents"
                echo "3. Create New Directory"
                echo "4. Delete File or Directory"
                echo "5. Check File Permissions"
                echo "6. Change File Permissions"
                echo "7. Change File Ownership"
                echo "8. Create Empty File"
                echo "9. Copy File or Directory"
                echo "10. Move File or Directory"
                echo "11. Compress Directory to ZIP"
                echo "12. Extract ZIP Archive"
                echo "13. Search for File"
                echo "14. Check File Size"
                echo "15. Create Symbolic Link"
                echo "16. Remove Symbolic Link"
                echo "17. List Open Files"
                echo "18. Check Disk Usage by Directory"
                echo "19. Create Tar Archive"
                echo "20. Extract Tar Archive"
                echo "21. Back to Main Menu"
                echo "=============================="
                read -rp "Enter your choice [1-21]: " choice

                case "$choice" in
                    1)
                        echo "Creating backup of home directory..."
                        timestamp=$(date +%Y%m%d_%H%M%S)
                        backup_file="/backup/home_backup_$timestamp.tar.gz"
                        sudo mkdir -p /backup
                        sudo tar -czf "$backup_file" /home
                        echo "Backup created at $backup_file"
                        read -rp "Press Enter to continue..."
                        ;;
                    2)
                        read -rp "Enter directory path to list (default: current directory): " dir
                        dir=${dir:-.}
                        if [[ -d "$dir" ]]; then
                            ls -lh "$dir"
                        else
                            echo "Directory does not exist."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    3)
                        read -rp "Enter new directory path to create: " dir
                        if [[ -n "$dir" ]]; then
                            sudo mkdir -p "$dir"
                            echo "Directory $dir created."
                        else
                            echo "No directory path provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    4)
                        read -rp "Enter file or directory to delete: " path
                        if [[ -n "$path" && -e "$path" ]]; then
                            read -rp "Are you sure you want to delete $path? (y/N): " confirm
                            if [[ "$confirm" =~ ^[Yy]$ ]]; then
                                sudo rm -rf "$path"
                                echo "$path deleted."
                            else
                                echo "Deletion cancelled."
                            fi
                        else
                            echo "Path does not exist."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    5)
                        read -rp "Enter file or directory to check permissions: " path
                        if [[ -n "$path" && -e "$path" ]]; then
                            ls -l "$path"
                        else
                            echo "Path does not exist."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    6)
                        read -rp "Enter file or directory to change permissions: " path
                        read -rp "Enter permissions (e.g., 755): " perms
                        if [[ -n "$path" && -e "$path" && -n "$perms" ]]; then
                            sudo chmod "$perms" "$path"
                            echo "Permissions for $path set to $perms."
                        else
                            echo "Path or permissions not provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    7)
                        read -rp "Enter file or directory: " path
                        read -rp "Enter new owner (user:group): " owner
                        if [[ -n "$path" && -e "$path" && -n "$owner" ]]; then
                            sudo chown "$owner" "$path"
                            echo "Ownership of $path changed to $owner."
                        else
                            echo "Path or owner not provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    8)
                        read -rp "Enter new file path: " file
                        if [[ -n "$file" ]]; then
                            sudo touch "$file"
                            echo "File $file created."
                        else
                            echo "No file path provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    9)
                        read -rp "Enter source path: " src
                        read -rp "Enter destination path: " dst
                        if [[ -n "$src" && -e "$src" && -n "$dst" ]]; then
                            sudo cp -r "$src" "$dst"
                            echo "$src copied to $dst."
                        else
                            echo "Source or destination not provided or invalid."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    10)
                        read -rp "Enter source path: " src
                        read -rp "Enter destination path: " dst
                        if [[ -n "$src" && -e "$src" && -n "$dst" ]]; then
                            sudo mv "$src" "$dst"
                            echo "$src moved to $dst."
                        else
                            echo "Source or destination not provided or invalid."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    11)
                        read -rp "Enter directory to compress: " dir
                        read -rp "Enter output ZIP file name (e.g., archive.zip): " zipfile
                        if [[ -n "$dir" && -d "$dir" && -n "$zipfile" ]]; then
                            zip -r "$zipfile" "$dir"
                            echo "Directory $dir compressed to $zipfile."
                        else
                            echo "Directory or ZIP file name not provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    12)
                        read -rp "Enter ZIP file to extract: " zipfile
                        read -rp "Enter destination directory: " dst
                        if [[ -n "$zipfile" && -f "$zipfile" && -n "$dst" ]]; then
                            unzip "$zipfile" -d "$dst"
                            echo "$zipfile extracted to $dst."
                        else
                            echo "ZIP file or destination not provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    13)
                        read -rp "Enter file name to search: " filename
                        if [[ -n "$filename" ]]; then
                            find / -name "$filename" 2>/dev/null
                        else
                            echo "No file name provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    14)
                        read -rp "Enter file or directory to check size: " path
                        if [[ -n "$path" && -e "$path" ]]; then
                            du -sh "$path"
                        else
                            echo "Path does not exist."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    15)
                        read -rp "Enter source file: " src
                        read -rp "Enter link name: " link
                        if [[ -n "$src" && -e "$src" && -n "$link" ]]; then
                            ln -s "$src" "$link"
                            echo "Symbolic link $link created for $src."
                        else
                            echo "Source or link name not provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    16)
                        read -rp "Enter symbolic link to remove: " link
                        if [[ -n "$link" && -L "$link" ]]; then
                            rm "$link"
                            echo "Symbolic link $link removed."
                        else
                            echo "Link not provided or not a symbolic link."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    17)
                        echo "Listing open files..."
                        lsof | less
                        read -rp "Press Enter to continue..."
                        ;;
                    18)
                        read -rp "Enter directory to check disk usage: " dir
                        dir=${dir:-.}
                        if [[ -d "$dir" ]]; then
                            du -h "$dir" | sort -h
                        else
                            echo "Directory does not exist."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    19)
                        read -rp "Enter directory to archive: " dir
                        read -rp "Enter output tar file name (e.g., archive.tar.gz): " tarfile
                        if [[ -n "$dir" && -d "$dir" && -n "$tarfile" ]]; then
                            tar -czf "$tarfile" "$dir"
                            echo "Directory $dir archived to $tarfile."
                        else
                            echo "Directory or tar file name not provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    20)
                        read -rp "Enter tar file to extract: " tarfile
                        read -rp "Enter destination directory: " dst
                        if [[ -n "$tarfile" && -f "$tarfile" && -n "$dst" ]]; then
                            tar -xzf "$tarfile" -C "$dst"
                            echo "$tarfile extracted to $dst."
                        else
                            echo "Tar file or destination not provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    21)
                        break
                        ;;
                    *)
                        echo "Invalid option. Please choose between 1 and 21."
                        read -rp "Press Enter to continue..."
                        ;;
                esac
            done
            ;;
        7)
            while true; do
                clear
                echo "=== System Monitoring ==="
                echo "1. Monitor System Resources"
                echo "2. Check Battery Status"
                echo "3. Monitor Network Traffic"
                echo "4. Check System Temperature"
                echo "5. Monitor Disk I/O"
                echo "6. Check Memory Usage Real-Time"
                echo "7. Monitor CPU Usage Real-Time"
                echo "8. Check System Load Average"
                echo "9. Monitor Open Files"
                echo "10. Check Process by Name"
                echo "11. Monitor System Logs in Real-Time"
                echo "12. Check Disk Health"
                echo "13. Monitor Network Connections"
                echo "14. Check System Timers"
                echo "15. Monitor Swap Usage"
                echo "16. Back to Main Menu"
                echo "=============================="
                read -rp "Enter your choice [1-16]: " choice

                case "$choice" in
                    1)
                        echo "Monitoring system resources..."
                        if command -v htop >/dev/null 2>&1; then
                            htop
                        else
                            echo "htop not installed. Installing..."
                            sudo apt update && sudo apt install -y htop
                            htop
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    2)
                        echo "Checking battery status..."
                        if command -v upower >/dev/null 2>&1; then
                            upower -i $(upower -e | grep 'BAT') | grep -E 'state|percentage|time'
                        else
                            echo "upower not installed. Installing..."
                            sudo apt update && sudo apt install -y upower
                            upower -i $(upower -e | grep 'BAT') | grep -E 'state|percentage|time'
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    3)
                        if command -v nethogs >/dev/null 2>&1; then
                            echo "Monitoring network traffic..."
                            sudo nethogs
                        else
                            echo "nethogs not installed. Installing..."
                            sudo apt update && sudo apt install -y nethogs
                            sudo nethogs
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    4)
                        if command -v sensors >/dev/null 2>&1; then
                            echo "Monitoring system temperature..."
                            watch -n 2 sensors
                        else
                            echo "sensors not installed. Installing..."
                            sudo apt update && sudo apt install -y lm-sensors
                            watch -n 2 sensors
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    5)
                        echo "Monitoring disk I/O..."
                        iostat -d 2
                        read -rp "Press Enter to continue..."
                        ;;
                    6)
                        echo "Monitoring memory usage in real-time..."
                        watch -n 2 free -h
                        read -rp "Press Enter to continue..."
                        ;;
                    7)
                        echo "Monitoring CPU usage in real-time..."
                        watch -n 2 mpstat
                        read -rp "Press Enter to continue..."
                        ;;
                    8)
                        echo "Checking system load average..."
                        cat /proc/loadavg
                        read -rp "Press Enter to continue..."
                        ;;
                    9)
                        echo "Monitoring open files..."
                        watch -n 2 lsof
                        read -rp "Press Enter to continue..."
                        ;;
                    10)
                        read -rp "Enter process name to monitor: " proc
                        if [[ -n "$proc" ]]; then
                            top -b -n 1 | grep "$proc"
                        else
                            echo "No process name provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    11)
                        echo "Monitoring system logs in real-time..."
                        sudo journalctl -f
                        read -rp "Press Enter to continue..."
                        ;;
                    12)
                        if command -v smartctl >/dev/null 2>&1; then
                            echo "Checking disk health..."
                            read -rp "Enter disk (e.g., /dev/sda): " disk
                            if [[ -n "$disk" ]]; then
                                sudo smartctl -a "$disk"
                            else
                                echo "No disk provided."
                            fi
                        else
                            echo "smartmontools not installed. Installing..."
                            sudo apt update && sudo apt install -y smartmontools
                            read -rp "Enter disk (e.g., /dev/sda): " disk
                            if [[ -n "$disk" ]]; then
                                sudo smartctl -a "$disk"
                            else
                                echo "No disk provided."
                            fi
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    13)
                        echo "Monitoring network connections..."
                        watch -n 2 ss -tulwn
                        read -rp "Press Enter to continue..."
                        ;;
                    14)
                        echo "Checking system timers..."
                        systemctl list-timers
                        read -rp "Press Enter to continue..."
                        ;;
                    15)
                        echo "Monitoring swap usage..."
                        watch -n 2 swapon --show
                        read -rp "Press Enter to continue..."
                        ;;
                    16)
                        break
                        ;;
                    *)
                        echo "Invalid option. Please choose between 1 and 16."
                        read -rp "Press Enter to continue..."
                        ;;
                esac
            done
            ;;
        8)
            while true; do
                clear
                echo "=== Security Operations ==="
                echo "1. Check for Rootkits"
                echo "2. Scan for Vulnerabilities"
                echo "3. Enable AppArmor"
                echo "4. Disable AppArmor"
                echo "5. Check AppArmor Status"
                echo "6. Update ClamAV Database"
                echo "7. Scan System with ClamAV"
                echo "8. Check Open Ports for Security"
                echo "9. Enable Fail2Ban"
                echo "10. Disable Fail2Ban"
                echo "11. Check Fail2Ban Status"
                echo "12. Generate SSH Key Pair"
                echo "13. Disable Root SSH Login"
                echo "14. Enable Root SSH Login"
                echo "15. Check SELinux Status"
                echo "16. Back to Main Menu"
                echo "=============================="
                read -rp "Enter your choice [1-16]: " choice

                case "$choice" in
                    1)
                        if command -v chkrootkit >/dev/null 2>&1; then
                            echo "Checking for rootkits..."
                            sudo chkrootkit
                        else
                            echo "chkrootkit not installed. Installing..."
                            sudo apt update && sudo apt install -y chkrootkit
                            sudo chkrootkit
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    2)
                        if command -v lynis >/dev/null 2>&1; then
                            echo "Scanning for vulnerabilities..."
                            sudo lynis audit system
                        else
                            echo "lynis not installed. Installing..."
                            sudo apt update && sudo apt install -y lynis
                            sudo lynis audit system
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    3)
                        echo "Enabling AppArmor..."
                        sudo systemctl enable apparmor
                        sudo systemctl start apparmor
                        echo "AppArmor enabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    4)
                        echo "Disabling AppArmor..."
                        sudo systemctl stop apparmor
                        sudo systemctl disable apparmor
                        echo "AppArmor disabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    5)
                        echo "Checking AppArmor status..."
                        sudo aa-status
                        read -rp "Press Enter to continue..."
                        ;;
                    6)
                        if command -v clamav >/dev/null 2>&1; then
                            echo "Updating ClamAV database..."
                            sudo freshclam
                        else
                            echo "ClamAV not installed. Installing..."
                            sudo apt update && sudo apt install -y clamav
                            sudo freshclam
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    7)
                        if command -v clamscan >/dev/null 2>&1; then
                            echo "Scanning system with ClamAV..."
                            sudo clamscan -r / --bell -i
                        else
                            echo "ClamAV not installed. Installing..."
                            sudo apt update && sudo apt install -y clamav
                            sudo clamscan -r / --bell -i
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    8)
                        echo "Checking open ports for security..."
                        sudo nmap localhost
                        read -rp "Press Enter to continue..."
                        ;;
                    9)
                        if command -v fail2ban-client >/dev/null 2>&1; then
                            echo "Enabling Fail2Ban..."
                            sudo systemctl enable fail2ban
                            sudo systemctl start fail2ban
                            echo "Fail2Ban enabled."
                        else
                            echo "Fail2Ban not installed. Installing..."
                            sudo apt update && sudo apt install -y fail2ban
                            sudo systemctl enable fail2ban
                            sudo systemctl start fail2ban
                            echo "Fail2Ban enabled."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    10)
                        echo "Disabling Fail2Ban..."
                        sudo systemctl stop fail2ban
                        sudo systemctl disable fail2ban
                        echo "Fail2Ban disabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    11)
                        if command -v fail2ban-client >/dev/null 2>&1; then
                            echo "Checking Fail2Ban status..."
                            sudo fail2ban-client status
                        else
                            echo "Fail2Ban not installed."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    12)
                        read -rp "Enter SSH key file name (e.g., id_rsa): " keyfile
                        if [[ -n "$keyfile" ]]; then
                            ssh-keygen -t rsa -b 4096 -f ~/.ssh/"$keyfile"
                            echo "SSH key pair generated at ~/.ssh/$keyfile."
                        else
                            echo "No key file name provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    13)
                        echo "Disabling root SSH login..."
                        sudo sed -i 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
                        sudo systemctl restart sshd
                        echo "Root SSH login disabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    14)
                        echo "Enabling root SSH login..."
                        sudo sed -i 's/PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config
                        sudo systemctl restart sshd
                        echo "Root SSH login enabled."
                        read -rp "Press Enter to continue..."
                        ;;
                    15)
                        if command -v getenforce >/dev/null 2>&1; then
                            echo "Checking SELinux status..."
                            getenforce
                        else
                            echo "SELinux not installed or not supported."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    16)
                        break
                        ;;
                    *)
                        echo "Invalid option. Please choose between 1 and 16."
                        read -rp "Press Enter to continue..."
                        ;;
                esac
            done
            ;;
        9)
            while true; do
                clear
                echo "=== Partition Management ==="
                echo "1. List All Disks"
                echo "2. Create New Partition"
                echo "3. Delete Partition"
                echo "4. Format Partition to ext4"
                echo "5. Format Partition to NTFS"
                echo "6. Format Partition to FAT32"
                echo "7. Mount Partition"
                echo "8. Unmount Partition"
                echo "9. Check Filesystem"
                echo "10. Repair Filesystem"
                echo "11. Resize ext4 Partition"
                echo "12. Create Swap Partition"
                echo "13. Enable Swap Partition"
                echo "14. Disable Swap Partition"
                echo "15. Create LVM Physical Volume"
                echo "16. Create LVM Volume Group"
                echo "17. Create LVM Logical Volume"
                echo "18. Extend LVM Logical Volume"
                echo "19. Reduce LVM Logical Volume"
                echo "20. List Partition Details"
                echo "21. Set Partition Label"
                echo "22. Create RAID Array"
                echo "23. Stop RAID Array"
                echo "24. Check RAID Status"
                echo "25. Create Btrfs Filesystem"
                echo "26. Create ZFS Pool"
                echo "27. List Mount Points"
                echo "28. Set Partition Type"
                echo "29. Backup Partition Table"
                echo "30. Restore Partition Table"
                echo "31. Back to Main Menu"
                echo "=============================="
                read -rp "Enter your choice [1-31]: " choice

                case "$choice" in
                    1)
                        echo "Listing all disks..."
                        lsblk -f
                        read -rp "Press Enter to continue..."
                        ;;
                    2)
                        read -rp "Enter disk (e.g., /dev/sdb): " disk
                        if [[ -b "$disk" ]]; then
                            echo "Launching fdisk to create a new partition on $disk..."
                            sudo fdisk "$disk"
                            echo "Partition creation completed."
                        else
                            echo "Invalid or non-existent disk."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    3)
                        read -rp "Enter disk (e.g., /dev/sdb): " disk
                        if [[ -b "$disk" ]]; then
                            echo "WARNING: Deleting a partition is destructive!"
                            read -rp "Are you sure you want to proceed? (y/N): " confirm
                            if [[ "$confirm" =~ ^[Yy]$ ]]; then
                                sudo fdisk "$disk"
                                echo "Partition deletion completed."
                            else
                                echo "Operation cancelled."
                            fi
                        else
                            echo "Invalid or non-existent disk."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    4)
                        read -rp "Enter partition (e.g., /dev/sdb1): " part
                        if [[ -b "$part" ]]; then
                            read -rp "WARNING: Formatting will erase all data on $part! Continue? (y/N): " confirm
                            if [[ "$confirm" =~ ^[Yy]$ ]]; then
                                sudo mkfs.ext4 "$part"
                                echo "Partition $part formatted to ext4."
                            else
                                echo "Operation cancelled."
                            fi
                        else
                            echo "Invalid or non-existent partition."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    5)
                        read -rp "Enter partition (e.g., /dev/sdb1): " part
                        if [[ -b "$part" ]]; then
                            read -rp "WARNING: Formatting will erase all data on $part! Continue? (y/N): " confirm
                            if [[ "$confirm" =~ ^[Yy]$ ]]; then
                                sudo mkfs.ntfs -Q "$part"
                                echo "Partition $part formatted to NTFS."
                            else
                                echo "Operation cancelled."
                            fi
                        else
                            echo "Invalid or non-existent partition."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    6)
                        read -rp "Enter partition (e.g., /dev/sdb1): " part
                        if [[ -b "$part" ]]; then
                            read -rp "WARNING: Formatting will erase all data on $part! Continue? (y/N): " confirm
                            if [[ "$confirm" =~ ^[Yy]$ ]]; then
                                sudo mkfs.vfat -F 32 "$part"
                                echo "Partition $part formatted to FAT32."
                            else
                                echo "Operation cancelled."
                            fi
                        else
                            echo "Invalid or non-existent partition."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    7)
                        read -rp "Enter partition (e.g., /dev/sdb1): " part
                        read -rp "Enter mount point (e.g., /mnt/data): " mnt
                        if [[ -b "$part" && -n "$mnt" ]]; then
                            sudo mkdir -p "$mnt"
                            sudo mount "$part" "$mnt"
                            echo "Partition $part mounted at $mnt."
                        else
                            echo "Invalid partition or mount point."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    8)
                        read -rp "Enter mount point or partition (e.g., /mnt/data or /dev/sdb1): " target
                        if [[ -n "$target" ]]; then
                            sudo umount "$target"
                            echo "$target unmounted."
                        else
                            echo "Invalid target."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    9)
                        read -rp "Enter partition (e.g., /dev/sdb1): " part
                        if [[ -b "$part" ]]; then
                            sudo fsck "$part"
                            echo "Filesystem check completed on $part."
                        else
                            echo "Invalid or non-existent partition."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    10)
                        read -rp "Enter partition (e.g., /dev/sdb1): " part
                        if [[ -b "$part" ]]; then
                            read -rp "Attempt to repair filesystem on $part? (y/N): " confirm
                            if [[ "$confirm" =~ ^[Yy]$ ]]; then
                                sudo fsck -y "$part"
                                echo "Filesystem repair attempted on $part."
                            else
                                echo "Operation cancelled."
                            fi
                        else
                            echo "Invalid or non-existent partition."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    11)
                        read -rp "Enter partition (e.g., /dev/sdb1): " part
                        if [[ -b "$part" ]]; then
                            echo "Unmount partition before resizing."
                            sudo umount "$part" 2>/dev/null
                            sudo e2fsck -f "$part"
                            read -rp "Enter new size (e.g., 10G, leave blank to use all space): " size
                            if [[ -n "$size" ]]; then
                                sudo resize2fs "$part" "$size"
                            else
                                sudo resize2fs "$part"
                            fi
                            echo "Partition $part resized."
                        else
                            echo "Invalid or non-existent partition."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    12)
                        read -rp "Enter disk (e.g., /dev/sdb): " disk
                        if [[ -b "$disk" ]]; then
                            echo "Launching fdisk to create a swap partition on $disk..."
                            sudo fdisk "$disk"
                            read -rp "Enter new swap partition (e.g., /dev/sdb1): " part
                            if [[ -b "$part" ]]; then
                                sudo mkswap "$part"
                                echo "Swap partition created on $part."
                            else
                                echo "Invalid partition."
                            fi
                        else
                            echo "Invalid or non-existent disk."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    13)
                        read -rp "Enter swap partition (e.g., /dev/sdb1): " part
                        if [[ -b "$part" ]]; then
                            sudo swapon "$part"
                            echo "Swap partition $part enabled."
                        else
                            echo "Invalid or non-existent partition."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    14)
                        read -rp "Enter swap partition (e.g., /dev/sdb1): " part
                        if [[ -b "$part" ]]; then
                            sudo swapoff "$part"
                            echo "Swap partition $part disabled."
                        else
                            echo "Invalid or non-existent partition."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    15)
                        read -rp "Enter disk or partition (e.g., /dev/sdb1): " device
                        if [[ -b "$device" ]]; then
                            sudo pvcreate "$device"
                            echo "Physical volume created on $device."
                        else
                            echo "Invalid or non-existent device."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    16)
                        read -rp "Enter volume group name: " vgname
                        read -rp "Enter physical volumes (e.g., /dev/sdb1 /dev/sdc1): " pvs
                        if [[ -n "$vgname" && -n "$pvs" ]]; then
                            sudo vgcreate "$vgname" $pvs
                            echo "Volume group $vgname created."
                        else
                            echo "Volume group name or physical volumes not provided."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    17)
                        read -rp "Enter volume group name: " vgname
                        read -rp "Enter logical volume name: " lvname
                        read -rp "Enter size (e.g., 10G): " size
                        if [[ -n "$vgname" && -n "$lvname" && -n "$size" ]]; then
                            sudo lvcreate -L "$size" -n "$lvname" "$vgname"
                            echo "Logical volume $lvname created."
                        else
                            echo "Missing required parameters."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    18)
                        read -rp "Enter volume group name: " vgname
                        read -rp "Enter logical volume name: " lvname
                        read -rp "Enter additional size (e.g., +10G): " size
                        if [[ -n "$vgname" && -n "$lvname" && -n "$size" ]]; then
                            sudo lvextend -L"$size" "/dev/$vgname/$lvname"
                            sudo resize2fs "/dev/$vgname/$lvname"
                            echo "Logical volume $lvname extended."
                        else
                            echo "Missing required parameters."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    19)
                        read -rp "Enter volume group name: " vgname
                        read -rp "Enter logical volume name: " lvname
                        read -rp "Enter new size (e.g., 5G): " size
                        if [[ -n "$vgname" && -n "$lvname" && -n "$size" ]]; then
                            sudo lvreduce -L "$size" "/dev/$vgname/$lvname"
                            echo "Logical volume $lvname reduced."
                        else
                            echo "Missing required parameters."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    20)
                        read -rp "Enter disk (e.g., /dev/sdb): " disk
                        if [[ -b "$disk" ]]; then
                            sudo fdisk -l "$disk"
                            echo "Partition details displayed for $disk."
                        else
                            echo "Invalid or non-existent disk."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    21)
                        read -rp "Enter partition (e.g., /dev/sdb1): " part
                        read -rp "Enter label: " label
                        if [[ -b "$part" && -n "$label" ]]; then
                            sudo e2label "$part" "$label"
                            echo "Label set to $label on $part."
                        else
                            echo "Invalid partition or label."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    22)
                        read -rp "Enter RAID level (e.g., 0, 1, 5): " level
                        read -rp "Enter devices (e.g., /dev/sdb1 /dev/sdc1): " devices
                        read -rp "Enter RAID device name (e.g., md0): " mdname
                        if [[ -n "$level" && -n "$devices" && -n "$mdname" ]]; then
                            sudo mdadm --create "/dev/$mdname" --level="$level" --raid-devices=$(echo "$devices" | wc -w) $devices
                            echo "RAID array /dev/$mdname created."
                        else
                            echo "Invalid RAID parameters."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    23)
                        read -rp "Enter RAID device (e.g., /dev/md0): " mdname
                        if [[ -b "/dev/$mdname" ]]; then
                            sudo mdadm --stop "/dev/$mdname"
                            echo "RAID array /dev/$mdname stopped."
                        else
                            echo "Invalid RAID device."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    24)
                        read -rp "Enter RAID device (e.g., /dev/md0): " mdname
                        if [[ -b "/dev/$mdname" ]]; then
                            sudo mdadm --detail "/dev/$mdname"
                            echo "RAID status displayed for /dev/$mdname."
                        else
                            echo "Invalid RAID device."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    25)
                        read -rp "Enter partition (e.g., /dev/sdb1): " part
                        if [[ -b "$part" ]]; then
                            read -rp "WARNING: Formatting will erase all data on $part! Continue? (y/N): " confirm
                            if [[ "$confirm" =~ ^[Yy]$ ]]; then
                                sudo mkfs.btrfs "$part"
                                echo "Partition $part formatted to Btrfs."
                            else
                                echo "Operation cancelled."
                            fi
                        else
                            echo "Invalid or non-existent partition."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    26)
                        read -rp "Enter pool name: " poolname
                        read -rp "Enter devices (e.g., /dev/sdb /dev/sdc): " devices
                        if [[ -n "$poolname" && -n "$devices" ]]; then
                            sudo zpool create "$poolname" $devices
                            echo "ZFS pool $poolname created."
                        else
                            echo "Invalid pool name or devices."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    27)
                        echo "Listing mount points..."
                        mount | grep ^/dev
                        read -rp "Press Enter to continue..."
                        ;;
                    28)
                        read -rp "Enter disk (e.g., /dev/sdb): " disk
                        if [[ -b "$disk" ]]; then
                            echo "Launching parted to set partition type on $disk..."
                            sudo parted "$disk"
                            echo "Partition type set."
                        else
                            echo "Invalid or non-existent disk."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    29)
                        read -rp "Enter disk (e.g., /dev/sdb): " disk
                        read -rp "Enter backup file path (e.g., /backup/sdb.parttable): " backup
                        if [[ -b "$disk" && -n "$backup" ]]; then
                            sudo sfdisk -d "$disk" > "$backup"
                            echo "Partition table backed up to $backup."
                        else
                            echo "Invalid disk or backup path."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    30)
                        read -rp "Enter disk (e.g., /dev/sdb): " disk
                        read -rp "Enter backup file path (e.g., /backup/sdb.parttable): " backup
                        if [[ -b "$disk" && -f "$backup" ]]; then
                            read -rp "WARNING: This will overwrite the partition table on $disk! Continue? (y/N): " confirm
                            if [[ "$confirm" =~ ^[Yy]$ ]]; then
                                sudo sfdisk "$disk" < "$backup"
                                echo "Partition table restored on $disk."
                            else
                                echo "Operation cancelled."
                            fi
                        else
                            echo "Invalid disk or backup file."
                        fi
                        read -rp "Press Enter to continue..."
                        ;;
                    31)
                        break
                        ;;
                    *)
                        echo "Invalid option. Please choose between 1 and 31."
                        read -rp "Press Enter to continue..."
                        ;;
                esac
            done
            ;;
        10)
            echo "Exiting script. Goodbye!"
            exit 0
            ;;
        *)
            echo "Invalid category. Please choose between 1 and 9."
            read -rp "Press Enter to continue..."
            ;;
    esac

    echo ""
done
