Files
purnell569 60f3a6d693 Repoint fork references from arif-banai to purnell569
Anything that describes or acts on *this* repository now points here. Attribution
to the upstream authors is deliberately left untouched.

Functional, would otherwise misbehave on this fork:
- Docker workflows pushed to a ghcr namespace this account cannot write to.
- scripts/run_jmusicbot.sh auto-updated from arif-banai's releases, so it would
  have replaced this jar with the upstream one.
- pom.xml scm/issueManagement/ciManagement described the upstream repo.
- Removed .github/FUNDING.yml, which put a Sponsor button on this repo that
  funded arif-banai.

Cosmetic:
- Badges repointed; dropped the CircleCI, CodeFactor and Discord badges, which
  reported on services this fork is not registered with.
- License badge now targets main rather than master.
- Fixed the README header image: it was a float-right <img> that overlapped the
  note block, now centred above the title with alt text.
- Refreshed the stale JMusicBot-0.6.2 jar name in the run examples.

Left alone on purpose: copyright headers, pom.xml <developers>, the NOTICE and
README credit tables, and the upstream commit provenance in docs/ARCHITECTURE.md.
2026-09-11 14:01:42 +09:30

72 lines
2.7 KiB
Bash

#!/bin/sh
# This will have this script check for a new version of JMusicBot every
# startup (and download it if the latest version isn't currently downloaded)
DOWNLOAD=true
# This will cause the script to run in a loop so that the bot auto-restarts
# when you use the shutdown command
LOOP=true
# JVM options for running JMusicBot
# --enable-native-access=ALL-UNNAMED: Required for Java 22+ to load native libraries (jdave, udpqueue)
JAVA_OPTS="${JAVA_OPTS:---enable-native-access=ALL-UNNAMED}"
download() {
if [ $DOWNLOAD = true ]; then
# First, check if the latest release is a pre-release
LATEST_RELEASE=$(curl -s https://api.github.com/repos/purnell569/MusicBot/releases/latest)
IS_PRERELEASE=$(echo "$LATEST_RELEASE" | grep -o '"prerelease":[^,}]*' | head -1 | grep -o 'true')
if [ "$IS_PRERELEASE" = "true" ]; then
# Latest is a pre-release, so get all releases and find the first non-prerelease
ALL_RELEASES=$(curl -s https://api.github.com/repos/purnell569/MusicBot/releases?per_page=10)
# Find the first release block that has "prerelease": false, then extract JAR URL from it
# This handles the JSON structure where assets are nested
URL=$(echo "$ALL_RELEASES" | awk '
BEGIN { in_non_prerelease = 0; found = 0 }
/"prerelease":\s*false/ { in_non_prerelease = 1 }
/"prerelease":\s*true/ { in_non_prerelease = 0 }
in_non_prerelease && /"browser_download_url".*\.jar/ && !found {
match($0, /"browser_download_url":\s*"([^"]+\.jar)"/, arr)
if (arr[1] != "") {
print arr[1]
found = 1
exit
}
}
')
else
# Latest is not a pre-release, use it
URL=$(echo "$LATEST_RELEASE" | grep -i "browser_download_url.*\.jar" | sed 's/.*\(http.*\)"/\1/')
fi
FILENAME=$(echo $URL | sed 's/.*\/\([^\/]*\)/\1/')
if [ -f $FILENAME ]; then
echo "Latest version already downloaded (${FILENAME})"
else
curl -L $URL -o $FILENAME
fi
fi
}
run() {
# JVM flags for optimal audio performance (set -Xms/-Xmx via JAVA_OPTS if desired):
# -XX:+UseZGC: Sub-millisecond GC pauses (generational mode is default in JDK 24+)
# -XX:+AlwaysPreTouch: Pre-allocate memory at startup to avoid page faults
# shellcheck disable=SC2086
java -XX:+UseZGC \
-XX:+AlwaysPreTouch \
-Dnogui=true \
$JAVA_OPTS \
-jar $(ls -t JMusicBot* | head -1)
}
while
download
run
$LOOP
do
continue
done