2022-02-13 18:30:06 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi
|
|
|
|
|
|
|
|
GITHUB_URL="https://github.com/the-djmaze/snappymail/releases/latest"
|
|
|
|
YOUR_SERVER_FOLDER="/var/www/snappy.somesite.com/"
|
|
|
|
|
|
|
|
# UPGRADING Snappymail
|
|
|
|
#
|
|
|
|
# I've found this to be working fine when upgrading my Snappymail. The
|
|
|
|
# commands should be used at your own risk. I take no responsibility.
|
|
|
|
#
|
|
|
|
# This example assumes that Snappymail is installed in the following
|
|
|
|
# folder;
|
|
|
|
#
|
|
|
|
# /var/www/snappy.somesite.com/ -- see $YOUR_SERVER_FOLDER
|
|
|
|
#
|
|
|
|
# Change the path to match your setup.
|
|
|
|
#
|
|
|
|
# By Uwe Bieling <pychi@gmx.de>
|
|
|
|
|
|
|
|
# Safty First ... make a backup
|
|
|
|
cd $YOUR_SERVER_FOLDER && cd ..
|
|
|
|
tar -czf backup_snappymail_`date +%Y%m%d`.tar.gz $YOUR_SERVER_FOLDER
|
|
|
|
|
|
|
|
# Download last release to /tmp
|
|
|
|
cd /tmp
|
2022-03-22 00:57:07 +08:00
|
|
|
DOWNLOAD_DATA=`curl -L -s $GITHUB_URL | grep -m 1 "href.*snappymail.*tar.gz" | sed "s/^.*href=\"//g" | sed "s/\".*$//g"`
|
|
|
|
echo $DOWNLOAD_DATA | wget --base=http://github.com -i - -O snappy.tar.gz
|
|
|
|
|
|
|
|
# Get Versions
|
|
|
|
OLD_VERSION=`cat $YOUR_SERVER_FOLDER"data/VERSION"`
|
|
|
|
NEW_VERSION=`echo $DOWNLOAD_DATA | grep -o "v.*/"`
|
2022-02-13 18:30:06 +08:00
|
|
|
|
|
|
|
# extract last release to folder
|
|
|
|
tar -xzvf snappy.tar.gz -C $YOUR_SERVER_FOLDER
|
|
|
|
|
|
|
|
# set permissions
|
|
|
|
find $YOUR_SERVER_FOLDER -type d -exec chmod 755 {} \;
|
|
|
|
find $YOUR_SERVER_FOLDER -type f -exec chmod 644 {} \;
|
|
|
|
chown -R www-data:www-data $YOUR_SERVER_FOLDER
|
|
|
|
|
2022-03-22 00:57:07 +08:00
|
|
|
echo -e "\033[1;32mFinished with snappymail-upgrade from $OLD_VERSION to ${NEW_VERSION:1:-1}... \033[0m"
|