#!/bin/bash
# - bof - #

clear;

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



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

 dropbox_='Yes';
 dropbox_='No';



<<'comment'

sudo pacman -S curl --noconfirm --needed;
bash <(curl -s https://www.u150.isdevelopment.us/Arch.Img/Arch_Install/ISs_Arch.Ins-Latest/02-Arch_PostInstallation.sh)



curl -o ~/Arch_PostInstallation.sh "https://www.u150.isdevelopment.us/Arch.Img/Arch_Install/ISs_Arch.Ins-Latest/02-Arch_PostInstallation.sh"
chmod +x ~/Arch_PostInstallation.sh; ~/./Arch_PostInstallation.sh;
chmod +x ~/Arch_PostInstallation.sh; ~/./Arch_PostInstallation.sh aP;
nvim ~/Arch_PostInstallation.sh;

cd ~/; rm -rf ~/Arch_PostInstallation.sh; nvim ~/Arch_PostInstallation.sh;
copy & paste this content
chmod +x ~/Arch_PostInstallation.sh; ~/./Arch_PostInstallation.sh;

# :A
# -  - #
# - Arch additional software installation script - #

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

# - Method   # 2 - #
sh -c "$(curl -fsSL 'https://www.u150.isdevelopment.us/Arch.Img/Arch_Install/ISs_Arch.Ins-Latest/02-Arch_PostInstallation.sh')"

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

# - Method   # 4 - #
apI_=Arch_PostInstallation.sh;
curl -s "https://www.u150.isdevelopment.us/Arch.Img/Arch_Install/ISs_Arch.Ins-Latest/02-$apI_" \
        -o ~/$apI_ && chmod +x ~/$apI_ && ~/./$apI_;

# - Method   # 5 - #
apI_=Arch_PostInstallation.sh;
curl -o ~/$apI_  "https://www.u150.isdevelopment.us/Arch.Img/Arch_Install/ISs_Arch.Ins-Latest/02-$apI_";
chmod +x ~/$apI_; ~/./$apI_;

# - Method   # 6 - #
cd ~/; rm -rf ~/Arch_PostInstallation.sh; nvim ~/Arch_PostInstallation.sh;
copy & paste this content
chmod +x ~/Arch_PostInstallation.sh; ~/./Arch_PostInstallation.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;
comment



# -  - #
# - Global variables - #
aPasswd_=$1;
logF_=~/.noInstalled-Arch_PostInstallation_$(date +%Y-%m-%d_%H-%M-%S).log;



aSoftware_='# - Additional software installed - #'; 

u150WServer_="https://www.u150.isdevelopment.us";
sAws_="/ProxmoxVE/Programs/Linux.Img/LinuxApplications.app/";



adminUser_=($USER);
adminPasswd_="Administrator2";

if [[ "$aUsr_" == "luz" ]]; then
  adminUser_=$aUsr_;
  adminPasswd_='Alma0322';
fi;

if [[ "$aUsr_" == "annetta" ]]; then
  adminUser_=$aUsr_;
  adminPasswd_='1234rayo';
fi;

if [[ "$aUsr_" == "jose" ]]; then
  adminUser_=$aUsr_;
  adminPasswd_='4258';
fi;

if [[ "$aUsr_" == "maksymiv" ]]; then
  adminUser_=$aUsr_;
  adminPasswd_='Sokil2000';
fi;

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



# -  - #
# - Greetings_ - #
function Greetings_(){
  Header_;
  echo -e "\n  Warning: This script is going to install several programs in your system.";
  echo "           It will take some time, probably more than an hour.";
  echo -e "\n           Be patient and grab some coffee.";
  echo -e "\nImportant: Do your installation on a Virtual Environment first for testing.";
  echo -e "\nProcedure: Open terminal & paste next commands:\n";

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

  echo "           nvim ~/Arch_PostInstallation.sh"
  echo -e "\n           Configure variables adminUser_, adminName_ & adminPasswd_ as you need.";
  echo -e "\n           chmod +x ~/Arch_PostInstallation.sh; ~/./Arch_PostInstallation.sh\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 ~/Arch_PostInstallation.sh;
          exit;
          break;;
        * ) echo "Please answer (y)es or (n)o.";;
    esac
done
}



# -  - #
# - Header_ - #
function Header_(){
  clear;
  echo "";
  figlet -f small "Additional" | lolcat;
  figlet -f small "Programs" | lolcat;
  echo -e "\n\nby Djalmar Enrique Rayo (2025) - GNU General Public License (GPL)";
  echo "----------------------- Light version: $lightVersion_ -----------------------";
}



# -  - #
# - AdditionalSoftware_ - #
function AdditionalSoftware_(){
  local msg_1='Additional software already installed...' \
        sS1_='' sS2_='' sS3_='' sS4_='';
  local sS10_=$aSoftware_ sS20_='' \
        tmp_=~/tmp.txt;
  local sC_1='#ILoveCandy' sC_2='' \
        ;
  echo "";

  if [[ -f "$aDesktopConf_" ]]; then
     sS20_=$(echo $(cat $aDesktopConf_ | grep "$sS10_" ));
     if [[ "$sS10_" == "$sS20_" ]]; then echo $msg_1; sleep 5; return; fi;
  fi;

  Log_ 2;
  Reflector_;
  pacmanConf_;
  update_;

  echo -e "\nInstalling additional software...\n";

<<'comment'
 ttf-inconsolata
comment

  if [[ "$lightVersion_" == "No" ]]; then
    lPrograms1_="bat chromium cronie eza fd ffmpeg flatpak fzf gnu-free-fonts \
                 imagemagick jq kitty poppler ripgrep tmux ttf-hack \
                 vscode webapp-manager wezterm yazi zoxide";
  else
    lPrograms1_="chromium cronie eza fd ffmpeg flatpak jq kitty ripgrep ttf-hack \
                 webapp-manager wezterm yazi";
  fi;
  tInstall_=$(sPackages_ "$lPrograms1_") || tInstall_=$lPrograms1_;
  sudo pacman -S $tInstall_ --noconfirm --needed;
  sudo systemctl enable --now cronie.service;
  systemctl status cronie.service;

  flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
  flatpak remote-add --if-not-exists appcenter https://flatpak.elementary.io/repo.flatpakrepo


  if [[ "$lightVersion_" == "No" ]]; then
    lPrograms1_="noto-fonts-emoji ttf-jetbrains-mono-nerd ttf-nerd-fonts-symbols ttf-nerd-fonts-symbols-mono";
  else
    lPrograms1_="ttf-jetbrains-mono-nerd ttf-nerd-fonts-symbols-mono";
  fi;
  tInstall_=$(sPackages_ "$lPrograms1_") || tInstall_=$lPrograms1_;
  sudo pacman -S $tInstall_ --noconfirm --needed;


<<'comment'
  lPrograms1_="nerd-fonts";
  tInstall_=$(sPackages_ "$lPrograms1_") || tInstall_=$lPrograms1_;
  sudo pacman -S $tInstall_ --noconfirm --needed;
comment


  lPrograms1_="gvfs-smb nautilus-share samba";
  tInstall_=$(sPackages_ "$lPrograms1_") || tInstall_=$lPrograms1_;
  sudo pacman -S $tInstall_ --noconfirm --needed;

  sudo pacman -S dnsutils p7zip ttf-freefont --noconfirm --needed;
  echo -e "\n\ndnsutils p7zip ttf-freefont were installed...";
  echo -e "\nPlease check for errors...\n\n\n";
  echo -e "\n\n10 seconds pause...\n\n\n";
  sleep 10;


  Yay_;


  if [[ "$lightVersion_" == "No" ]]; then
    Yaourt_;

    echo -e "\nInstalling pamac...\n";
    yay -S pamac-aur --noconfirm --needed;

    echo -e "\nInstalling paru helper...\n";
    yay -S paru --noconfirm --needed;

    echo -e "\nInstalling preLoad...\n";
    yay -S preload --noconfirm --needed;

    echo -e "\nInstalling icons themes...\n";

    # - Icon themes - #
    yay -S antu-classic-icon-theme-git arc-faenza-icon-theme --noconfirm --needed;
    yay -S arc-gtk-theme arc-icon-theme pinta --noconfirm --needed;

    yay -S archdroid-icon-theme ardis-icon-theme-circle faba-icon-theme-git inxi \
          la-capitaine-icon-theme-git moka-icon-theme-git --noconfirm --needed;

    yay -S numix-gtk-theme numix-icon-theme numix-square-icon-theme pix \
          whitesur-icon-theme --noconfirm --needed;

<<'comment'
  paru -S tela-icon-theme --noconfirm --needed;
  paru -S paper-icon-theme-git --noconfirm --needed;
comment

    yay -S faenza-cupertino-icon-theme --noconfirm --needed;
    yay -S numix-circle-icon-theme --noconfirm --needed;

    # -  - #
    # - Download youtube videos - #
    yay -S yt-dlp --noconfirm --needed;
    # -  - #
    # - Download sample - #
    # yt-dlp https://www.youtube.com/watch?v=-RY1YMvceRY;

    # -  - #
    # - Package manager - #
    yay -S octopi --noconfirm --needed;
  else
    yay -S arc-gtk-theme arc-icon-theme --noconfirm --needed;
    yay -S archdroid-icon-theme ardis-icon-theme-circle inxi --noconfirm --needed;
    yay -S yt-dlp --noconfirm --needed;
  fi;


  pipeWire_;


  if [[ "$lightVersion_" == "No" ]]; then
    ttf_ms_fonts_;

    if [[ "$dropbox_" == "Yes" ]]; then
      echo -r "\n\nInstalling dropbox...\n\n";
      yay -S dropbox --noconfirm --needed;
      echo -r "\n\nInstalling dropbox...\n\n\n";
    fi;
  fi;

  #Brave_;
  BalenaEtcher_;
  ClipGrab_;

  sudo sed -i '4 i '"$aSoftware_" $aDesktopConf_;


<<'comment'
  # -  - #
  # - pacmanConf_ - #
  xrandr --output Virtual-1 --mode 2560x1080;
comment



  sudo inxi -SCMm -t c -P -x;

  cd $Dir_;
  echo -e "\n\n\nAdditional software has been installed successfully...\n\n\n";
  sleep 10;
}



# -  - #
# - pacmanConf_ - #
function pacmanConf_(){
  local pacmanF_=/etc/pacman.conf \
        sSed_='ParallelDownloads = 5' \
        candy_='ILoveCandy';
  echo -e "\nConfiguring $pacmanF_...\n";
  
  sudo sed -i 's/#ParallelDownloads = 5/'"$sSed_"'/' $pacmanF_;
  sudo sed -i 's/#ParallelDownloads = 3/'"$sSed_"'/' $pacmanF_;
  sudo sed -i 's/ParallelDownloads = 3/'"$sSed_"'/' $pacmanF_;
  sudo sed -i 's/#Color/Color/' $pacmanF_;
  ln=$(sed -n '/ParallelDownloads = 5/{=}' $pacmanF_);

  # -  - #
  # - Search ILoveCandy - #
  sC_2=$( cat $pacmanF_ | grep $sC_1);
  if [[ "$sC_2" != "" ]]; then
     sudo sed -i 's/#ILoveCandy/ILoveCandy/' $pacmanF_;
  else
     sC_2=$( cat $pacmanF_ | grep $candy_);
     if [[ "$sC_2" == "" ]]; then
        ln=$(echo "$(($ln + 1))");
        sudo sed -i $ln' i ILoveCandy' $pacmanF_;
     fi;
  fi;

  echo "";
}



# -  - #
# - Reflector_ - #
function Reflector_(){
  local sS1_='reflector' sS2_='';

  # -  - #
  # - Search package in repository - #
  echo -e "\nInstalling reflector...\n\n";
  lPrograms1_="reflector";
  tInstall_=$(sPackages_ "$lPrograms1_") || tInstall_=$lPrograms1_;
  sudo pacman -S $tInstall_ --noconfirm --needed;

  # -  - #
  # - Updating arch mirrorlist - #
  echo -e "\nUpdating arch mirror list...\n\n";
  sudo reflector --verbose --threads 50 -l 101 -f 101 --number 50 --sort rate --save /etc/pacman.d/mirrorlist;
  echo -e "\nMirror list updated...\n\n";
  sleep 10;
}



# -  - #
# - Yay_ - #
function Yay_(){
  local sS1_='' \
        sY_=yay-git \
        sD_=~/Downloads;
  echo "";

  sS1_=$(echo $(pacman -Qqe | grep -oF "$sY_" ) | awk '{print $1;}' );
  if [[ "$sS1_" == "$sY_" ]]; then
    echo "Yay helper already installed...";
  else
    echo -e "\nInstalling yay helper...\n\n";
    cd $sD_;
    git clone https://aur.archlinux.org/yay-git.git;
    cd $sY_;
    #makepkg -sic PKGBUILD;
    makepkg -sic;
    yay -Y --save --answerclean All;
    yay -Y --save --answerdiff All;
    yay -Y --save --answeredit All;

    cd $sD_;
    rm -rf $sY_;
  fi;

  cd $Dir_;
  echo -e "\n\n";
  sleep 10;

<<'comment'
yD_=~/.config/yay;
jF_=config.json;
mkdir $yD_;
yay -P -g >> $yD_/$jF_;
chmod 777 $yD_/$jF_;
yay --aururl "https://aur.tuna.tsinghua.edu.cn" --save;
yay -P -g;
comment

}



# -  - #
# - Yaourt_ - #
function Yaourt_(){
  local sS1_='' \
        sY_=yaourt \
        sP_=package-query \
        sD_=~/Downloads;
  echo "";

  sS1_=$(echo $(pacman -Qqe | grep -oF "$sY_" ) | awk '{print $1;}' );
  if [[ "$sS1_" == "$sY_" ]]; then
    echo "Yaourt helper already installed...";
  else
    echo -e "\nInstalling Yaourt helper...\n\n";
    cd $sD_;
    git clone https://aur.archlinux.org/package-query.git;
    cd $sP_;
    echo 'Y' | makepkg -sic PKGBUILD;

    cd $sD_;
    git clone https://aur.archlinux.org/yaourt.git;
    cd $sY_;
    echo 'Y' | makepkg -sic PKGBUILD;
    cd $sD_;
    rm -rf $sP_;
    rm -rf $sY_;
  fi;

  echo -e "\n\n";
  cd $Dir_;
  sleep 10;
}



# -  - #
# - pipeWire_ - #
function pipeWire_(){
  echo -e "\nInstalling pipewire...\n";
  lPrograms1_="alsa-utils gst-plugin-pipewire pavucontrol \
               pipewire pipewire-audio pipewire-alsa pipewire-jack \
               pipewire-pulse sof-firmware wireplumber";
  tInstall_=$(sPackages_ "$lPrograms1_") || tInstall_=$lPrograms1_;
  sudo pacman -S $tInstall_ --needed;
  echo -e "\n\n";
}



# -  - #
# - sshPublicKey_ - #
function sshPublicKey_(){
  local pKey_1='ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC4hC7L1g9A3WuMrVzCZxy0uT+EQa3AfFGpvX6l94o3nFK4LIjGRf8xjamC3/nfIVApqjGg+w1QSrG4urWzYXVJSl7oKkMyJFSigDOdaZpM6dCQvwQSiTiKoAPrf/Pne99gGemqmjD9aW2WeCewtkIUHDqfW/nZ9iBtDWxygJOjBZD4SJ04NBj2HtwmPY/xSBwnXzd418ppj2LevOJMIH+6WdKfOz5Dkmmg2L2pzyQmCdnRot0VpwSGz2+6E6a1UqaPQsSFwaax9JTkoNvRpJmtGqnaqH9qG8EmRWcGtMEzEq2efwBYgz0pId33cpBI3SXfuJB4udGPfskdkKAmWG85Czhm/r94dcLBJ7STI4I6V6OKVDx3/3UfQZyfL4XM+VPFHf7ALoPtIfPNvNCAwpQpbHgNnUVMv81fSsEK8oe1mRLuj1xPqcFw6+n8RvyyvD9v3/lz6zjKb80rnTmTqY8Wvp9nNk986PbvYMWw56amsKZFcGaQN57jwMOLYLK/yWk= is_derayo@HPLaptopArch';
  local pKey_2='ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDopoGALJZXDoWKpjBBQqkjgCnzkTtzR9QihguMY8oO2H+tTXTDHUypjXs3wb91HyMkaax/qcE/LdRZWbW0IkUcGL0YkhQwM45Yv+TWkmhnFPz+im1pal73QfnhDeJ2hlGhYLAz09yGgQ6SVo3z+Nswtsdx5b/T3TWdY3njIZ17o9Iu3tKsaUtoKTp/cAhZ+V2+7+Wq8yS6DjL3LQMlRPhgSVH/derZeXViNHLyzkBRiR4uE6ama5EyaC3KzI6kEVDmuCE4pAOCvspMatbAtim0UXFBHe7fzwfg0JYlW3reL49Rz9Cn6G/04xCUIhr1eZCyhBJyh8YclEN8wkATPBULKD+qJS+eVX+rMLCMYvjBMBidNbkNfAKci/q7FR4My3KIl4TgWUVG8JodsNLkL7LtoFq/l5moqZCDczKMS/Q8SPnC7RQ27hNEg6IbSAkK8FmPH7BEkY2qNdF3uKMpxm8DGwI8XCeTPccKcQAyUPHFl8vhEuiIKA0FJdd5uAntDdc= is_derayo@HPDesktopZorin';
  local sName_='sshPublicKey' \
        ssh_=~/.ssh \
        rootSsh_=/root/.ssh \
        aKeys_=~/.ssh/authorized_keys;
  local msg_0='Configuring '$sName_' ...' \
        msg_1=$sName_' already configured...' \
        sS1_='' sS2_='';
  echo "";

  if [[ -d "$ssh_" ]] && [[ -f "$aKeys_" ]]; then
    sS1_=$(echo $(cat "$aKeys_" | grep "$pKey_1"));
    sS2_=$(echo $(cat "$aKeys_" | grep "$pKey_2"));
    if [[ "$sS1_" == "$pKey_1" ]] && [[ "$sS2_" == "$pKey_2" ]]; then echo $msg_1; sleep 5; return; fi;
  fi;
  echo $msg_0;

  mkdir -p $ssh_;
  chmod 700 $ssh_;
  touch $aKeys_;
  chmod 600 $aKeys_;

  if [[ "$sS1_" == "" ]]; then echo $pKey_1 >> $aKeys_; fi;
  if [[ "$sS2_" == "" ]]; then echo $pKey_2 >> $aKeys_; fi;

  sudo mkdir -p $rootSsh_;
  sudo chmod 700 $rootSsh_;
  sudo cp -pv $aKeys_ $rootSsh_;
  sudo chown -R root:root $rootSsh_;

  echo $sName_' has been configured...';
  sleep 10;
}



# -  - #
# - bashrc - #
function bashrc_(){
  local sWs_=$u150WServer_"/Arch.Img/Arch_Configuration/Arch_bashrc_fstab_pacman-conf.Ins/Bashrc-Zshrc(Latest)/" \
        bO_=Arch.bashrc \
        aO_=Arch.rc-Alias \
        rO_=root.profile \
        b_=~/.bashrc \
        a_=~/.rc-Alias \
        r_=.profile;
  local m0_='Configuring '$bO_'...' \
        m1_=$bO_' already configured...' \
        conf_='# - Configured - #' \
        sS1_='' sS2_='';
  echo "";

  if [[ -f "$b_" ]]; then
     sS1_=$(echo $(cat $b_ | grep -oF "$conf_" ));
     if [[ "$sS1_" == "$conf_" ]]; then echo $m1_; sleep 5; return; fi;
  fi;

  cd ~/;
  echo $m0_;
  curl $sWs_$bO_ -o $b_;
  curl $sWs_$aO_ -o $a_;
  curl $sWs_$rO_ -o $r_;

  sS1_=$(echo $(cat $b_ | grep -oF "$conf_" ));
  if [[ "$sS1_" == "" ]]; then
     sed -i "5 i # -  - #" $b_; 
     sed -i "6 i $conf_" $b_;
     sed -i "7 i # -  - #" $b_; 
  fi;

  sudo cp $b_ $a_ /root;
  sudo chown root:root $r_;
  sudo mv $r_ /root;

  cd $Dir_;
  echo -e $b_" file has been configured...\n\n\n";
  sleep 10;
}



# -  - #
# - DataBtrfs_ - #
function DataBtrfs_(){
  local svD_='Data' \
        sBtrfs_='';
  local m0_='Configuring Btrfs '$svD_' subvolumes...' \
        m1_='Btrfs '$svD_' subvolumes already configured...' \
        sS1_="# - Btrfs $svD_ configured - #" sS2_="" \
        aUser_=$adminUser_ dl='' \
        svDoc_='Documents' \
        svI_='Images';
  echo "";

  if [[ -f "$aDesktopConf_" ]]; then
    sS2_=$(echo $(cat $aDesktopConf_ | grep "$sS1_" ));
    if [[ "$sS2_" == "$sS1_" ]]; then echo $m1_; sleep 5; return; fi;
  fi;

  echo -e "\n\n\n$m0_\n\n\n";

  # - Check if Data subvolume exists - #
  sBtrfs_=$(echo $(sudo btrfs subvolume list /$svD_ | grep "@$svD_" ) | awk '{print $9;}');
  if [[ "$sBtrfs_" == "" ]]; then echo "Subvolume " $svD_" doesn't exist..."; return; fi;

  # - Check if subvolume Documents exists - #
  sBtrfs_=$(sudo btrfs subvolume list /$svD_ | grep -oF -m1 "$svDoc_");
  if [[ "$sBtrfs_" == "" ]]; then
    echo -e "Creating Btrfs "$svDoc_" subvolumes...\n\n";
    # -  - #
    # - Create btrfs Documents subvolumes - #
    sudo btrfs subvolume create /$svD_/$svDoc_;
    sudo btrfs subvolume create /$svD_/$svDoc_/Downloads;
    sudo btrfs subvolume create /$svD_/$svDoc_/Music;
    sudo btrfs subvolume create /$svD_/$svDoc_/Pictures;
    sudo btrfs subvolume create /$svD_/$svDoc_/Videos;

    echo -e "\n\n\nCreating Btrfs "$svI_" subvolumes...\n\n";
    # -  - #
    # - Create btrfs Images subvolumes - #
    sudo btrfs subvolume create /$svD_/$svI_;
    sudo btrfs subvolume create /$svD_/$svI_/Backup;
    sudo btrfs subvolume create /$svD_/$svI_/Programs;
    sudo btrfs subvolume create /$svD_/$svI_/VManager;

    sudo chown -R $aUser_:$aUser_ /$svD_;
    sudo chmod -R 775 /$svD_;

    echo -e "\n\n\nBtrfs Documents subvolumes...\n\n";
    sudo btrfs subvolume list /$svD_;
    echo "";
    read -t 3 -p '';
    sudo sed -i '5 i '"$sS1_" $aDesktopConf_;
  fi;

  echo -e "\n\nBtrfs $svD_ volumes configured successfully...\n\n\n";
  sleep 10;
}



# -  - #
# - ttf_ms_fonts_ - #
function ttf_ms_fonts_(){
  local ttfD_="https://www.education.isdevelopment.us/Arch.Ins/Software.Ins/" \
        ttfF_=ttf-ms-fonts.tar.bz2 \
        Down_=~/Downloads/ \
        fonts_=ttf-ms-fonts;

  echo -e "\nInstalling ttf-ms-fonts...";

  # -  - #
  # - ~/Downloads/ttf-ms-fonts.tar.bz2 - #
  cd $Down_;
  curl -O $ttfD_$ttfF_;
  tar -xvf $ttfF_;

  cd $fonts_;
  echo 'Y' | makepkg -sic PKGBUILD;

  cd $Dir_;
  rm -rf $Down_$fonts_*;
  echo "";
  sleep 10;
}



# -  - #
# - DataDirectories_ - #
function DataDirectories_(){
  local DDir_='Data directories' \
        configF_=~/.config/user-dirs.dirs \
        conf_='# - Configured - #';
  local m0_='Configuring '$DDir_' ...' \
        m1_=$DDir_' already configured...';
  local h_=home \
        d_=Data \
        doc_=Documents \
        dow_=Downloads \
        mus_=Music \
        pic_=Pictures \
        vid_=Videos \
        aUser_=$adminUser_ \
        sS1_='' sS2_='' searchZfs='';
  local zD_=$d_ \
        zDp_=DataPool;
  echo '';

  # cat /etc/fstab | grep "Data" | grep -v "DataPool"

  mkdir -p ~/.config;
  if [[ -f "$configF_" ]]; then
     sS1_=$(echo $(cat $configF_ | grep -oF "$conf_" ));
     if [[ "$sS1_" == "$conf_" ]]; then echo $m1_; sleep 5; return; fi;
  fi;

  sS1_='/'$d_;    # /Data
  if [[ ! -d "$sS1_" ]]; then \
     echo '/Data directoty does not exist in the system...'; sleep 5; return; fi;

  echo $m0_;
  sudo mkdir -p /$d_;
  sudo chown -R $aUser_:$aUser_ /$d_;
  sudo chmod -R 775 /$d_;
   
  echo "";
  echo "Creating Documents directories...";
  mkdir -p /$d_/$doc_;
  mkdir -p /$d_/$doc_/$dow_;
  mkdir -p /$d_/$doc_/$mus_;
  mkdir -p /$d_/$doc_/$pic_;
  mkdir -p /$d_/$doc_/$vid_;

  sudo rm -rf /$h_/$aUser_/$doc_;
  sudo rm -rf /$h_/$aUser_/$dow_;
  sudo rm -rf /$h_/$aUser_/$mus_;
  sudo rm -rf /$h_/$aUser_/$pic_;
  sudo rm -rf /$h_/$aUser_/$vid_;

  ln -s /$d_/$doc_ /$h_/$aUser_/$doc_;
  ln -s /$d_/$doc_/$dow_ /$h_/$aUser_/$dow_;
  ln -s /$d_/$doc_/$mus_ /$h_/$aUser_/$mus_;
  ln -s /$d_/$doc_/$pic_ /$h_/$aUser_/$pic_;
  ln -s /$d_/$doc_/$vid_ /$h_/$aUser_/$vid_;

  mkdir -p /$d_/$doc_/ToShare-FullAccess;
  mkdir -p /$d_/$doc_/ToShare-JustRead;

  chmod 777 /$d_/$doc_/ToShare-FullAccess;
  chmod 777 /$d_/$doc_/ToShare-JustRead;

  echo "Deleting $configF_ configuration file...";
  rm -rf $configF_;

  echo "Creating new $configF_ configuration file...";


rm -rf $configF_;
cat <<EOT >>$configF_;
# -  - #
# - Configured - #
# - nvim ~/.config/user-dirs.dirs - #
# -  - #

XDG_DOCUMENTS_DIR="/$d_/$doc_"
XDG_DOWNLOAD_DIR="/$d_/$doc_/$dow_"
XDG_MUSIC_DIR="/$d_/$doc_/$mus_"
XDG_PICTURES_DIR="/$d_/$doc_/$pic_"
XDG_VIDEOS_DIR="/$d_/$doc_/$vid_"

EOT

  sed -i '6 i XDG_DESKTOP_DIR="$HOME/Desktop"' $configF_;
  sed -i '7 i XDG_TEMPLATES_DIR="$HOME/Templates"' $configF_;
  sed -i '8 i XDG_PUBLICSHARE_DIR="$HOME/Public"' $configF_;

  echo -e "\n$DDir_ have been configured...";
  sleep 10;
}



# -  - #
# - Brave_ - #
function Brave_(){
  local bWServer_=$u150WServer_$sAws_"Brave.Ins/" \
        sD_=~/Downloads/ \
        bTar_=Brave.tar.bz2 \
        aHome_=~/.local/share/applications/ \
        aF_=Brave.desktop \
        bImage_=Brave-Web-Browser-Debian-x86-64.AppImage \
        iHome_=~/.AppImages/ \
        bF_=Brave \
        bIcon_=Brave.png;

  echo -e "\nInstalling $bF_...";

<<'comment'
  mkdir -p ~/.local/share/applications;
  mkdir -p ~/.AppImages/Brave;
comment

  mkdir -p $aHome_ $iHome_$bF_;
  rm -rf $aHome_$aF_;


cat <<EOT >> $aHome_$aF_;
[Desktop Entry]
Type=Application
Name=$bF_
Comment=Internet browser
Exec=$iHome_$bF_/$bImage_
Icon=$iHome_$bF_/$bIcon_
Terminal=false
StartupWMClass=$bF_
StartupNotify=false
Categories=Network;
EOT

  cd $sD_;

  # -  - #
  # - ~/Downloads/Brave.tar.bz2 - #
  curl -O $bWServer_$bTar_;

  # -  - #
  # - Untar - #
  tar -xvf $bTar_;

  cd $bF_.Ins;
  chmod +x $bImage_;

  mv $bImage_ $bIcon_ $iHome_$bF_;
  cd ..;
  rm -rf $bF_.*;

  cd $Dir_;
  echo "";
  sleep 10;
}



# -  - #
# - BalenaEtcher_ - #
function BalenaEtcher_(){
  local bWServer_=$u150WServer_$sAws_"BalenaEtcher.Ins/" \
        sD_=~/Downloads/ \
        bTar_=BalenaEtcher.tar.bz2 \
        aHome_=~/.local/share/applications/ \
        aF_=BalenaEtcher.desktop \
        bImage_=balenaEtcher-1.18.4-x64.AppImage \
        iHome_=~/.AppImages/ \
        bF_=BalenaEtcher \
        bIcon_=BalenaEtcher2.png;

  echo -e "\nInstalling $bF_...";

<<'comment'
  mkdir -p ~/.local/share/applications;
  mkdir -p ~/.AppImages/BalenaEtcher;
comment

  mkdir -p $aHome_ $iHome_$bF_;
  rm -rf $aHome_$aF_;

cat <<EOT >> $aHome_$aF_;
[Desktop Entry]
Type=Application
Name=$bF_
Comment=Burn ISO files to USB stick
Exec=$iHome_$bF_/$bImage_
Icon=$iHome_$bF_/$bIcon_
Terminal=false
StartupWMClass=$bF_
Categories=System;
StartupNotify=false
EOT

  cd $sD_;

  # -  - #
  # - ~/Downloads/BalenaEtcher.tar.bz2 - #
  curl -O $bWServer_$bTar_;

  # -  - #
  # - Untar - #
  tar -xvf $bTar_;

  cd $bF_.Ins;
  chmod +x $bImage_;

  mv $bImage_ $bIcon_ $iHome_$bF_;
  cd ..;
  rm -rf $bF_.*;

  cd $Dir_;
  echo "";
  sleep 10;
}



# -  - #
# - ClipGrab_ - #
function ClipGrab_(){
  local bWServer_=$u150WServer_$sAws_"ClipGrab.Ins/" \
        sD_=~/Downloads/ \
        bTar_=ClipGrab.tar.bz2 \
        aHome_=~/.local/share/applications/ \
        aF_=ClipGrab.desktop \
        bImage_=ClipGrab-3.9.14-x86_64.AppImage \
        iHome_=~/.AppImages/ \
        bF_=ClipGrab \
        bIcon_=ClipGrabIcon1.png;

  echo -e "\nInstalling $bF_...";

<<'comment'
  mkdir -p ~/.local/share/applications;
  mkdir -p ~/.AppImages/ClipGrab;
comment

  mkdir -p $aHome_ $iHome_$bF_;
  rm -rf $aHome_$aF_;

cat <<EOT >> $aHome_$aF_;
[Desktop Entry]
Type=Application
Name=$bF_
Comment=Youtube video downloader
Exec=$iHome_$bF_/$bImage_
Icon=$iHome_$bF_/$bIcon_
Terminal=false
StartupWMClass=$bF_
Categories=Network;
StartupNotify=false
EOT

  cd $sD_;

  # -  - #
  # - ~/Downloads/ClipGrab.tar.bz2 - #
  curl -O $bWServer_$bTar_;

  # -  - #
  # - Untar - #
  tar -xvf $bTar_;

  cd $bF_.Ins;
  chmod +x $bImage_;

  mv $bImage_ $bIcon_ $iHome_$bF_;
  cd ..;
  rm -rf $bF_.*;

  cd $Dir_;
  echo "";
  sleep 10;
}



function cleaning_(){

  echo -e "\nCleaning system cache...";
  sudo pacman -Scc --noconfirm;

  echo 'Removing orphan packages...';
  sudo pacman -R $(pacman -Qtdq) --noconfirm;

  echo 'Cleaning user cache...';
  sudo du -sh ~/.cache/;
  rm -rf ~/.cache/*;
  sudo rm -rf ~/.cache/*;

  echo -e "Cleaning done...\n";
}



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

  rm -rf $tmp_;

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

$sS_



# - eof - #
EOT

  sudo mv $tmp_ $aDesktopConf_;
  sudo chown -R root:root $aDesktopConf_;
  echo -e "\n\n";
}
comment


# -  - #
# - samba - #
function samba_(){
  local sWs_=https://www.education.isdevelopment.us/Arch.Ins/Software.Ins/Bashrc-Zshrc.Ins/ \
        sH_=/etc/samba/smb.conf \
        sF_=smb.conf \
        gF_=/etc/group \
        pF_=/etc/passwd \
        sS_=sambashare \
        sU_='smbguest' \
        aU_=$adminUser_ \
        aP_=$adminPasswd_;
  local m0_='Configuring '$sH_' ...' \
        m1_=$sH_' already configured...' \
        sS1_="# - Configured - #" sS2_='' sS3_='' sS4_='';
  echo "";

  if [[ -f "$sH_" ]]; then
    sS2_=$(echo $(cat $sH_ | grep "$sS1_" ));
    if [[ "$sS2_" == "$sS1_" ]]; then echo $m1_; sleep 5; return; fi;
  fi;

  echo -e "\n\n\n"$m0_;

  echo -e "\nCreating $sS_ group...";
  sudo groupadd -r $sS_;

  echo "Creating $sU_ user...";
  sudo useradd -r -s /usr/bin/nologin $sU_;

  echo "Creating $sU_ user password...";
  (echo $sU_; sleep 1; echo $sU_ ) | sudo passwd $sU_;

  echo "Adding $sU_ user to $sS_ group...";
  sudo usermod -aG $sS_ $sU_;

  echo "Adding $aU_ user to $sS_ group...";
  sudo usermod -aG $sS_ $aU_;

  echo "Enabling $sU_ user in samba...";
  sudo gpasswd $sS_ -a $sU_;

  echo "Enabling $aU_ user in samba...";
  sudo gpasswd $sS_ -a $aU_;

  echo "Creating $sU_ user password on samba...";
  (echo $sU_; sleep 1; echo $sU_ ) | sudo pdbedit -a -u $sU_;

  echo "Creating $aU_ user password on samba...";
  (echo $aP_; sleep 1; echo $aP_ ) | sudo pdbedit -a -u $aU_;

  echo "";
  cat $gF_ | grep $sU_;
  cat $gF_ | grep $aU_;

  cat $pF_ | grep $sU_;
  cat $pF_ | grep $aU_;


  echo -e "\nGenerating $sH_..."

  cd ~/;
  curl $sWs_$sF_ -o $sF_;
  sed -i "s/adminUser_/$aU_/" $sF_;
  sudo mv $sF_ $sH_;

  echo -e "\nRestart samba service...";
  sudo systemctl enable --now smb nmb;
  sudo systemctl start smb.service nmb.service
  echo -e "\n$sH_ has been configured...\n";
  sleep 10;
}



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



checkComputer_ Arch_PostInstallation.sh;
Greetings_;
distroVersion_;
AdditionalSoftware_;
sshPublicKey_;
bashrc_;
DataBtrfs_;
DataDirectories_;
samba_;

rm -rf ~/Arch_PostInstallation.sh;



cleaning_;

echo -e "\n\n";
duf;
echo -e "\n\nPost installation is done...";
echo -e "System will shutdown now so changes will reflect...\n\n\n";
sleep 10;



sudo shutdown now;
sudo reboot now;



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



# - eof - #