deploy: dynamic remote staging dir resolution for exegesis RPM SSH deploy
This commit is contained in:
1 parent
70a69ef647
commit
0d4b2a5d27
2 files changed
+76
-7
No files matched your search
@@ -3,8 +3,8 @@
|
|||||||
<!-- HS-COMMIT-STATUS:START -->
|
<!-- HS-COMMIT-STATUS:START -->
|
||||||
> **Gitea Commit & Release Telemetry (`v2.17.1` • Namespace `urn:io:hyperstitionstud`)**
|
> **Gitea Commit & Release Telemetry (`v2.17.1` • Namespace `urn:io:hyperstitionstud`)**
|
||||||
> - **Repository Role & Public Route:** Shared PEP 420 Python core library (`hyperstitionstud_io.*`), MCP/REST server, `/quant/`, `/learn/`, `/engineering/`, `/math/`, & `/donate/` webroots → [`https://hyperstitionstud.io/`](https://hyperstitionstud.io/)
|
> - **Repository Role & Public Route:** Shared PEP 420 Python core library (`hyperstitionstud_io.*`), MCP/REST server, `/quant/`, `/learn/`, `/engineering/`, `/math/`, & `/donate/` webroots → [`https://hyperstitionstud.io/`](https://hyperstitionstud.io/)
|
||||||
> - **Latest Commit Scope (`hyperstitionstudio-core`):** Synchronized v2.17.1 release state across 2 tracked module/artifact surface(s)
|
> - **Latest Commit Scope (`hyperstitionstudio-core`):** Synchronized v2.17.1 release state across 1 tracked module/artifact surface(s)
|
||||||
> - **Touched Files / Surfaces:** `deploy/push-all-to-git-libre-audio.sh`, `src/hyperstitionstud_io/ci/deploy_scripts_sync.py`
|
> - **Touched Files / Surfaces:** `deploy/push-all-to-git-libre-audio.sh`
|
||||||
> - **Live Verified Ecosystem Metrics (`v2.17.1`):** `6` Repositories • `17` CLI Entrypoints • `20` MCP/REST Tools • `14` URN Resources • `63` Verified Web Routes • `388` KG Nodes / `1,282` Edges • `282` Glossary Entries • `4,943` Offline CMUdict Phonetics • `0` Synthetic Data
|
> - **Live Verified Ecosystem Metrics (`v2.17.1`):** `6` Repositories • `17` CLI Entrypoints • `20` MCP/REST Tools • `14` URN Resources • `63` Verified Web Routes • `388` KG Nodes / `1,282` Edges • `282` Glossary Entries • `4,943` Offline CMUdict Phonetics • `0` Synthetic Data
|
||||||
<!-- HS-COMMIT-STATUS:END -->
|
<!-- HS-COMMIT-STATUS:END -->
|
||||||
|
|
||||||
|
|||||||
@@ -227,16 +227,85 @@ if [[ "${SKIP_EXEGESIS_DEPLOY}" -eq 0 ]] && [[ -n "${EXEGESIS_HOST}" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
RPM_NAME="$(basename "${RPM_FILE}")"
|
RPM_NAME="$(basename "${RPM_FILE}")"
|
||||||
echo "[deploy] Found built RPM: ${RPM_FILE}"
|
RPM_SIZE_BYTES="$(wc -c < "${RPM_FILE}" | tr -d '[:space:]')"
|
||||||
|
MIN_STAGE_KB="$(( (RPM_SIZE_BYTES + 1023) / 1024 + 1024 ))"
|
||||||
|
echo "[deploy] Found built RPM: ${RPM_FILE} (${RPM_SIZE_BYTES} bytes)"
|
||||||
|
|
||||||
echo "[deploy] Transferring ${RPM_NAME} to ${EXEGESIS_HOST}:/tmp/${RPM_NAME}..."
|
echo "[deploy] Resolving writable remote staging directory on ${EXEGESIS_HOST} (need >= ${MIN_STAGE_KB} KiB)..."
|
||||||
scp "${RPM_FILE}" "${EXEGESIS_HOST}:/tmp/${RPM_NAME}"
|
REMOTE_STAGE_DIR="$(
|
||||||
|
ssh -o BatchMode=yes -o ConnectTimeout=5 "${EXEGESIS_HOST}" bash -s -- "${MIN_STAGE_KB}" <<'EOF_STAGE'
|
||||||
|
set -euo pipefail
|
||||||
|
min_kb="${1:-2048}"
|
||||||
|
home_dir="${HOME:-$(pwd)}"
|
||||||
|
for cand in "/tmp" "${home_dir}/.cache/rpm-stage" "${home_dir}/rpm-stage"; do
|
||||||
|
created_parent=0
|
||||||
|
if [[ "${cand}" != "/tmp" ]]; then
|
||||||
|
if [[ ! -d "${cand}" ]]; then
|
||||||
|
mkdir -p "${cand}" || continue
|
||||||
|
created_parent=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ ! -d "${cand}" ]] || [[ ! -w "${cand}" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if mount_opts="$(findmnt -n -o OPTIONS -T "${cand}" 2>&1)"; then
|
||||||
|
mount_opts="${mount_opts//[[:space:]]/}"
|
||||||
|
case ",${mount_opts}," in
|
||||||
|
*,noexec,*)
|
||||||
|
if [[ "${created_parent}" -eq 1 ]]; then
|
||||||
|
rmdir "${cand}" || true
|
||||||
|
fi
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
avail_kb="$(df -Pk "${cand}" 2>&1 | awk 'NR==2 {print $4}')"
|
||||||
|
case "${avail_kb}" in
|
||||||
|
''|*[!0-9]*) avail_kb=0 ;;
|
||||||
|
esac
|
||||||
|
if [[ "${avail_kb}" -lt "${min_kb}" ]]; then
|
||||||
|
if [[ "${created_parent}" -eq 1 ]]; then
|
||||||
|
rmdir "${cand}" || true
|
||||||
|
fi
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if stage_dir="$(mktemp -d "${cand}/ingglish-exegesis-stage.XXXXXX" 2>&1)"; then
|
||||||
|
if [[ -d "${stage_dir}" ]] && [[ -w "${stage_dir}" ]]; then
|
||||||
|
printf '%s\n' "${stage_dir}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ "${created_parent}" -eq 1 ]]; then
|
||||||
|
rmdir "${cand}" || true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "[ERROR] Failed to resolve a writable remote staging directory with >= ${min_kb} KiB free and without noexec." >&2
|
||||||
|
exit 1
|
||||||
|
EOF_STAGE
|
||||||
|
)"
|
||||||
|
if [[ -z "${REMOTE_STAGE_DIR}" ]]; then
|
||||||
|
echo "[ERROR] Remote staging directory resolution returned an empty path on ${EXEGESIS_HOST}." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
REMOTE_RPM_PATH="${REMOTE_STAGE_DIR}/${RPM_NAME}"
|
||||||
|
echo "[deploy] Using remote staging directory: ${REMOTE_STAGE_DIR}"
|
||||||
|
|
||||||
|
cleanup_remote_stage() {
|
||||||
|
ssh -o BatchMode=yes -o ConnectTimeout=5 "${EXEGESIS_HOST}" "rm -rf '${REMOTE_STAGE_DIR}'; if [ -d \"\${HOME}/.cache/rpm-stage\" ]; then rmdir --ignore-fail-on-non-empty \"\${HOME}/.cache/rpm-stage\" || true; fi; if [ -d \"\${HOME}/rpm-stage\" ]; then rmdir --ignore-fail-on-non-empty \"\${HOME}/rpm-stage\" || true; fi" || true
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "[deploy] Transferring ${RPM_NAME} to ${EXEGESIS_HOST}:${REMOTE_RPM_PATH}..."
|
||||||
|
if ! scp "${RPM_FILE}" "${EXEGESIS_HOST}:${REMOTE_RPM_PATH}"; then
|
||||||
|
cleanup_remote_stage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "[deploy] Installing/upgrading ${RPM_NAME} on ${EXEGESIS_HOST}..."
|
echo "[deploy] Installing/upgrading ${RPM_NAME} on ${EXEGESIS_HOST}..."
|
||||||
|
INSTALL_CMD="rc=0; sudo rpm -Uvh --replacepkgs '${REMOTE_RPM_PATH}' || rc=\$?; rm -rf '${REMOTE_STAGE_DIR}'; if [ -d \"\${HOME}/.cache/rpm-stage\" ]; then rmdir --ignore-fail-on-non-empty \"\${HOME}/.cache/rpm-stage\" || true; fi; if [ -d \"\${HOME}/rpm-stage\" ]; then rmdir --ignore-fail-on-non-empty \"\${HOME}/rpm-stage\" || true; fi; exit \${rc}"
|
||||||
if [[ -t 0 ]]; then
|
if [[ -t 0 ]]; then
|
||||||
ssh -t "${EXEGESIS_HOST}" "sudo rpm -Uvh --replacepkgs /tmp/${RPM_NAME} && rm -f /tmp/${RPM_NAME}"
|
ssh -t "${EXEGESIS_HOST}" "${INSTALL_CMD}"
|
||||||
else
|
else
|
||||||
ssh "${EXEGESIS_HOST}" "sudo rpm -Uvh --replacepkgs /tmp/${RPM_NAME} && rm -f /tmp/${RPM_NAME}"
|
ssh "${EXEGESIS_HOST}" "${INSTALL_CMD}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[deploy] Running in-situ dry-run verification on ${EXEGESIS_HOST}..."
|
echo "[deploy] Running in-situ dry-run verification on ${EXEGESIS_HOST}..."
|
||||||
|
|||||||
Reference in new issue
Block a user