From e47fe43386fdcc603f11521e08d1865e0f381412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 20 Jan 2021 02:50:21 +0100 Subject: Add 9vm init.d script 9vm controls a Plan 9 virtual machine. --- etc/init.d/9vm | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 etc/init.d/9vm (limited to 'etc') diff --git a/etc/init.d/9vm b/etc/init.d/9vm new file mode 100755 index 0000000..1a13fd9 --- /dev/null +++ b/etc/init.d/9vm @@ -0,0 +1,40 @@ +#!/sbin/openrc-run + +name=9vm +description='Plan 9 virtual machine' + +VMPATH=/9 +SESSION=9vm +CMD='sh /9/startcon' +PATTERN=qemu-system-i386 + +depend() { + use net +} + +start() { + ebegin Starting Plan 9 virtual machine + (cd $VMPATH && screen -h 1024 -dmS $SESSION $CMD) + if pgrep -f "$PATTERN" > /dev/null + then + eend 0 + return 0 + else + eend 1 + return 1 + fi +} + +stop() { + if pgrep -f "$PATTERN" > /dev/null + then + screen -p 0 -S $SESSION -X eval 'stuff "fshalt"\015' + sleep 10 +# TODO: Check screen output to see when fshalt has finished. +# TIP: C-a H activates logging to screenlog.1 (or 0,2,3,...?) + screen -p 0 -S $SESSION -X eval 'stuff 2' + screen -p 0 -S $SESSION -X eval 'stuff "quit"\015' + fi + einfo Plan 9 virtual machine is shut down. + eend 0 +} -- cgit v1.2.3