Created
March 15, 2016 17:37
-
-
Save ael-code/95f2635ccd6e70498fd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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