#!/bin/sh set -e [ -e "/dev/net/tun" ] || { echo "/dev/net/tun not found. Is the container running in privileged mode?"; exit 1; } [ -n "$DISK_FILENAME" ] || DISK_FILENAME="rq0.dsk" echo -n "Checking for disk... " if [ -f "/mnt/$DISK_FILENAME" ]; then [ -w "/mnt/$DISK_FILENAME" ] || { echo "Disk /mnt/$DISK_FILENAME exists and is not writable"; exit 1; } echo "Disk found and is writable." else [ -w "/mnt/" ] || { echo "Disk /mnt/$DISK_FILENAME not found and /mnt not writable"; exit 1; } [ -f "/rq0.dsk.gz" ] || { echo "Disk /mnt/$DISK_FILENAME not found and image was not built with a default disk"; exit 1; } echo "Disk not found." echo "Extracting default disk image..." gzip -cd /rq0.dsk.gz > "/mnt/$DISK_FILENAME" || { echo "Failed to extract default disk image to /mnt/$DISK_FILENAME"; exit 1; } fi # Start CoreDNS as soon as possible after validations done echo "Starting CoreDNS..." [ -z "$COREDNS_DEBUG" ] && COREDNS_QUIET="-quiet" coredns "$COREDNS_QUIET" -conf /Corefile & # Set exit command only if NOEXIT not set [ -z "$NOEXIT" ] && EXIT_CMD="exit" || EXIT_CMD="" echo "Configuring simh..." # Allow overriding boot.ini.template [ -f /mnt/boot.ini.template ] && cp -f /mnt/boot.ini.template /mnt/boot.ini.template sed -e "s//${DISK_FILENAME}/" \ -e "s//${EXIT_CMD}/" /boot.ini.template > /boot.ini echo "Configuring networking..." [ -z "$CIDR" ] && CIDR=28 [ -z "$HOSTIP" ] && HOSTIP=1.3.3.1 [ -z "$PDPIP" ] && PDPIP=1.3.3.7 ip tuntap add pdp mode tap ip link set pdp up ip addr add "${HOSTIP}/${CIDR}" dev pdp iptables -t nat -A PREROUTING ! -i pdp -p tcp --dport 4000 -j ACCEPT # dz serial device iptables -t nat -A PREROUTING ! -i pdp -j DNAT --to-destination "$PDPIP" iptables -t nat -A POSTROUTING ! -o pdp -j MASQUERADE echo "Booting PDP-11..." pdp11 /boot.ini