#!/bin/bash
dpkg-reconfigure openssh-server
useradd -m nginx
case $(hostname) in 
    webserver1)
    # the "northbound" interface towards jumphost1-eth1<->eth1-webserver1
    ip addr replace dev eth1 172.16.200.11/24
    ip addr replace dev eth1 fd4c:00a6:b6a7::af/127
    # create a test file to view/download
    su - nginx -c 'echo "welcome!" > /home/nginx/webserver1.txt'
    # spawn python3 http server (with ipv6 support)
    # su - nginx -c 'python3 -m http.server 31337 --bind ::'
    (su - nginx -c 'python3 /usr/local/bin/webserver.py 31337') &
    ;;

    webserver2)
    # the "northbound" interface towards jumphost2-eth1<->eth1-webserver2
    ip addr replace dev eth1 172.16.201.12/24
    ip addr replace dev eth1 fd4c:00a6:b6a7::cf/127
    # create a test file to view/download
    su - nginx -c 'echo "welcome (again)!" > /home/nginx/webserver2.txt'
    su - nginx -c 'echo "...is a lie." > /home/nginx/CAKE'
    # spawn python3 http server (with ipv6 support)
    # su - nginx -c 'python3 -m http.server 41337 --bind ::'
    (su - nginx -c 'python3 /usr/local/bin/webserver.py 41337') &
    ;;
esac

# service started in case above
/usr/sbin/sshd -D
