#!/bin/sh

#update
sudo apt update
#upgrade
sudo apt upgrade -y
#install necessary dependencies
sudo apt install -y sudo
sudo apt install -y apt-transport-https
sudo cat << EOF | sudo tee /etc/apt/sources.list.d/tor.list
deb     [arch=arm64 signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org bookworm main
deb-src [arch=arm64 signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org bookworm main
EOF
sudo apt update
sudo apt install -y tor deb.torproject.org-keyring
sudo systemctl start tor
sudo apt install -y ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw logging off
sudo ufw enable
sudo systemctl enable ufw
sudo apt install -y nginx
sudo apt install -y libnginx-mod-stream
sudo apt install -y python3-pip
sudo apt install -y curl
sudo apt install -y git --install-recommends
sudo apt install -y nodejs
sudo apt install -y mariadb-server
sudo apt install -y mariadb-client
sudo apt install -y npm
sudo apt install -y libssl-dev
sudo apt install -y fail2ban
echo -e "[sshd]\nenabled=true" | sudo tee /etc/fail2ban/jail.local && echo -e "[sshd]\nbackend=systemd\nenabled=true" | sudo tee /etc/fail2ban/jail.local
sudo systemctl restart fail2ban
sudo apt install -y jq
sudo adduser --system --disabled-password --shell /bin/bash --group --home /home/bitcoin bitcoin
sudo adduser --system --disabled-password --shell /bin/bash --group --home /home/fulcrum fulcrum
sudo adduser --system --disabled-password --shell /bin/bash --group --home /home/mempool mempool
sudo adduser --system --disabled-password --shell /bin/bash --group --home /home/lnd lnd
sudo adduser --system --disabled-password --shell /bin/bash --group --home /home/thunderhub thunderhub
sudo adduser bitcoin debian-tor
sudo adduser mempool bitcoin
sudo adduser fulcrum bitcoin
sudo adduser mempool debian-tor
sudo adduser fulcrum debian-tor
cd /home/admin/
#
sudo cat << EOF | sudo tee -a /var/spool/cron/crontabs/root
*/1 * * * * /home/admin/cookie.sh
EOF

sudo service cron restart

sudo chmod +x /home/admin/cookie.sh
#
sudo cp bitcoin2.sh /home/bitcoin/bitcoin2.sh
sudo chmod +x /home/bitcoin/bitcoin2.sh
sudo chown bitcoin:bitcoin /home/bitcoin/bitcoin2.sh
#
sudo chmod +x /home/admin/fulcrum.sh
#sudo chown admin:admin /admin/fulcrum.sh
#
sudo cp mempool.sh /home/mempool/mempool.sh
sudo chmod +x /home/mempool/mempool.sh
sudo chown mempool:mempool /home/mempool/mempool.sh
#
sudo cp mempool2.sh /home/mempool/mempool2.sh
sudo chmod +x /home/mempool/mempool2.sh
sudo chown mempool:mempool /home/mempool/mempool2.sh
#
#sudo cp bitcoin2.sh /home/bitcoin/bitcoin2.sh
sudo chmod +x /home/admin/mempool3.sh
#sudo chown mempool:mempool /home/admin/mempool3.sh
#
#
sudo chmod +x /home/admin/bitcoin.sh
sudo chmod +x /home/admin/lnurl.sh

cd && rm system.sh
./bitcoin.sh
