fix(nx): resolve deploy dir when invoked via /usr/local/bin symlink
readlink -f fixes sourcing nexus-1panel.sh; register nexus-1panel global cmd. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -125,6 +125,7 @@ install_root_commands() {
|
||||
"${NEXUS_ROOT}/deploy/nexus-1panel.sh" \
|
||||
"${NEXUS_ROOT}/deploy/sync-install-wizard-to-container.sh" 2>/dev/null || true
|
||||
ln -sf "${NEXUS_ROOT}/deploy/nx" /usr/local/bin/nx
|
||||
ln -sf "${NEXUS_ROOT}/deploy/nexus-1panel.sh" /usr/local/bin/nexus-1panel
|
||||
ln -sf "${NEXUS_ROOT}/deploy/install-nexus-fresh.sh" /usr/local/bin/nexus-fresh
|
||||
ln -sf "${NEXUS_ROOT}/deploy/quick-install.sh" /usr/local/bin/nexus-install
|
||||
ln -sf "${NEXUS_ROOT}/deploy/install-1panel-docker.sh" /usr/local/bin/nexus-1panel-docker 2>/dev/null || true
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
NX_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# 经 /usr/local/bin/nx 符号链接调用时,须 readlink 才能找到 deploy/ 目录
|
||||
NX_SELF="$(readlink -f "${BASH_SOURCE[0]}")"
|
||||
NX_DIR="$(cd "$(dirname "$NX_SELF")" && pwd)"
|
||||
# shellcheck source=./nexus-1panel.sh
|
||||
source "${NX_DIR}/nexus-1panel.sh"
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# 2026-06-05 — nx 符号链接路径修复
|
||||
|
||||
## 问题
|
||||
|
||||
`/usr/local/bin/nx` → `/opt/nexus/deploy/nx` 时,`dirname $BASH_SOURCE` 解析为
|
||||
`/usr/local/bin`,`source nexus-1panel.sh` 失败。
|
||||
|
||||
## 修复
|
||||
|
||||
- `deploy/nx`:使用 `readlink -f` 解析真实路径
|
||||
- `install-nexus-fresh.sh`:注册 `nexus-1panel` → `deploy/nexus-1panel.sh`
|
||||
|
||||
## 服务器立即修复
|
||||
|
||||
```bash
|
||||
cd /opt/nexus && git pull
|
||||
ln -sf /opt/nexus/deploy/nx /usr/local/bin/nx
|
||||
ln -sf /opt/nexus/deploy/nexus-1panel.sh /usr/local/bin/nexus-1panel
|
||||
nx god
|
||||
```
|
||||
Reference in New Issue
Block a user