#!/usr/bin/zsh

echo "[+] Enabling the SSH Service"
sudo systemctl enable ssh
sudo systemctl start ssh

echo "[+] Enabled, push your SSH key via 'ssh-copy-id -i lkey.pub kali@<ip>'"
echo "[+] SSH Config File"
echo "Host kali"
echo "    HostName 192.168.122.XXX"
echo "    User kali"
echo "    IdentityFile $home/documents/keys/KEY"

echo -n "[*] Do you want to install all packages via apt? [y/n] "
read yesno

if [[ "$yesno" == "y" ]]; then
    sudo apt install ripgrep neovim fzf hexyl vifm feh xclip xrdp python3-pip
fi

echo "[+] Enabling XRDP, get ready for Remmina ;)"
sudo systemctl enable xrdp
sudo systemctl start xrdp


# .zpretzo
echo -n "[*] Do you want to install zpretzo? [y/n] "
read yesno

if [[ "$yesno" == "y" ]]; then
    cd $HOME
    [ ! -d "$HOME/.zprezto" ] && git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"

    setopt EXTENDED_GLOB
    for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
      rm -rf "${ZDOTDIR:-$HOME}/.${rcfile:t}"
      echo "[*] Symlinking $rcfile -> ${ZDOTDIR:-$HOME}/.${rcfile:t}"
      ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
    done
fi


echo -n "[*] Copy (and overwrite) dotfiles? [y/n] "
read yesno

if [[ $yesno -eq "y" ]]; then
    backup_dir=/tmp/dotfiles-backup-$(date "+%H%M%S")
    rsync --backup --backup-dir $backup_dir --exclude .git/ --exclude install.sh -r . $HOME
    echo "[+] Dotfiles installed :) Backup available @ $backup_dir"
fi


# Creating vim folders
mkdir -p $HOME/.config/nvim/backups
mkdir -p $HOME/.config/nvim/undo

# Creating other needed folders
mkdir $HOME/documents
mkdir $HOME/documents/tools
mkdir $HOME/documents/bin
# setup SSH Folders & default import rule
mkdir $HOME/.ssh
mkdir $HOME/.ssh/config.d/
echo "Include config.d/*" > $HOME/.ssh/config

# Cleaning default folders
rm -rf $HOME/Documents
rm -rf $HOME/Pictures
rm -rf $HOME/Public
rm -rf $HOME/Videos
rm -rf $HOME/Templates
rm -rf $HOME/Music
rm -rf $HOME/Desktop

echo "[+] Done :)"
