From a7df9c0d786db8afa0199e300b0b76fc02822fd1 Mon Sep 17 00:00:00 2001 From: dreth Date: Sat, 10 Aug 2024 12:02:38 +0200 Subject: [PATCH] add optional architecture overriding for downloading altserver, netmuxd and provision binaries --- README.md | 25 ++++++++++++++++++++++++ docker-compose.yml | 6 ++++++ scripts/get-binaries.sh | 43 ++++++++++++++++++++++++++++++++++++++--- 3 files changed, 71 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4601f88..557c3b2 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,31 @@ sudo docker run -d \ Logs will be stored in the directory where the container is ran inside `./logs` +## Optional environment variables + +It's possible to override which architecture of altserver, netmuxd and anisette-server are downloaded by setting the following environment variables in the docker compose file: + +```yaml + environment: + - OVERRIDE_ALTSERVER_ARCH=x86_64 + - OVERRIDE_NETMUXD_ARCH=x86_64 + - OVERRIDE_ANISETTE_ARCH=x86_64 +``` + +or alternatively adding them in the `docker run` command before the image name: + +```shell + -e OVERRIDE_ALTSERVER_ARCH=x86_64 \ + -e OVERRIDE_NETMUXD_ARCH=x86_64 \ + -e OVERRIDE_ANISETTE_ARCH=x86_64 \ +``` + +You can check for which architectures are available by checking the releases of each project: + +- [AltServer-Linux](https://github.com/NyaMisty/AltServer-Linux/releases) +- [netmuxd](https://https://github.com/jkcoxson/netmuxd/releases) +- [Provision](https://github.com/Dadoum/Provision/releases) (this is the anisette-server) + ## Provision libraries Provision automatically pulls the libraries it requires (libCoreADI.so and libstoreservicescore.so) from the apple music android apk, but this requires a 60+MB download it does automatically, so I decided to include these in the root of the repo already and have the `docker-entrypoint.sh` decompress them where Provision normally would. This is optional and can be removed/commented from the `docker-entrypoint.sh` if you prefer to have Provision download and pull them from the apk. diff --git a/docker-compose.yml b/docker-compose.yml index 79b0a3f..a0e8a6f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,5 +15,11 @@ services: - "/var/run:/var/run" - "/sys/fs/cgroup:/sys/fs/cgroup:ro" network_mode: host + # Optional environment variables to override the default architecture + # for the altserver, netmuxd, and anisette binaries. + # environment: + # - OVERRIDE_ALTSERVER_ARCH=x86_64 + # - OVERRIDE_NETMUXD_ARCH=x86_64 + # - OVERRIDE_ANISETTE_ARCH=x86_64 privileged: true restart: unless-stopped diff --git a/scripts/get-binaries.sh b/scripts/get-binaries.sh index fb77e20..4261f48 100644 --- a/scripts/get-binaries.sh +++ b/scripts/get-binaries.sh @@ -42,6 +42,17 @@ save_version() { fi } +# Function to save the architecture to the architectures file +save_architecture() { + local component="$1" + local architecture="$2" + if grep -q "^$component" "/altserver/bin/architectures"; then + sed -i "s/^$component .*/$component $architecture/" "/altserver/bin/architectures" + else + echo "$component $architecture" >> "/altserver/bin/architectures" + fi +} + # Generalized function to check version and download files check_and_download() { local component="$1" @@ -78,6 +89,11 @@ anisette_url="https://api.github.com/repos/Dadoum/Provision/releases/latest" ARCH="$(uname -m)" +# Override architectures +OVERRIDE_ALTSERVER_ARCH="${OVERRIDE_ALTSERVER_ARCH:-}" +OVERRIDE_NETMUXD_ARCH="${OVERRIDE_NETMUXD_ARCH:-}" +OVERRIDE_ANISETTE_ARCH="${OVERRIDE_ANISETTE_ARCH:-}" + # Ensure bin directory exists mkdir -p "/altserver/bin" @@ -87,10 +103,31 @@ altstore_download_url=$(curl -s "$altstore_url" | jq -r "$altstore_download_path check_and_download "AltStore" "$altstore_url" "$altstore_version_path" "$altstore_download_url" "/altserver/bin/AltStore.ipa" # Check and download AltServer -check_and_download "AltServer" "$altserver_url" ".tag_name" "https://github.com/NyaMisty/AltServer-Linux/releases/download/%s/AltServer-${ARCH}" "/altserver/bin/AltServer" +# If the architecture is overridden, use the overridden value +if [ -n "$OVERRIDE_ALTSERVER_ARCH" ]; then + ALTSERVER_PKG_ARCH="AltServer-${OVERRIDE_ALTSERVER_ARCH}" +else + ALTSERVER_PKG_ARCH="AltServer-${ARCH}" +fi +check_and_download "AltServer" "$altserver_url" ".tag_name" "https://github.com/NyaMisty/AltServer-Linux/releases/download/%s/${ALTSERVER_PKG_ARCH}" "/altserver/bin/AltServer" # Check and download netmuxd -check_and_download "netmuxd" "$netmuxd_url" ".tag_name" "https://github.com/jkcoxson/netmuxd/releases/download/%s/${ARCH}-linux-netmuxd" "/altserver/bin/netmuxd" +if [ -n "$OVERRIDE_NETMUXD_ARCH" ]; then + NETMUXD_PKG_ARCH="${OVERRIDE_NETMUXD_ARCH}-linux-netmuxd" +else + NETMUXD_PKG_ARCH="${ARCH}-linux-netmuxd" +fi +check_and_download "netmuxd" "$netmuxd_url" ".tag_name" "https://github.com/jkcoxson/netmuxd/releases/download/%s/${NETMUXD_PKG_ARCH}" "/altserver/bin/netmuxd" # Check and download anisette-server -check_and_download "anisette-server" "$anisette_url" ".tag_name" "https://github.com/Dadoum/Provision/releases/download/%s/anisette-server-${ARCH}" "/altserver/bin/anisette-server" +if [ -n "$OVERRIDE_ANISETTE_ARCH" ]; then + ANISETTE_PKG_ARCH="anisette-server-${OVERRIDE_ANISETTE_ARCH}" +else + ANISETTE_PKG_ARCH="anisette-server-${ARCH}" +fi +check_and_download "anisette-server" "$anisette_url" ".tag_name" "https://github.com/Dadoum/Provision/releases/download/%s/${ANISETTE_PKG_ARCH}" "/altserver/bin/anisette-server" + +# Save the architectures +save_architecture "AltServer" "$ALTSERVER_PKG_ARCH" +save_architecture "netmuxd" "$NETMUXD_PKG_ARCH" +save_architecture "anisette-server" "$ANISETTE_PKG_ARCH"