diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-10-27 20:34:18 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-10-27 20:34:18 -0200 |
commit | 8fe35a2abf1016af5dfbbe3b958e8351a93a0d55 (patch) | |
tree | b935acf2dc42854bd7b67143de70ea114c49d5d9 | |
parent | e9c3cef4d02f5984dce207244d1b3fb01e4e91cc (diff) | |
download | puppet-drupal-8fe35a2abf1016af5dfbbe3b958e8351a93a0d55.tar.gz puppet-drupal-8fe35a2abf1016af5dfbbe3b958e8351a93a0d55.tar.bz2 |
Auto-upgrade support
-rwxr-xr-x | files/drupal | 60 | ||||
-rw-r--r-- | manifests/autoupgrade.pp | 25 | ||||
-rw-r--r-- | manifests/maintenance.pp | 4 |
3 files changed, 79 insertions, 10 deletions
diff --git a/files/drupal b/files/drupal index 30af128..00bdb9e 100755 --- a/files/drupal +++ b/files/drupal @@ -143,10 +143,31 @@ function drupal_update { done } +# Get the current installed version of a given series +function drupal_current { + local series="$1" + + if [ -z "$series" ]; then + series="8" + fi + + if [ -e "$BASE/drupal-${series}" ]; then + readlink $BASE/drupal-${series} | sed -e 's/^drupal-//' + else + echo 0 + fi +} + # Get the latest version of a given series # https://drupal.stackexchange.com/questions/23700/how-to-find-download-latest-drupal-version-via-bash#23704 function drupal_latest { - latest="`wget -O- -q https://updates.drupal.org/release-history/drupal/${1}.x | grep -oPm1 "(?<=<download_link>)[^<]+" | head -1`" + local series="$1" + + if [ -z "$series" ]; then + series="8" + fi + + latest="`wget -O- -q https://updates.drupal.org/release-history/drupal/${series}.x | grep -oPm1 "(?<=<download_link>)[^<]+" | head -1`" latest="`basename $latest`" echo $latest | sed -e 's/^drupal-//' -e 's/.tar.gz$//' @@ -206,14 +227,29 @@ function drupal_upgrade { exit 1 fi - # Setup + # Get versions old="$1" new="$2" - old_major="`drupal_get_major $old`" - new_major="`drupal_get_major $new`" - extra_folders="" - drupal_series="$new_major" - + + # Fix versions if just a series is given + if [ "$old" == "8" ] && [ -z "$new" ]; then + old="`drupal_current 8`" + new="`drupal_latest 8`" + drupal_series="8" + elif [ "$old" == "7" ] && [ -z "$new" ]; then + old="`drupal_current 7`" + new="`drupal_latest 7`" + drupal_series="7" + elif [ "$old" == "6" ] && [ -z "$new" ]; then + old="`drupal_current 6`" + new="`drupal_latest 6`" + drupal_series="6" + else + old_major="`drupal_get_major $old`" + new_major="`drupal_get_major $new`" + drupal_series="$new_major" + fi + if [ "$old_major" != "$new_major" ]; then echo "Major versions doesn't match" exit 1 @@ -240,6 +276,8 @@ function drupal_upgrade { fi done + extra_folders="" + # Extra folder for extra_folder in $extra_folders; do if [ -d ../drupal-$old/$extra_folder ]; then @@ -301,7 +339,7 @@ fi # Main procedure if [ -z "$1" ]; then - echo "Usage: `basename $0` <cron|download|update|updatedb|upgrade|run|make> [arguments]" + echo "Usage: `basename $0` <cron|download|update|updatedb|upgrade|current|latest|run|make> [arguments]" exit 1 elif [ "$1" == "cron" ]; then drupal_iterate cron @@ -326,6 +364,12 @@ elif [ "$1" == "updatedb" ]; then elif [ "$1" == "upgrade" ]; then shift drupal_upgrade $* +elif [ "$1" == "current" ]; then + shift + drupal_current $* +elif [ "$1" == "latest" ]; then + shift + drupal_latest $* elif [ "$1" == "run" ]; then shift drupal_iterate $* diff --git a/manifests/autoupgrade.pp b/manifests/autoupgrade.pp new file mode 100644 index 0000000..c4a22cc --- /dev/null +++ b/manifests/autoupgrade.pp @@ -0,0 +1,25 @@ +class drupal::autoupgrade { + # Keep 8.x codebase updated + cron { "drupal-autoupgrade-8.x": + command => "/usr/local/bin/drupal upgrade 8", + user => drupal, + # Run once a week after security releases (usually on Wednesdays) + weekday => 5, + hour => "01", + minute => "30", + ensure => present, + require => [ File['/usr/local/bin/drupal'], User['drupal'] ], + } + + # Keep 7.x codebase updated + cron { "drupal-autoupgrade-7.x": + command => "/usr/local/bin/drupal upgrade 7", + user => drupal, + # Run once a week after security releases (usually on Wednesdays) + weekday => 5, + hour => "01", + minute => "30", + ensure => present, + require => [ File['/usr/local/bin/drupal'], User['drupal'] ], + } +} diff --git a/manifests/maintenance.pp b/manifests/maintenance.pp index 720089e..d757122 100644 --- a/manifests/maintenance.pp +++ b/manifests/maintenance.pp @@ -6,7 +6,7 @@ class drupal::maintenance { hour => "*/1", minute => "15", ensure => present, - require => [ File['/usr/local/sbin/drupal'], User['drupal'] ], + require => [ File['/usr/local/bin/drupal'], User['drupal'] ], } # Keep themes and modules up-to-date @@ -18,6 +18,6 @@ class drupal::maintenance { hour => "02", minute => "30", ensure => present, - require => User['drupal'], + require => [ File['/usr/local/bin/drupal'], User['drupal'] ], } } |