www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 7a103d054e0223b252ab979fc1b3b0d4f3d44d68
parent 7ddc804dc9595d631e402c82af931bea2510d646
Author: Georges Dupéron <georges.duperon@gmail.com>
Date:   Tue, 11 Sep 2018 20:55:33 +0200

Halt the VM automatically

Diffstat:
Mconfig.scm | 7+++++--
Mto-be-run-in-vm.sh | 15+++++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)

diff --git 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 @@ -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" +) &