monitoring: find user-local wallet-cli

This commit is contained in:
Hernâni Marques 2026-07-17 12:32:07 +02:00
parent cd3cb1c054
commit b9d37f6729
No known key found for this signature in database
GPG key ID: CB5738652768F7E9
2 changed files with 23 additions and 2 deletions

View file

@ -599,14 +599,35 @@ read_secret() {
}
find_wallet_cli() {
# Must return a path suitable for: node "$WALLET_CLI" …
# Prefer *.mjs / bundled entry; plain /usr/bin/taler-wallet-cli is often a
# shell wrapper and cannot be passed to node.
if [ -n "${WALLET_CLI:-}" ] && [ -f "$WALLET_CLI" ]; then
echo "$WALLET_CLI"; return 0
fi
local c cand
for c in \
"${HOME}/.local/bin/taler-wallet-cli.mjs" \
"${HOME}/taler/opt/taler-wallet-cli/usr/lib/taler-wallet-cli/node_modules/taler-wallet-cli/bin/taler-wallet-cli.mjs" \
/home/hernani/taler/opt/taler-wallet-cli/usr/lib/taler-wallet-cli/node_modules/taler-wallet-cli/bin/taler-wallet-cli.mjs \
/Users/newkamek/src/taler/taler-typescript-core/packages/taler-wallet-cli/bin/taler-wallet-cli.mjs \
"$(command -v taler-wallet-cli 2>/dev/null || true)"
/usr/lib/taler-wallet-cli/node_modules/taler-wallet-cli/bin/taler-wallet-cli.mjs \
/usr/share/taler-wallet-cli/bin/taler-wallet-cli.mjs
do
[ -n "$c" ] && [ -f "$c" ] && { echo "$c"; return 0; }
done
# Debian package wrapper → resolve real .mjs
cand=$(command -v taler-wallet-cli 2>/dev/null || true)
if [ -n "$cand" ] && [ -f "$cand" ]; then
if head -1 "$cand" 2>/dev/null | grep -q 'node\|mjs'; then
# shebang node script or .mjs
echo "$cand"; return 0
fi
# follow symlink into package tree
if [ -L "$cand" ]; then
c=$(readlink -f "$cand" 2>/dev/null || true)
[ -n "$c" ] && [ -f "$c" ] && { echo "$c"; return 0; }
fi
fi
return 1
}