5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

vagrant destroy && vagrant up を実行するシェルスクリプト

Last updated at Posted at 2014-07-26

Vagrantfileの調整や勉強時に。


2014/07/26
スクリプトを使わずに一行で同じことを行える方法を教えて頂きました。

$ vagrant destroy -f && vagrant up

-f(force)オプション:強制的に実行。
command && command: 続けてコマンドを実行。

tsuyoshi_cho様 ありがとうございました。


expectがインストールできていること前提です。

$ expect -v
expect version 5.44.1.15

なければ
$ sudo yum install expect

va-reup.sh
#!/bin/sh

expect -c "
  set timeout 10
  spawn vagrant destroy $1
  expect \"Are you sure you want to destroy\"
  send \"y\r\"
  interact
"
vagrant up $1

引数にvm名を指定できます。
$ sudo ./va-reup.sh vm名

5
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?