This is an automated email from the ASF dual-hosted git repository.

jgallimore pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git


The following commit(s) were added to refs/heads/master by this push:
     new 590c87a  TOMEE-2654 Expose service user and service password in 
service installation scripts
     new 8ecdd60  Merge pull request #545 from 
jgallimore/tomee-2654-win-service-user
590c87a is described below

commit 590c87a6702cf9f37b9d735c69379df05811c8f5
Author: Jonathan Gallimore <[email protected]>
AuthorDate: Mon Sep 2 11:26:44 2019 +0100

    TOMEE-2654 Expose service user and service password in service installation 
scripts
---
 tomee/apache-tomee/src/main/resources/service.bat  | 29 ++++++++++++++++++++-
 .../main/resources/service.install.as.admin.bat    | 30 +++++++++++++++++++++-
 2 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/tomee/apache-tomee/src/main/resources/service.bat 
b/tomee/apache-tomee/src/main/resources/service.bat
index a8098aa..4485423 100644
--- a/tomee/apache-tomee/src/main/resources/service.bat
+++ b/tomee/apache-tomee/src/main/resources/service.bat
@@ -118,6 +118,8 @@ set "EXECUTABLE=%proc%"
 rem Set default Service name (If you change this then rename also TomEE.exe to 
the same name)
 set SERVICE_NAME=TomEE
 set PR_DISPLAYNAME=Apache TomEE
+set OLD_SERVICEUSER=%PR_SERVICEUSER%
+set OLD_SERVICEPASSWORD=%PR_SERVICEPASSWORD%
 
 if "x%1x" == "xx" goto displayUsage
 set SERVICE_CMD=%1
@@ -126,10 +128,17 @@ if "x%1x" == "xx" goto checkServiceCmd
 :checkUser
 if "x%1x" == "x/userx" goto runAsUser
 if "x%1x" == "x--userx" goto runAsUser
+
+if "x%1x" == "x/service-userx" goto serviceUser
+if "x%1x" == "x--service-userx" goto serviceUser
+if "x%1x" == "x/service-passwordx" goto servicePassword
+if "x%1x" == "x--service-passwordx" goto servicePassword
+
+if "x%1x" == "xx" goto checkServiceCmd
+
 set SERVICE_NAME=%1
 set PR_DISPLAYNAME=Apache TomEE (%1)
 shift
-if "x%1x" == "xx" goto checkServiceCmd
 goto checkUser
 :runAsUser
 shift
@@ -138,6 +147,21 @@ set SERVICE_USER=%1
 shift
 runas /env /savecred /user:%SERVICE_USER% "%COMSPEC% /K \"%SELF%\" 
%SERVICE_CMD% %SERVICE_NAME%"
 goto end
+
+:serviceUser
+shift
+if "x%1x" == "xx" goto displayUsage
+set PR_SERVICEUSER=%1
+shift
+goto checkUser
+
+:servicePassword
+shift
+if "x%1x" == "xx" goto displayUsage
+set PR_SERVICEPASSWORD=%1
+shift
+goto checkUser
+
 :checkServiceCmd
 if /i %SERVICE_CMD% == install goto doInstall
 if /i %SERVICE_CMD% == remove goto doRemove
@@ -182,6 +206,7 @@ if exist "%PR_JVM%" goto foundJvm
 set PR_JVM=auto
 :foundJvm
 echo Using JVM:              "%PR_JVM%"
+echo Using Service User:     "%PR_SERVICEUSER%"
 
 "%EXECUTABLE%" //IS//%SERVICE_NAME% ^
     --DisplayName=%SERVICE_NAME% ^
@@ -235,4 +260,6 @@ rem the drawback was it was preventing custom native lib to 
be loaded even if ad
 echo The service '%SERVICE_NAME%' has been installed.
 
 :end
+set PR_SERVICE_USER=%OLD_SERVICEUSER%
+set PR_SERVICE_PASSWORD=%OLD_SERVICEPASSWORD%
 cd "%CURRENT_DIR%"
diff --git a/tomee/apache-tomee/src/main/resources/service.install.as.admin.bat 
b/tomee/apache-tomee/src/main/resources/service.install.as.admin.bat
index dcfbe6b..e2718ca 100644
--- a/tomee/apache-tomee/src/main/resources/service.install.as.admin.bat
+++ b/tomee/apache-tomee/src/main/resources/service.install.as.admin.bat
@@ -22,6 +22,9 @@ REM================================================
 @if not "%ECHO%" == ""  echo %ECHO%
 @if "%OS%" == "Windows_NT" setlocal
 
+set OLD_SERVICEUSER=%PR_SERVICEUSER%
+set OLD_SERVICEPASSWORD=%PR_SERVICEPASSWORD%
+
 if "%OS%" == "Windows_NT" (
   set "DIRNAME=%~dp0%"
 ) else (
@@ -30,4 +33,29 @@ if "%OS%" == "Windows_NT" (
 
 pushd %DIRNAME%
 
-service install
\ No newline at end of file
+:checkUser
+if "x%1x" == "x/service-userx" goto serviceUser
+if "x%1x" == "x--service-userx" goto serviceUser
+if "x%1x" == "x/service-passwordx" goto servicePassword
+if "x%1x" == "x--service-passwordx" goto servicePassword
+
+goto install
+
+:serviceUser
+shift
+if "x%1x" == "xx" goto displayUsage
+set PR_SERVICEUSER=%1
+shift
+goto checkUser
+
+:servicePassword
+shift
+if "x%1x" == "xx" goto displayUsage
+set PR_SERVICEPASSWORD=%1
+shift
+goto checkUser
+
+:install
+service install
+set PR_SERVICEUSER=%OLD_SERVICEUSER%
+set PR_SERVICEPASSWORD=%OLD_SERVICEPASSWORD%

Reply via email to