docker-qemu-reactos/scripts/bin/container-init
Héctor Molinero Fernández 88a1b868a8 Shutdown services gracefully
2021-11-02 19:23:18 +01:00

23 lines
534 B
Bash
Executable File

#!/bin/sh
set -eu
# Create ReactOS disk
if [ ! -f /var/lib/qemu/images/reactos.img ]; then
qemu-img create -f qcow2 /var/lib/qemu/images/reactos.img "${VM_DISK_SIZE:?}"
fi
stop() {
for s in "${SVDIR:?}"/*; do sv force-stop "${s:?}" >/dev/null 2>&1; done
kill -HUP "${RUNSVDIRPID:?}"; wait "${RUNSVDIRPID:?}"
}
trap stop EXIT TERM INT HUP
if [ "$#" -gt 0 ] || [ -t 0 ] || [ -t 1 ]; then
runsvdir -P "${SVDIR:?}" >/dev/null 2>&1 & RUNSVDIRPID=$!
"$@"
else
runsvdir -P "${SVDIR:?}" & RUNSVDIRPID=$!
wait "${RUNSVDIRPID:?}"
fi