aboutsummaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-10-27 20:34:18 -0200
committerSilvio Rhatto <rhatto@riseup.net>2017-10-27 20:34:18 -0200
commit8fe35a2abf1016af5dfbbe3b958e8351a93a0d55 (patch)
treeb935acf2dc42854bd7b67143de70ea114c49d5d9 /files
parente9c3cef4d02f5984dce207244d1b3fb01e4e91cc (diff)
downloadpuppet-drupal-8fe35a2abf1016af5dfbbe3b958e8351a93a0d55.tar.gz
puppet-drupal-8fe35a2abf1016af5dfbbe3b958e8351a93a0d55.tar.bz2
Auto-upgrade support
Diffstat (limited to 'files')
-rwxr-xr-xfiles/drupal60
1 files changed, 52 insertions, 8 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 $*