Skip to content

Instantly share code, notes, and snippets.

@viniciusban
Last active August 29, 2015 13:57
Show Gist options
  • Save viniciusban/9814141 to your computer and use it in GitHub Desktop.
Save viniciusban/9814141 to your computer and use it in GitHub Desktop.
Do I have root privileges? Am I inside the Vagrant VM?
# Do I have root privileges?
# Also known as: Am I running with sudo?
if [ $EUID -ne 0 ]; then
echo "You must run the script as root or using sudo"
exit 1
fi
# Am I inside the Vagrant VM?
if [ "$SUDO_USER" != "vagrant" ]; then
echo "You must be in a VM to run me"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment