2.0.0 init

Completely revamped the container to support the new external configuration files.
This commit is contained in:
PassiveLemon
2023-07-19 16:27:14 -04:00
parent 3fc92bac27
commit 5ece7c0da4
4 changed files with 87 additions and 31 deletions

View File

@@ -1,20 +1,50 @@
#!/usr/bin/env bash
cd /zoraxy/data/
if [ "$(curl -s "https://api.github.com/repos/tobychui/zoraxy/git/refs/tags" | jq 'any(.[] | tostring; test("API rate limit exceeded"))')" = "true" ]; then
echo "|| Currently rate limited by GitHub. Please wait until it clears. ||"
exit
fi
if [ "$VERSION" != "" ]; then
echo "|| Using release ${VERSION} ||"
release=${VERSION}
# Container update notifier
. /zoraxy/notifier.sh
# Remove the V from the version if its present
VERSION=$(echo "${VERSION}" | awk '{gsub(/^v/, ""); print}')
# If version isn't valid, hard stop.
function versionvalidate () {
if [ -z $(curl -s "https://api.github.com/repos/tobychui/zoraxy/git/refs/tags" | jq -r ".[].ref | select(contains(\"${VERSION}\"))") ]; then
echo "|| ${VERSION} is not a valid version. Please ensure it is set correctly. ||"
exit
fi
}
# Version setting
if [ "${VERSION}" = "latest" ]; then
# Latest release
VERSION=$(curl -s https://api.github.com/repos/tobychui/zoraxy/releases | jq -r "[.[] | select(.tag_name)] | max_by(.created_at) | .tag_name")
versionvalidate
echo "|| Using Zoraxy version ${VERSION} (latest). ||"
else
echo "|| Using latest release ||"
# Gets the latest pre-release version tag. Will be updated when official release comes out.
release=$(curl -s https://api.github.com/repos/tobychui/zoraxy/releases | jq -r 'map(select(.prerelease)) | .[0].tag_name')
versionvalidate
echo "|| Using Zoraxy version ${VERSION}. ||"
fi
if [ ! -e "/zoraxy/data/zoraxy_linux_amd64-${release}" ]; then
echo "|| Downloading version ${release} ||"
curl -Lso /zoraxy/data/zoraxy_linux_amd64-${release} https://github.com/tobychui/zoraxy/releases/download/${release}/zoraxy_linux_amd64
chmod u+x /zoraxy/data/zoraxy_linux_amd64-${release}
# Downloads & setup
if [ ! -f "/zoraxy/server/zoraxy_bin_${VERSION}" ]; then
echo "|| Cloning repository... ||"
cd /zoraxy/source/
git clone --depth=1 --branch main https://github.com/tobychui/zoraxy
cd /zoraxy/source/zoraxy/src/
echo "|| Building... ||"
go mod tidy
go build
mkdir -p /usr/local/bin/
mv /zoraxy/source/zoraxy/src/zoraxy /usr/local/bin/zoraxy_bin_${VERSION}
chmod 755 /usr/local/bin/zoraxy_bin_${VERSION}
echo "|| Finished. ||"
fi
./zoraxy_linux_amd64-${release} ${ARGS}
# Starting
cd /zoraxy/config/
zoraxy_bin_${VERSION} ${ARGS}