#!/bin/bash

# To download and execute
# curl -s https://corpum.com/root.sh | bash

# To set up larger font on system
# dpkg-reconfigure console-setup


#CHANGE HOSTNAME
#EDIT /etc/hostname
#EDIT /etc/hosts
# or 
hostnamectl set-hostname nostr;


#CREATE MY DIRECTORIES
mkdir /root/Downloads;
mkdir /root/Applications;
mkdir /root/Temp;
mkdir /root/Trash;


#UPDATE THE SYTEM
apt update -y;
# apt upgrade -y;

#GENERAL TOOLS
apt install htop -y
apt install ranger -y
apt install sshfs -y
apt install curl -y
apt install vim -y
apt install secure-delete -y
apt install jq -y
apt install wget -y
# apt-get install syncthing -y
add-apt-repository ppa:arduino-team/arduino-stable
apt update
apt install arduino -y
apt install font-manager -y
apt install -y docker.io
systemctl start docker
apt install moreutils -y;

#NODE
# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash

# nvm install node


#FUN 
apt install cmatrix -y

#############################################################################
#             ALIAI
#############################################################################

#            BASIC COMMANDS
#############################################################################
echo "alias ll='ls -l'" >> ~/.bashrc
echo "alias la='ls -a'" >> ~/.bashrc
echo "alias lla='ls -al'" >> ~/.bashrc
echo "alias l='ls -CF'" >> ~/.bashrc
echo "alias ss='gnome-screenshot -a'" >> ~/.bashrc
echo "alias untargz='tar -xzf'" >> ~/.bashrc


#            (DE)COMPRESSION
#############################################################################
echo "alias un.tar.bz2='tar xvjf'" >> ~/.bashrc
echo "alias un.tar.gz='tar -xzf'" >> ~/.bashrc
echo "alias un.gz=gunzip" >> ~/.bashrc


#            FINAL
#############################################################################
echo "Run 'source .bashrc' to load aliai."

#            BACKGROUND COLOR
#############################################################################
gsettings set org.gnome.desktop.background picture-options 'none'
gsettings set org.gnome.desktop.background primary-color '#000000'



printf "

#############################################################################
#            TOR
#############################################################################

"
# apt update;
apt install -y tor;
apt install -y apt-transport-tor;

sed -i 's/#ControlPort 9051/ControlPort 9051/' /etc/tor/torrc
sed -i 's/#CookieAuthentication 1/CookieAuthentication 0/' /etc/tor/torrc
/etc/init.d/tor restart


printf "\n\n****** Current IP******"
curl ifconfig.me

printf "\n\n******  Tor IP   ******"
# torify curl ifconfig.me 2>/dev/null
torify curl checkip.amazonaws.com 

echo "Press any key to continue..."
read -n 1 -s




printf "\n


#############################################################################
#          MULLVAD
#############################################################################


\n
"
#torify wget http://o54hon2e2vj6c7m3aqqu6uyece65by3vgoxxhlqlsvkmacw6a7m7kiad.onion/en/download/app/deb/latest

torify curl -fsSLo /usr/share/keyrings/mullvad-keyring.asc https://repository.mullvad.net/deb/mullvad-keyring.asc;
printf "deb [signed-by=/usr/share/keyrings/mullvad-keyring.asc arch=$( dpkg --print-architecture )] https://repository.mullvad.net/deb/stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/mullvad.list;

apt update;
apt install mullvad-vpn;

mullvad account login 6627506529903776;
mullvad lockdown-mode set on;
mullvad relay set location ch;
mullvad connect;

while true; do
  # Run the command
  mullvad status;

  # Ask for confirmation to run it again
  read -p "Run again? (y/n) " answer

  # Check the answer and break the loop if it's not "y"
  case $answer in
    y|Y) continue ;;
    n|N) break ;;
    *) echo "Invalid input. Please enter y or n." ;;
  esac
done



# echo "Press any key to continue..."
# read -n 1 -s



printf "\n


#############################################################################
#            NOSTR
#############################################################################
"

# Nostr Army Knife (NAK)
curl -L -o /usr/local/bin/nak https://github.com/fiatjaf/nak/releases/download/v0.11.3/nak-v0.11.3-linux-amd64
chmod +x /usr/local/bin/nak

# Stirfry Nostr Relay
# sudo apt install -y git g++ make libssl-dev zlib1g-dev liblmdb-dev libflatbuffers-dev libsecp256k1-dev libzstd-dev
# cd /usr/local/bin
# git clone https://github.com/hoytech/strfry && cd strfry/
# git submodule update --init
# make setup-golpe
# make -j4



#  Nostr Alai
timestamp=$(date +%s); nak req -s $timestamp -k 1 --stream $nak_relays_read | jq -r '"\n\(.pubkey[-5:])\n     \(.content)\n"'
echo "alias un.gz=gunzip" >> ~/.bashrc
alias nostr_all='timestamp=$(date +%s); nak req -s $timestamp -k 1 --stream $nak_relays_read | jq -r '\''"\n\(.pubkey[-5:])\n     \(.content)\n"'\'''

echo "alias nostr_all='timestamp=\$(date +%s); nak req -s \$timestamp -k 1 --stream \$nak_relays_read | jq -r '\''\"\n\(.pubkey[-5:])\n     \(.content)\n\"'\''" >> ~/.bashrc

# Nostr terminal
curl -L -o /usr/local/bin/nt https://corpum.com/nt
chmod +x /usr/local/bin/nt

printf "
#############################################################################
#            CLEAR COMMAND LINE HISTORY
#############################################################################
"
history -c

