This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
certbot-haproxy/dev_vars

72 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "ERROR: You need to source this script, not run it."
echo "Please run like this: \`source $0\`"
exit 255
fi
VERBOSE=0
for arg in "$@"; do
if [ "${arg}" = "-v" -o "${arg}" = "--verbose" ]; then
VERBOSE=1
echo "Verbose mode enabled"
fi
done
commands_exist () {
DEPS_MISSING=0
for cmd in $1; do
if ! type "${cmd}" &> /dev/null; then
DEPS_MISSING=1
echo "Dependency '${cmd}' is not installed."
fi
done
return $DEPS_MISSING
}
function_defined() {
type "$1" &> /dev/null;
}
please_install () {
if [ -f /etc/redhat-release ] ; then
PKMGR=$(which yum)
elif [ -f /etc/debian_version ] ; then
PKMGR=$(which apt-get)
fi
echo
echo "Before running this script, please run:"
echo "${PKMGR} install $1"
}
log () {
if [ $VERBOSE -eq 1 ]; then
echo "$1"
fi
}
CMDS="virtualenv python2.7 pip"
DEPS="virtualenv python2.7 python-setuptools"
if [ ! -d "${PWD}/venv/" ]; then
log "Virtual environment is not present."
log "Checking for dependencies."
if ! commands_exist "${CMDS}"; then
log "Missing one or more dependencies."
please_install "${DEPS}"
exit 1
fi
log "Creating virtual environment."
virtualenv "${PWD}/venv"
fi
if function_defined deactivate; then
log "Deactivating activated virtual environment."
deactivate
fi
log "Checking for dependencies."
source "$PWD/venv/bin/activate"
pip install -e .