#!/usr/bin/env bash # Assemble the importable egg: egg.json with install.sh inserted as its install script. # # egg/build.sh [OUT] default OUT: dist/egg-rust-runicgateway.json # # The install script is kept as a real file so it can be read, diffed and shellchecked; an install # script edited inside a JSON string is one nobody reviews. PR Checks runs this, so a broken egg # fails a pull request, and release.yml runs it to produce the asset a panel admin imports. set -euo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" OUT="${1:-dist/egg-rust-runicgateway.json}" mkdir -p "$(dirname "$OUT")" bash -n "$HERE/install.sh" sh -n "$HERE/with-sidecar.sh" jq --rawfile script "$HERE/install.sh" \ '.scripts.installation.script = $script' "$HERE/egg.json" > "$OUT" # The shape Pterodactyl's importer requires, and the variables this egg exists to add. jq -e ' .meta.version == "PTDL_v2" and (.scripts.installation.script | startswith("#!/bin/bash")) and (.startup | startswith("$( [ -x ./rust-link/with-sidecar.sh ]")) and ([.variables[].env_variable] as $v | ["RUSTLINK_SERVER_ID","RUSTLINK_WEB_PORT","RUSTLINK_WEB_TOKEN","RUNICGATEWAY_BUNDLE", "RUSTLINK_RETAIN_DAYS","FRAMEWORK","REGEN_SERVER","REMOVE_FILES"] | all(. as $k | $v | index($k))) ' "$OUT" >/dev/null || { echo "egg/build.sh: $OUT is missing something the egg must have" >&2; exit 1; } echo "egg: $OUT"