-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_backdrop.sh
43 lines (34 loc) · 1.43 KB
/
update_backdrop.sh
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
#!/bin/bash
set -e
# TODO: detect if we're in a backdrop root directory, if not fail out.
echo "Assuming we're in the backdrop root directory."
# Get the current version number
CURRENT_VERSION=$(php -r "include 'core/includes/bootstrap.inc'; echo BACKDROP_VERSION;")
echo "Current version is $CURRENT_VERSION"
# Get the new version number
NEW_VERSION=$(curl -sS "https://api.github.com/repos/backdrop/backdrop/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
echo "New version is $NEW_VERSION"
if [ "$CURRENT_VERSION" = "$NEW_VERSION" ]; then
echo "Versions are the same. Exiting"
exit
fi
# Backup the core directory
mv core core.bak.$CURRENT_VERSION
# Install the new core directory
curl -sS -O -L https://github.com/backdrop/backdrop/archive/refs/tags/$NEW_VERSION.tar.gz
tar -xzf $NEW_VERSION.tar.gz
mv backdrop-$NEW_VERSION/core ./core
# clean up
rm $NEW_VERSION.tar.gz
rm -Rf backdrop-$NEW_VERSION
# Instructions
echo
echo
echo "All done..."
echo
echo "We backed up your core directory to core.bak.$CURRENT_VERSION. If you don't want to accidentally commit these backups, you can add the following to your .gitignore file:" | fold -s
echo " core.bak.*"
echo
echo "Be sure to read *ALL* the release notes between $CURRENT_VERSION and $NEW_VERSION to see if you need to update any scaffold files like .htaccess, robots.txt, etc. Visit the releases page at " | fold -s
echo " https://github.com/backdrop/backdrop/releases/"
echo