From 354962ef6b82cbaf23e084d47409af70e3f4d16e Mon Sep 17 00:00:00 2001 From: margiov <giovanni.marzulli@gmail.com> Date: Thu, 28 Sep 2017 14:23:37 +0200 Subject: [PATCH] charm moodle rev2 --- README.md | 9 +++++++-- hooks/config-changed | 10 ++++++++-- hooks/install | 1 - hooks/mysql-db-relation-changed | 6 +++--- hooks/pgsql-db-relation-changed | 6 +++--- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5ee89ea..d30eeb7 100755 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ Moodle is a learning platform designed to provide educators, administrators and To install Moodle by Juju charm, you need to deploy PostgreSQL or MySQL and set relation between them. Follow this step by step instructions on using the charm: - juju deploy postgresql + juju deploy postgresql (or juju deploy mysql) juju deploy cs:~csd-garr/moodle - juju add-relation postgresql:db moodle + juju add-relation postgresql:db moodle (or juju add-relation mysql moodle) Expose the Moodle installation @@ -59,6 +59,11 @@ It referes to Moodle git branch. By default this charm checkouts MOODLE_33_STABL juju config moodle branch=MOODLE_33_STABLE +##Moodle data dir +Path of the Moodle data directory + + juju config moodle datadir="/moodledata" + ##Enable SMTP Moodle needs to send e-mail notifications to users. You can set up your outgoing e-mail configuration using an external SMTP server or enabling "enable-smtp" parameter in order to install a local Postfix SMTP server diff --git a/hooks/config-changed b/hooks/config-changed index 95c2561..3854324 100755 --- a/hooks/config-changed +++ b/hooks/config-changed @@ -150,7 +150,7 @@ fi #Install cron job for Moodle auto-update if "auto-update" is true if [ $(config-get auto-update) == "True" ]; then - cp hooks/inc/moodle_update /etc/cron.d/ + cp $JUJU_CHARM_DIR/hooks/inc/moodle_update /etc/cron.d/ else if [ -f /etc/cron.d/moodle_update ]; then rm /etc/cron.d/moodle_update; fi fi @@ -164,7 +164,13 @@ else apt-get remove -y postfix fi -status-set active +DBNAME=`grep dbname $WWWROOT/config.php | cut -d \' -f 2` + +if [ -z "$DBNAME"]; then + status-set blocked "Waiting for active database relation" +else + status-set active "Unit is Ready" +fi diff --git a/hooks/install b/hooks/install index 22763c7..f2ca5bf 100755 --- a/hooks/install +++ b/hooks/install @@ -147,5 +147,4 @@ fi service apache2 restart -status-set blocked "Waiting for active database connection" diff --git a/hooks/mysql-db-relation-changed b/hooks/mysql-db-relation-changed index 6dd5eee..f650b2f 100644 --- a/hooks/mysql-db-relation-changed +++ b/hooks/mysql-db-relation-changed @@ -74,11 +74,11 @@ else #Install Moodle PHP cron as cron job executed every minute echo "*/1 * * * * root /usr/bin/php $WWWROOT/admin/cli/cron.php >/dev/null" > /etc/cron.d/moodle_cron #Create cron job for Moodle auto-update - echo "* 2 * * * root $(pwd)/hooks/inc/update_moodle.sh" > hooks/inc/moodle_update + echo "* 2 * * * root $JUJU_CHARM_DIR/hooks/inc/update_moodle.sh" > $JUJU_CHARM_DIR/hooks/inc/moodle_update #Install cron job for Moodle auto-update if "auto-update" is true if [ $(config-get auto-update) == "True" ]; then - cp hooks/inc/moodle_update /etc/cron.d/ + cp $JUJU_CHARM_DIR/hooks/inc/moodle_update /etc/cron.d/ else if [ -f /etc/cron.d/moodle_update ]; then rm /etc/cron.d/moodle_update; fi fi @@ -112,6 +112,6 @@ service apache2 restart juju-log "Make the application port available, now that we know we have a site to expose" -status-set active +status-set active "Unit is Ready" open-port 80 diff --git a/hooks/pgsql-db-relation-changed b/hooks/pgsql-db-relation-changed index 793a8e8..2ddcf47 100644 --- a/hooks/pgsql-db-relation-changed +++ b/hooks/pgsql-db-relation-changed @@ -74,11 +74,11 @@ else #Install Moodle PHP cron as cron job executed every minute echo "*/1 * * * * root /usr/bin/php $WWWROOT/admin/cli/cron.php >/dev/null" > /etc/cron.d/moodle_cron #Create cron job for Moodle auto-update - echo "* 2 * * * root $(pwd)/hooks/inc/update_moodle.sh" > hooks/inc/moodle_update + echo "* 2 * * * root $JUJU_CHARM_DIR/hooks/inc/update_moodle.sh" > $JUJU_CHARM_DIR/hooks/inc/moodle_update #Install cron job for Moodle auto-update if "auto-update" is true if [ $(config-get auto-update) == "True" ]; then - cp hooks/inc/moodle_update /etc/cron.d/ + cp $JUJU_CHARM_DIR/hooks/inc/moodle_update /etc/cron.d/ else if [ -f /etc/cron.d/moodle_update ]; then rm /etc/cron.d/moodle_update; fi fi @@ -94,6 +94,6 @@ service apache2 restart juju-log "Make the application port available, now that we know we have a site to expose" -status-set active +status-set active "Unit is Ready" open-port 80 -- GitLab