blduser.bat 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. REM *************************************************************************
  2. REM
  3. REM Licensed Materials - Property of IBM
  4. REM
  5. REM "Restricted Materials of IBM"
  6. REM
  7. REM IBM Informix Dynamic Server
  8. REM Copyright IBM Corporation 2008 All rights reserved.
  9. REM
  10. REM Title: blduser.bat
  11. REM Description: Script to create database sysuser
  12. REM
  13. REM *************************************************************************
  14. REM ###
  15. REM # Set infdir and outfile name
  16. REM ###
  17. set INFDIR=%INFORMIXDIR%
  18. set OUTFILE=%INFDIR%\tmp\blduser.out.%INFORMIXSERVER%
  19. set CHKFILE=%INFDIR%\tmp\sysuserdbchk.out.%INFORMIXSERVER%
  20. set BLDUSER_STATFILE=%INFDIR%\tmp\blduser.%INFORMIXSERVER%.sql
  21. set SYSUSERDB=sysuser
  22. REM ###
  23. REM # Inherit the message constants
  24. REM ###
  25. call %INFDIR%\etc\conv\strmaps.bat
  26. REM ###
  27. REM # Setup the WINROOT path
  28. REM ###
  29. set WINROOT=%SystemRoot%
  30. if "x%WINROOT%" == "x" set WINROOT=C:\WINDOWS
  31. REM ###
  32. REM # Remove emergency boot file since it's data is now obsolete
  33. REM ###
  34. copyboot
  35. REM # Put something in output file, so user knows something happened
  36. type %INFDIR%\etc\blduser.1in > %OUTFILE% 2>&1
  37. set DBPATH_PREV=%DBPATH%
  38. set DBPATH=
  39. set DBCOUNT=0
  40. set TABCOUNT=0
  41. REM Create 'sysuser' in English
  42. set DB_LOCALE=en_us.8859-1
  43. set CLIENT_LOCALE=en_us.8859-1
  44. REM Create print_msg.sql and call it through dbaccess from print_msg.bat
  45. REM to print message to online.log
  46. echo echo set lock mode to wait 60; ^> print_msg.sql > print_msg.bat
  47. echo echo database sysmaster; ^>^> print_msg.sql >> print_msg.bat
  48. echo echo insert into logmessage values (%%1%%); ^>^> print_msg.sql >> print_msg.bat
  49. echo %INFDIR%\bin\dbaccess - print_msg.sql >> print_msg.bat
  50. REM If the database 'sysuser' exists then we don't have much to do
  51. echo output to "%CHKFILE%" without headings > %INFDIR%\tmp\blduser1.sql
  52. echo select count^(*^) from sysdatabases where name = '%SYSUSERDB%'; >> %INFDIR%\tmp\blduser1.sql
  53. %INFDIR%\bin\dbaccess sysmaster %INFDIR%\tmp\blduser1.sql
  54. del %INFDIR%\tmp\blduser1.sql
  55. IF EXIST %CHKFILE% (
  56. FOR /f "delims== " %%i IN ('type %CHKFILE%') do set DBCOUNT=%%i
  57. del %CHKFILE%
  58. ) ELSE set DBCOUNT=0
  59. del %OUTFILE%
  60. IF %DBCOUNT% == 0 GOTO bldsysuser
  61. REM If the database 'sysuser' exists then we check 'sysauth' table
  62. echo output to "%CHKFILE%" without headings > %INFDIR%\tmp\blduser2.sql
  63. echo select count^(*^) from systables where tabname = 'sysauth'; >> %INFDIR%\tmp\blduser2.sql
  64. %INFDIR%\bin\dbaccess sysuser %INFDIR%\tmp\blduser2.sql >> %OUTFILE% 2>&1
  65. del %INFDIR%\tmp\blduser2.sql
  66. IF EXIST %CHKFILE% (
  67. FOR /f "delims== " %%i IN ('type %CHKFILE%') do set TABCOUNT=%%i
  68. del %CHKFILE%
  69. ) ELSE set TABCOUNT=0
  70. IF %TABCOUNT% == 1 (
  71. call print_msg.bat %S_SYSUSER_EXIST%
  72. del %OUTFILE%
  73. del print_msg.bat print_msg.sql
  74. goto exit
  75. ) ELSE (
  76. REM 'sysuser' exists, but it's not created by IDS
  77. call print_msg.bat %S_BLD_SYSUSER_FAIL%
  78. echo Database 'sysuser' exists, but it is not created by IDS. >> %OUTFILE% 2>&1
  79. echo >> %OUTFILE% 2>&1
  80. echo IBM Informix database server will store remote trusted user's authentication >> %OUTFILE% 2>&1
  81. echo information and database security administrator metadata in database 'sysuser'. >> %OUTFILE% 2>&1
  82. echo >> %OUTFILE% 2>&1
  83. echo Please drop database 'sysuser' and rerun blduser.bat as informix after the >> %OUTFILE% 2>&1
  84. echo server comes On-Line. >> %OUTFILE% 2>&1
  85. del print_msg.bat print_msg.sql
  86. goto exit
  87. )
  88. :bldsysuser
  89. REM ###
  90. REM # Build the 'sysuser' database
  91. REM ###
  92. echo "About to run sysuser.sql" >> %OUTFILE% 2>&1
  93. dbaccess - %INFDIR%\etc\sysuser.sql >> %OUTFILE% 2>&1
  94. REM # Check to see that there were no errors
  95. REM # Make sure find.exe runs from \winnt\system32 and not from a DOS directory
  96. %WINROOT%\System32\find /V "%INFDIR%" %OUTFILE% | %WINROOT%\System32\find /I "error"
  97. REM # 0 means found and error so sysuser.sql failed
  98. if ERRORLEVEL 1 goto SUCCESS
  99. if ERRORLEVEL 0 goto FAILURE
  100. :SUCCESS
  101. REM ###
  102. REM # Else it was successful, so remove OUTFILE and ...
  103. REM # put s_sysuser_succ msg into sysmaster 'logmessage' table.
  104. REM # See olmsg.src for msg.
  105. REM ###
  106. echo "Inserting success msg into logmessage table" >> %OUTFILE% 2>&1
  107. echo insert into logmessage(message_num) values (%S_BLD_SYSUSER_SUCC%); > %BLDUSER_STATFILE%
  108. dbaccess sysmaster %BLDUSER_STATFILE% >> %OUTFILE% 2>&1
  109. del %OUTFILE% print_msg.bat
  110. goto exit
  111. :FAILURE
  112. REM ###
  113. REM # Was there an error?
  114. REM # If yes, then drop 'sysuser' and ...
  115. REM # put s_bld_sysuser_err msg into the sysmaster 'logmessage' table.
  116. REM # See olmsg.src for msg.
  117. REM ###
  118. echo Cleaning up whatever was successfully created >> %OUTFILE%
  119. dbaccess - - < %INFDIR%\etc\blduser.2in >> %OUTFILE% 2>&1
  120. echo insert into logmessage(message_num) values (%S_BLD_SYSUSER_FAIL%); > %BLDUSER_STATFILE%
  121. dbaccess sysmaster %BLDUSER_STATFILE% >> %OUTFILE% 2>&1
  122. del print_msg.bat
  123. goto exit
  124. :exit
  125. del %BLDUSER_STATFILE%