Bug 1301578

Summary: apply-updates.bat in jon-server-3.3-update-04.zip only works reliably in the USA
Product: [Other] RHQ Project Reporter: Tom Fonteyne <tfonteyn>
Component: Core ServerAssignee: RHQ Project Maintainer <rhq-maint>
Status: CLOSED NOTABUG QA Contact: Mike Foley <mfoley>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 4.12CC: bkramer, hrupp, loleary, mfoley, miburman
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1301575 Environment:
Last Closed: 2016-01-25 14:00:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1301575    
Bug Blocks:    

Description Tom Fonteyne 2016-01-25 12:31:22 UTC
+++ This bug was initially created as a clone of Bug #1301575 +++

Download "jon-server-3.3-update-04.zip" on a Windows machine.

In "apply-updates.bat" we have:

rem Calculate time stamp.
set MM=%date:~4,2%
set DD=%date:~7,2%
set YY=%date:~12,2%

On a UK machine:

echo %date%
25/01/2016

echo %date:~4,2%
1/

echo %date:~7,2%
01

echo %date:~12,2%
ECHO is on.  (the result is an empty string, so it reacts to just 'echo')

On a Dutch machine:

echo %date%
ma 25/01/2016

echo %date:~4,2%
5/

echo %date:~7,2%
1/

echo %date:~12,2%
6

In other words: the string manipulation will only work reliable if used on a United States machine. In other countries, this will not only fail to get the correct date, but will make the script break when using these as a filename.

Solution:
- do no presume everyone is US based.
- port the script use Powershell, which since Windows Vista is always available.
- use wmic:

@echo off
setlocal enabledelayedexpansion
set DT=
for /f "delims=" %%a in ('wmic OS Get localdatetime  ^| find "."') do set DT=%%a
set DT=%DT:~0,8%
echo %DT%
-> YYYYMMDD or use 2,8  to get YYMMDD if you prefer

Comment 1 Larry O'Leary 2016-01-25 14:00:30 UTC
The apply-update component is not available in RHQ. This is a JBoss ON component. 

The JBoss ON variant of this bug has been captured in bug 1301575.