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