mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Violette Roche-Montane
18.06.2013 3d5556323efd46fa7f1647ab567723933c1c825b
CR-1848 OPENDJ-983 On Windows, unexpected error message while running start-ds -V/-F/-s on an instance not configured
4 files modified
56 ■■■■■ changed files
opends/lib/winlauncher.exe patch | view | raw | blame | history
opends/resource/bin/start-ds.bat 8 ●●●●● patch | view | raw | blame | history
opends/resource/bin/stop-ds.bat 10 ●●●●● patch | view | raw | blame | history
opends/src/build-tools/windows/common.c 38 ●●●●● patch | view | raw | blame | history
opends/lib/winlauncher.exe
Binary files differ
opends/resource/bin/start-ds.bat
@@ -39,8 +39,16 @@
cd /d %INSTANCE_DIR%
set INSTANCE_ROOT=%CD%
cd /d %CUR_DIR%
set TEMP_LOG=%TEMP%\logs\
if NOT EXIST %INSTANCE_ROOT%\logs\ (
  if NOT EXIST %TEMP_LOG% (
    md %TEMP_LOG%
  )
  set LOG="%TEMP_LOG%native-windows.out"
) ELSE (
set LOG="%INSTANCE_ROOT%\logs\native-windows.out"
)
set SCRIPT=start-ds.bat
echo %SCRIPT%: invoked >> %LOG%
opends/resource/bin/stop-ds.bat
@@ -24,7 +24,7 @@
rem
rem
rem      Copyright 2006-2010 Sun Microsystems, Inc.
rem      Portions Copyright 2011-2012 ForgeRock AS
rem      Portions Copyright 2011-2013 ForgeRock AS
setlocal
@@ -50,8 +50,16 @@
cd /d%INSTANCE_DIR%
set INSTANCE_ROOT=%CD%
cd /d%CUR_DIR%
set TEMP_LOG=%TEMP%\logs\
if NOT EXIST %INSTANCE_ROOT%\logs\ (
  if NOT EXIST %TEMP_LOG% (
    md %TEMP_LOG%
  )
  set LOG="%TEMP_LOG%native-windows.out"
) ELSE (
set LOG="%INSTANCE_ROOT%\logs\native-windows.out"
)
set SCRIPT=stop-ds.bat
rem This is the template to use for logging.  Make sure to use >>
opends/src/build-tools/windows/common.c
@@ -23,6 +23,7 @@
*
*
*      Copyright 2008-2010 Sun Microsystems, Inc.
*      Portions Copyright 2013 ForgeRock AS
*/
#include "common.h"
@@ -40,6 +41,7 @@
char * getDebugLogFileName();
void debugInner(BOOL isError, const char *msg, va_list ap);
void deleteIfLargerThan(char * fileName, DWORD maxSize);
BOOL isExistingDirectory(char * fileName);
// ----------------------------------------------------
// Function used to create a process with the given command.
@@ -318,11 +320,15 @@
  char path [MAX_PATH];
  char execName [MAX_PATH];
  char * lastSlash;
  char logpath[MAX_PATH];
  char * temp;
  FILE *file;
  if (logFile != NULL) 
  {
    return logFile;
  }
  temp = getenv("TEMP");
  // Get the name of the executable.  
  GetModuleFileName (
@@ -339,9 +345,26 @@
  lastSlash = strrchr(execName, '\\');
  lastSlash[0] = '\0';
  sprintf(path, "%s\\logs\\%s", execName, DEBUG_LOG_NAME);
  logFile = _strdup(path);
  // Instance root is in execName (eg. C:\opendj
  // and adds the log's folder name to it
  strcpy(logpath, execName);
  strcat(logpath, "\\logs\\");
  // If the log folder doesn's exist in the instance path
  // we create the log file in the temp directory.
  if (isExistingDirectory(logpath))
  {
    sprintf(path, "%s\\logs\\%s", execName, DEBUG_LOG_NAME);
  } else {
    strcat(temp, "\\logs\\");
    mkdir(temp);
    strcat(temp, DEBUG_LOG_NAME);
    file = fopen(temp,"a+");
    fclose(file);
    sprintf(path, "%s", temp);
  }
  logFile = _strdup(path);
  return logFile;
}
@@ -395,3 +418,14 @@
    DeleteFile(fileName);
  }
}
// ---------------------------------------------------------------
// Checks if the specifed directory exist.
// ---------------------------------------------------------------
BOOL isExistingDirectory(char * fileName)
{
  DWORD str = GetFileAttributes(fileName);
  return (str != INVALID_FILE_ATTRIBUTES &&
         (str & FILE_ATTRIBUTE_DIRECTORY));
}