24 lines
972 B
Bash
24 lines
972 B
Bash
#!/bin/ash
|
|
##Script for updating SnappyMailVer
|
|
NewSnappyMailVer=$(curl -s https://api.github.com/repos/the-djmaze/snappymail/releases/latest | grep 'tag_name.*' | cut -d : -f 2,3 | tr -d \" |tr -d , |tr -d " ")
|
|
|
|
printf "SnappyMail: checking for upgrades... "
|
|
|
|
if [ "$NewSnappyMailVer" != "$(cat /opt/SnappyMail-installed)" ];
|
|
then
|
|
echo "update found"
|
|
#Backup Config
|
|
mv /opt/webmail/data/_data_ /tmp/_data_
|
|
rm -rf /opt/webmail
|
|
curl -L https://github.com/the-djmaze/snappymail/releases/download/$NewSnappyMailVer/snappymail-${NewSnappyMailVer//v}.tar.gz -o /tmp/smc.tar.gz || exit 1
|
|
tar -C /opt/webmail -xzf /tmp/smc.tar.gz
|
|
chown -R nginx:nginx /opt/webmail
|
|
find /opt/webmail/ -type d -exec chmod 755 {} \;
|
|
find /opt/webmail/ -type f -exec chmod 644 {} \;
|
|
echo $NewSnappyMailVer > /opt/webmail-installed
|
|
#Restore config
|
|
mv /tmp/_data_ /opt/webmail/data/_data_
|
|
echo "upgrade complete"
|
|
else
|
|
echo "update not found"
|
|
fi |