Skip to content

Commit dbf0fa6

Browse files
committed
Scripts: Add dist/install-codex.sh and update Makefile
Signed-off-by: Michael Mayer <michael@photoprism.app>
1 parent 4ea628a commit dbf0fa6

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

scripts/dist/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ install-tensorflow:
3636
tensorflow-gpu: install-tensorflow-gpu
3737
install-tensorflow-gpu:
3838
/scripts/install-tensorflow.sh gpu
39+
codex:
40+
/scripts/install-codex.sh
3941
davfs: install-davfs
4042
install-davfs:
4143
/scripts/install-davfs.sh

scripts/dist/install-codex.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
3+
# Installs the Codex CLI coding agent on Linux.
4+
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-codex.sh)
5+
6+
set -Eeuo pipefail
7+
8+
echo "Installing Codex CLI..."
9+
10+
# Ensure npm exists
11+
if ! command -v npm >/dev/null 2>&1; then
12+
echo "ERROR: npm not found. Please install Node.js (npm) and re-run." >&2
13+
exit 1
14+
fi
15+
16+
# Create CODEX_HOME if set (and not '/')
17+
if [ -n "${CODEX_HOME:-}" ]; then
18+
if [ "${CODEX_HOME}" = "/" ]; then
19+
echo "ERROR: refusing to use CODEX_HOME='/'" >&2
20+
exit 2
21+
fi
22+
install -d -m 700 -- "${CODEX_HOME}"
23+
fi
24+
25+
# Choose sudo only if available and not already root
26+
SUDO=""
27+
if command -v sudo >/dev/null 2>&1 && [ "$(id -u)" -ne 0 ]; then
28+
SUDO="sudo"
29+
fi
30+
31+
# Some npm versions don’t support --location=global; detect and adapt
32+
if npm help install 2>/dev/null | grep -q -- '--location'; then
33+
NPM_GLOBAL_OPTS=(install -g --location=global --no-fund --no-audit)
34+
else
35+
NPM_GLOBAL_OPTS=(install -g --no-fund --no-audit)
36+
fi
37+
38+
# Install / update Codex CLI
39+
$SUDO npm "${NPM_GLOBAL_OPTS[@]}" "@openai/codex@latest"
40+
41+
# Show result
42+
if command -v codex >/dev/null 2>&1; then
43+
echo "Codex installed at: $(command -v codex)"
44+
codex --version || true
45+
fi
46+
47+
echo "Done."

0 commit comments

Comments
 (0)