~george-edison55/charms/precise/statusnet/added-maintainer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash

set -e

# Retrieve the settings from the database
juju-log "Retrieving database relationship"
DB_NAME=`relation-get database`
DB_USER=`relation-get user`
DB_PASS=`relation-get password`
DB_HOST=`relation-get private-address`

# Make sure the database info is available before we proceed
if [[ -z $DB_NAME || -z $DB_USER || -z $DB_PASS || -z $DB_HOST ]] ; then

    juju-log "No database relationship set yet"
    exit 0
    
fi

# Check to see if the installation has taken place
if [ -f /opt/statusnet_installed ] ; then

    juju-log "Installation already complete"
    # TODO: update MySQL information in the config file
    # StatusNet does not provide a script for this
    exit 0

fi

# Check to see if the other config options are available
TITLE=`config-get title`
NICKNAME=`config-get nickname`
PASSWORD=`config-get password`
EMAIL=`config-get email`

if [[ -n $TITLE && -n $NICKNAME && -n $PASSWORD && -n $EMAIL ]] ; then
    
    # Perform the installation
    juju-log "Performing installation"
    /var/www/scripts/install_cli.php --server= `unit-get public-address` --sitename $TITLE --fancy true --host $DB_HOST --database $DB_NAME --username $DB_USER --password $DB_PASS --admin-nick $NICKNAME --admin-pass $PASSWORD --admin-email $EMAIL
    
    # Signal that the installation has taken place
    touch /opt/statusnet_installed
    
else
    
    # Stick the database parameters in a file
    juju-log "Storing database connection parameters"
    cat > /opt/statusnet_db_config <<EOD
$DB_HOST
$DB_NAME
$DB_USER
$DB_PASS
EOD
    
fi