diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index b3c0310..9512c82 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -3,12 +3,6 @@ set -euo pipefail API_SOCKET="/hy.socks" -_stop() { - ch-remote --api-socket "$API_SOCKET" power-button -} - -trap _stop EXIT TERM - /usr/bin/cloud-hypervisor \ --kernel /boot/vmlinuz-virt --initramfs /boot/initramfs-virt \ --disk path=/image/vm.raw,image_type=raw \ @@ -17,5 +11,15 @@ trap _stop EXIT TERM --cmdline "root=/dev/vda rootfstype=ext4 modules=ext4a rw console=hvc0" \ --cpus boot=${CPU_COUNT:-4} \ --memory size=${MEMORY:-4G},shared=on \ - --net "tap=$NET_INTERFACE,mac=$NET_MAC" - $@ + --net "tap=$NET_INTERFACE,mac=$NET_MAC" \ + $@ & + +CH_PID=$! + +_stop() { + ch-remote --api-socket "$API_SOCKET" power-button +} + +trap _stop TERM + +wait $CH_PID \ No newline at end of file