// To create a CDROM distribution, set the bIsCDROM variable to TRUE // and set all components "Include in Build" options to "Yes" in the // IDE. For a web distribution set bIsCDROM to FALSE and set "Include // in Build" to "No" for those components mentioned in the SetComponents() // function of this script. //////////////////////////////////////////////////////////////////////////////// // // IIIIIII SSSSSS // II SS InstallShield (R) // II SSSSSS (c) 1996-1997, InstallShield Software Corporation // II SS (c) 1990-1996, InstallShield Corporation // IIIIIII SSSSSS All Rights Reserved. // // // This code is generated as a starting setup template. You should // modify it to provide all necessary steps for your setup. // // // File Name: Setup.rul // // Description: InstallShield script // // Comments: This template script performs a basic setup. With minor // modifications, this template can be adapted to create // new, customized setups. // //////////////////////////////////////////////////////////////////////////////// // Include header files #include "sdlang.h" #include "sddialog.h" ////////////////////// string defines //////////////////////////// #define UNINST_LOGFILE_NAME "Uninst.isu" //////////////////// installation declarations /////////////////// // ----- DLL function prototypes ----- // your DLL function prototypes // ---- script function prototypes ----- // generated by the Project Wizard prototype ShowDialogs(); prototype MoveFileData(); prototype HandleMoveDataError( NUMBER ); prototype ProcessBeforeDataMove(); prototype ProcessAfterDataMove(); prototype SetupRegistry(); prototype SetupFolders(); prototype CleanUpInstall(); prototype SetupInstall(); prototype SetupScreen(); prototype CheckRequirements(); prototype DialogShowSdLicense(); prototype DialogShowSdFinishReboot(); // your script function prototypes prototype DialogGreenstoneInstallationType(); prototype DialogSetupType(); prototype DialogSelectCollections(); prototype DialogAskDestPath(); prototype DialogGetAdminPassword(); prototype SetComponents(); prototype SetAdminPassword(); prototype CheckWin32s(); prototype CreateServerTxt(); prototype EditGsdlsiteCfg(); prototype EditSetupBat(); prototype rs(BYREF STRING); prototype InstallCollOrganizer(); prototype SetPermissions(); // ----- global variables ------ // generated by the Project Wizard BOOL bWinNT, bIsShellExplorer, bInstallAborted, bIs32BitSetup; STRING svDir; STRING svName, svCompany, svSerial; STRING svDefGroup; STRING szAppPath; STRING svSetupType; // your global variables BOOL bCompact, bIsCDROM; STRING svAdminPassword, svLogFile; // for _LaunchAppEx function #ifndef STILL_ACTIVE #define STILL_ACTIVE 0x00000103 #endif #if _ISCRIPT_VER < 0x600 #ifndef BYVAL #define BYVAL #endif #endif prototype _LaunchAppEx(STRING, STRING, NUMBER, NUMBER, NUMBER, BYREF NUMBER); prototype BOOL kernel32.CreateProcessA(POINTER, BYVAL STRING, POINTER, POINTER, BOOL, NUMBER, POINTER, POINTER, POINTER, POINTER); prototype BOOL kernel32.GetExitCodeProcess(NUMBER, POINTER); prototype NUMBER kernel32.WaitForSingleObject(NUMBER, NUMBER); prototype BOOL kernel32.CloseHandle(HWND); typedef STARTUPINFO begin NUMBER cb; POINTER lpReserved; POINTER lpDesktop; POINTER lpTitle; NUMBER dwX; NUMBER dwY; NUMBER dwXSize; NUMBER dwYSize; NUMBER dwXCountChars; NUMBER dwYCountChars; NUMBER dwFillAttribute; NUMBER dwFlags; NUMBER wShowWindow; POINTER lpReserved2; HWND hStdInput; HWND hStdOutput; HWND hStdError; end; typedef PROCESS_INFORMATION begin NUMBER hProcess; HWND hThread; NUMBER dwProcessId; NUMBER dwThreadId; end; /////////////////////////////////////////////////////////////////////////////// // // MAIN PROGRAM // // The setup begins here by hiding the visible setup // window. This is done to allow all the titles, images, etc. to // be established before showing the main window. The setup is // then performed in a series of calls to script defined functions, // with error checking at each step. // /////////////////////////////////////////////////////////////////////////////// program Disable( BACKGROUND ); CheckRequirements(); SetupInstall(); SetupScreen(); // set this variable to TRUE if we're creating a CDROM installation bIsCDROM = TRUE; if (bIsCDROM) then CheckWin32s(); endif; if (ShowDialogs()<0) goto end_install; if (ProcessBeforeDataMove()<0) goto end_install; if (MoveFileData()<0) goto end_install; if (ProcessAfterDataMove()<0) goto end_install; if (SetupRegistry()<0) goto end_install; if (SetupFolders()<0) goto end_install; end_install: CleanUpInstall(); if (bIsCDROM) then InstallCollOrganizer(); endif; // If an unrecoverable error occurred, clean up // the partial installation. Otherwise, exit normally. if (bInstallAborted) then abort; endif; endprogram /////////////////////////////////////////////////////////////////////////////// // // Function: ShowDialogs // // Purpose: This function manages the display and navigation of // the standard dialogs that exist in a setup. // /////////////////////////////////////////////////////////////////////////////// function ShowDialogs() NUMBER nResult; begin Dlg_Start: // beginning of dialogs label Dlg_SdLicense: nResult = DialogShowSdLicense(); if (nResult = BACK) goto Dlg_Start; if (bIs32BitSetup) then Dlg_GreenstoneInstallationType: nResult = DialogGreenstoneInstallationType(); if (nResult = BACK) goto Dlg_SdLicense; if (bIsCDROM) then Dlg_SetupType: nResult = DialogSetupType(); if (nResult = BACK) goto Dlg_GreenstoneInstallationType; else bCompact = TRUE; endif; else ComponentSetupTypeSet(MEDIA, "Local Library"); svSetupType = "Local Library"; bCompact = TRUE; endif; SetComponents(); if (bIsCDROM) then Dlg_SelectCollections: nResult = DialogSelectCollections(); else Dlg_AskDestPath: nResult = DialogAskDestPath(); endif; if (nResult = BACK) then if (bIs32BitSetup = FALSE) goto Dlg_SdLicense; if (bIsCDROM = FALSE) goto Dlg_GreenstoneInstallationType; goto Dlg_SetupType; endif; Dlg_GetAdminPassWord: nResult = DialogGetAdminPassword(); if (nResult = BACK) then if (bIsCDROM) goto Dlg_SelectCollections; goto Dlg_AskDestPath; endif; return 0; end; /////////////////////////////////////////////////////////////////////////////// // // Function: ProcessBeforeDataMove // // Purpose: This function performs any necessary operations prior to the // actual file transfer. // /////////////////////////////////////////////////////////////////////////////// function ProcessBeforeDataMove() NUMBER nResult; begin // Create app information, uninstallation, and App Paths registry keys. InstallationInfo( @COMPANY_NAME, @PRODUCT_NAME, @PRODUCT_VERSION, @PRODUCT_KEY ); svLogFile = UNINST_LOGFILE_NAME; nResult = DeinstallStart( svDir, svLogFile, @UNINST_KEY, 0 ); if (nResult < 0) then MessageBox( @ERROR_UNINSTSETUP, WARNING ); endif; szAppPath = TARGETDIR; if ((bIs32BitSetup) && (bIsShellExplorer)) then RegDBSetItem( REGDB_APPPATH, szAppPath ); RegDBSetItem( REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY ); RegDBSetItem( REGDB_UNINSTALL_NAME, @UNINST_DISPLAY_NAME ); endif; // TO DO : any other tasks you want to perform before file transfer return 0; end; /////////////////////////////////////////////////////////////////////////////// // // Function: MoveFileData // // Purpose: This function handles the file transfer for // the setup. // /////////////////////////////////////////////////////////////////////////////// function MoveFileData() NUMBER nResult, nDisk; begin nDisk = 1; SetStatusWindow( 0, "" ); Disable( DIALOGCACHE ); Enable( STATUS ); StatusUpdate( ON, 100 ); nResult = ComponentMoveData( MEDIA, nDisk, 0 ); HandleMoveDataError( nResult ); Disable( STATUS ); return nResult; end; /////////////////////////////////////////////////////////////////////////////// // // Function: HandleMoveDataError // // Purpose: This function handles the error (if any) during the file transfer // operation. // /////////////////////////////////////////////////////////////////////////////// function HandleMoveDataError( nResult ) STRING szErrMsg, svComponent , svFileGroup , svFile; begin svComponent = ""; svFileGroup = ""; svFile = ""; switch (nResult) case 0: return 0; default: ComponentError ( MEDIA , svComponent , svFileGroup , svFile , nResult ); szErrMsg = @ERROR_MOVEDATA + "\n\n" + @ERROR_COMPONENT + " " + svComponent + "\n" + @ERROR_FILEGROUP + " " + svFileGroup + "\n" + @ERROR_FILE + " " + svFile; SprintfBox( SEVERE, @TITLE_CAPTIONBAR, szErrMsg, nResult ); bInstallAborted = TRUE; return nResult; endswitch; end; /////////////////////////////////////////////////////////////////////////////// // // Function: ProcessAfterDataMove // // Purpose: This function performs any necessary operations needed after // all files have been transferred. // /////////////////////////////////////////////////////////////////////////////// function ProcessAfterDataMove() STRING szReferenceFile; begin CreateServerTxt(); EditGsdlsiteCfg(); EditSetupBat(); SetAdminPassword(); SetPermissions(); szReferenceFile = svDir ^ @PRODUCT_KEY; DeinstallSetReference( szReferenceFile ); return 0; end; /////////////////////////////////////////////////////////////////////////////// // // Function: SetupRegistry // // Purpose: This function makes the registry entries for this setup. // /////////////////////////////////////////////////////////////////////////////// function SetupRegistry() NUMBER nResult; begin // TO DO : Add all your registry entry keys here. // Call registry functions and/or create keys from // the InstallShield IDE's Resources pane. nResult = CreateRegistrySet( "" ); return nResult; end; /////////////////////////////////////////////////////////////////////////////// // // Function: SetupFolders // // Purpose: This function creates all the folders and shortcuts for the // setup. This includes program groups and items for Windows 3.1. // /////////////////////////////////////////////////////////////////////////////// function SetupFolders() NUMBER nResult; STRING szIsData; NUMBER nType; begin if (Is(USER_ADMINISTRATOR,szIsData)==TRUE) then nType = COMMON; else nType = PERSONAL; endif; ProgDefGroupType(nType); if (CreateProgramFolder(@FOLDER_NAME) < 0) then MessageBox("CreateProgramFolder failed.", SEVERE); endif; // The following adds the shortcuts. if (AddFolderIcon(@FOLDER_NAME, @README, "\"" + TARGETDIR ^ "README.TXT\"", "", "", 0, "", REPLACE) < 0) then MessageBox("AddFolderIcon failed.", SEVERE); endif; if (AddFolderIcon(@FOLDER_NAME, @TEXT_UNINSTALL, UNINST + " -f\"" + svLogFile + "\"", "", "", 0, "", REPLACE) < 0) then MessageBox("AddFolderIcon failed.", SEVERE); endif; if (svSetupType = "Local library") then if (AddFolderIcon(@FOLDER_NAME, @FOLDER_NAME, "\"" + TARGETDIR ^ "server.exe\"", "", "", 0, "", REPLACE) < 0) then MessageBox("AddFolderIcon failed.", SEVERE); endif; endif; nResult = CreateShellObjects( "" ); return nResult; end; /////////////////////////////////////////////////////////////////////////////// // // Function: CleanUpInstall // // Purpose: This cleans up the setup. Anything that should // be released or deleted at the end of the setup should // be done here. // /////////////////////////////////////////////////////////////////////////////// function CleanUpInstall() begin if (bInstallAborted) then return 0; endif; DialogShowSdFinishReboot(); if (BATCH_INSTALL) then // ensure locked files are properly transferred CommitSharedFiles(0); endif; return 0; end; /////////////////////////////////////////////////////////////////////////////// // // Function: SetupInstall // // Purpose: This will initialize the setup. Any general initialization // needed for the installation should be performed here. // /////////////////////////////////////////////////////////////////////////////// function SetupInstall() begin Enable( CORECOMPONENTHANDLING ); bInstallAborted = FALSE; svDir = PROGRAMFILES ^ "gsdl"; TARGETDIR = svDir; SdProductName( @PRODUCT_NAME ); Enable( DIALOGCACHE ); return 0; end; /////////////////////////////////////////////////////////////////////////////// // // Function: SetupScreen // // Purpose: This function establishes the screen look. This includes // colors, fonts, and text to be displayed. // /////////////////////////////////////////////////////////////////////////////// function SetupScreen() begin Enable( FULLWINDOWMODE ); Enable( INDVFILESTATUS ); SetTitle( @TITLE_MAIN, 24, WHITE ); SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION ); // Caption bar text. Enable( BACKGROUND ); Delay( 1 ); end; /////////////////////////////////////////////////////////////////////////////// // // Function: CheckRequirements // // Purpose: This function checks all minimum requirements for the // application being installed. If any fail, then the user // is informed and the setup is terminated. // /////////////////////////////////////////////////////////////////////////////// function CheckRequirements() NUMBER nvDx, nvDy, nvResult; STRING svResult, szIsData; begin bWinNT = FALSE; bIsShellExplorer = FALSE; // Check screen resolution. GetExtents( nvDx, nvDy ); if (nvDy < 480) then MessageBox( @ERROR_VGARESOLUTION, WARNING ); abort; endif; // set 'setup' operation mode bIs32BitSetup = TRUE; GetSystemInfo( ISTYPE, nvResult, svResult ); if (nvResult = 16) then bIs32BitSetup = FALSE; // running 16-bit setup return 0; // no additional information required endif; // --- 32-bit testing after this point --- // Determine the target system's operating system. GetSystemInfo( OS, nvResult, svResult ); if (nvResult = IS_WINDOWSNT) then // Running Windows NT. bWinNT = TRUE; // Check to see if the shell being used is EXPLORER shell. if (GetSystemInfo( OSMAJOR, nvResult, svResult ) = 0) then if (nvResult >= 4) then bIsShellExplorer = TRUE; endif; endif; elseif (nvResult = IS_WINDOWS95) then bIsShellExplorer = TRUE; endif; // setup must be run as administrator on NT/2000 if (bWinNT && (Is(USER_ADMINISTRATOR,szIsData)!=TRUE)) then MessageBox(@TEXT_NOT_ADMIN, SEVERE); abort; endif; end; /////////////////////////////////////////////////////////////////////////////// // // Function: DialogShowSdLicense // // Purpose: This function displays the license agreement dialog. // // /////////////////////////////////////////////////////////////////////////////// function DialogShowSdLicense() NUMBER nResult; STRING szTitle, szMsg, szQuestion, szLicenseFile; begin szLicenseFile = SUPPORTDIR ^ "license.txt"; szTitle = ""; szMsg = ""; szQuestion = ""; nResult = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile ); return nResult; end; /////////////////////////////////////////////////////////////////////////////// // // Function: DialogShowSdFinishReboot // // Purpose: This function will show the last dialog of the product. // It will allow the user to reboot and/or show some readme text. // /////////////////////////////////////////////////////////////////////////////// function DialogShowSdFinishReboot() NUMBER nResult, nDefOptions; STRING szTitle, szMsg1, szMsg2, szOption1, szOption2; NUMBER bOpt1, bOpt2; begin szTitle = ""; if (svSetupType = "Web Library") then szMsg1 = @TEXT_FINISH2; elseif (svSetupType = "Source Code") then szMsg1 = @TEXT_FINISH3; else szMsg1 = @TEXT_FINISH1; endif; szMsg2 = ""; bOpt1 = TRUE; bOpt2 = FALSE; szOption1 = @TEXT_README; szOption2 = ""; nResult = SdFinish(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2); if (bOpt1 = TRUE) then LaunchAppAndWait("notepad", TARGETDIR ^ "README.TXT", WAIT); endif; return 0; end; /////////////////////////////////////////////////////////////////////////////// // // // /////////////////////////////////////////////////////////////////////////////// function DialogGreenstoneInstallationType() NUMBER nResult; STRING szTitle, szMsg; begin szTitle = @TEXT_INSTALL_TYPE; szMsg = @TEXT_INSTALL_TYPE_DESC; nResult = SdSetupTypeEx(szTitle, szMsg, "", svSetupType, 0); return nResult; end; function DialogSetupType() NUMBER nResult, nvCheck1, nvCheck2; STRING szMsg, szText1, szText2; begin nvCheck1 = TRUE; nvCheck2 = FALSE; szMsg = @TEXT_SETUP_TYPE_DESC; szText1 = @TEXT_COMPACT; szText2 = @TEXT_FULL; nResult = AskOptions(EXCLUSIVE, szMsg, szText1, nvCheck1, szText2, nvCheck2); bCompact = nvCheck1; return nResult; end; function DialogSelectCollections() NUMBER nResult; STRING szTitle, szMsg; begin szTitle = @TEXT_SELECT_COLLECTIONS; szMsg = @TEXT_SELECT_COLLECTIONS_DESC; nResult = SdComponentDialog(szTitle, szMsg, svDir, "collections"); TARGETDIR = svDir; return nResult; end; function DialogAskDestPath() NUMBER nResult; begin nResult = SdAskDestPath("", "", svDir, 0); TARGETDIR = svDir; return nResult; end; function DialogGetAdminPassword() STRING szTitle, szMsg, szField1; NUMBER nResult; begin svAdminPassword = "admin"; // the default szTitle = @TEXT_ADMIN_PW; szMsg = @TEXT_ADMIN_PW_DESC; szField1 = @TEXT_PW; nResult = SdShowDlgEdit1(szTitle, szMsg, szField1, svAdminPassword); return nResult; end; function SetComponents() begin if (bCompact) then // compact installation ComponentSelectItem(MEDIA, "Documentation", FALSE); ComponentSelectItem(MEDIA, "Export Collection", FALSE); else // full installation ComponentSelectItem(MEDIA, "Documentation", TRUE); ComponentSelectItem(MEDIA, "Export Collection", TRUE); endif; if (bIs32BitSetup = FALSE) then // Windows 3.1 - make certain no components that may contain // long filenames are selected ComponentSelectItem(MEDIA, "Build-time files", FALSE); ComponentSelectItem(MEDIA, "Build-time executables", FALSE); ComponentSelectItem(MEDIA, "Export Collection", FALSE); ComponentSelectItem(MEDIA, "Not installed files", FALSE); ComponentSelectItem(MEDIA, "Source files", FALSE); ComponentSelectItem(MEDIA, "Web library", FALSE); ComponentSelectItem(MEDIA, "cgi-bin", FALSE); ComponentSelectItem(MEDIA, "Source files - Windows", FALSE); ComponentSelectItem(MEDIA, "Not installed files - windows", FALSE); endif; if (bIsCDROM = FALSE) then // not a CDROM installation - make sure CDROM only components // aren't selected (should also make sure these components have // their "Include in Build" option set to "No" in the IDE) ComponentSelectItem(MEDIA, "Not installed files", FALSE); ComponentSelectItem(MEDIA, "Documentation", FALSE); ComponentSelectItem(MEDIA, "collections", FALSE); ComponentSelectItem(MEDIA, "Export Collection", FALSE); endif; end; // use setpw to set the admin password in the users.db database function SetAdminPassword() STRING cmd, cmdline, dbfile; begin dbfile = TARGETDIR ^ "etc" ^ "users.db"; cmd = "\"" + TARGETDIR ^ "bin" ^ "windows" ^ "setpw.exe\""; cmdline = " -u admin -p " + svAdminPassword + " -o \"" + dbfile + "\""; if (LaunchApp(cmd, cmdline) != 0) then MessageBox(@TEXT_SETPW_FAIL, WARNING); endif; end; // Create and display the SERVER.TXT file if // installing the web library or source code function CreateServerTxt() STRING szTitle, szMsg, svTmp; STRING szServerTxt, svCgiBin, svGSDLHOME; LIST listInfo; begin if (svSetupType = "Local Library") then return; endif; szServerTxt = TARGETDIR ^ "SERVER.TXT"; svCgiBin = TARGETDIR ^ "cgi-bin"; svGSDLHOME= TARGETDIR; szTitle = ""; szMsg = " "; listInfo = ListCreate(STRINGLIST); ListAddString(listInfo, @TEXT_SERVERTXT_01, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_02, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_03, AFTER); ListAddString(listInfo, " ", AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_04, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_05, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_06, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_07, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_08, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_09, AFTER); ListAddString(listInfo, " ", AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_10, AFTER); Sprintf(svTmp, @TEXT_SERVERTXT_11, szServerTxt); ListAddString(listInfo, svTmp, AFTER); ListAddString(listInfo, " ", AFTER); Sprintf(svTmp, @TEXT_SERVERTXT_12, TARGETDIR); ListAddString(listInfo, svTmp, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_13, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_14, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_15, AFTER); Sprintf(svTmp, @TEXT_SERVERTXT_16, svCgiBin); ListAddString(listInfo, svTmp, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_17, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_18, AFTER); ListAddString(listInfo, " ", AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_19, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_20, AFTER); ListAddString(listInfo, " ", AFTER); rs(svCgiBin); rs(svGSDLHOME); ListAddString(listInfo, " ScriptAlias /gsdl/cgi-bin \"" + svCgiBin + "/\"", AFTER); ListAddString(listInfo, " ", AFTER); ListAddString(listInfo, " Options None", AFTER); ListAddString(listInfo, " AllowOverride None", AFTER); ListAddString(listInfo, " ", AFTER); ListAddString(listInfo, " ", AFTER); ListAddString(listInfo, " Alias /gsdl \"" + svGSDLHOME + "/\"", AFTER); ListAddString(listInfo, " ", AFTER); ListAddString(listInfo, " Options Indexes MultiViews FollowSymLinks", AFTER); ListAddString(listInfo, " AllowOverride None", AFTER); ListAddString(listInfo, " Order allow,deny", AFTER); ListAddString(listInfo, " Allow from all", AFTER); ListAddString(listInfo, " ", AFTER); ListAddString(listInfo, " ", AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_21, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_22, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_23, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_24, AFTER); ListAddString(listInfo, " ", AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_25, AFTER); ListAddString(listInfo, @TEXT_SERVERTXT_26, AFTER); ListAddString(listInfo, " ", AFTER); SdShowInfoList(szTitle, szMsg, listInfo); ListWriteToFile(listInfo, szServerTxt); ListDestroy(listInfo); end; // if we're installing the web library or the source code // we need to edit the gsdlsite.cfg file appropriately. // this function relies on the format of the gsdlsite.cfg // file remaining exactly as it currently is function EditGsdlsiteCfg() STRING svReturnLine, szInsertLine; NUMBER nResult, nvLineNumber; begin if (svSetupType = "Local Library") then return; endif; VarSave(SRCTARGETDIR); SRCDIR = TARGETDIR ^ "cgi-bin"; nResult = FileGrep("gsdlsite.cfg", "**GSDLHOME**", svReturnLine, nvLineNumber, RESTART); if (nResult = 0) then szInsertLine = "gsdlhome \"" + TARGETDIR + "\""; FileInsertLine("gsdlsite.cfg", szInsertLine, nvLineNumber, REPLACE); else MessageBox(@TEXT_FILEGREP_FAILED, WARNING); endif; nResult = FileGrep("gsdlsite.cfg", "#httpprefix", svReturnLine, nvLineNumber, RESTART); if (nResult = 0) then szInsertLine = "httpprefix /gsdl"; FileInsertLine("gsdlsite.cfg", szInsertLine, nvLineNumber, REPLACE); else MessageBox(@TEXT_FILEGREP_FAILED, WARNING); endif; nResult = FileGrep("gsdlsite.cfg", "httpimg /images", svReturnLine, nvLineNumber, RESTART); if (nResult = 0) then szInsertLine = "httpimg /gsdl/images"; FileInsertLine("gsdlsite.cfg", szInsertLine, nvLineNumber, REPLACE); else MessageBox(@TEXT_FILEGREP_FAILED, WARNING); endif; VarRestore(SRCTARGETDIR); end; // edit setup.bat (if it was installed) function EditSetupBat() STRING svReturnLine, szInsertLine; NUMBER nResult, nvLineNumber; begin if (ComponentIsItemSelected(MEDIA, "Build-time files")=TRUE) then VarSave(SRCTARGETDIR); SRCDIR = TARGETDIR; nResult = FileGrep("setup.bat", "**GSDLHOME**", svReturnLine, nvLineNumber, RESTART); if (nResult = 0) then szInsertLine = "set GSDLHOME=" + TARGETDIR; FileInsertLine("setup.bat", szInsertLine, nvLineNumber, REPLACE); else MessageBox(@TEXT_FILEGREP_FAILED, WARNING); endif; VarRestore(SRCTARGETDIR); endif; end; function CheckWin32s() STRING szTitle, szMsg, svResult, szInfo, svPath, svVersionNumber; NUMBER nvResult,nResult, nvWin32, nvOSTYPE, nvOLDWIN32S, nvWIN32SINSTALLED; begin if (GetSystemInfo (OS, nvOSTYPE, svResult) < 0) then MessageBox("Couldn't get Operating System info.", SEVERE); endif; // get information about win32s nvOLDWIN32S=0; GetSystemInfo (WIN32SINSTALLED, nvWIN32SINSTALLED, svResult); if (nvWIN32SINSTALLED == TRUE) then GetSystemInfo (WIN32SMAJOR, nvWin32, svResult); if (nvWin32 == 0) then nvOLDWIN32S = 1; else GetSystemInfo (WIN32SMINOR, nvWin32, svResult); if (nvWin32 < 30) then nvOLDWIN32S = 1; endif; endif; endif; // run Win32s installation if required. if ((nvOSTYPE == IS_WINDOWS) || (nvOSTYPE == IS_WIN32S)) then if ((nvWIN32SINSTALLED == 0)) then if (CreateProgramFolder(@FOLDER_NAME) < 0) then MessageBox("CreateProgramFolder failed.", SEVERE); endif; if (AddFolderIcon(@FOLDER_NAME, @INSTALL_GSDL, "\"" + SRCDIR ^ "setup.exe\"", "", "", 0, "", REPLACE) < 0) then MessageBox("AddFolderIcon failed.", SEVERE); endif; MessageBox(@TEXT_ERROR_NO_WIN32S, INFORMATION); LaunchApp(SRCDIR ^ "bin" ^ "windows" ^ "win32s" ^ "setup.exe",""); exit; else if (nvOLDWIN32S == 1) then MessageBox(@TEXT_ERROR_OLD_WIN32S, INFORMATION); endif; endif; endif; end; // turn any backslashes in string into forward slashes function rs (svString) NUMBER i; begin for i = 0 to StrLength(svString) if (svString[i] = '\\') then svString[i] = '/'; endif; endfor; end; // Display a messagebox asking if the Collection Organizer // should be installed and run it's installer if it should function InstallCollOrganizer() begin if (bIs32BitSetup = FALSE) then // can't install Organizer on Windows 3.1 return; endif; if (AskYesNo(@TEXT_COLLORG, YES) == YES) then LaunchApp(SRCDIR ^ ".." ^ "windows_utilities" ^ "CollOrganizer.exe", ""); endif; end; // if running NT/2000 we need to make the collect and tmp // directories and some contents of the etc directory writable // by all users (otherwise certain functions will only work // if Greenstone is run by someone with admin privileges) function SetPermissions() STRING szProgram, szCmdLine; NUMBER nvExitCode; begin if (bWinNT) then szProgram = WINSYSDIR ^ "cmd.exe"; szCmdLine = "/c cacls \"" + TARGETDIR ^ "tmp\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + TARGETDIR ^ "collect\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + TARGETDIR ^ "etc" ^ "errout.txt\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + TARGETDIR ^ "etc" ^ "initout.txt\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + TARGETDIR ^ "etc" ^ "key.db\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + TARGETDIR ^ "etc" ^ "users.db\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + TARGETDIR ^ "etc" ^ "main.cfg\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + TARGETDIR ^ "etc" ^ "history.db\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + TARGETDIR ^ "etc" ^ "usage.txt\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); endif; end; function _LaunchAppEx(szProgram, szCmdLine, nWait, nShow, nTimeOut, nvExitCode) STARTUPINFO siData; PROCESS_INFORMATION piData; begin siData.cb = 68; siData.lpReserved = NULL; siData.lpDesktop = NULL; siData.lpTitle = NULL; siData.dwX = 0; siData.dwY = 0; siData.dwXSize = 0; siData.dwYSize = 0; siData.dwXCountChars = 0; siData.dwYCountChars = 0; siData.dwFillAttribute = 0; siData.dwFlags = 1; siData.wShowWindow = nShow; siData.lpReserved2 = NULL; siData.hStdInput = NULL; siData.hStdOutput = NULL; siData.hStdError = NULL; if (CreateProcessA(NULL, szProgram + " " + szCmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &siData, &piData) = 0) then return (-1); endif; if ( nWait != WAIT ) then nvExitCode = 0; return 0; endif; WaitForSingleObject(piData.hProcess, nTimeOut); GetExitCodeProcess(piData.hProcess, &nvExitCode); CloseHandle(piData.hProcess); CloseHandle(piData.hThread); return 0; end; /////////////////////////////////////////////////////////////////////////////// // // // /////////////////////////////////////////////////////////////////////////////// // --- include script file section --- #include "sddialog.rul"