#!/bin/bash
# - bof - #



<<'comment'

# -  - #
ssh -p 51832 192.168.1.100;
ssh -p 51832 root@192.168.1.100;

sudo nvim /etc/default/grub;



# -  - #
# - Install automatic security updates - #
sudo apt update && sudo apt upgrade -y --autoremove && sudo apt clean;


# -  - #
# - Esencial software - #
xdg-user-dirs-update;
sudo apt install dialog duf curl figlet git lolcat neovim openssh-server pv webapp-manager -y;
sudo apt install dialog duf curl figlet git htop inxi lolcat net-tools neovim openssh-server pv webapp-manager -y;


bash <(curl -s https://www.u150.isdevelopment.us/Ubuntu.Img/uConfigurationFiles.Ins/Quique_Functions/Create_zRam_Function_.sh)

# -  - #
# - Timezone - #
sudo timedatectl set-ntp true;
sudo timedatectl set-timezone America/New_York;
timedatectl status;
timedatectl;



cd ~/; rm -rf ~/grub_.sh; vim ~/grub_.sh;
Copy & paste this content
chmod +x ~/grub_.sh; ~/./grub_.sh;

comment



# -  - #
# - createzRam_ - #
function createzRam_(){
  local zRamCnf_=/etc/systemd/zram-generator.conf \
        swapFile_;

  clear;
  echo -e "\n\n=== Removing swap.img and configuring zram... ===\n";

  source <(curl -s https://www.education.isdevelopment.us/Functions/Functions.sh)
  distroVersion_;
  swapFile_=$(get_swapfile_name);
  
  # 1. Check if swapFile_ exists
  if [ -f "$swapFile_" ]; then
    echo "  → Found $swapFile_"
    echo "  → Disabling swap file..."
    sudo swapoff "$swapFile_" 2>/dev/null || true
    echo "  → Removing $swapFile_ from /etc/fstab..."
    sudo sed -i "\|$swapFile_|d" /etc/fstab
    echo "  → Deleting $swapFile_..."
    sudo rm -f "$swapFile_"
    echo "  → $(basename "$swapFile_") removed successfully."  # Shows just the filename
  else
    echo "  → No swap file found. Skipping."
  fi

  # 5. Create zram
  echo -e "\n\n=== Installing zram... ===\n";

  # Distro-specific package names for zram-generator
  # Uses Opt variable from distroVersion_()
  local lPrograms1_
  case $Opt in
    1 | 4 )
      # - ubuntu, debian, linuxmint, zorin - #
      lPrograms1_="systemd-zram-generator";;
    2 )
      # - arch - #
      lPrograms1_="zram-generator";;
    3 )
      # - fedora - #
      lPrograms1_="zram-generator";;
    * )
      # - Fallback - let sPackages_ try its best - #
      lPrograms1_="zram-generator";;
  esac
  sPackages_ "$lPrograms1_";

    echo "  → Creating $zRamCnf_ ..."
    sudo tee "$zRamCnf_" > /dev/null << ZRAMEOF
[zram0]
zram-size = ram / 2
compression-algorithm = zstd
swap-priority = 100
fs-type = swap
ZRAMEOF
    echo -e "\n\n$zRamCnf_ details:\n"
    cat "$zRamCnf_"
    sudo systemctl daemon-reload
    sudo systemctl start /dev/zram0
    sleep 4;
    sudo systemctl status /dev/zram0 --no-pager;

  echo -e "\nChecking zram status...\n"
  if command -v zramctl &> /dev/null; then
    zramctl
  else
    echo "zramctl not found - install util-linux if needed"
  fi

  free -h

  # Verify swap is active
  echo -e "\nVerifying swap status..."
  if swapon --show 2>/dev/null | grep -q zram; then
    echo "✓ zram swap is active and ready"
  else
    echo "⚠ Warning: zram swap not found. You may need to reboot."
  fi

  echo -e "\n\nZram was installed successfully...\n";
}



clear;
createzRam_;



# - eof - #