#!/bin/bash

if [ "$EUID" -ne 0 ]
then
  echo "Please run as root!"
  exit
fi

apt update

apt install --no-install-recommends ufw xserver-xorg x11-xserver-utils xinit openbox -y
apt install git gcc g++ make cmake chromium-browser unclutter -y
apt purge nodejs npm -y

# XServer
echo "allowed_users=anybody" >/etc/X11/Xwrapper.config
cp autostart.config /etc/xdg/openbox/autostart


# Keys and stuff ---
# Nodejs
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash

# Yarn
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

# MongoDB
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list

# End Keys and stuff ---


# Firewall
ufw allow ssh
ufw allow 3000/tcp
ufw allow 3015/tcp
ufw --force enable

# Final update
apt update
apt install nodejs yarn mongodb-org -y
apt upgrade -y

systemctl daemon-reload
systemctl enable mongod

reboot now
