Ubuntu 20.04 Virtual Machine Startup, Stop, and Destroy Script

スポンサーリンク
スポンサーリンク

At first

Describes a script for starting, stopping, and destroying Ubuntu20.04 virtual machines built using a script.

The script you are using is published as vm-configure on github, so please download it from github or download it from here.

See the link below for the vm-configure folder configuration.

/host-osx/ubuntu-20.04-start.command

This is a script to start Ubuntu20.04 virtual machine.

The location of the script file is in the current directory.

SCRIPT_DIR=$(dirname "$0")
cd "$SCRIPT_DIR"

Re-loading bash’s default environment variables.

if [ -e "${HOME}/.bash_profile" ]; then
    . "${HOME}/.bash_profile"
fi

Launching com.collbow.vagrant service registered with launchd.

When you start this service, the virtual machine auto-start and stop scripts are called to start the virtual machine.

See the link below for the virtual machine auto-start/stop script.

launchctl start com.collbow.vagrant

/host-osx/ubuntu-20.04-stop.command

This is a script to start Ubuntu20.04 virtual machine.

The location of the script file is in the current directory.

SCRIPT_DIR=$(dirname "$0")
cd "$SCRIPT_DIR"

Re-loading bash’s default environment variables.

if [ -e "${HOME}/.bash_profile" ]; then
    . "${HOME}/.bash_profile"
fi

Stopping com.collbow.vagrant service registered with launchd.

Stopping this service will terminate the auto-start/stop script for the virtual machine and stop the virtual machine.

See the link below for the virtual machine auto-start/stop script.

launchctl stop com.collbow.vagrant

/host-osx/ubuntu-20.04/vm-destroy.command

This is a script to destroy Ubuntu20.04 virtual machines.

The location of the script file is in the current directory.

SCRIPT_DIR=$(dirname "$0")
cd "$SCRIPT_DIR"

Re-loading bash’s default environment variables.

if [ -e "${HOME}/.bash_profile" ]; then
    . "${HOME}/.bash_profile"
fi

The execution result of the script is set to output to the file (vm-destroy.command.log) with .log after the execution script file name, and the execution start date and time are output to the log file.

exec &>>(tee "${0}.log")
date "+%Y/%m/%d %H:%M:%S"

Removing com.collbow.vagrant services registered with launchd.

launchctl unload "${HOME}/Library/LaunchAgents/com.collbow.vagrant.plist"
rm -f "${HOME}/Library/LaunchAgents/com.collbow.vagrant.plist"

Loading the Vagrantfile in the current directory and destroying the virtual machine defined in the Vagranfile.

vagrant destroy

Comment

スポンサーリンク