aboutsummaryrefslogtreecommitdiff
path: root/etc/init.d/9vm
diff options
context:
space:
mode:
Diffstat (limited to 'etc/init.d/9vm')
-rwxr-xr-xetc/init.d/9vm40
1 files changed, 40 insertions, 0 deletions
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
+}