#!/bin/bash
# Copyright 2021-2022 Ian Jackson, Simon Tatham, and contributors to Hippotat
# SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Hippotat-OpenSSL-Exception
# There is NO WARRANTY.

set -e

fifo=tmp/uml/q
mkfifo -m600 $fifo

(
 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=991958
 : <$fifo
 cat
) 								| 	\
 bwrap --dev-bind / / --tmpfs /dev/shm					\
 linux mem=512M rootfstype=hostfs rootflags=/ rw			\
       con=fd:2,fd:2 con1=fd:0,fd:1 init="${0%/*}"/psusan-uml-inside  	\
       -- psusan-uml-tmp=$PWD/tmp/uml				|	\
(
 read banner
 : >$fifo
 printf '%s\n' "$banner"
 cat
)
