At work, I'm running linux, and use vagrant on a daily basis. What I find annoying is that the system often hangs when I reboot/shut down, if I forgot to
vagrant halt any virtual boxes I may have fired up.
To counter this, I'd like to write a shutdown script, along the lines of:
#! /bin/sh cd ~/vagrants/vagrant_1 vagrant halt cd ../vagrant_2 vagrant halt exit 0
However, for I'm not too sure if
~ will still be available to me, and even if it is, if the home dir in question will always be the right one, and if the script will have access too it. So I thought I'd do:
#! /bin/sh VAGRANT_HOME="~/vagrants/" #or "/home/my_user/vagrants" if [ -d "$VAGRANT_HOME" ]; then cd $VAGRANT_HOMEvagrant_1 vagrant halt cd $VAGRANT_HOMEvagrant_2 vagrant halt fi
But even so, I can't help finding this silly, since I have added a couple of aliasses to my
.profile file, including:
alias vagranthalt="cd ~/vagrants/vagrant_1 && vagrant halt && cd - && cd ~/vagrants/vagrant_2 && vagrant halt && cd -"
Which I'd like to use, but I'm not sure if these aliasses will still be available when my script is executed. I think I'll only need it @ runlevel 6, but might also need to symlink the script to run on runlevel 0, too.
Basically, what I'd like to know is this:
- will existing aliasses be available to me, or not?
- Is there a user executing this script (and will I therefore be able to use
- should I make sure I have, at least, read-rights on the vagrant dirs in the script
- Is there another way to ensure the vagrant boxes are shutdown, that is perhaps slightly easier?