service.cmd 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. @echo off
  2. setlocal
  3. REM Set intermediate env vars because the %VAR:x=y% notation below
  4. REM (which replaces the string x with the string y in VAR)
  5. REM doesn't handle undefined environment variables. This way
  6. REM we're always dealing with defined variables in those tests.
  7. set CHK_JAVA_HOME=_%JAVA_HOME%
  8. set CHK_SERVICE_HOME=_%SERVICE_HOME%
  9. set CHK_CREDENTIAL_FILE=_%AWS_CREDENTIAL_FILE%
  10. if "%CHK_CREDENTIAL_FILE:"=%" == "_" goto CREDENTIAL_FILE_MISSING
  11. SET AWS_CREDENTIAL_FILE=%AWS_CREDENTIAL_FILE:"=%
  12. :CREDENTIAL_FILE_MISSING
  13. if "%CHK_SERVICE_HOME:"=%" == "_" goto SERVICE_HOME_MISSING
  14. if "%CHK_JAVA_HOME:"=%" == "_" goto JAVA_HOME_MISSING
  15. REM If a classpath exists preserve it
  16. SET SERVICE_HOME=%SERVICE_HOME:"=%
  17. SET LIB="%SERVICE_HOME%\lib"
  18. REM Brute force
  19. SET CP=%LIB%\service.jar
  20. SET CP=%CP%;%LIB%\CliCommando-1.0.jar
  21. SET CP=%CP%;%LIB%\Commons-codec-1.3.jar
  22. SET CP=%CP%;%LIB%\Commons-cli-1.1.jar
  23. SET CP=%CP%;%LIB%\activation-1.1.jar
  24. SET CP=%CP%;%LIB%\CliCommando-1.0.jar
  25. SET CP=%CP%;%LIB%\commons-discovery-0.2.jar
  26. SET CP=%CP%;%LIB%\commons-httpclient-3.0.jar
  27. SET CP=%CP%;%LIB%\commons-logging-1.0.4.jar
  28. SET CP=%CP%;%LIB%\commons-logging-api-1.1.1.jar
  29. SET CP=%CP%;%LIB%\service.jar
  30. SET CP=%CP%;%LIB%\jaxb-api-2.0.jar
  31. SET CP=%CP%;%LIB%\jaxb-impl-2.0.1.jar
  32. SET CP=%CP%;%LIB%\jaxws-api-2.0.jar
  33. SET CP=%CP%;%LIB%\jdom-1.0.jar
  34. SET CP=%CP%;%LIB%\log4j.jar
  35. SET CP=%CP%;%LIB%\serializer.jar
  36. SET CP=%CP%;%LIB%\stax-api-1.0.1.jar
  37. SET CP=%CP%;%LIB%\wsdl4j-1.6.1.jar
  38. SET CP=%CP%;%LIB%\wss4j-1.5.7.jar
  39. SET CP=%CP%;%LIB%\wstx-asl-3.2.0.jar
  40. SET CP=%CP%;%LIB%\xalan-j2-2.7.0.jar
  41. SET CP=%CP%;%LIB%\xfire-all-1.2.6.jar
  42. SET CP=%CP%;%LIB%\xfire-jsr181-api-1.0-M1.jar
  43. SET CP=%CP%;%LIB%\xmlsec-1.4.2.jar
  44. REM Grab the class name
  45. SET CMD=%1
  46. REM SHIFT doesn't affect %* so we need this clunky hack
  47. SET ARGV=%2
  48. SHIFT
  49. SHIFT
  50. :ARGV_LOOP
  51. IF (%1) == () GOTO ARGV_DONE
  52. REM Get around strange quoting bug
  53. SET ARG=%1
  54. REM Escape the minus sign for negative numbers
  55. ECHO %ARG% > %TEMP%\argtest
  56. FINDSTR /B \-[0-9.] %TEMP%\argtest > NUL
  57. if %ERRORLEVEL%==0 (
  58. SET ARG=\%ARG%
  59. )
  60. DEL %TEMP%\argtest
  61. SET ARG=%ARG:"=%
  62. SET ARGV=%ARGV% "%ARG%"
  63. SHIFT
  64. GOTO ARGV_LOOP
  65. :ARGV_DONE
  66. REM Make sure JAVA_HOME has only a single sorrounding double quotes
  67. set JAVA_HOME="%JAVA_HOME:"=%"
  68. REM run
  69. %JAVA_HOME%\bin\java %SERVICE_JVM_ARGS% -classpath %CP% com.amazon.webservices.Cli %CMD% %ARGV%
  70. goto DONE
  71. :JAVA_HOME_MISSING
  72. echo JAVA_HOME is not set
  73. exit /b 1
  74. :SERVICE_HOME_MISSING
  75. echo "This command is not intended to be run directly. Please see documentation on using service commands."
  76. exit /b 1
  77. :DONE
  78. endlocal