Launch SICA VM as a systemd service
This commit is contained in:
parent
aace8e98c4
commit
b9449748fc
|
@ -8,4 +8,19 @@
|
||||||
onShutdown = "shutdown";
|
onShutdown = "shutdown";
|
||||||
qemuPackage = pkgs.qemu_kvm;
|
qemuPackage = pkgs.qemu_kvm;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Declarative configuration of the VMs
|
||||||
|
systemd.services.sica = {
|
||||||
|
description = "SICA database";
|
||||||
|
wantedBy = [ "default.target" ];
|
||||||
|
script = ''
|
||||||
|
disk=/vault/VMs/sica.qcow2
|
||||||
|
sock=/run/qemu-sica.mon.sock
|
||||||
|
${pkgs.qemu_kvm}/bin/qemu-kvm -m 1G -nic user,hostfwd=tcp::2222-:22 -hda $disk -monitor unix:$sock,server,nowait -nographic
|
||||||
|
'';
|
||||||
|
preStop = ''
|
||||||
|
echo 'system_powerdown' | ${pkgs.socat}/bin/socat - UNIX-CONNECT:/run/qemu-sica.mon.sock
|
||||||
|
sleep 10
|
||||||
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue