start.sh 689 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. # Example:
  3. # ./start.sh --date=2021-12-05
  4. PORT="9000"
  5. PROXY_URL="http://localhost:$PORT/"
  6. BIN_FILE="./nptm"
  7. CURRENT_REGISTRY=$(npm config get registry)
  8. echo "Current registry: $CURRENT_REGISTRY"
  9. cleanup() {
  10. echo ""
  11. echo "----------------------------------------"
  12. echo "Shutdown..."
  13. echo "Restore npm configuration..."
  14. npm config set registry "$CURRENT_REGISTRY"
  15. echo "Registry restored: $(npm config get registry)"
  16. }
  17. trap cleanup EXIT
  18. echo "Switching npm to port $PORT ($PROXY_URL)"
  19. npm config set registry "$PROXY_URL"
  20. echo "Starting Time Machine on port $PORT..."
  21. echo "----------------------------------------"
  22. "$BIN_FILE" --port="$PORT" "$@"