Skip to content

Instantly share code, notes, and snippets.

@danlamanna
Created February 22, 2018 01:06
Show Gist options
  • Save danlamanna/c3e7704fcd2f35d4ea4aa6c7bf641c2f to your computer and use it in GitHub Desktop.
Save danlamanna/c3e7704fcd2f35d4ea4aa6c7bf641c2f to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
. /usr/bin/virtualenvwrapper.sh
BASE_PATH="$HOME/projects/girder/prs"
GIRDER_GITHUB_URL="https://github.com/girder/girder"
readonly VENV_PREFIX="girder"
readonly PR="$1"
shift
readonly GIRDER_PATH="$BASE_PATH/$PR/girder"
if [ -z "$BUILD_WEB" ]; then
readonly BUILD_WEB=1
else
readonly BUILD_WEB=0
fi
# setup dirs
mkdir -p "$BASE_PATH/$PR/"{assetstore,build,etc,girder,logs}
if [[ ! -d "$GIRDER_PATH/.git" ]]; then
git clone [email protected]:girder/girder.git "$GIRDER_PATH"
fi
# setup virtualenv
set +e
mkvirtualenv -a "$BASE_PATH/$PR" "$VENV_PREFIX-$PR"
set -e
workon "$VENV_PREFIX-$PR"
pushd girder
# setup git tree
hub checkout "$GIRDER_GITHUB_URL/pull/$PR"
# setup package
pip install --upgrade pip setuptools
pip install -r requirements-dev.txt -e .[plugins,sftp] -e clients/python
if [[ ! -f "$BASE_PATH/$PR/etc/girder.local.cfg" ]]; then
cp girder/conf/girder.dist.cfg "$BASE_PATH/$PR/etc/girder.local.cfg"
ln -sf "$BASE_PATH/$PR/etc/girder.local.cfg" "$GIRDER_PATH/girder/conf/girder.local.cfg"
fi
sed -i "s|mongodb://localhost:27017/girder\"|mongodb://localhost:27017/girder_$PR\"|" \
"$BASE_PATH/$PR/etc/girder.local.cfg"
sed -i "s|# log_root=\"/path/to/log/root\"|log_root = \"$BASE_PATH/$PR/logs\"|" \
"$BASE_PATH/$PR/etc/girder.local.cfg"
# bootstrap girder with default user/assetstore
python - <<____HERE
from girder.models.model_base import ValidationException
from girder.utility.model_importer import ModelImporter
try:
admin = ModelImporter.model('user').createUser('girder', 'girder', 'girder', 'girder', '[email protected]',
admin=True)
except ValidationException:
# Ignore if user already exists
pass
try:
assetstore = ModelImporter.model('assetstore').createFilesystemAssetstore('assetstore',
"$BASE_PATH/$PR/assetstore")
except ValidationException:
pass
____HERE
# setup web
if [[ "$BUILD_WEB" -eq 1 ]]; then
girder-install web --dev --no-plugins
fi
echo ""
echo "done."
echo ""
echo "to use: workon $VENV_PREFIX-$PR"
echo "to remove: rm -rf $BASE_PATH/$PR && rmvirtualenv $VENV_PREFIX-$PR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment