#!/bin/bash -e

sudo apt install wireguard systemd-resolved \
    unattended-upgrades postfix dovecot-imapd rsync apache2 kamailio

( umask 377
  echo "AJkzVxfTm/KvRjzTN/9X2jYy+CAugiwZfN5F3JTegms=" \
  | sudo tee /etc/wireguard/private-key >/dev/null )

( cd
  umask 077
  if [ ! -d .ssh ]; then mkdir .ssh; fi
  ( echo -n "ssh-rsa"
    echo -n " AAAAB3NzaC1yc2EAAAADAQABAAABgQDXxXnqFaUq3WAmmW/P8OMm3cf"
    echo -n "AGJoL1UC8yjbsRzt63RmusID2CvPTJfO/sbNAxDKHPBvYJqiwBY8Wh2V"
    echo -n "BDXoO2lWAK9JOSvXMZZRmBh7Yk6+NsPSbeZ6H3DgzdmKubs4E5XEdkmO"
    echo -n "iivyiGBWiwzDKAOqWvb60yWDDNEuHyGNznKjyL+nAOzul1hP5f23vX3e"
    echo -n "VhTxV0zdClksvIppGsYY3EvhMxasnjvGOhECz1Pq/9PPxakY1kBKMFj8"
    echo -n "yh75UfYJyRiUcFUVZD/dQyDMj7gtihv4ANiUAIgn94I4Gt9t8a2OiLyr"
    echo -n "KhJAwTQrs4CA+suY+3uDcp2FuQAvuzpa2moUufNetQn9YYCpCQaio8I3"
    echo -n "N9N5POqPGtNT/8Fv1wwWsl/T363NJma7lrtQXKgq52YYmaUNnHxPFqLP"
    echo -n "/9ELaAKbKrXTel0ew/LyVEO6QJ6fU7lE3LYMF5DngleOpuOHyQdIJKvS"
    echo -n "oCb7ilDuG8ekZd3ZEROhtyHlr7UcHrtmZMYjhlRc="
    echo " A Small Institute Administrator" ) \
  >>.ssh/authorized_keys )

( cd /etc/network/; \
  [ -f interfaces~ ] || sudo mv interfaces interfaces~ )
cat <<EOF | sudo tee /etc/network/interfaces >/dev/null
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto enp0s3
iface enp0s3 inet static
    address 192.168.15.4/24
    gateway 192.168.15.1

# Testing interface
auto enp0s8
iface enp0s8 inet static
    address 192.168.58.3/24
EOF

( cd front_ssh/; sudo cp -b ssh_host_* /etc/ssh/ )
