Created
June 12, 2013 15:52
-
-
Save sebmaynard/5766596 to your computer and use it in GitHub Desktop.
Upgrade an owncloud instance. Check the notes at the top for assumptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Upgrade an owncloud instance. Makes the following assumptions: | |
# 1. you're running this as the same user who owns (and can write to) $OWNCLOUD_FOLDER | |
# 2. $TMP_FOLDER is writeable by this user | |
# These should be absolute paths | |
OWNCLOUD_FOLDER=/var/public_html_ssl/cloud | |
TMP_FOLDER=/tmp/owncloud-upgrade | |
if [[ "$1" == "" ]] ; then | |
echo "Need a version to download (e.g. 5.0.7)" | |
exit | |
fi | |
VERSION=$1 | |
# make sure the temp directory exists first | |
rm -r $TMP_FOLDER | |
mkdir -p $TMP_FOLDER | |
if [[ ! -d $TMP_FOLDER ]] ; then | |
echo "Can't find the temporary folder. " | |
exit | |
fi | |
echo "Backing up existing owncloud" | |
rsync -a $OWNCLOUD_FOLDER/ $TMP_FOLDER/owncloud-backup/ | |
OC_FILENAME=owncloud-$VERSION.tar.bz2 | |
echo "Fetching new version" | |
wget -q http://download.owncloud.org/community/$OC_FILENAME -O $TMP_FOLDER/$OC_FILENAME | |
if [[ $? -ne 0 ]] ; then | |
echo "Couldn't find that owncloud version to download" | |
exit | |
fi | |
echo "Extracting new version" | |
tar -C $TMP_FOLDER -xf $TMP_FOLDER/$OC_FILENAME | |
if [[ $? -ne 0 ]] ; then | |
echo "Couldn't extract owncloud" | |
exit | |
fi | |
echo "Upgrading!" | |
rsync --inplace -rt $TMP_FOLDER/owncloud/ $OWNCLOUD_FOLDER/ | |
if [[ $? -ne 0 ]] ; then | |
echo "The upgrade rsync failed; Be careful..." | |
exit | |
fi | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment