49 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/bash
 | |
| 
 | |
| # NUPST Launcher Script
 | |
| # This script detects architecture and OS, then runs NUPST with the appropriate Node.js binary
 | |
| 
 | |
| # First, handle symlinks correctly
 | |
| REAL_SCRIPT_PATH=$(readlink -f "${BASH_SOURCE[0]}")
 | |
| SCRIPT_DIR=$(dirname "$REAL_SCRIPT_PATH")
 | |
| 
 | |
| # For debugging
 | |
| # echo "Script path: $REAL_SCRIPT_PATH"
 | |
| # echo "Script dir: $SCRIPT_DIR"
 | |
| 
 | |
| # If we're run via symlink from /usr/local/bin, use the hardcoded installation path
 | |
| if [[ "$SCRIPT_DIR" == "/usr/local/bin" ]]; then
 | |
|   PROJECT_ROOT="/opt/nupst"
 | |
| else
 | |
|   # Otherwise, use relative path from script location
 | |
|   PROJECT_ROOT="$( cd "$SCRIPT_DIR/.." &> /dev/null && pwd )"
 | |
| fi
 | |
| 
 | |
| # For debugging
 | |
| # echo "Project root: $PROJECT_ROOT"
 | |
| 
 | |
| # Set Node.js binary path directly
 | |
| NODE_BIN="$PROJECT_ROOT/vendor/node-linux-x64/bin/node"
 | |
| 
 | |
| # If binary doesn't exist, try system Node as fallback
 | |
| if [ ! -f "$NODE_BIN" ]; then
 | |
|   if command -v node &> /dev/null; then
 | |
|     NODE_BIN="node"
 | |
|     echo "Using system Node.js installation"
 | |
|   else  
 | |
|     echo "Error: Node.js binary not found at $NODE_BIN"
 | |
|     echo "Please run the setup script or install Node.js manually."
 | |
|     exit 1
 | |
|   fi
 | |
| fi
 | |
| 
 | |
| # Run NUPST with the Node.js binary
 | |
| if [ -f "$PROJECT_ROOT/dist_ts/index.js" ]; then
 | |
|   exec "$NODE_BIN" "$PROJECT_ROOT/dist_ts/index.js" "$@"
 | |
| elif [ -f "$PROJECT_ROOT/dist/index.js" ]; then
 | |
|   exec "$NODE_BIN" "$PROJECT_ROOT/dist/index.js" "$@"
 | |
| else
 | |
|   echo "Error: Could not find NUPST's index.js file."
 | |
|   echo "Please run the setup script to download the required files."
 | |
|   exit 1
 | |
| fi |