2022-02-13 18:30:06 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
#
|
2022-03-24 02:36:31 +08:00
|
|
|
# The script can only be run from the SnappyMail install directory!
|
2022-02-13 18:30:06 +08:00
|
|
|
#
|
|
|
|
# By Uwe Bieling <pychi@gmx.de>
|
2022-03-24 02:36:31 +08:00
|
|
|
# and Jordan S (https://github.com/jas8522)
|
|
|
|
|
2022-10-09 02:46:09 +08:00
|
|
|
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
2022-03-24 02:36:31 +08:00
|
|
|
LATEST_URL="https://snappymail.eu/repository/latest.tar.gz"
|
2022-12-06 00:56:46 +08:00
|
|
|
cd "${SCRIPT_DIR}"
|
2022-03-24 02:36:31 +08:00
|
|
|
OWNERGROUP=`stat -c "%U:%G" snappymail`
|
|
|
|
OLD_VERSION=`grep "define('APP_VERSION" index.php | awk -F\' '{print $4}'`
|
2022-02-13 18:30:06 +08:00
|
|
|
|
2022-12-03 17:19:28 +08:00
|
|
|
# check if we are root
|
|
|
|
if [[ $(id -u) -ne 0 ]] ; then echo -e "\033[1;31mPlease run as root\033[0m" ; exit 1 ; fi
|
|
|
|
|
|
|
|
# check if we are in the correct dir
|
|
|
|
if [ ! -d snappymail/v ] ; then echo -e "\033[1;31mThis script can only be run from the SnappyMail install directory\033[0m" ; exit 1 ; fi
|
2022-02-13 18:30:06 +08:00
|
|
|
|
|
|
|
# Download last release to /tmp
|
2022-03-24 02:36:31 +08:00
|
|
|
echo -e "\033[1;33mDownloading last release\033[0m"
|
2022-12-03 17:19:28 +08:00
|
|
|
wget $LATEST_URL -O /tmp/snappymail_latest.tar.gz >/dev/null 2>&1
|
2022-03-24 02:36:31 +08:00
|
|
|
NEW_VERSION=`tar -tf /tmp/snappymail_latest.tar.gz | grep "snappymail/v/.*/index.php" | awk -F/ '{print $3}'`
|
2022-02-13 18:30:06 +08:00
|
|
|
|
2022-12-03 17:19:28 +08:00
|
|
|
if [ $OLD_VERSION != $NEW_VERSION ] ;
|
|
|
|
then
|
|
|
|
# Safety First ... make a backup
|
|
|
|
DSTAMP=`date +%Y-%m-%d`
|
|
|
|
echo -e "\033[1;33mBacking up snappymail $OLD_VERSION to ../backup_snappymail_${DSTAMP}.tar.gz\033[0m"
|
|
|
|
tar -czf ../backup_snappymail_${DSTAMP}.tar.gz .
|
|
|
|
|
|
|
|
# installing
|
|
|
|
echo -e "\033[1;33mInstalling $NEW_VERSION\033[0m";
|
|
|
|
tar -xzf /tmp/snappymail_latest.tar.gz;
|
|
|
|
|
|
|
|
# set permissions
|
|
|
|
echo -e "\033[1;33mSet permissions\033[0m"
|
|
|
|
find . -type d -exec chmod 755 {} \;
|
|
|
|
find . -type f -exec chmod 644 {} \;
|
|
|
|
chmod u+x "${SCRIPT_DIR}/upgrade.sh"
|
2022-12-03 17:32:32 +08:00
|
|
|
chown -R $OWNERGROUP $SCRIPT_DIR
|
2022-12-03 17:19:28 +08:00
|
|
|
echo -e "\033[1;32mFinished with snappymail upgrade from $OLD_VERSION to $NEW_VERSION... \033[0m"
|
|
|
|
|
|
|
|
else
|
|
|
|
echo -e "\033[1;31msame Version skipping.. \033[0m";
|
|
|
|
fi
|