export DEBIAN_FRONTEND=noninteractive
cd $HOME

HBASE_VERSION=2.4.9
HBASE_ARCHIVE=hbase-$HBASE_VERSION-bin.tar.gz

# HBase
sudo apt-get -y install default-jdk-headless
wget -nv https://archive.apache.org/dist/hbase/$HBASE_VERSION/$HBASE_ARCHIVE
tar xvf $HBASE_ARCHIVE
rm $HBASE_ARCHIVE

echo "export PATH=$PATH:$HOME/hbase-2.4.9/bin" >> ~/.profile
echo "export JAVA_HOME=/usr/lib/jvm/default-java" >> ~/.profile
# MongoDB
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
echo "deb https://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
sudo apt-get update
sudo apt-get -y install mongodb-org
# Neo4J
wget -O - https://debian.neo4j.com/neotechnology.gpg.key | sudo apt-key add -
echo 'deb https://debian.neo4j.com stable latest' | sudo tee -a /etc/apt/sources.list.d/neo4j.list
sudo apt-get update
sudo apt-get -y install neo4j
# zwei Zeilen in /etc/neo4j/neo4j.conf aktivieren (cf. https://neo4j.com/docs/operations-manual/current/configuration/password-and-user-recovery/)
# dbms.security.auth_enabled=false
sudo sed -i "s/^#dbms.security.auth_enabled/dbms.security.auth_enabled/g" /etc/neo4j/neo4j.conf
# dbms.default_listen_address=0.0.0.0
sudo sed -i "s/^#dbms.default_listen_address/dbms.default_listen_address/g" /etc/neo4j/neo4j.conf
# Zugriffsrechte Import-Verzeichnis anpassen
sudo chmod a+w /var/lib/neo4j/import
# Postgres
# cf. https://linuxhint.com/install-postgresql-debian/
sudo apt -y install postgresql postgresql-contrib
sudo systemctl disable postgresql
# externer Zugriff:
# * in /etc/postgresql/13/main/pg_hba.conf allow
echo 'host      all     all     0.0.0.0/0       md5' | sudo tee -a /etc/postgresql/13/main/pg_hba.conf
# * /etc/postgresql/13/main/postgresql.conf listen
sudo sed -i "s/^#listen_addresses.*$/listen_addresses = '*'/g" /etc/postgresql/13/main/postgresql.conf
echo "CREATE USER student WITH PASSWORD '123456';" | sudo -i -u postgres psql
echo "CREATE DATABASE student;" | sudo -i -u postgres psql
echo "GRANT ALL PRIVILEGES ON DATABASE student TO student;" | sudo -i -u postgres psql
sudo apt-get -y install redis
sudo systemctl disable redis

# cf. https://askubuntu.com/questions/217358/how-can-i-display-my-machines-ip-address-on-a-tty-login-screen
cat << 'EOF' > /tmp/update-issue
#!/bin/sh
MSG=$(cat /etc/issue | grep -v IP)
IP_ADDRESSES=$(/sbin/ifconfig | grep 'inet' | grep -v '127' |grep -v 'inet6'|awk '{ print $2 }'
)
printf "%s\n" "$MSG" > /etc/issue
for i in $IP_ADDRESSES; do
  printf "%s\n" "IP: $i" >> /etc/issue
done;
EOF
sudo mv /tmp/update-issue /etc/network/if-up.d/
sudo chmod 0755 /etc/network/if-up.d/update-issue
# Linuxlogo :-)
sudo apt-get -y install linuxlogo
echo "linuxlogo" >> ~/.profile

# set locale
sudo apt-get -y install locales
sudo sed -i 's/^# *\(de_DE.UTF-8\)/\1/' /etc/locale.gen
sudo locale-gen
# set timezone
sudo timedatectl set-timezone Europe/Berlin

#  (apt-)cache löschen
sudo rm -rf /var/cache/*