Skip to content

Instantly share code, notes, and snippets.

@ael-code
Created March 15, 2016 17:37
Show Gist options
  • Save ael-code/95f2635ccd6e70498fd7 to your computer and use it in GitHub Desktop.
Save ael-code/95f2635ccd6e70498fd7 to your computer and use it in GitHub Desktop.
[Unit]
Description=VBox Virtual Machine %i Service
Requires=systemd-modules-load.service
After=systemd-modules-load.service
[Service]
User=username
Group=vboxusers
ExecStart=/usr/bin/VBoxHeadless -s %i
ExecStop=/usr/bin/VBoxManage controlvm %i savestate
[Install]
WantedBy=multi-user.target
#! /bin/bash
VM_NAME=""
IP=""
USER=""
PWD=""
WORK_DIR=""
systemctl start vboxvmservice@$VM_NAME.service
while [ true ];
do
sshpass -p $PWD ssh -t -o StrictHostKeyChecking=no $USER@$IP "cd $WORK_DIR; tmux attach || tmux"
if [ $? -ne 0 ]; then
sleep 3
else
break
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment