3
relation-set port=80 private-address=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'|head -n 1`
7
UNIT_NAME=`echo $JUJU_UNIT_NAME | cut -d/ -f1`
8
UNIT_DIR=/srv/${UNIT_NAME}
10
DB_USER=$(relation-get user)
11
DB_PASSWORD=$(relation-get password)
12
DB_HOST=$(relation-get host)
13
DB_DATABASE=$(relation-get database)
17
juju-log "Executing $name"
19
if [ -z "$DB_USER" ] ; then
20
juju-log "No database information yet."
21
exit 0 # wait for future handshake from database service unit
24
cat > ${UNIT_DIR}/db_settings.py << EOF
25
# Settings for database connexion
29
"ENGINE": 'django.db.backends.postgresql_psycopg2',
30
"NAME": '$DB_DATABASE',
32
"PASSWORD": '$DB_PASSWORD',
41
python ${UNIT_DIR}/manage.py syncdb --noinput
42
python ${UNIT_DIR}/manage.py migrate --noinput
44
chown www-data ${UNIT_DIR} -R
45
chmod g+rw ${UNIT_DIR} -R
47
exec $base/config-changed
49
/etc/init.d/gunicorn start
50
/etc/init.d/gunicorn reload