This howto shows how to detect OpenVZ support on the host and in the container.
#!/bin/bash
if [ -f /proc/user_beancounters ] ; then
envID=$(cat /proc/1/status |grep envID |cut -f 2)
if [ $envID -eq 0 ] ; then
echo "OpenVZ Host"
else
echo "OpenVZ Guest"
fi
else
echo "Not OpenVZ"
fi