Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
executable file 66 lines (47 sloc) 2.2 KB
#!/bin/sh
# =============================================================================
# Post-install hook file for configuring dotcloud server
echo "Writing the local settings file..."
echo " - Setting the path to the Shareabouts config"
echo " - Adding the flavor to the installed applications"
cat >> src/project/local_settings.py <<EOF
import json
import os.path
with open('/home/dotcloud/environment.json') as f:
env = json.load(f)
# The SHAREABOUTS_FLAVOR environment variable is used as a prefix for the
# Shareabouts configuration. configuration is expected to live in a package
# named 'flavors.<SHAREABOUTS_FLAVOR>'. This package will correspond to a
# folder in the root of the src tree that contains all the configuration
# information for the flavor.
SHAREABOUTS_FLAVOR = env.get('SHAREABOUTS_FLAVOR')
INSTALLED_APPS = ('flavors.' + SHAREABOUTS_FLAVOR,) + INSTALLED_APPS
SHAREABOUTS_CONFIG = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'flavors', SHAREABOUTS_FLAVOR))
STATIC_ROOT = '/home/dotcloud/current/static/'
# Debug is False by default, true if set in the environment.
DEBUG = (env.get('DEBUG', 'False') in ['true', 'True'])
TEMPLATE_DEBUG = DEBUG
EOF
echo "Injecting the Shareabouts API access info into the config file at $SHAREABOUTS_FLAVOR"
python -c "
import json
with open('/home/dotcloud/environment.json') as f:
env = json.load(f)
print
print 'dataset_api_key: ' + env.get('SHAREABOUTS_API_KEY')
print 'api_root: ' + env.get('SHAREABOUTS_API_ROOT', 'SHAREABOUTS_API_ROOT-not-set-in-dotcloud-environment!!!')
print 'analytics_key: ' + env.get('SHAREABOUTS_ANALYTICS_KEY', 'SHAREABOUTS_ANALYTICS_KEY-not-set-in-dotcloud-environment!!!')
print 'feedback_key: ' + env.get('SHAREABOUTS_FEEDBACK_KEY', 'SHAREABOUTS_FEEDBACK_KEY-not-set-in-dotcloud-environment!!!')
" | cat >> src/flavors/$SHAREABOUTS_FLAVOR/config.yml
echo "Syncing the database..."
src/manage.py syncdb --migrate --noinput
echo "Setting up static file service..."
src/manage.py collectstatic --noinput
echo "Configuring nginx to serve static files..."
cat >> nginx.conf <<EOF
location /static/ { root /home/dotcloud/current ; }
EOF
echo "Compiling translations..."
cd src/sa_web
../manage.py compilemessages
cd ../..
Something went wrong with that request. Please try again.