From 7a103d054e0223b252ab979fc1b3b0d4f3d44d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Tue, 11 Sep 2018 20:55:33 +0200 Subject: [PATCH] Halt the VM automatically --- config.scm | 7 +++++-- to-be-run-in-vm.sh | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/config.scm b/config.scm index 42fc14e..ebdc696 100644 --- a/config.scm +++ b/config.scm @@ -1,5 +1,6 @@ (use-modules (gnu) - (gnu services shepherd)) + (gnu services shepherd) + (gnu packages admin)) (define my-service (shepherd-service-type @@ -9,7 +10,9 @@ (documentation "This command is executed when the GUIX system boots.") (provision '(my-stuff)) (start #~(lambda () - (system "(read len < /dev/sdb; dd if=/dev/sdc bs=1 count=$len | sh) > /dev/tty1"))))))) + (system (string-append "(read len < /dev/sdb; head -c $len < /dev/sdc | sh -s " + #$shepherd + ") > /dev/tty1")))))))) (operating-system (bootloader diff --git a/to-be-run-in-vm.sh b/to-be-run-in-vm.sh index 46cf757..3da6aa7 100644 --- a/to-be-run-in-vm.sh +++ b/to-be-run-in-vm.sh @@ -1,5 +1,12 @@ #!/bin/sh +if [ "$#" -ne 1 ]; then + echo "Usage: $0 shepherd" + echo "where shepherd is the path to shepherd in the GUIX store as" + echo "given by \`shepherd' from (use-modules (gnu packages admin))" + exit 1 +fi + echo { read len_script; read len_tar; } < /dev/sdb pwd @@ -9,3 +16,11 @@ sha1sum signing-key.pub guix archive --authorize < signing-key.pub guix archive --import < hello.nar + +# Wait for the control socket for shepherd to appear and halt the VM. +( + while [ ! -e /var/run/shepherd/socket ]; do + sleep 1 + done + "$1/sbin/halt" +) &