2014-06-20 14:41:18 -04:00
|
|
|
#!/bin/sh
|
|
|
|
PRG="$0"
|
2014-03-26 03:06:39 -04:00
|
|
|
|
2014-06-20 14:41:18 -04:00
|
|
|
# resolve relative symlinks
|
2016-06-08 08:31:16 -04:00
|
|
|
while [ -h "$PRG" ]; do
|
2015-06-29 08:04:34 -04:00
|
|
|
ls=`ls -ld "$PRG"`
|
|
|
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
|
|
if expr "$link" : '/.*' > /dev/null; then
|
|
|
|
PRG="$link"
|
|
|
|
else
|
|
|
|
PRG="`dirname "$PRG"`/$link"
|
|
|
|
fi
|
2014-06-20 14:41:18 -04:00
|
|
|
done
|
|
|
|
|
|
|
|
# make it fully qualified
|
|
|
|
WORKING_DIR=`pwd`
|
|
|
|
PRG_DIR=`dirname "$PRG"`
|
|
|
|
APP_ROOT=`cd "$PRG_DIR" && pwd`
|
|
|
|
|
|
|
|
# restore original working dir
|
|
|
|
cd "$WORKING_DIR"
|
|
|
|
|
|
|
|
|
2015-06-29 08:04:34 -04:00
|
|
|
|
|
|
|
# update core application files
|
2016-10-24 16:17:47 -04:00
|
|
|
JAR_XZ_FILE="$APP_ROOT/FileBot.jar.xz"
|
|
|
|
JAR_XZ_URL="https://sourceforge.net/projects/filebot/files/filebot/HEAD/FileBot.jar.xz"
|
2016-06-08 08:31:16 -04:00
|
|
|
|
|
|
|
# check if file has changed
|
2016-10-24 16:17:47 -04:00
|
|
|
JAR_XZ_SHA1_EXPECTED=`curl --retry 5 "$JAR_XZ_URL/list" | egrep -o "[a-z0-9]{40}"`
|
|
|
|
JAR_XZ_SHA1=`sha1sum $JAR_XZ_FILE | cut -d' ' -f1`
|
2016-06-08 08:31:16 -04:00
|
|
|
|
2016-10-24 16:17:47 -04:00
|
|
|
if [ -z "$JAR_XZ_SHA1_EXPECTED" ]; then
|
2016-07-08 05:39:05 -04:00
|
|
|
echo "SHA1 hash unknown"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-10-24 16:17:47 -04:00
|
|
|
if [ "$JAR_XZ_SHA1" == "$JAR_XZ_SHA1_EXPECTED" ]; then
|
|
|
|
echo "$JAR_XZ_FILE [SHA1: $JAR_XZ_SHA1]"
|
2016-06-08 08:31:16 -04:00
|
|
|
exit 0
|
|
|
|
fi
|
2015-06-29 08:04:34 -04:00
|
|
|
|
2016-10-24 16:17:47 -04:00
|
|
|
echo "Update $JAR_XZ_FILE"
|
|
|
|
curl -L -o "$JAR_XZ_FILE" -z "$JAR_XZ_FILE" --retry 5 "$JAR_XZ_URL" # FRS will redirect to (unsecure) HTTP download link
|
2016-06-08 08:31:16 -04:00
|
|
|
|
2016-10-24 16:17:47 -04:00
|
|
|
# check if file has been corrupted (or modified) in transit
|
|
|
|
JAR_XZ_SHA1=`sha1sum $JAR_XZ_FILE | cut -d' ' -f1`
|
|
|
|
echo "$JAR_XZ_FILE [SHA1: $JAR_XZ_SHA1]"
|
2015-06-29 08:04:34 -04:00
|
|
|
|
2016-10-24 16:17:47 -04:00
|
|
|
if [ "$JAR_XZ_SHA1" != "$JAR_XZ_SHA1_EXPECTED" ]; then
|
|
|
|
echo "SHA1 hash mismatch [SHA1: $JAR_XZ_SHA1_EXPECTED]"
|
|
|
|
rm -vf "$JAR_XZ_FILE"
|
2016-06-08 08:31:16 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2016-10-24 16:17:47 -04:00
|
|
|
|
|
|
|
# unpack new jar
|
|
|
|
xz --decompress --force --keep "$JAR_XZ_FILE"
|