From 16946df5139a48946b74a88d6d4d0826469bd890 Mon Sep 17 00:00:00 2001 From: Someone Date: Wed, 20 Jan 2016 17:07:48 +0100 Subject: [PATCH] runvm changes to run as a systemd service --- runvm.sh | 28 ++++++++++++++++++++++------ runvmVMNAME@.service | 18 ++++++++++++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) create mode 100755 runvmVMNAME@.service diff --git a/runvm.sh b/runvm.sh index e5b2a2e..e3b6da9 100755 --- 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 index 0000000..97f7182 --- /dev/null +++ b/runvmVMNAME@.service @@ -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 + -- 2.43.0