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
|
|
|
|
PRG_DIR=`dirname "$PRG"`
|
|
|
|
APP_ROOT=`cd "$PRG_DIR" && pwd`
|
|
|
|
|
|
|
|
|
2015-06-29 08:04:34 -04:00
|
|
|
# update core application files
|
2018-06-12 15:25:10 -04:00
|
|
|
PACKAGE_NAME="CHANGES.tar.xz.gpg"
|
2017-04-13 05:54:09 -04:00
|
|
|
PACKAGE_FILE="$APP_ROOT/$PACKAGE_NAME"
|
2017-06-08 18:35:28 -04:00
|
|
|
PACKAGE_URL="https://get.filebot.net/filebot/latest/$PACKAGE_NAME"
|
2015-06-29 08:04:34 -04:00
|
|
|
|
2017-04-13 05:54:09 -04:00
|
|
|
echo "Update $PACKAGE_FILE"
|
2017-06-08 18:35:28 -04:00
|
|
|
HTTP_CODE=`curl -L -o "$PACKAGE_FILE" -z "$PACKAGE_FILE" --retry 5 "$PACKAGE_URL" -w "%{http_code}"`
|
2015-06-29 08:04:34 -04:00
|
|
|
|
2017-06-08 18:35:28 -04:00
|
|
|
if [ $HTTP_CODE -ne 200 ]; then
|
|
|
|
echo "$HTTP_CODE NO UPDATE"
|
2016-06-08 08:31:16 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2016-10-24 16:17:47 -04:00
|
|
|
|
2017-04-13 05:54:09 -04:00
|
|
|
|
|
|
|
# initialize gpg
|
2017-04-13 07:29:12 -04:00
|
|
|
GPG_HOME="$APP_ROOT/data/.gpg"
|
2017-04-13 05:54:09 -04:00
|
|
|
|
2017-04-13 06:10:53 -04:00
|
|
|
if [ ! -d "$GPG_HOME" ]; then
|
2017-04-16 08:11:48 -04:00
|
|
|
mkdir -p "$GPG_HOME" && chmod 700 "$GPG_HOME" && gpg --homedir "$GPG_HOME" --import "$APP_ROOT/maintainer.pub"
|
2017-04-13 05:54:09 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# verify signature and extract jar
|
2018-06-12 15:25:10 -04:00
|
|
|
gpg --batch --yes --homedir "$GPG_HOME" --trusted-key "4E402EBF7C3C6A71" --decrypt "$PACKAGE_FILE" | tar -xJvf "-"
|