Update update.sh

master
andryyy 2017-06-21 16:44:57 +02:00
parent e9b2c2845e
commit 2c8a5ce3f8
1 changed files with 19 additions and 18 deletions

View File

@ -21,14 +21,15 @@ export LC_ALL=C
DATE=$(date +%Y-%m-%d_%H_%M_%S)
BRANCH=$(git rev-parse --abbrev-ref HEAD)
TMPFILE=$(mktemp "${TMPDIR:-/tmp}/curldata.XXXXXX")
FORGED_SCRIPT=$(mktemp "${TMPDIR:-/tmp}/updatesh.XXXXXX")
echo -e "\e[32mChecking for newer update script...\e[0m"
curl -#o ${TMPFILE} https://raw.githubusercontent.com/mailcow/mailcow-dockerized/${BRANCH}/update.sh
if [[ $(sha1sum ${TMPFILE} | awk '{ print $1 }') != $(sha1sum ./update.sh | awk '{ print $1 }') ]]; then
echo "Updating script, please run this script again, exiting."
chmod +x ${TMPFILE}
mv ${TMPFILE} ./update.sh
SHA1_1=$(sha1sum update.sh)
git fetch origin ${BRANCH}
git checkout origin/${BRANCH} update.sh
SHA1_2=$(sha1sum update.sh)
if [[ ${SHA1_1} != ${SHA1_2} ]]; then
echo "update.sh changed, please run this script again, exiting."
chmod +x update.sh
exit 0
fi
rm -f mv ${TMPFILE}