mirror of
https://github.com/photoprism/photoprism.git
synced 2025-09-26 21:01:58 +08:00
Scripts: Add dist/install-codex.sh and update Makefile
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
2
scripts/dist/Makefile
vendored
2
scripts/dist/Makefile
vendored
@@ -36,6 +36,8 @@ install-tensorflow:
|
||||
tensorflow-gpu: install-tensorflow-gpu
|
||||
install-tensorflow-gpu:
|
||||
/scripts/install-tensorflow.sh gpu
|
||||
codex:
|
||||
/scripts/install-codex.sh
|
||||
davfs: install-davfs
|
||||
install-davfs:
|
||||
/scripts/install-davfs.sh
|
||||
|
47
scripts/dist/install-codex.sh
vendored
Executable file
47
scripts/dist/install-codex.sh
vendored
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Installs the Codex CLI coding agent on Linux.
|
||||
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-codex.sh)
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
echo "Installing Codex CLI..."
|
||||
|
||||
# Ensure npm exists
|
||||
if ! command -v npm >/dev/null 2>&1; then
|
||||
echo "ERROR: npm not found. Please install Node.js (npm) and re-run." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create CODEX_HOME if set (and not '/')
|
||||
if [ -n "${CODEX_HOME:-}" ]; then
|
||||
if [ "${CODEX_HOME}" = "/" ]; then
|
||||
echo "ERROR: refusing to use CODEX_HOME='/'" >&2
|
||||
exit 2
|
||||
fi
|
||||
install -d -m 700 -- "${CODEX_HOME}"
|
||||
fi
|
||||
|
||||
# Choose sudo only if available and not already root
|
||||
SUDO=""
|
||||
if command -v sudo >/dev/null 2>&1 && [ "$(id -u)" -ne 0 ]; then
|
||||
SUDO="sudo"
|
||||
fi
|
||||
|
||||
# Some npm versions don’t support --location=global; detect and adapt
|
||||
if npm help install 2>/dev/null | grep -q -- '--location'; then
|
||||
NPM_GLOBAL_OPTS=(install -g --location=global --no-fund --no-audit)
|
||||
else
|
||||
NPM_GLOBAL_OPTS=(install -g --no-fund --no-audit)
|
||||
fi
|
||||
|
||||
# Install / update Codex CLI
|
||||
$SUDO npm "${NPM_GLOBAL_OPTS[@]}" "@openai/codex@latest"
|
||||
|
||||
# Show result
|
||||
if command -v codex >/dev/null 2>&1; then
|
||||
echo "Codex installed at: $(command -v codex)"
|
||||
codex --version || true
|
||||
fi
|
||||
|
||||
echo "Done."
|
Reference in New Issue
Block a user