#!/bin/bash
# - bof - #



<<'comment'

bash <(curl -s https://www.education.isdevelopment.us/Arch.Ins/05-Arch_WareHouseInstall-FlatpakManager.sh)



# :A
# -  - #
# - Arch Xfce final configuration script - #

# - Method   # 1 - #
bash <(curl -s https://www.education.isdevelopment.us/Arch.Ins/05-Arch_WareHouseInstall-FlatpakManager.sh)

# - Method   # 2 - #
cd ~/; xfC_=WareHouseInstall.sh;
curl -o ~/$xfC_ "https://www.education.isdevelopment.us/Arch.Ins/05-Arch_WareHouseInstall-FlatpakManager.sh"
chmod +x ~/$xfC_; ~/./$xfC_;
nvim ~/$xfC_;

# - Method   # 3 - #
cd ~/; rm -rf ~/WareHouseInstall.sh; nvim ~/WareHouseInstall.sh;
copy & paste this content
chmod +x ~/WareHouseInstall.sh; ~/./WareHouseInstall.sh;



# - Configured - #

# -  - #
# - Vim commands - #
https://vim.rtorr.com/

rm -rf ~/.bashrc;
nvim ~/.bashrc;

rm -rf ~/.zshrc;
nvim ~/.zshrc;

ssh-keygen -R 192.168.1.1

# - On client - #
cd ~/.ssh;
ssh-keygen -t rsa;

cat ~/.ssh/id_rsa.pub;

# - On server - #
nvim ~/.ssh/authorized_keys;

sudo apt install curl git htop inxi net-tools ntp neovim screenfetch tree -y;
sudo pacman -S curl git htop inxi net-tools ntp neovim screenfetch tree --noconfirm --needed;
comment



# -  - #
# - Global variables - #

# -  - #
# - Overwrite checkComputer - #
 overwriteCc_="No";
#overwriteCc_="Yes";

system_=$([ -d /sys/firmware/efi ] && echo "UEFI" || echo "BIOS" );
hostName_=$(uname -n);
wHi_=~/WareHouseInstall.sh;



# -  - #
# - Greetings_ - #
function Greetings_(){
  Header_;
  echo -e "\n  Warning: This script is going to install the Flatpak-WareHouse"
  echo -e "\nImportant: This procedure will take a few minutes.";
  echo -e "\nProcedure: Open terminal & paste next command:\n";

cat <<"EOF"
  bash <(curl -s https://www.education.isdevelopment.us/Arch.Ins/05-Arch_WareHouseInstall-FlatpakManager.sh)
EOF

  echo -e "\n\n";

while true; do
    read -p "Do you want to start the installation now? (Yy/Nn): " yn
    case $yn in
        [Yy]* )
          echo -e "\n\n\nInstallation starting...\n\n"
          break;;
        [Nn]* )
          rm -rf $wHi_;
          exit;
          break;;
        * ) echo "Please answer (y)es or (n)o.";;
    esac
done
}



# -  - #
# - Header_ - #
function Header_(){
  clear;
  echo "";
  figlet -f small "$dVersion_ Linux" | lolcat;
  figlet -f small "Flatpak WareHouse" | lolcat;
  echo -e "\nby Djalmar Enrique Rayo (2025) - GNU General Public License (GPL)";
  echo "----------------------- Light version: $lightVersion_ ----------------------";
  echo "              Installation: $system_     Hostname: $hostName_";

  # -  - #
  # - Check if running on SSH - #
  # Because checkSsh_ handles its own exit codes, we can drop [ ... ] entirely!
  if checkSsh_; then
    # Always quote variables inside file operations for absolute safety
    rm -rf "$wHi_";
    exit 1;
  fi
}



source <(curl -s https://www.education.isdevelopment.us/Functions/Functions.sh)
lightVersion_=$( lVersion_ );



checkComputer_ WareHouseInstall.sh;
distroVersion_;

case $Opt in
  1)
    dVersion_='Ubuntu';
    ;;
  2)
    dVersion_='Arch';
    ;;
  3)
    dVersion_='Fedora';
    ;;
esac

Greetings_;
update_;

installFlatpak_;
wareHouse_;



rm -rf "$wHi_";

echo -e "\n\nComputer will reboot so all changes are applied...";
sleep 10;

sudo shutdown now;



<<'comment'
cd ~/; rm -rf ~/WareHouseInstall.sh; nvim ~/WareHouseInstall.sh;
copy & paste this content
chmod +x ~/WareHouseInstall.sh; ~/./WareHouseInstall.sh;
comment



# - eof - #