#!/bin/bash
# - bof - #



 aUsr_="is_derayo";
#aUsr_="luz";
#aUsr_="jose";
#aUsr_="maksymiv";



 lightVersion_='No';
 lightVersion_='Yes';



# -  - #
# - Overwrite checkComputer - #
 overwriteCc_='No';
#overwriteCc_='Yes';
 
 hName_="";
#hName_="HPLaptopArch";



# -  - #
# - When "VMachine_=Yes" system will use  - #
# - All video cards (generics) - #
 VMachine_='No';
 VMachine_='Yes';

# -  - #
# - All video cards - #
<<'comment'
  # -  - #
  # - Check computer's video architecture - #
  lspci | grep -E "VGA|3D"

  1. Amd
  2. Intel
  3. nVidia
comment

vDrivers_=3;



<<'comment'

cd ~/; curl -o ~/ArchInstall.sh "https://www.u150.isdevelopment.us/Arch.Img/Arch_Install/ISs_Arch.Ins-Latest/01-ArchInstall.sh"
chmod +x ~/ArchInstall.sh; ~/./ArchInstall.sh
chmod +x ~/ArchInstall.sh; ~/./ArchInstall.sh , , aP;


cd ~/; rm -rf ~/ArchInstall.sh; vim ~/ArchInstall.sh;
vim ~/ArchInstall.sh;
chmod +x ~/ArchInstall.sh; ~/./ArchInstall.sh;



# :A
# -  - #
# - Download Arch.iso - #

cd ~/Downloads;
sIso_='ArchLinux_2025-06-01(64bit).iso';
sWs_=https://www.isdevelopment.us/Arch.Img/;
curl $sWs_$sIso_ -o $sIso_;



# :B
# -  - #
# - Arch installation script - #

# - Method   # 1 - #
# - Recomended for guest users so they can edit adminUser, adminName & adminPasswd - #
curl -o ~/ArchInstall.sh "https://www.u150.isdevelopment.us/Arch.Img/Arch_Install/ISs_Arch.Ins-Latest/01-ArchInstall.sh"
vim ~/ArchInstall.sh;
chmod +x ~/ArchInstall.sh; ~/./ArchInstall.sh;



# - Method   # 2 - #
curl -s "https://www.u150.isdevelopment.us/Arch.Img/Arch_Install/ISs_Arch.Ins-Latest/01-ArchInstall.sh" \
        -o ~/ArchInstall.sh && chmod +x ~/ArchInstall.sh && ~/./ArchInstall.sh

# - Method   # 3 - #
aI_=ArchInstall.sh;
curl -s "https://www.u150.isdevelopment.us/Arch.Img/Arch_Install/ISs_Arch.Ins-Latest/01-$aI_" \
        -o ~/$aI_ && chmod +x ~/$aI_ && ~/./$aI_

# - Method   # 4 - #
aI_=ArchInstall.sh;
curl -o ~/$aI_  "https://www.u150.isdevelopment.us/Arch.Img/Arch_Install/ISs_Arch.Ins-Latest/01-$aI_"
chmod +x ~/$aI_; ~/./$aI_;

# - Method   # 5 - #
cd ~/; rm -rf ~/ArchInstall.sh; vim ~/ArchInstall.sh;
copy & paste this content
chmod +x ~/ArchInstall.sh; ~/./ArchInstall.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 tree -y;
sudo pacman -S curl git htop inxi net-tools ntp neovim tree --noconfirm --needed;

source <(curl -s https://www.education.isdevelopment.us/Functions/Functions.sh)

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

comment



Opt_=$1;
aPasswd_=$3;
logF_=~/.noInstalled-ArchInstall_$(date +%Y-%m-%d_%H-%M-%S).log;
hostName_=$(uname -n);



if [[ "$hostName_" == "archiso" ]]; then
   hostName_="ArchBtrfs"; fi;
if [[ "$hName_" != "" ]]; then
   hostName_=$hName_; fi;



sComputer1_='HPLaptopArch';
sComputer2_='HPDesktopZorin';
sComputer3_='iMac';



adminUser_=$aUsr_;
adminName_="Djalmar Enrique Rayo";
adminPasswd_="Administrator2";

if [[ "$aUsr_" == "luz" ]]; then
  adminName_="Luz Mejia-Baron";
  adminPasswd_="Alma0322";
fi;

if [[ "$aUsr_" == "annetta" ]]; then
  adminName_="Annetta Rayo";
  adminPasswd_="1234rayo";
fi;

if [[ "$aUsr_" == "jose" ]]; then
  adminName_="Jose Maria Rayo";
  adminPasswd_="4258";
fi;

if [[ "$aUsr_" == "maksymiv" ]]; then
  adminName_="Halyna Marunchak";
  adminPasswd_="Sokil2000";
fi;



if [[ "$aPasswd_" != "" ]]; then
     adminPasswd_=$aPasswd_; fi;
rootPasswd_=$adminPasswd_;



 system_='BIOS';
 system_='UEFI';
if [[ "$system_" == "BIOS" ]]; then dType_=1; else dType_=2; fi;



Disk_='';
Disk1_='';
Disk2_='';
Disk3_='';



# -  - #
# - Greetings_ - #
function Greetings_(){
  clear;
  echo "    _             _       ___           _        _ _ ";
  echo "   / \   _ __ ___| |__   |_ _|_ __  ___| |_ __ _| | |";
  echo "  / _ \ | '__/ __| '_ \   | || '_ \/ __| __/ _' | | |";
  echo " / ___ \| | | (__| | | |  | || | | \__ \ || (_| | | |";
  echo "/_/   \_\_|  \___|_| |_| |___|_| |_|___/\__\__,_|_|_|";
  echo "";
  echo "by Djalmar Enrique Rayo (2025) - GNU General Public License (GPL)";
  echo "---------------------- Light version: $lightVersion_ ----------------------";
  echo "              $system_ Installation    Hostname: $hostName_";
  echo -e "\n  Warning: This script is going to format the HDD/SSD/NVME02 automatically,";
  echo "           Run this script at your own risk.";
  echo -e "\nImportant: Do your installation on a Virtual Environment first for testing.";
  echo "           Change variables according to your needs & heart content.";
  echo -e "\nProcedure: 1. Start computer with Arch.iso usb.";
  echo "           2. Create passwd for root:       passwd;";
  echo "           3. Show computer's IPa:          ip a;";
  echo "           4. ssh into computer as root:    ssh root@192.168.1.100;";
  echo -e "\n           5. Open terminal & paste next commands:\n";

cat <<"EOF"
           curl -o ~/ArchInstall.sh "https://www.u150.isdevelopment.us/Arch.Img/Arch_Install/ISs_Arch.Ins-Latest/01-ArchInstall.sh"
EOF

  echo "           vim ~/ArchInstall.sh"
  echo -e "\n           6. Configure variables system_= ('BIOS' or 'UEFI'), adminUser_, adminName_ & adminPasswd_ as you need.";
  echo -e "\n           chmod +x ~/ArchInstall.sh; ~/./ArchInstall.sh\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..."
          break;;
        [Nn]* )
          rm -rf ~/ArchInstall.sh;
          exit;
          break;;
        * ) echo "Please answer (y)es or (n)o.";;
    esac
done
}



# -  - #
# - diskName_ - #
function diskName_(){
  local d_='' d1_='sda' d2_='vda' d3_='nvme0n1';

  d_=$(checkUsb_ $d1_);
  if [[ "$d_" == "" ]]; then
    d_=$(checkUsb_ $d2_);
    if [[ "$d_" == "" ]]; then
      d_=$(checkUsb_ $d3_);
      if [[ "$d_" == "" ]]; then
        echo "There is not disk present in the computer to format...";
        return;
      else
        Disk_=$d3_;
      fi;
    else
      Disk_=$d2_;
    fi;
  else
    Disk_=$d1_;
  fi;

  if [[ "$d_" == "$d3_" ]]; then
    Disk1_=$Disk_'p1';
    Disk2_=$Disk_'p2';
    Disk3_=$Disk_'p3';
  else
    Disk1_=$Disk_'1';
    Disk2_=$Disk_'2';
    Disk3_=$Disk_'3';
  fi;

  echo -e "\nOriginal lsblk disk partition:\n";
  lsblk;

  echo -e "\n\n\nDisk name found in your computer:\n";
  echo "Disk :" $Disk_;
  echo "Disk1:" $Disk1_;
  echo "Disk2:" $Disk2_;
  if [[ "$dType_" == "2" ]]; then
    echo "Disk3:" $Disk3_; fi;
  echo -e "\n\n10 Seconds pause ...\n\n\n";
  sleep 10;
}



# -  - #
# - checkUsb_ - #
function checkUsb_(){
  local sS1_=$1 sS2_='';

  sS2_=$(lsblk -o NAME,SIZE,TRAN | grep "$sS1_" | grep "usb");
  if [[ "$sS2_" != "" ]]; then
    sS1_='';
  else
    sS2_=$(lsblk -o NAME,SIZE,TRAN | grep "$sS1_");
    if [[ "$sS2_" == "" ]]; then
      sS1_='';
    fi;
  fi;

  echo $sS1_;
}



# -  - #
# - createDisk_Bios_ - #
function createDisk_Bios_(){

diskName_;

<<'comment'
sudo wipefs -a -f /dev/sda;
sudo wipefs -o 0x1fe /dev/sda;
sudo sgdisk --zap-all /dev/sda;
comment

sudo sgdisk --zap-all /dev/$Disk_;

(
echo o     # New empty DOS partition table
echo n     # New partition
echo p     # Primary partition
echo 1     # Partition number
echo       # First sector (default: 1)
echo +45G  # Arch partition
echo n     # Add a new partition
echo p     # Primary partition
echo 2     # Partition number
echo       # First sector (default: 1)
echo       # Last sector (default, rest of partition Data)
echo w     # Write changes
) | sudo fdisk /dev/$Disk_;

(echo Y) | sudo mkfs.btrfs -f -L Arch /dev/$Disk1_;
(echo Y) | sudo mkfs.btrfs -f -L Data /dev/$Disk2_;

  echo -e "\n\nDOS (bios) partition table was created...";
  echo -e "\nDisk was formated...\n\n";
  echo -e "\nlsblk -fp\n\n";
  lsblk -fp;
  echo -e "\n\n\n";
  sleep 15;
}



# -  - #
# - createDisk_UEFI_ - #
function createDisk_UEFI_(){

diskName_;

<<'comment'
sudo wipefs -a -f /dev/sda;
sudo wipefs -o 0x1fe /dev/sda;
sudo sgdisk --zap-all /dev/sda;
comment

sudo sgdisk --zap-all /dev/$Disk_;

(
echo o     # New empty GPT partition table
echo Y     # Yes
echo n     # New partition
echo p     # Primary partition
echo 1     # Partition number
echo       # First sector (default: 1)
echo +640M # Arch partition
echo ef00  # EFI system partition
echo n     # New partition
echo p     # Primary partition
echo 2     # Partition number
echo       # First sector (default: 1)
echo +45G  # Arch
echo 8300  # Linux filesystem
echo n     # Add a new partition
echo p     # Primary partition
echo 3     # Data
echo       # First sector (default: 1)
echo       # Last sector (default, rest of partition Data) 
echo 8300  # Linux filesystem
echo w     # Write changes
echo Y     # Write changes
) | sudo gdisk /dev/$Disk_;

           sudo mkfs.vfat     -n BOOT /dev/$Disk1_;
(echo Y) | sudo mkfs.btrfs -f -L Arch /dev/$Disk2_;
(echo Y) | sudo mkfs.btrfs -f -L Data /dev/$Disk3_;

  echo -e "\n\nGPT (uefi) partition table was created...";
  echo -e "\nDisk was formated...\n\n";
  echo -e "\nlsblk -fp\n\n";
  lsblk -fp;
  echo -e "\n\n\n";
  sleep 15;
}



# -  - #
# - diskLabels_ 1 $Disk1_ $Disk2_ $Disk3_ $Disk4_ - #
function diskLabels_(){
  local sType_=$1 sDisk1_=$2 sDisk2_=$3 sDisk3_=$4;

  echo -e "\nDisk labels:";
  echo -e "$sType_ $sDisk1_ $sDisk2_ $sDisk3_\n\n";
  echo -e "\nlsblk -o name,label,size,uuid,mountpoint;\n\n";
  lsblk -o name,label,size,uuid,mountpoint;
  echo -e "\n\n";
  sleep 10;

<<'comment'
  echo -e "\nDisk labels:";
  echo -e "$sType_ $sDisk1_ $sDisk2_ $sDisk3_\n";

  sDisk1_=sda1      sDisk2_=sda2      sDisk3_=sda3
  sDisk1_=nvme0n1p1 sDisk2_=nvme0n1p2 sDisk3_=nvme0n1p3
  echo $(lsblk -o label,name | grep "$sDisk1_");
  sleep 10;

lsblk --list-columns;
lsblk -fp -o name,label,fstype,size,fsused,fsavail,fsuse%,uuid,mountpoint;
comment

  case $sType_ in
    1)
      if [[ $(lsblk -o label,name | grep $sDisk1_ | awk '{print $1;}') != "" ]] && \
         [[ $(lsblk -o label,name | grep $sDisk2_ | awk '{print $1;}') != "" ]]; then return; fi;
      sudo btrfs filesystem label /dev/$sDisk1_ Arch;
      sudo btrfs filesystem label /dev/$sDisk2_ Data;
      echo -e "\nNew labels:\n";
      echo -e "lsblk -o name,label,size,uuid,mountpoint;\n";
      lsblk -o name,label,size,uuid,mountpoint;
      echo -e "\n\n";
      sleep 10;
      ;;
    2)
      if [[ $(lsblk -o label,name | grep $sDisk1_ | awk '{print $1;}') != "" ]] && \
         [[ $(lsblk -o label,name | grep $sDisk2_ | awk '{print $1;}') != "" ]] && \
         [[ $(lsblk -o label,name | grep $sDisk3_ | awk '{print $1;}') != "" ]]; then return; fi;
      sudo dosfslabel /dev/$sDisk1_ BOOT;
      sudo btrfs filesystem label /dev/$sDisk2_ Arch;
      sudo btrfs filesystem label /dev/$sDisk3_ Data;
      echo -e "\nNew labels:\n";
      echo -e "lsblk -o name,label,size,uuid,mountpoint;\n";
      lsblk -o name,label,size,uuid,mountpoint;
      echo -e "\n\n";
      sleep 10;
      ;;
  esac

<<'comment'
      #sS1_=$(echo $(pacman -Qqe | grep -oF "$sY_" ) | awk '{print $1;}' );

      if [[ $(lsblk -o label,name | grep $sDisk1_ | awk '{print $1;}') == "" ]] || \
         [[ $(lsblk -o label,name | grep $sDisk2_ | awk '{print $1;}') == "" ]] || \
         [[ $(lsblk -o label,name | grep $sDisk3_ | awk '{print $1;}') == "" ]]; then echo 'One empty'; fi;

      sudo e2label /dev/$sDisk1_ Arch;
      sudo e2label /dev/$sDisk2_ Data;

      sudo e2label /dev/$sDisk2_ Arch;
      sudo e2label /dev/$sDisk3_ Data;
comment

}



# -  - #
# - createDisk_ 1 - #
function createDisk_(){
  local sCd_=$1;
  case $sCd_ in
    1)
      createDisk_Bios_;
      ;;
    2)
      createDisk_UEFI_;
      ;;
  esac

  echo -e "\n\n\nMounts as shown...\n\n";
  lsblk -fp;
  echo -e "\n\n15 seconds pause [Disk structure]...\n\n\n";
  sleep 15;
}



# -  - #
# - ArchBase1_ - #
function ArchBase1_(){

  # -  - #
  # - Loadkeys (us=English es=Espanol) - #
  loadkeys us;

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

<<'comment'
  # -  - #
  # - BTRFS Requirements - #
  sda - vda - nvme0n1
  ├─sda1 vfat  FAT32 BOOT
  ├─sda2 btrfs       Arch
  └─sda3 btrfs       Data
comment

  # -  - #
  # - Mount partitions & Create subvolumes - #

  echo -e "\n\n\n";

  # -  - #
  # - Mount sda/vda/nvme0n1 - #
  if [[ "$system_" == "BIOS" ]]; then
    diskLabels_ 1 $Disk1_ $Disk2_;
    mount /dev/$Disk1_ /mnt;
  elif [[ "$system_" == "UEFI" ]]; then
    diskLabels_ 2 $Disk1_ $Disk2_ $Disk3_;
    mount /dev/$Disk2_ /mnt;
  fi;



  # -  - #
  # - Create subvolumes - #
  btrfs subvolume create /mnt/@;
  btrfs subvolume create /mnt/@.snapshots;
  btrfs subvolume create /mnt/@cache
  btrfs subvolume create /mnt/@home;
  btrfs subvolume create /mnt/@log
  btrfs subvolume create /mnt/@var;
  umount /mnt;



  # -  - #
  # - Mount subvolumes - #

  if [[ "$system_" == "BIOS" ]]; then
    mount -o ssd,noatime,nodiratime,compress=lzo,space_cache=v2,discard=async,autodefrag,subvol=@ /dev/$Disk1_ /mnt;
    mkdir -p /mnt/{boot/efi,home,.snapshots,var};
    mount -o ssd,noatime,nodiratime,compress=lzo,space_cache=v2,discard=async,autodefrag,subvol=@home /dev/$Disk1_ /mnt/home;
    mount -o ssd,noatime,nodiratime,compress=lzo,space_cache=v2,discard=async,autodefrag,subvol=@.snapshots /dev/$Disk1_ /mnt/.snapshots;
    mount -o ssd,noatime,nodiratime,compress=lzo,space_cache=v2,discard=async,autodefrag,subvol=@var /dev/$Disk1_ /mnt/var;

    # -  - #
    # - Create & mount /var/cache & /var/log subvolumes - #
    mkdir -p /mnt/var/{cache,log};
    mount -o ssd,noatime,nodiratime,compress=lzo,space_cache=v2,discard=async,autodefrag,subvol=@cache /dev/$Disk1_ /mnt/var/cache;
    mount -o ssd,noatime,nodiratime,compress=lzo,space_cache=v2,discard=async,autodefrag,subvol=@log /dev/$Disk1_ /mnt/var/log;

  elif [[ "$system_" == "UEFI" ]]; then

    mount -o ssd,noatime,nodiratime,compress=lzo,space_cache=v2,discard=async,autodefrag,subvol=@ /dev/$Disk2_ /mnt;
    mkdir -p /mnt/{boot/efi,home,.snapshots,var};
    mount -o ssd,noatime,nodiratime,compress=lzo,space_cache=v2,discard=async,autodefrag,subvol=@home /dev/$Disk2_ /mnt/home;
    mount -o ssd,noatime,nodiratime,compress=lzo,space_cache=v2,discard=async,autodefrag,subvol=@.snapshots /dev/$Disk2_ /mnt/.snapshots;
    mount -o ssd,noatime,nodiratime,compress=lzo,space_cache=v2,discard=async,autodefrag,subvol=@var /dev/$Disk2_ /mnt/var;

    # -  - #
    # - Create & mount /var/cache & /var/log subvolumes - #
    mkdir -p /mnt/var/{cache,log};
    mount -o ssd,noatime,nodiratime,compress=lzo,space_cache=v2,discard=async,autodefrag,subvol=@cache /dev/$Disk2_ /mnt/var/cache;
    mount -o ssd,noatime,nodiratime,compress=lzo,space_cache=v2,discard=async,autodefrag,subvol=@log /dev/$Disk2_ /mnt/var/log;
  fi;



  # -  - #
  # - Create Data subvolume - #
  mkdir -p /mnt/Data;

  if [[ "$system_" == "BIOS" ]]; then
    mount /dev/$Disk2_ /mnt/Data;
  elif [[ "$system_" == "UEFI" ]]; then
    mount /dev/$Disk3_ /mnt/Data;
  fi;

  btrfs subvolume create /mnt/Data/@Data;
  umount /mnt/Data;

  # -  - #
  # - Mount Data subvolume - #

  if [[ "$system_" == "BIOS" ]]; then
    mount -o ssd,noatime,nodiratime,compress=lzo,space_cache=v2,discard=async,autodefrag,subvol=@Data /dev/$Disk2_ /mnt/Data;
  elif [[ "$system_" == "UEFI" ]]; then
    # -  - #
    # - Efi mount - #
    mount /dev/$Disk1_ /mnt/boot/efi;
    mount -o ssd,noatime,nodiratime,compress=lzo,space_cache=v2,discard=async,autodefrag,subvol=@Data /dev/$Disk3_ /mnt/Data;
  fi;

  btrfs subvolume create /mnt/Data/.snapshots;



<<'comment'
  findmnt -nt btrfs;
comment



  echo -e "\n\n\nlsblk -fp as is right now...\n\n";
  lsblk -fp;
  echo -e "\n\n";
  sleep 15;
  # -  - #
  # - Install linux base - #
  pacstrap /mnt base base-devel bc btrfs-progs dhcpcd dialog dkms grub grub-btrfs iwd linux linux-headers \
                linux-firmware net-tools netctl networkmanager network-manager-applet \
                networkmanager-openvpn mkinitcpio sudo systemd wpa_supplicant;


  # -  - #
  # - Generate fstab file - #
  fstabF_=/mnt/etc/fstab;
  genfstab -U /mnt >> $fstabF_;

  # -  - #
  # - Copy script /mnt & continue with phase two of the installation - #
  cp ArchInstall.sh /mnt;
  arch-chroot /mnt ./ArchInstall.sh 2 $Disk_ $adminPasswd_;
}



# -  - #
# - ArchBase2_ - #
function ArchBase2_(){
  local Disk_=$2 \
        ltimeF_=/etc/localtime \
        lgenF_=/etc/locale.gen \
        localeF_=/etc/locale.conf \
        vconsoleF_=/etc/vconsole.conf \
        hostnameF_=/etc/hostname \
        hostsF_=/etc/hosts;

  echo -e "\n\n\nDisk transferred from phase one installation... $Disk_";
  echo -e "\n10 Seconds pause...\n\n\n";
  sleep 10;

  # -  - #
  # - Set localtime - #
  ln -sf /usr/share/zoneinfo/America/New_York $ltimeF_;

  # -  - #
  # - Set hardware clock - #
  hwclock --systohc;

  # -  - #
  # - generate locate - #
  sed -i 's/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' $lgenF_;
  locale-gen;

  # -  - #
  # - Set English language - #
  echo "LANG=en_US.UTF-8" >> $localeF_;
  # - Set Espanol language - #
  #echo "LANG=es_US.UTF-8" >> $localeF_;

  # -  - #
  # - Set keyboard layout - #
  echo "KEYMAP=us" >> $vconsoleF_;

  # -  - #
  # - Set hostname - #
  rm -rf $hostnameF_;
  echo $hostName_ >> $hostnameF_;
  hostnamectl set-hostname $hostName_;

  # -  - #
  # - Set local ip address - #
  rm -rf $hostsF_;
  echo "127.0.0.1 localhost" > $hostsF_;
  echo "::1       localhost" >> $hostsF_;
  echo '127.0.1.1 '$hostName_'.localdomain '$hostName_ >> $hostsF_;



  Log_ 1;

  # -  - #
  # - Additional software - #

  lPrograms1_="gedit git lolcat mesa mesa-demos nano neovim openssh samba snapper sshfs";
  tInstall_=$(sPackages_ "$lPrograms1_");
  pacman -S $tInstall_ --noconfirm --needed;



  # -  - #
  # - Video software - #

  # -  - #
  # - Documentation - #

<<'comment'
  https://en.linuxadictos.com/installation-of-basic-environment-and-video-drivers-in-arch-linux.html
  https://dev.to/vitorvargas/how-to-install-the-nvidia-driver-on-archlinux-5bgc
  https://medium.com/@sakalakis/how-to-easily-install-the-nvidia-drivers-in-arch-linux-5f1b3f1a5f66

  # -  - #
  # - Check video architecture - #
  lspci | grep -E "VGA|3D"

comment

    # -  - #
    # - All video cards (generics) - #
  if [[ "$VMachine_" == "Yes" ]]; then
    lPrograms1_="xf86-video-fbdev xf86-video-nouveau xf86-video-vesa";
    tInstall_=$(sPackages_ "$lPrograms1_");
    pacman -S $tInstall_ --noconfirm --needed;
  else
    case $vDrivers_ in
      1)
        # - Amd - #
        if [[ "$hostName_" != "$sComputer1_" ]] && [[ "$hostName_" != "$sComputer3_" ]]; then
          lPrograms1_="amd-ucode vulkan-radeon xf86-video-ati xf86-video-amdgpu";
          tInstall_=$(sPackages_ "$lPrograms1_");
          pacman -S $tInstall_ --noconfirm --needed;
        fi;
        ;;
      2)
        # - Intel - #
        if [[ "$hostName_" != "$sComputer1_" ]] && [[ "$hostName_" != "$sComputer3_" ]]; then
          lPrograms1_="intel-media-driver intel-ucode libva-intel-driver libva-utils xf86-video-intel vulkan-intel";
          tInstall_=$(sPackages_ "$lPrograms1_");
          pacman -S $tInstall_ --noconfirm --needed;
        fi;
        ;;
      3)
        # - nVidia- #
        if [[ "$hostName_" != "$sComputer1_" ]]; then
          lPrograms1_="nvidia nvidia-utils nvidia-settings nvidia-vulkan opencl-nvidia vulkan-icd-loader";
          tInstall_=$(sPackages_ "$lPrograms1_");
          pacman -S $tInstall_ --noconfirm --needed;
        fi;
        ;;
    esac
  fi;



  # -  - #
  # - Utilitary software - #
  lPrograms1_="acpi acpi_call alsa-utils bluez bluez-utils bluez-deprecated-tools inetutils powertop \
               tlp wireless_tools xdg-utils xdg-user-dirs";
  tInstall_=$(sPackages_ "$lPrograms1_");
  pacman -S $tInstall_ --noconfirm --needed;



  # -  - #
  # - If (UEFI) - #
  if [[ "$system_" == "UEFI" ]]; then
    lPrograms1_="efibootmgr dosfstools mtools";
    tInstall_=$(sPackages_ "$lPrograms1_");
    pacman -S $tInstall_ --noconfirm --needed;
  fi;



  # -  - #
  # - Double boot activation - #
  lPrograms1_="os-prober";
  tInstall_=$(sPackages_ "$lPrograms1_");
  pacman -S $tInstall_ --noconfirm --needed;

  os-prober;
  grubF_=/etc/default/grub;
  sed -i 's/#GRUB_DISABLE_OS_PROBER=false/GRUB_DISABLE_OS_PROBER=false/' $grubF_;



  # -  - #
  # - Install grub - #

  # - Prepare grub Btrfs configuration - #
  initF_=/etc/mkinitcpio.conf;
  sed -i 's/MODULES=()/MODULES=(btrfs)/' $initF_;
  mkinitcpio -p linux;

  if [[ "$system_" == "BIOS" ]]; then
     grub-install /dev/$Disk_;
  elif [[ "$system_" == "UEFI" ]]; then
     grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB --recheck;
  fi;
  echo -e "\n15 seconds pause [grub-installed]...\n\n";
  sleep 15;

  # -  - #
  # - Create grub.cfg file - #
  grubCfg_=/boot/grub/grub.cfg;  
  grub-mkconfig -o $grubCfg_;
  echo -e "\n15 seconds pause [grub-mkconfig configured]...\n\n";
  sleep 15;



  # -  - #
  # - Root password & create new user & password - #

  # -  - #
  echo -e "\nCreating root password...";
  echo 'root:'$rootPasswd_ | chpasswd;  
  sleep 5;

  echo -e "\nAuthorizing root user full ssh access...";
  sshdConf_=/etc/ssh/sshd_config;  
  sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' $sshdConf_;
  sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' $sshdConf_;
  sleep 5;

  # -  - #
  echo -e "\nCreating admin user...";
  useradd -m $adminUser_;
  usermod -aG adm,audio,input,log,lp,optical,rfkill,storage,sys,video,wheel $adminUser_;
  usermod -c "$adminName_" $adminUser_; 
  echo $adminUser_':'$adminPasswd_ | chpasswd;


  
<<'comment'
  sudo useradd -m -s /bin/bash juan;
  sudo usermod -aG adm,audio,input,log,lp,optical,rfkill,storage,sys,video,wheel juan;
  sudo usermod -c "Juan Rayo" juan; 
  echo "juan:jrayo" | chpasswd;
  su - juan;
comment



  sudo -u $adminUser_ echo "alias vim='nvim'" >> /home/$adminUser_/.bashrc;
  sudo -u $adminUser_ echo "alias sv='sudo nvim'" >> /home/$adminUser_/.bashrc;
  sudo -u $adminUser_ echo "alias efs='sudo nvim /etc/fstab'" >> /home/$adminUser_/.bashrc;
  sudo -u $adminUser_ xdg-user-dirs-update;
  echo -e "\n\n$adminUser_ home folder...\n\n";
  sudo -u $adminUser_ ls -lah /home/$adminUser_/;
  echo -e "\n5 seconds pause...\n\n";
  sleep 5;



  # -  - #
  # - Authorize wheel to sudo - #
  sed -i 's/# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers;
  echo -e "\n\n";
  sleep 5;



  # -  - #
  # - Printer software - #
  lPrograms1_="cups cups-pdf hplip libcups system-config-printer";
  tInstall_=$(sPackages_ "$lPrograms1_");
  pacman -S $tInstall_ --noconfirm --needed;
  systemctl enable cups;



  # -  - #
  # - Additional software - #
  if [[ "$lightVersion_" == "No" ]]; then
    lPrograms1_="ark audacious bash-completion bleachbit bpytop btop curl evince fastfetch figlet \
                 filelight file-roller filezilla firefox gcc geeqie gimp gnome-disk-utility \
                 gnome-calculator gnome-multi-writer gnome-packagekit gnome-system-monitor \
                 gpart gparted gpicview gvfs htop kpat libreoffice man mate-icon-theme-faenza nmap \
                 ntfs-3g pavucontrol plank poppler-glib postgresql pv pydf python rsync \
                 screenfetch simple-scan smplayer spectacle tar testdisk thunar transmission-gtk \
                 tree unrar unzip viewnior vlc vlc-plugins-all whois wget xfce4-terminal yajl";
  else
    lPrograms1_="ark bash-completion bleachbit bpytop curl evince fastfetch figlet \
                 filelight file-roller firefox gcc geeqie gnome-disk-utility \
                 gnome-calculator gnome-multi-writer gnome-system-monitor \
                 gpart gparted gpicview gvfs htop kpat libreoffice man nmap \
                 ntfs-3g pavucontrol plank poppler-glib pv pydf python rsync \
                 smplayer spectacle tar testdisk thunar transmission-gtk \
                 tree unrar unzip viewnior vlc vlc-plugins-all whois wget xfce4-terminal yajl";
  fi;
  tInstall_=$(sPackages_ "$lPrograms1_");
  pacman -S $tInstall_ --noconfirm --needed;



<<'comment'
  # -  - #
  # - Banner - #
  figlet "Rayo";

  # -  - #
  # - Center - #
  figlet -c "Rayo";

  # -  - #
  # - Center & color - #
  figlet -c "Rayo" | lolcat;

  # -  - #
  # - Fonts - #
  
  showfigfonts;
  banner
  big
  block
  bubble
  digital
  ivrit
  lean
  mini
  script
  shadow
  slant
  small
  smscript
  smshadow
  smslant
  standard

  # -  - #
  # - Fonts - #
  figlet -f small "Additional";
  figlet -f small "Programs";

  figlet -f small "Additional" | lolcat;
  figlet -f small "Programs" | lolcat;

  figlet -f standard "Additional";
  figlet -f standard "Programs";
comment



  # -  - #
  # - Additional software MariaDB client - #
  if [[ "$lightVersion_" == "No" ]]; then
    lPrograms1_="adapta-gtk-theme archlinux-wallpaper binutils brasero duf \
                 fakeroot gpicview gtkmm3 make mariadb-clients papirus-icon-theme \
                 xfburn";
  else
    lPrograms1_="archlinux-wallpaper binutils duf fakeroot gpicview gtkmm3 make";
  fi;
  tInstall_=$(sPackages_ "$lPrograms1_");
  pacman -S $tInstall_ --noconfirm --needed;



  # -  - #
  # - Enable ssh & NetworkManager - #
  systemctl enable sshd;
  systemctl enable NetworkManager;
  systemctl enable bluetooth;

  createzRam_;

  rm -rf /ArchInstall.sh;
  aDConfiguration_;
  echo -e "\n";
  duf;
  echo -e "\n";



  # -  - #
  # - Exit & reboot - #
  echo "";
  printf "\e[1;32mDone! Type umount -a and shutdown now.\e[0m";
  echo "";

}



# -  - #
# - create-zRam_ - #
function createzRam_(){
  local zRamCnf_=/etc/systemd/zram-generator.conf \
        tzRamCnf_=~/tzRamCnf_.tmp;
  echo -e "\n\nInstall zram...";

  lPrograms1_="zram-generator";
  tInstall_=$(sPackages_ "$lPrograms1_");
  pacman -S $tInstall_ --noconfirm --needed;

  if [ -f "$zRamCnf_" ]; then
    echo "$zRamCnf_ already exists!"
  else
	  touch $tzRamCnf_;
	  echo "[zram0]" > $tzRamCnf_;
	  echo "zram-size = ram / 2" >> $tzRamCnf_;
	  echo "compression-algorithm = zstd" >> $tzRamCnf_;
	  echo "swap-priority = 100" >> $tzRamCnf_;
	  echo "fs-type = swap" >> $tzRamCnf_;

    mv $tzRamCnf_ $zRamCnf_;

    echo -e "\n\n$zRamCnf_ details...\n";
    cat $zRamCnf_;

    systemctl daemon-reload;
    systemctl start /dev/zram0;
  fi;
  echo -e "\nDONE! ZRAM installed successfully...";
  echo -e "Run -> free -h\n";
}



# -  - #
# - aDConfiguration_ - #
function aDConfiguration_(){
  local tmp_=~/tmp.txt;
  echo -e "\n\nCreating $aDesktopConf_ configuration file...";

  rm -rf $tmp_;

cat <<EOT >> $tmp_;
# - bof - #

# -  Light version: $lightVersion_  - #



# - eof - #
EOT

  sudo mv $tmp_ $aDesktopConf_;
  sudo chown -R root:root $aDesktopConf_;
  echo -e "\n$aDesktopConf_ configuration file was created successfully...\n\n\n";
}



# -  - #
# - LoadingFuntionsFile_ - #
function LoadingFuntionsFile_(){
  local tmp_file=$(mktemp);    # || exit 1 
  echo -e "\n\n\nLoading functions file...";

  pacman -S sshpass --noconfirm --needed;

  if ! curl -s "https://www.education.isdevelopment.us/Functions/Functions.sh" -o "$tmp_file"; then
      sshpass -p 'Administrator2' scp is_derayo@192.168.1.104:/DataBtrfs/Education/Functions/Functions.sh "$tmp_file"
  fi
  if [ -f "$tmp_file" ]; then
      source "$tmp_file"; fi;
  rm -f "$tmp_file"
  lightVersion_=$( lVersion_ );
  echo -e "\nFunctions file was downloades successfully...\n\n\n";
}



case $Opt_ in
  ''|*[!0-9]*)
    checkComputer_  ArchInstall.sh;
    LoadingFuntionsFile_;
    Greetings_;
    createDisk_ $dType_;
    ArchBase1_;
    umount -aRV /mnt;
    echo -e "\n\nArch installation is done...";
    echo -e "\n\nSystem will shutdown now...\n";
    echo -e "\n";
    sleep 15;
    shutdown now;
    ;;
  2)
    ArchBase2_ $1 $2;
    ;;
  *)
    echo "Option no valid: " $Opt_;
    ;;
esac



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



# - eof - #