#!/bin/bash
if ! [[ -d drupal_new ]] ; then
mkdir drupal_new && cd drupal_new
else
cd drupal_new
fi
#wget $(wget -O- -q https://updates.drupal.org/release-history/drupal/7.x | grep -oPm1 "(?<=<download_link>)[^<]+") && tar -zxf drupal*.tar.gz --exclude=sites && rm -r drupal*.tar.gz && cd ../
wget $(wget -O- -q https://updates.drupal.org/release-history/drupal/7.x | grep -oPm1 "(?<=<download_link>)[^<]+" | sort -V | grep -v 'dev' | tail -1) && tar -zxf drupal*.tar.gz --exclude=sites && rm -r drupal*.tar.gz && cd ../
read -p "Enter a Drupal-site folder name: " sitename
if [[ -d $sitename ]] ; then
echo "The directory $sitename exists"
echo ""
echo "Creating $sitename backup in drupal_new folder"
echo "**********************************************"
cp -aRp "$sitename" drupal_new && tar -cf - -C "$sitename" . | gzip -c > drupal_new/"$sitename".tar.gz
echo "Backup "$sitename" created, see $sitename.tar.gz file"
else
echo "The directory $sitename does not exist. Try again..."
rm -rf drupal_new/drupal* && exit 0
fi
echo ""
echo "Comparing $sitename with original"
echo "*********************************"
diff -ur '--exclude=sites' drupal_new/drupal* "$sitename" > drupal_new/compare-"$sitename"-`date +%F`.diff
echo "See result in compare-$sitename.diff file"
echo ""
echo "Updating $sitename core"
echo "***********************"
cp -Rf drupal_new/drupal*/* "$sitename" && rm -rf drupal_new/drupal* && rm -rf drupal_new/"$sitename"
echo "Update '$sitename is completed. Now run update.php script from your browser"
# Document Root (see web-server *.conf file), may be /var/www or /var/www/html, or /htdocs
# - site1
# - site2
# - ... etc. ...
# - drupal_update.sh
# "site1", "site2" its "a Drupal-site folder name"
Update Drupal core from command line.
Save it as drupal_update.sh, place in Document Root folder and run it.
Known shortcomings:
1. In name of site directory shouldn't be named "drupal".
2. On dedicated servers it may require superuser privileges.
Before use, be sure to test!
Save it as drupal_update.sh, place in Document Root folder and run it.
Known shortcomings:
1. In name of site directory shouldn't be named "drupal".
2. On dedicated servers it may require superuser privileges.
Before use, be sure to test!
1 Response
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.