root/branches/asyncio/install-windows/OrangeFS-Client/Script Files/Setup.Rul @ 9319

Revision 9319, 17.9 KB (checked in by sdsnyde, 13 months ago)

fixed bad merge

Line 
1//===========================================================================
2//
3//  File Name:    Setup.rul
4//
5//  Description:  Blank setup main script file
6//
7//  Comments:     Blank setup is an empty setup project. If you want to
8//                                create a new project via. step-by step instructions use the
9//                                Project Assistant.
10//
11//===========================================================================
12
13// Included header files ----------------------------------------------------
14#include "ifx.h"
15#include "MountPointUserModeDialog.Rul"
16#include "ListMapDialog.Rul"
17#include "CertMapDialog.Rul"
18#include "LDAPMapDialog.Rul"
19
20// Note: In order to have your InstallScript function executed as a custom
21// action by the Windows Installer, it must be prototyped as an
22// entry-point function.
23
24// The keyword export identifies MyFunction() as an entry-point function.
25// The argument it accepts must be a handle to the Installer database.
26   
27/* export prototype MyFunction(HWND); */
28
29prototype InstallServices();
30prototype InstallDriver();
31prototype WriteOrangeFSTab(STRING);
32prototype InitConfigFile(BYREF NUMBER, STRING);
33prototype WriteListMapConfig(NUMBER, STRING, STRING, STRING);
34prototype WriteCertMapConfig(NUMBER, STRING);
35prototype WriteLDAPMapConfig(NUMBER, STRING, STRING, STRING, STRING,
36                             NUMBER, STRING, STRING, STRING, STRING);
37prototype CloseConfigFile(NUMBER);
38
39// global variables
40/*
41#define USERMAP_LIST     1
42#define USERMAP_CERT     2
43#define USERMAP_LDAP     3
44*/
45
46// 64-bit flag
47BOOL bIs64Bit;
48// Program Files and System directories for appropriate architecture
49STRING szProgramFilesDir, szSystemDir;
50
51//---------------------------------------------------------------------------
52// OnBegin
53//
54// The OnBegin event is called directly by the framework after the setup
55// initializes.
56//---------------------------------------------------------------------------
57function OnBegin()
58begin
59    // Set directory locations based on architecture (32/64-bit)
60    bIs64Bit = SYSINFO.bIsWow64;
61    if (bIs64Bit) then
62        szProgramFilesDir = PROGRAMFILES64;
63        szSystemDir = WINSYSDIR64;
64    else
65        szProgramFilesDir = PROGRAMFILES;
66        szSystemDir = WINSYSDIR;
67    endif;
68end;
69//---------------------------------------------------------------------------
70// OnFirstUIBefore
71//
72// The OnFirstUIBefore event is called by the framework when the setup is
73// running in first install mode. By default this event displays UI allowing
74// the end user to specify installation parameters.
75//---------------------------------------------------------------------------
76function OnFirstUIBefore()
77    NUMBER nResult, nSetupType, nvSize, nUser;
78    STRING szTitle, szMsg, szQuestion, svName, svCompany, szFile;
79    STRING szLicenseFile;
80        BOOL bCustom, bIgnore1, bIgnore2;
81begin   
82    // TO DO: if you want to enable background, window title, and caption bar title                                                                   
83    // SetTitle( @PRODUCT_NAME, 24, WHITE );                                       
84    // SetTitle( @PRODUCT_NAME, 0, BACKGROUNDCAPTION );                           
85    // Enable( FULLWINDOWMODE );                                                   
86    // Enable( BACKGROUND );                                                     
87    // SetColor(BACKGROUND,RGB (0, 128, 128));                                     
88
89    // Added in InstallShield 15 - Show an appropriate error message if
90    // -removeonly is specified and the product is not installed.
91    if( REMOVEONLY ) then
92        Disable( DIALOGCACHE );
93                szMsg = SdLoadString( IDS_IFX_ERROR_PRODUCT_NOT_INSTALLED_UNINST );
94                SdSubstituteProductInfo( szMsg );
95                MessageBox( szMsg, SEVERE );
96                abort;
97    endif;
98   
99        nSetupType = TYPICAL;   
100
101Dlg_SdWelcome:
102    szTitle = "";
103    szMsg   = "";
104    nResult = SdWelcome(szTitle, szMsg);
105    if (nResult = BACK) goto Dlg_SdWelcome;
106           
107Dlg_SdLicense:                             
108    szQuestion = "";
109    nResult = SdLicense(szTitle, szMsg, szQuestion, "license.txt");
110    if (nResult = BACK) goto Dlg_SdWelcome;
111       
112/*
113Dlg_SdRegisterUser:
114    szMsg = "";
115    szTitle = "";
116    nResult = SdRegisterUser( szTitle, szMsg, svName, svCompany );
117    if (nResult = BACK) goto Dlg_SdWelcome;
118
119Dlg_SetupType:
120    szTitle = "";
121    szMsg   = "";
122    nResult = SetupType2(szTitle, szMsg, "", nSetupType, 0);
123    if (nResult = BACK) then
124        goto Dlg_SdWelcome;
125    else
126            nSetupType = nResult;
127        if (nSetupType != CUSTOM) then
128                nvSize = 0;
129                FeatureCompareSizeRequired(MEDIA, INSTALLDIR, nvSize);
130                if (nvSize != 0) then     
131                MessageBox(szSdStr_NotEnoughSpace, WARNING);
132                    goto Dlg_SetupType;
133            endif;
134                        bCustom = FALSE;
135                        goto Dlg_SdStartCopy;
136                else
137                        bCustom = TRUE;
138        endif;
139    endif;   
140*/
141
142Dlg_SdAskDestPath:     
143    nResult = SdAskDestPath(szTitle, szMsg, INSTALLDIR, 0);
144    if (nResult = BACK) goto Dlg_SdLicense;
145/*
146Dlg_SdFeatureTree:
147    szTitle    = "";
148    szMsg      = "";
149    if (nSetupType = CUSTOM) then
150                nResult = SdFeatureTree(szTitle, szMsg, INSTALLDIR, "", 2);
151                if (nResult = BACK) goto Dlg_SdAskDestPath; 
152    endif;
153*/
154Dlg_SdStartCopy:
155    szTitle = "";
156    szMsg   = "";
157    nResult = SdStartCopy2( szTitle, szMsg );                   
158       
159    if (nResult = BACK) goto Dlg_SdAskDestPath;
160
161    // Added in IS 2009 - Set appropriate StatusEx static text.
162    SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) );
163
164    // setup default status
165    Enable(STATUSEX);
166 
167    return 0;
168end;                   
169           
170// Output the file "orangefstab" with the file system location URI in it
171function WriteOrangeFSTab(szFSURI)
172    NUMBER nFileHandle;
173begin
174    OpenFileMode(FILE_MODE_APPEND);
175   
176    if (CreateFile(nFileHandle, INSTALLDIR, "orangefstab") < 0) then
177        MessageBox("File " + INSTALLDIR + "\\orangefstab could not be created. " +
178                   "You must add this file manually (see documentation).", SEVERE);
179    else
180        WriteLine(nFileHandle, szFSURI + " /mnt/pvfs2 pvfs2 defaults,noauto 0 0");
181       
182        CloseFile(nFileHandle);
183    endif;
184end;
185
186function InitConfigFile(nvFileHandle, szMountPoint)
187begin                       
188    // create the config file
189    OpenFileMode(FILE_MODE_APPEND);
190   
191    if (CreateFile(nvFileHandle, INSTALLDIR, "orangefs.cfg") < 0) then
192        MessageBox("File " + INSTALLDIR + "\\orangefs.cfg could not be created. " +
193                   "You must add this file manually (see documentation).", SEVERE);
194        return -1;
195    endif;
196   
197    // write the mount point
198    if (szMountPoint != "Auto") then
199        WriteLine(nvFileHandle, "mount " + szMountPoint);   
200    endif;
201   
202    return 0;
203end;
204
205function WriteListMapConfig(nFileHandle, szUserID, szUID, szGID)
206begin
207    // write list map mode setting and one user
208    WriteLine(nFileHandle, "user-mode list");
209   
210    if (szUserID != "" && szUID != "" && szGID != "") then
211        WriteLine(nFileHandle, "user " + szUserID + " " + szUID + ":" + szGID);
212    endif;
213   
214end;
215
216function WriteCertMapConfig(nFileHandle, szCertDirPrefix)
217begin         
218    // write cert map mode settings
219    WriteLine(nFileHandle, "user-mode certificate");
220   
221    if (szCertDirPrefix != "") then
222       WriteLine(nFileHandle, "cert-dir-prefix " + szCertDirPrefix);
223    endif;
224end;
225
226function WriteLDAPMapConfig(nFileHandle, szHost, szUserDN, szPassword, szRoot,
227                            nScope, szClass, szNamingAttr, szUIDAttr, szGIDAttr)
228begin
229    // write LDAP map options
230    WriteLine(nFileHandle, "user-mode ldap");
231   
232    if (szHost != "") then
233        WriteLine(nFileHandle, "ldap-host " + szHost);
234    endif;
235   
236    if (szUserDN != "") then
237        WriteLine(nFileHandle, "ldap-bind-dn " + szUserDN);
238    endif;
239   
240    if (szPassword != "") then
241        WriteLine(nFileHandle, "ldap-password " + szPassword);
242    endif;
243   
244    if (szRoot != "") then
245        WriteLine(nFileHandle, "ldap-search-root " + szRoot);
246    endif;
247   
248    if (nScope = LDAPSCOPE_SUBTREE) then
249        WriteLine(nFileHandle, "ldap-search-scope subtree");
250    else
251        WriteLine(nFileHandle, "ldap-search-scope onelevel");
252    endif;
253   
254    if (szClass != "") then
255        WriteLine(nFileHandle, "ldap-search-class " + szClass);
256    endif;
257   
258    if (szNamingAttr != "") then
259        WriteLine(nFileHandle, "ldap-naming-attr " + szNamingAttr);
260    endif;
261   
262    if (szUIDAttr != "") then
263        WriteLine(nFileHandle, "ldap-uid-attr " + szUIDAttr);
264    endif;
265   
266    if (szGIDAttr != "") then
267        WriteLine(nFileHandle, "ldap-gid-attr " + szGIDAttr);
268    endif;
269       
270end;
271
272function CloseConfigFile(nFileHandle)
273begin
274    CloseFile(nFileHandle);
275end;
276
277
278function InstallDriver()
279    STRING svExePath;
280begin                                                 
281    svExePath = szProgramFilesDir ^ "\\Dokan\\DokanLibrary\\dokanctl.exe";
282   
283    LaunchAppAndWait(svExePath, "/i d", LAAW_OPTION_WAIT);
284end;   
285
286function InstallServices()
287    NUMBER rc, line, error;
288    STRING file, errText;
289begin
290    if (!ServiceExistsService("DokanMounter")) then
291        rc = ServiceAddService("DokanMounter",
292                               "DokanMounter",
293                               "OrangeFS/Dokan driver interface service",
294                               szProgramFilesDir ^ "\\Dokan\\DokanLibrary\\mounter.exe",
295                               TRUE,
296                               "");
297        if (rc < ISERR_SUCCESS) then
298            GetExtendedErrInfo(file, line, error);
299            Sprintf(errText, " (%d)", error);
300            MessageBox("DokanMounter service installation failed:\n" +
301                        FormatMessage(error) + errText + " " +
302                        szProgramFilesDir + "\\Dokan\\DokanLibrary\\mounter.exe", SEVERE);
303        endif;
304    endif;
305    if (!ServiceExistsService("orangefs-client")) then
306        rc = ServiceAddService("orangefs-client",
307                               "OrangeFS Client",
308                               "Allows transparent access to Orange file systems.",
309                               INSTALLDIR ^ "\\orangefs-client -service",
310                               FALSE,
311                               "");
312        if (rc < ISERR_SUCCESS) then
313            GetExtendedErrInfo(file, line, error);
314            Sprintf(errText, " (%d)", error);
315            MessageBox("OrangeFS Client service installation failed:\n" +
316                        FormatMessage(error) + errText + " " +
317                        INSTALLDIR + "\\orangefs-client -service", SEVERE);
318        endif;
319    endif;
320end;
321                       
322//---------------------------------------------------------------------------
323// OnFirstUIAfter
324//
325// The OnFirstUIAfter event called by the framework after the file transfer
326// of the setup when the setup is running in first install mode. By default
327// this event displays UI that informs the end user that the setup has been
328// completed successfully.
329//---------------------------------------------------------------------------
330function OnFirstUIAfter()
331    STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2, szTemp;
332    STRING szFSURI, szMountPoint, szUserMapMode;
333    STRING szUserID, szUID, szGID;
334    STRING szCertPrefixDir;
335    NUMBER bOpt1, bOpt2, nUserMapMode, nRC;   
336    NUMBER nCertMapMode;
337    BOOL bLDAP_AD, bLDAP_eDir, bLDAP_Custom;
338    NUMBER nLDAPMapDefault;
339    STRING szHost, szUserDN, szPassword, szRoot, szClass,
340           szNamingAttr, szUIDAttr, szGIDAttr;
341    NUMBER nScope;
342    NUMBER nFileHandle;
343begin
344        Disable(STATUSEX);
345
346        bOpt1   = FALSE;
347    bOpt2   = FALSE; 
348         
349    // in silent mode, a preconfigured orangefstab and orangefs.cfg
350    // are installed
351    if (MODE = SILENTMODE) goto Label_DlgSkip;
352   
353Dlg_MountPointUserMap:
354    // prompt for file system location, mount point and user mapping mode
355    Disable(BACKBUTTON);
356    nUserMapMode = 0;
357    nRC = MountPointUserModeDialog(szFSURI, szMountPoint, nUserMapMode);
358   
359Dlg_UserMap:
360    // prompt for user mapping settings
361    Enable(BACKBUTTON);
362    switch(nUserMapMode)
363        case USERMAP_LIST:
364            nRC = ListMapDialog(szUserID, szUID, szGID);
365        case USERMAP_CERT:
366            nRC = CertMapDialog(nUserMapMode, szCertPrefixDir);
367        case USERMAP_LDAP:
368            bLDAP_AD = TRUE;
369            bLDAP_eDir = FALSE;
370            bLDAP_Custom = FALSE;
371            AskOptions(EXCLUSIVE, "Select LDAP Default Values", "Microsoft Active Directory", bLDAP_AD,
372                       "Novell eDirectory", bLDAP_eDir, "Custom (no defaults)", bLDAP_Custom);
373            if (bLDAP_AD) then
374                nLDAPMapDefault = LDAPMAP_AD;
375            elseif (bLDAP_eDir) then
376                nLDAPMapDefault = LDAPMAP_EDIR;
377            else
378                nLDAPMapDefault = LDAPMAP_CUSTOM;
379            endif;
380            nRC = LDAPMapDialog(nLDAPMapDefault, szHost, szUserDN, szPassword, szRoot, nScope,
381                                szClass, szNamingAttr, szUIDAttr, szGIDAttr);
382    endswitch;
383   
384    if (nRC = BUTTON_BACK) then
385        goto Dlg_MountPointUserMap;
386    endif;
387       
388    WriteOrangeFSTab(szFSURI);
389   
390    InitConfigFile(nFileHandle, szMountPoint);
391    switch (nUserMapMode)
392       case USERMAP_LIST:
393           WriteListMapConfig(nFileHandle, szUserID, szUID, szGID);
394       case USERMAP_CERT:
395           WriteCertMapConfig(nFileHandle, szCertPrefixDir);
396       case USERMAP_LDAP:
397           WriteLDAPMapConfig(nFileHandle, szHost, szUserDN, szPassword, szRoot, nScope,
398                              szClass, szNamingAttr, szUIDAttr, szGIDAttr);
399    endswitch;
400    CloseConfigFile(nFileHandle);
401
402Label_DlgSkip:
403       
404    InstallServices();
405   
406    InstallDriver();   
407
408    if ( BATCH_INSTALL ) then
409        SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
410    else
411        szMsg2 = "Documentation is available in " + (INSTALLDIR ^ "Doc") + ".";
412        szOpt1 = "Start the OrangeFS services";
413        bOpt1 = TRUE;
414            SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bOpt1 , bOpt2 );
415           
416        if (bOpt1) then
417            ServiceStartService("DokanMounter", "");
418            ServiceStartService("orangefs-client", "");
419        endif;
420        endif;
421end;
422//---------------------------------------------------------------------------
423// OnMaintUIBefore
424//
425// The OnMaintUIBefore event is called by the framework when the setup is
426// running in maintenance mode. By default this event displays UI that
427// allows the end user to add or remove features, repair currently
428// installed features or uninstall the application.
429//---------------------------------------------------------------------------
430function OnMaintUIBefore()
431        NUMBER nResult, nType;
432        STRING szTitle, szMsg, svDir, svResult, szCaption, szExePath;
433begin
434        // TO DO: if you want to enable background, window title, and caption bar title                                                                 
435        // SetTitle( @PRODUCT_NAME, 24, WHITE );                                       
436        // SetTitle( @PRODUCT_NAME, 0, BACKGROUNDCAPTION );                     
437        // SetColor(BACKGROUND,RGB (0, 128, 128));                                     
438        // Enable( FULLWINDOWMODE );                                           
439        // Enable( BACKGROUND );                                                       
440                               
441        // prompt to remove program
442        svResult = SdLoadString(IFX_MAINTUI_MSG);
443        szCaption = SdLoadString(IFX_ONMAINTUI_CAPTION);
444        nResult = SprintfBox(MB_OKCANCEL, szCaption, "%s", svResult);
445        if (nResult = IDOK) then
446            // Stop and remove the services
447            ServiceStopService("orangefs-client");
448            ServiceRemoveService("orangefs-client");
449            ServiceStopService("DokanMounter");
450            ServiceRemoveService("DokanMounter");
451           
452            // uninstall driver
453        szExePath = szProgramFilesDir ^ "\\Dokan\\DokanLibrary\\dokanctl.exe";
454   
455        LaunchAppAndWait(szExePath, "/u d", LAAW_OPTION_WAIT);
456                                       
457        // remove files etc.
458        FeatureRemoveAll();
459       
460        // setup default status
461        SetStatusWindow(0, "");
462        Enable(STATUSEX);
463        StatusUpdate(ON, 100);
464    endif;                                       
465       
466/*     
467Dlg_Start:
468
469    // Added in Version 9.5 - Support for REMOVEONLY option.
470    if( !REMOVEONLY ) then
471                // In standard mode show maintenance dialog
472                Disable(BACKBUTTON);
473                nType = SdWelcomeMaint(szTitle, szMsg, MODIFY);
474                Enable(BACKBUTTON);
475        else
476        // Hide the initial progress dialog as otherwise the user can
477        // click on it, and hide the MessageBox.
478        Disable( DIALOGCACHE );
479
480        // In RemoveOnly mode, set to remove.
481        nType = REMOVEALL;
482    endif;
483       
484        // Show Uninstall Confirmation Dialog
485    if ( nType = REMOVEALL ) then
486                nResult = MessageBox( SdLoadString( IFX_MAINTUI_MSG ), MB_YESNO );
487                if (nResult != IDYES ) then
488           
489            if( REMOVEONLY ) then
490                // In REMOVEONLY mode, abort the setup.
491                abort;
492            else
493                // In non-REMOVEONLY mode, redisplay the previous dialog.
494                            goto Dlg_Start;
495            endif;
496
497                endif;
498        endif;
499
500        nResult = NEXT;
501
502Dlg_SdFeatureTree:
503        if (nType = MODIFY) then
504                szTitle = "";
505                szMsg = "";
506                nResult = SdFeatureTree(szTitle, szMsg, INSTALLDIR, "", 2);
507                if (nResult = BACK) goto Dlg_Start;
508        endif;
509
510        switch(nType)
511        case REMOVEALL:
512       
513            ComponentRemoveAll();
514
515            // Added in IS 2009 - Set appropriate StatusEx static text.
516            SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REMOVEALL ) );
517
518        case REPAIR:
519       
520            ComponentReinstall();
521
522            // Added in IS 2009 - Set appropriate StatusEx static text.
523            SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REPAIR ) );
524
525
526        case MODIFY:
527
528            // Added in IS 2009 - Set appropriate StatusEx static text.
529            SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_MODIFY ) );
530
531    endswitch;
532   
533        Enable(STATUSEX);
534*/
535end;
Note: See TracBrowser for help on using the browser.