fix(daemon, setup): Improve shutdown command detection and fallback logic; update setup script to use absolute Node/npm paths

This commit is contained in:
2025-03-26 15:49:54 +00:00
parent 83ba9c2611
commit be6a7314c3
4 changed files with 187 additions and 24 deletions

View File

@@ -239,10 +239,20 @@ echo "dist_ts directory successfully downloaded from npm registry."
# Make launcher script executable
chmod +x "$SCRIPT_DIR/bin/nupst"
# Add our Node.js bin directory to the PATH temporarily
# Set path to our Node.js binaries
NODE_BIN_DIR="$SCRIPT_DIR/vendor/$NODE_DIR/bin"
NODE_BIN="$NODE_BIN_DIR/node"
NPM_BIN="$NODE_BIN_DIR/npm"
# Ensure we have executable permissions
chmod +x "$NODE_BIN" "$NPM_BIN"
# Save original PATH but don't modify it
# We'll use the full paths to binaries instead
OLD_PATH="$PATH"
export PATH="$NODE_BIN_DIR:$PATH"
echo "Using Node binary: $NODE_BIN"
echo "Using NPM binary: $NPM_BIN"
# Remove existing node_modules directory and package files
echo "Cleaning up existing installation..."
@@ -278,12 +288,11 @@ echo '{
# Install ONLY net-snmp
echo "Installing ONLY net-snmp dependency..."
echo "Using Node.js binary from: $NODE_BIN_DIR"
echo "Node version: $(node --version)"
echo "NPM version: $(npm --version)"
echo "Node version: $("$NODE_BIN" --version)"
echo "NPM version: $("$NPM_BIN" --version)"
# Use clean install to ensure only net-snmp is installed
npm --prefix "$SCRIPT_DIR" install --no-audit --no-fund
# Use absolute paths to binaries to ensure we use our Node.js
"$NPM_BIN" --prefix "$SCRIPT_DIR" install --no-audit --no-fund
INSTALL_STATUS=$?
if [ $INSTALL_STATUS -ne 0 ]; then
@@ -301,8 +310,7 @@ else
rm -f "$SCRIPT_DIR/package.json.bak"
fi
# Restore the original PATH
export PATH="$OLD_PATH"
# We didn't modify PATH, so no need to restore it
echo "NUPST setup completed successfully."
echo "You can now run NUPST using: $SCRIPT_DIR/bin/nupst"