Skip to content

Instantly share code, notes, and snippets.

@jeffgca
Created January 14, 2011 19:36
Show Gist options
  • Select an option

  • Save jeffgca/780099 to your computer and use it in GitHub Desktop.

Select an option

Save jeffgca/780099 to your computer and use it in GitHub Desktop.
Stupid bash script to detec if we're running on a vm, and set a watchfile.
#!/bin/bash
IS_VM="No"
WATCHFILE="$HOME/.isVm"
if [ -f $WATCHFILE ]; then
exit;
fi
DMI_OUTPUT=`sudo dmidecode | awk '/Manufacturer: (Bochs|VMware)/ {print $2}'`
# echo $DMI_OUTPUT
if [[ "$DMI_OUTPUT" =~ (Bochs|VMware) ]]; then
echo "matched!"
$IS_VM="Yes"
fi
echo "$IS_VM" > $WATCHFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment