From 94e5f0f13a1d2b1a26880c1781a18837bd3cb916 Mon Sep 17 00:00:00 2001 From: Enzo Arroyo Date: Thu, 7 Jul 2022 21:37:16 +0200 Subject: [PATCH 1/2] plugins: Add vagrant plugin for OMB --- plugins/vagrant/README.md | 33 +++++++++++++++ plugins/vagrant/vagrant.plugin.sh | 70 +++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 plugins/vagrant/README.md create mode 100644 plugins/vagrant/vagrant.plugin.sh diff --git a/plugins/vagrant/README.md b/plugins/vagrant/README.md new file mode 100644 index 0000000..ef762be --- /dev/null +++ b/plugins/vagrant/README.md @@ -0,0 +1,33 @@ +# vagrant plugin + +## Introduction + +The `vagrant plugin` adds several aliases for useful [vagrant](https://www.vagrantup.com/downloads) commands and [aliases](#aliases). + +To use it, add `vagrant` to the plugins array of your bashrc file: + +``` +plugins=(... vagrant) +``` + +## Aliases + +| Command | Description | +|:------------------|:--------------------------------------------------------------| +| `va` | command `vagrant` | +| `vaver` | Show the vagrant version in this host | +| `vaconf` | command `vagrant ssh-config` | +| `vastat` | command `vagrant global-status` | +| `vacheck` | command `vagrant validate` | +| `vaport` | command `vagrant port` | +| `vapvm` | command `vagrant plugin install *[ virtualbox \| libvirt ]*` | +| `vapi` | command `vagrant plugin install *[ package ]*` | +| `vapr` | command `vagrant plugin uninstall *[ package ]*` | +| `vau` | command `vagrant up *[ virtualbox \| libvirt ]*` | +| `vah` | command `vagrant halt` | +| `vat` | command `vagrant destroy -f` | +| `vai` | command `vagrant init -m *[ centos/7 ]*` | +| `varel` | command `vagrant reload` | +| `vaba` | command `vagrant box add` | +| `vabr` | command `vagrant box remove` | +| `vabl` | command `vagrant box list` | diff --git a/plugins/vagrant/vagrant.plugin.sh b/plugins/vagrant/vagrant.plugin.sh new file mode 100644 index 0000000..2bb4712 --- /dev/null +++ b/plugins/vagrant/vagrant.plugin.sh @@ -0,0 +1,70 @@ +#! bash oh-my-bash.module +# Functions +function vagrant-version(){ + vagrant --version +} + +function vagrant-init(){ + if [ -n "$1" ] ; then + echo "Vagrant init for : $1 Creating...." + vagrant init -m "$1" + else + echo "Usage : vai " + echo "Example : vai centos/7" + fi +} + +function vagrant-up(){ + if [ -n "$1" ] ; then + echo "Vagrant up for provider : $1 Running...." + vagrant up --provider "$1" + else + echo "Vagrant up for provider : virtualbox Running...." + vagrant up + fi +} + +function vagrant-plugin-vm(){ + case "$1" in + "virtualbox") + echo "Vagrant plugin install for provider : $1 Running...." + vagrant plugin install vagrant-vbguest + ;; + "libvirt") + echo "Vagrant plugin install for provider : $1 Running...." + vagrant plugin install vagrant-libvirt + ;; + *) + echo "Usage : vapvm " + echo "Example : vapvm virtualbox" + ;; + esac +} + +function vagrant-status(){ + if [ -f "Vagrantfile" ]; then + vagrant status + else + vagrant global-status + fi +} + + +# Alias +alias va='vagrant' +alias vaver='vagrant-version' +alias vaconf='vagrant ssh-config' +alias vastat='vagrant-status' +alias vacheck='vagrant validate' +alias vaport='vagrant port' +alias vapvm='vagrant-plugin-vm' +alias vapi='vagrant plugin install' +alias vapr='vagrant plugin uninstall' +alias vau='vagrant-up' +alias vah='vagrant halt' +alias vat='vagrant destroy -f' +alias vai='vagrant-init' +alias varel='vagrant reload' +alias vaba='vagrant box add' +alias vabr='vagrant box remove' +alias vavl='vagrant box list' From 4866624f79f649c94bed85242709295f43297cf2 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Fri, 8 Jul 2022 05:28:38 +0900 Subject: [PATCH 2/2] plugins/vagrant: Add style changes --- plugins/vagrant/README.md | 10 +++++----- plugins/vagrant/vagrant.plugin.sh | 29 ++++++++++++++++------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/plugins/vagrant/README.md b/plugins/vagrant/README.md index ef762be..dec93e4 100644 --- a/plugins/vagrant/README.md +++ b/plugins/vagrant/README.md @@ -2,18 +2,18 @@ ## Introduction -The `vagrant plugin` adds several aliases for useful [vagrant](https://www.vagrantup.com/downloads) commands and [aliases](#aliases). +The `vagrant plugin` adds several useful aliases for [vagrant](https://www.vagrantup.com/downloads) commands and [aliases](#aliases). -To use it, add `vagrant` to the plugins array of your bashrc file: +To use them, add `vagrant` to the `plugins` array of your bashrc file: -``` +```bash plugins=(... vagrant) ``` ## Aliases -| Command | Description | -|:------------------|:--------------------------------------------------------------| +| Command | Description | +|:-------------------|:-------------------------------------------------------------| | `va` | command `vagrant` | | `vaver` | Show the vagrant version in this host | | `vaconf` | command `vagrant ssh-config` | diff --git a/plugins/vagrant/vagrant.plugin.sh b/plugins/vagrant/vagrant.plugin.sh index 2bb4712..f3ed205 100644 --- a/plugins/vagrant/vagrant.plugin.sh +++ b/plugins/vagrant/vagrant.plugin.sh @@ -1,21 +1,23 @@ #! bash oh-my-bash.module + # Functions -function vagrant-version(){ +function vagrant-version() { vagrant --version } -function vagrant-init(){ - if [ -n "$1" ] ; then +function vagrant-init() { + if [[ $1 ]]; then echo "Vagrant init for : $1 Creating...." vagrant init -m "$1" else - echo "Usage : vai " - echo "Example : vai centos/7" + echo "Usage : vai " >&2 + echo "Example : vai centos/7" >&2 + return 2 fi } -function vagrant-up(){ - if [ -n "$1" ] ; then +function vagrant-up() { + if [[ $1 ]]; then echo "Vagrant up for provider : $1 Running...." vagrant up --provider "$1" else @@ -24,7 +26,7 @@ function vagrant-up(){ fi } -function vagrant-plugin-vm(){ +function vagrant-plugin-vm() { case "$1" in "virtualbox") echo "Vagrant plugin install for provider : $1 Running...." @@ -35,14 +37,15 @@ function vagrant-plugin-vm(){ vagrant plugin install vagrant-libvirt ;; *) - echo "Usage : vapvm " - echo "Example : vapvm virtualbox" + echo "Usage : vapvm " >&2 + echo "Example : vapvm virtualbox" >&2 + return 2 ;; esac } -function vagrant-status(){ - if [ -f "Vagrantfile" ]; then +function vagrant-status() { + if [[ -f Vagrantfile ]]; then vagrant status else vagrant global-status @@ -50,7 +53,7 @@ function vagrant-status(){ } -# Alias +# Aliases alias va='vagrant' alias vaver='vagrant-version' alias vaconf='vagrant ssh-config'