Only activate virtualenv if we're not in one already.
@@ -12,6 +12,11 @@ then
exit 1
fi
+# Check to see if we're in a virtualenv or not.
+# Cribbed from: https://stackoverflow.com/a/15454916
+ACTIVATED=$(python -c 'import sys; print ("1" if hasattr(sys, "real_prefix") else "0")')
+if [ "${ACTIVATED}" -eq 0 ]
+then
# Start in TWLight user's home dir.
cd /home/${TWLIGHT_UNIXNAME}
@@ -20,6 +25,7 @@ virtualenv TWLight 2>/dev/null
# Activate Django virtualenv.
source TWLight/bin/activate
+fi
# Environment variables may not be loaded under all conditions.
if [ -z "${TWLIGHT_HOME}" ]
