runvm changes to run as a systemd service
authorSomeone <someone@somenet.org>
Wed, 20 Jan 2016 16:07:48 +0000 (17:07 +0100)
committerSomeone <someone@somenet.org>
Wed, 20 Jan 2016 16:07:48 +0000 (17:07 +0100)
runvm.sh
runvmVMNAME@.service [new file with mode: 0755]

index e5b2a2e7dd924223acf8c65068702b80045312cb..e3b6da9e3e64ec24be57c026511ce61c65075c8b 100755 (executable)
--- a/runvm.sh
+++ b/runvm.sh
@@ -1,6 +1,22 @@
-xhost +local:
-sed -e 's/#VMNAME#/'$1'/g' ~/s/runvm.xbindkeysrc.template > ~/.xbindkeysrc.template.$1
-xbindkeys -f ~/.xbindkeysrc.template.$1
-/usr/bin/synergyc -f --debug ERROR --name fujivm 10.11.0.1:24800 &
-VirtualBox --startvm $1 --fullscreen
-rm ~/.xbindkeysrc.template.$1
+#!/bin/bash
+
+if [[ $1 == "startx" ]] ; then
+  VMNAME=$2
+  xhost +local:
+  sed -e 's/#VMNAME#/'$VMNAME'/g' ~/bin/runvm.xbindkeysrc.template > ~/.xbindkeysrc.template.$VMNAME
+  xbindkeys -f ~/.xbindkeysrc.template.$VMNAME
+#  /usr/bin/synergyc -f --debug ERROR --name fujivm 10.11.0.1:24800 &
+  VirtualBox --startvm $VMNAME --fullscreen
+  rm ~/.xbindkeysrc.template.$VMNAME
+else
+  VMNAME=$1
+  if [[ $2 != "" ]] ; then
+    VMNAME="$(echo $1 | sed -e 's/^'$2'//')"
+  fi
+  reset
+  echo "Security check completed."
+  echo "Continue to boot ${VMNAME}?"
+  read unused
+  echo "Booting ${VMNAME}"
+  startx $0 startx $VMNAME >/tmp/runvm.$VMNAME.log  2>&1
+fi
diff --git a/runvmVMNAME@.service b/runvmVMNAME@.service
new file mode 100755 (executable)
index 0000000..97f7182
--- /dev/null
@@ -0,0 +1,18 @@
+[Unit]
+Description=%p on %I
+
+[Service]
+Type=simple
+User=jan
+WorkingDirectory=/home/jan/
+ExecStart=-/bin/zsh -c '~/bin/runvm.sh %p runvm'
+ExecStop=-/bin/sh -c 'echo %p ended.'
+StandardInput=tty
+StandardOutput=tty
+TTYPath=/dev/%I
+Restart=always
+RestartSec=15
+
+[Install]
+WantedBy=multi-user.target
+