Author: kkolinko
Date: Mon Feb 17 09:38:03 2014
New Revision: 1568920

URL: http://svn.apache.org/r1568920
Log:
Merged revisions r1568779-r1568780, r1568828 from tomcat/trunk:

Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56143
Allow service.bat to be launched from a non-UAC console,
by using arguments instead of env variables to pass options to prunsrv.

Fix regression in r1567742 that values for --StdOutput, --StdError were lost.

Pass --LogPath option to service removal command, to avoid using default value 
for this option 
(service uninstallation logs were written to 
%SystemRoot%\system32\LogFiles\Apache).

Align Commons Daemon options between service.bat and exe installer:
service.bat changes:
--DisplayName
--StartPath, --StopPath (They should be unnecessary in --StartMode jvm, but exe 
installed sets them and they are visible and settable in configuration dialog)
--Classpath: Reference tomcat-juli.jar only once when home==base.
--JvmOptions: Just reordered.

exe installer changes:
--JvmMs, --JvmMx

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/bin/service.bat
    tomcat/tc7.0.x/trunk/res/tomcat.nsi
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
    tomcat/tc7.0.x/trunk/webapps/docs/windows-service-howto.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1568779-1568780,1568828

Modified: tomcat/tc7.0.x/trunk/bin/service.bat
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/bin/service.bat?rev=1568920&r1=1568919&r2=1568920&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/bin/service.bat (original)
+++ tomcat/tc7.0.x/trunk/bin/service.bat Mon Feb 17 09:38:03 2014
@@ -75,7 +75,7 @@ set "EXECUTABLE=%CATALINA_HOME%\bin\tomc
 
 rem Set default Service name
 set SERVICE_NAME=Tomcat@VERSION_MAJOR@
-set PR_DISPLAYNAME=Apache Tomcat @VERSION_MAJOR@
+set DISPLAYNAME=Apache Tomcat @VERSION_MAJOR@ %SERVICE_NAME%
 
 if "x%1x" == "xx" goto displayUsage
 set SERVICE_CMD=%1
@@ -85,7 +85,7 @@ if "x%1x" == "xx" goto checkServiceCmd
 if "x%1x" == "x/userx" goto runAsUser
 if "x%1x" == "x--userx" goto runAsUser
 set SERVICE_NAME=%1
-set PR_DISPLAYNAME=Apache Tomcat %1
+set DISPLAYNAME=Apache Tomcat @VERSION_MAJOR@ %1
 shift
 if "x%1x" == "xx" goto checkServiceCmd
 goto checkUser
@@ -108,7 +108,11 @@ goto end
 
 :doRemove
 rem Remove the service
-"%EXECUTABLE%" //DS//%SERVICE_NAME%
+echo Removing the service '%SERVICE_NAME%' ...
+echo Using CATALINA_BASE:    "%CATALINA_BASE%"
+
+"%EXECUTABLE%" //DS//%SERVICE_NAME% ^
+    --LogPath "%CATALINA_BASE%\logs"
 if not errorlevel 1 goto removed
 echo Failed removing '%SERVICE_NAME%' service
 goto end
@@ -124,45 +128,43 @@ echo Using CATALINA_BASE:    "%CATALINA_
 echo Using JAVA_HOME:        "%JAVA_HOME%"
 echo Using JRE_HOME:         "%JRE_HOME%"
 
-rem Use the environment variables as an example
-rem Each command line option is prefixed with PR_
-
-set PR_DESCRIPTION=Apache Tomcat @VERSION@ Server - http://tomcat.apache.org/
-set "PR_INSTALL=%EXECUTABLE%"
-set "PR_LOGPATH=%CATALINA_BASE%\logs"
-set 
"PR_CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_BASE%\bin\tomcat-juli.jar;%CATALINA_HOME%\bin\tomcat-juli.jar"
 rem Set the server jvm from JAVA_HOME
-set "PR_JVM=%JRE_HOME%\bin\server\jvm.dll"
-if exist "%PR_JVM%" goto foundJvm
+set "JVM=%JRE_HOME%\bin\server\jvm.dll"
+if exist "%JVM%" goto foundJvm
 rem Set the client jvm from JAVA_HOME
-set "PR_JVM=%JRE_HOME%\bin\client\jvm.dll"
-if exist "%PR_JVM%" goto foundJvm
-set PR_JVM=auto
-set PR_STDOUTPUT=auto
-set PR_STDERROR=auto
+set "JVM=%JRE_HOME%\bin\client\jvm.dll"
+if exist "%JVM%" goto foundJvm
+set JVM=auto
 :foundJvm
-echo Using JVM:              "%PR_JVM%"
+echo Using JVM:              "%JVM%"
+
+set 
"CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_BASE%\bin\tomcat-juli.jar"
+if not "%CATALINA_HOME%" == "%CATALINA_BASE%" set 
"CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\tomcat-juli.jar"
+
 "%EXECUTABLE%" //IS//%SERVICE_NAME% ^
+    --Description "Apache Tomcat @VERSION@ Server - http://tomcat.apache.org/"; 
^
+    --DisplayName "%DISPLAYNAME%" ^
+    --Install "%EXECUTABLE%" ^
+    --LogPath "%CATALINA_BASE%\logs" ^
+    --StdOutput auto ^
+    --StdError auto ^
+    --Classpath "%CLASSPATH%" ^
+    --Jvm "%JVM%" ^
+    --StartMode jvm ^
+    --StopMode jvm ^
+    --StartPath "%CATALINA_HOME%" ^
+    --StopPath "%CATALINA_HOME%" ^
     --StartClass org.apache.catalina.startup.Bootstrap ^
     --StopClass org.apache.catalina.startup.Bootstrap ^
     --StartParams start ^
     --StopParams stop ^
-    --JvmOptions 
"-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed;-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties"
 ^
-    --StartMode jvm ^
-    --StopMode jvm ^
+    --JvmOptions 
"-Dcatalina.home=%CATALINA_HOME%;-Dcatalina.base=%CATALINA_BASE%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed;-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties"
 ^
     --JvmMs 128 ^
     --JvmMx 256
 if not errorlevel 1 goto installed
 echo Failed installing '%SERVICE_NAME%' service
 goto end
 :installed
-rem Clear the environment variables. They are not needed any more.
-set PR_DISPLAYNAME=
-set PR_DESCRIPTION=
-set PR_INSTALL=
-set PR_LOGPATH=
-set PR_CLASSPATH=
-set PR_JVM=
 echo The service '%SERVICE_NAME%' has been installed.
 
 :end

Modified: tomcat/tc7.0.x/trunk/res/tomcat.nsi
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/res/tomcat.nsi?rev=1568920&r1=1568919&r2=1568920&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/res/tomcat.nsi (original)
+++ tomcat/tc7.0.x/trunk/res/tomcat.nsi Mon Feb 17 09:38:03 2014
@@ -318,7 +318,7 @@ Section -post
     FileWrite $ServiceInstallLog "$\r$\n"
     FileWrite $ServiceInstallLog '"$INSTDIR\bin\$TomcatServiceFileName" 
//US//$TomcatServiceName --JvmOptions 
"-Dcatalina.home=$INSTDIR#-Dcatalina.base=$INSTDIR#-Djava.endorsed.dirs=$INSTDIR\endorsed#-Djava.io.tmpdir=$INSTDIR\temp#-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager#-Djava.util.logging.config.file=$INSTDIR\conf\logging.properties"'
     FileWrite $ServiceInstallLog "$\r$\n"
-    FileWrite $ServiceInstallLog '"$INSTDIR\bin\$TomcatServiceFileName" 
//US//$TomcatServiceName --StdOutput auto --StdError auto'
+    FileWrite $ServiceInstallLog '"$INSTDIR\bin\$TomcatServiceFileName" 
//US//$TomcatServiceName --StdOutput auto --StdError auto --JvmMs 128 --JvmMx 
256'
     FileWrite $ServiceInstallLog "$\r$\n"
     FileClose $ServiceInstallLog
   ${EndIf}
@@ -326,7 +326,7 @@ Section -post
   DetailPrint "Configuring $TomcatServiceName service"
   nsExec::ExecToLog '"$INSTDIR\bin\$TomcatServiceFileName" 
//US//$TomcatServiceName --Classpath 
"$INSTDIR\bin\bootstrap.jar;$INSTDIR\bin\tomcat-juli.jar" --StartClass 
org.apache.catalina.startup.Bootstrap --StopClass 
org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop  
--StartMode jvm --StopMode jvm'
   nsExec::ExecToLog '"$INSTDIR\bin\$TomcatServiceFileName" 
//US//$TomcatServiceName --JvmOptions 
"-Dcatalina.home=$INSTDIR#-Dcatalina.base=$INSTDIR#-Djava.endorsed.dirs=$INSTDIR\endorsed#-Djava.io.tmpdir=$INSTDIR\temp#-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager#-Djava.util.logging.config.file=$INSTDIR\conf\logging.properties"'
-  nsExec::ExecToLog '"$INSTDIR\bin\$TomcatServiceFileName" 
//US//$TomcatServiceName --StdOutput auto --StdError auto'
+  nsExec::ExecToLog '"$INSTDIR\bin\$TomcatServiceFileName" 
//US//$TomcatServiceName --StdOutput auto --StdError auto  --JvmMs 128 --JvmMx 
256'
 
   ${If} $TomcatShortcutAllUsers == "1"
     WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" 
"ApacheTomcatMonitor@VERSION_MAJOR_MINOR@_$TomcatServiceName" 
'"$INSTDIR\bin\$TomcatServiceManagerFileName" //MS//$TomcatServiceName'
@@ -1099,7 +1099,7 @@ Section Uninstall
   nsExec::ExecToLog '"$INSTDIR\bin\$TomcatServiceManagerFileName" 
//MQ//$TomcatServiceName'
   ; Delete Tomcat service
   DetailPrint "Uninstalling $TomcatServiceName service"
-  nsExec::ExecToLog '"$INSTDIR\bin\$TomcatServiceFileName" 
//DS//$TomcatServiceName'
+  nsExec::ExecToLog '"$INSTDIR\bin\$TomcatServiceFileName" 
//DS//$TomcatServiceName --LogPath "$INSTDIR\logs"'
   ClearErrors
 
   ; Don't know if 32-bit or 64-bit registry was used so, for now, remove both

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1568920&r1=1568919&r2=1568920&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Mon Feb 17 09:38:03 2014
@@ -74,6 +74,27 @@
   </subsection>
   <subsection name="Other">
     <changelog>
+      <fix>
+        <bug>56143</bug>: Improve <code>service.bat</code> so that it can be
+        launched from a non-UAC console. This includes using a single call to
+        <code>tomcat7.exe</code> to install the Windows service rather than
+        three calls, and using command line arguments instead of environment
+        variables to pass the settings. (markt/kkolinko)
+      </fix>
+      <fix>
+        Fix regression in 7.0.52: when using <code>service.bat install</code>
+        to install the service the values for --StdOutput, --StdError options
+        were passed as blank instead of "auto". (kkolinko)
+      </fix>
+      <fix>
+        Align options between <code>service.bat</code> and <code>exe</code>
+        Windows installer. For <code>service.bat</code> the changes are in
+        --Classpath, --DisplayName, --StartPath, --StopPath. For
+        <code>exe</code> installer the changes are in --JvmMs, --JvmMx options,
+        which are now 128 Mb and 256 Mb respectively instead of being empty.
+        Explicitly specify --LogPath path when uninstalling Windows service,
+        avoiding default value for that option. (kkolinko)
+      </fix>
       <scode>
         Simplify Windows *.bat files: remove %OS% checks, as java 6 does
         not run on ancient non-NT operating systems. (kkolinko)

Modified: tomcat/tc7.0.x/trunk/webapps/docs/windows-service-howto.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/windows-service-howto.xml?rev=1568920&r1=1568919&r2=1568920&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/windows-service-howto.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/windows-service-howto.xml Mon Feb 17 
09:38:03 2014
@@ -308,11 +308,16 @@ script. If necessary, you can use the <c
 a user to use for the installation of the service.
 </p>
 <p>
-<strong>NOTE:</strong> On Windows Vista or any other operating system with User
-Account Control (UAC) you must either disable UAC or right-click on cmd.exe and
-select "Run as administrator" in order to run this script. If UAC is enabled
-neither being logged on with an Administrator account, nor using the
-<code>/user</code> switch is sufficient.
+<strong>NOTE:</strong> On Windows Vista or any later operating system with User
+Account Control (UAC) enabled you will be asked for additional privileges
+when 'Tomcat<version-major/>.exe' is launched by the script.<br/>
+If you want to pass additional options to service installer as
+<code>PR_*</code> environment variables, you have to either configure them
+globally in OS, or launch the program that sets them with elevated privileges
+(e.g. right-click on cmd.exe and select "Run as administrator"; on Windows 8
+(or later) or Windows Server 2012 (or later), you can open an elevated command
+prompt for the current directory from the Explorer
+by clicking on the "File" menu bar). See issue <bug>56143</bug> for details.
 </p>
 <p>
 <source>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to