From 99c9026d7e3409170f1d4c23552cd6ffa71a4544 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 17 Oct 2024 12:52:26 +0200 Subject: Add auto repo clone --- .gitignore | 1 + Dockerfile | 2 +- forgebot.sh | 4 +++- forgebot_proper.sh | 3 ++- repo | 1 - 5 files changed, 7 insertions(+), 4 deletions(-) delete mode 160000 repo diff --git a/.gitignore b/.gitignore index e46761e..ee194af 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ env.sh notificationdata messagedata forgebotdata +repo diff --git a/Dockerfile b/Dockerfile index a8b68c8..66872aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM alpine -RUN apk add --no-cache websocat bash jq grep curl +RUN apk add --no-cache websocat bash jq grep curl git COPY ./ /app/forgebot/ WORKDIR "/app/forgebot" ENTRYPOINT ["/app/forgebot/forgebot_proper.sh"] diff --git a/forgebot.sh b/forgebot.sh index 98a246a..c0e3cac 100755 --- a/forgebot.sh +++ b/forgebot.sh @@ -7,9 +7,11 @@ # curl # find +rm -fr "${DATA_DIR:-.}/repo" +git clone http://github.com/notenoughupdates/notenoughupdates-repo "${DATA_DIR:-.}/"repo --depth=1 function get_duration() { - jq '.recipes[] | select(.type ="forge") | .duration * 1000' < repo/items/$1.json + jq '.recipes[] | select(.type ="forge") | .duration * 1000' < "${DATA_DIR:-.}"/repo/items/$1.json } diff --git a/forgebot_proper.sh b/forgebot_proper.sh index 947be04..834347a 100755 --- a/forgebot_proper.sh +++ b/forgebot_proper.sh @@ -12,7 +12,7 @@ require_program() { fi done } -require_program curl jq websocat printf grep find sed mkdir touch rm mv mkfifo basename tty +require_program curl jq websocat printf grep find sed mkdir touch rm mv mkfifo basename tty git if ! [[ "$(grep --version)" = *GNU* ]]; then echo Using non-GNU grep. This can cause issues since we use some non standard grep options. exit 1 @@ -28,6 +28,7 @@ if [[ x"$HYPIXEL_KEY" == x ]]; then echo "Please set HYPIXEL_KEY to your hypixel api key" exit 1 fi +echo Data dir: "${DATA_DIR:-.}" source "$(dirname -- "$0")"/atrocity/load.sh source "$(dirname -- "$0")"/hypixel_api.sh source "$(dirname -- "$0")"/data.sh diff --git a/repo b/repo deleted file mode 160000 index 52f3f65..0000000 --- a/repo +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 52f3f65469b9b5fcd976b4573a7927aba5371cb8 -- cgit