diff options
author | John Ankarström <john@ankarstrom.se> | 2021-01-20 02:50:21 +0100 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-01-20 02:50:21 +0100 |
commit | e47fe43386fdcc603f11521e08d1865e0f381412 (patch) | |
tree | 9f4e97f65e771cc16109bf58b53bc6f53ded66fc /etc | |
parent | 428d6e34e529046e0272db77908114e1b1809202 (diff) | |
download | alpine-e47fe43386fdcc603f11521e08d1865e0f381412.tar.gz |
Add 9vm init.d script
9vm controls a Plan 9 virtual machine.
Diffstat (limited to 'etc')
-rwxr-xr-x | etc/init.d/9vm | 40 |
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 +} |