Back to home page

Enduro/X

 
 

    


0001 #!/usr/bin/pscript
0002 
0003 userlog("Provision script started");
0004 
0005 print("\n");
0006 print("    ______          __                    ___  __\n");
0007 print("   / ____/___  ____/ /_  ___________    _/_/ |/ /\n");
0008 print("  / __/ / __ \\/ __  / / / / ___/ __ \\ _/_/ |   / \n");
0009 print(" / /___/ / / / /_/ / /_/ / /  / /_/ //_/  /   |  \n");
0010 print("/_____/_/ /_/\\__,_/\\__,_/_/   \\____/_/   /_/|_|  \n");
0011 print("\n");
0012 print("                     Provision\n");
0013 print("\n");
0014 
0015 
0016 //Include wizard base.
0017 compilestring(getwizardbase())();
0018 
0019 //Provision class
0020 class Provision extends WizardBase {
0021 
0022         constructor()
0023         {
0024                 base.constructor();
0025 
0026                 /* Override the default q path for BSD.. */
0027                 if ("FREEBSD"==getosname())
0028                 {
0029                         qpath = "/mnt/mqueue";
0030                 }
0031         }
0032         
0033         //Queue prefix
0034         //TODO: Detect by OS + compiled q mode.
0035         </ order=0, name = "Queue device path", type = "string", min=1, max=512 /> 
0036         qpath = "/dev/mqueue";
0037         
0038         //Get some random number...
0039         </ order=1, name = "Cluster node id", type = "number", min=1, max=32 /> 
0040         nodeid = "1";
0041         
0042         </ order=2, name = "System code (prefix/setfile name, etc)", type = "string",
0043                 min=1, max=8, regex="^[A-Za-z0-9]+"/> 
0044         qprefix = "test1";
0045         
0046         //</ order=3, name = "Setup sample XA config", type = "yn"/> 
0047         //sampleXA = "n";
0048         
0049         //we need: Qspace, Qdata, tmlogs folder
0050         
0051         </ order=3, name = "System wide tpcall() timeout, seconds", type = "number"/> 
0052         timeout = "90";
0053         
0054         </ order=4, name = "Application home", type = "string", min=1, max=512, regex="^/.*" /> 
0055         appHome = "";
0056         
0057         //If starts with '/' - then assume that it is full path...
0058         </ order=6, name = "Executables/binaries sub-folder of Apphome", type = "path"/> 
0059         binDir = "bin";
0060         
0061         </ order=8, name = "Configuration sub-folder of Apphome", type = "path"/> 
0062         confDir = "conf";
0063         
0064         </ order=9, name = "Log sub-folder of Apphome", type = "path"/> 
0065         logDir = "log";
0066         
0067         </ order=10, name = "Unified Buffer Format (UBF) field defs sub-folder of Apphome", 
0068                 type = "path"/> 
0069         ubfDir = "ubftab";
0070         
0071         </ order=11, name = "Temp sub-dir (used for pid file)", type = "path"/> 
0072         tempDir = "tmp";
0073         
0074         </ order=12, name = "Configure persistent queue", type = "yn"/> 
0075         installQ = "y";
0076         
0077         </ order=13, name = "Transaction Manager Logs sub-folder of Apphome", 
0078                 type = "path" depend="(::prov.installQ==\"y\")" /> 
0079         tmDir = "tmlogs";
0080         
0081         </ order=14, name = "Queue data sub-folder of Apphone", 
0082                 type = "path" depend="(::prov.installQ==\"y\")" /> 
0083         qdata = "qdata";
0084         
0085         </ order=15, name = "Persistent queue space namme", min=1, max=30,
0086                 type = "string" depend="(::prov.installQ==\"y\")" regex="^[A-Za-z0-9]+" /> 
0087         qSpace = "SAMPLESPACE";
0088         
0089         </ order=16, name = "Sample persistent queue name", min=1, max=30,
0090                 type = "string" depend="(::prov.installQ==\"y\")" regex="^[A-Za-z0-9]+" /> 
0091         qName = "TESTQ1";
0092         
0093         </ order=17, name = "Target service for automatic queue for sample Q", min=1, max=30,
0094                 type = "string" depend="(::prov.installQ==\"y\")"/> 
0095         qSvc = "TESTSVC1";
0096         
0097         </ order=18, name = "Install event server", type = "yn"/> 
0098         eventSv = "y";
0099         
0100         </ order=19, name = "Configure Client Process Monitor Server", type = "yn"/> 
0101         cpmSv = "y";
0102         
0103         </ order=20, name = "Install Configuration server", type = "yn"/> 
0104         configSv = "y";
0105         
0106         </ order=21, name = "Install bridge connection", type = "yn"/> 
0107         bridge = "y";
0108         
0109         </ order=22, name = "Bridge -> Role: Active(a) or passive(p)?", type = "string", 
0110                 regex="^[apAP]?", depend="::prov.bridge==\"y\""/> 
0111         bridgeRole = "a";
0112 
0113         </ order=23, name = "Bridge -> IP: Listen address", type = "regex", 
0114                 regex="^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$", 
0115                 depend="(::prov.bridge==\"y\" && ::prov.bridgeRole.toupper()==\"P\")"/> 
0116         ipl = "0.0.0.0";
0117         
0118         </ order=24, name = "Bridge -> IP: Connect to", type="regex", regex="^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$", 
0119                 depend="(::prov.bridge==\"y\" && ::prov.bridgeRole.toupper()==\"A\")"/> 
0120         ipc = "127.0.0.1";
0121         
0122         </ order=25, name = "Bridge -> IP: Port number", type="number", min=0, max=65000, 
0123                 depend="(::prov.bridge==\"y\")" /> 
0124         port = "21003";
0125         
0126         </ order=26, name = "Other cluster node id", type="number", min=1, max=32, 
0127                 depend="(::prov.bridge==\"y\")" /> 
0128         otherNodeId = "2";
0129 
0130         </ order=27, name = "IPC Key used for System V semaphores", 
0131                         type="string", regex="[0-9a-fA-F]+" min=1, max=8 /> 
0132         ipckey = "44000";
0133         
0134         </ order=28, name = "Load balance over cluster", 
0135                         type="number", min=0, max=100 /> 
0136         ldbal = "0";
0137         
0138         </ order=29, name = "Logging: ATMI sub-system log level 5 - highest (debug), 0 - minimum (off)", 
0139                         type="number", min=0, max=5 /> 
0140         ndrxlev = "5";
0141         
0142         
0143         </ order=30, name = "Logging: UBF sub-system log level 5 - highest (debug), 0 - minimum (off)", 
0144                         type="number", min=0, max=5 /> 
0145         ubflev = "1";
0146         
0147         </ order=31, name = "Logging: /user sub-system log level 5 - highest (debug), 0 - minimum (off)", 
0148                         type="number", min=0, max=5 /> 
0149         tplev = "5";
0150         
0151         ////////////////////////////////////////////////////////////////////////
0152         //User server blocks
0153         ////////////////////////////////////////////////////////////////////////
0154         </ order=32, name = "Configure User server #1", 
0155                         type="yn"/> 
0156         usv1 = "n";
0157         
0158         //Binary name
0159         </ order=33, name = "User server #1: binary name", type="string", min=1,
0160                 depend="(::prov.usv1==\"y\")" /> 
0161         usv1_name = "";
0162         
0163         </ order=34, name = "User server #1: min", type="number", min=0,
0164                 depend="(::prov.usv1==\"y\")" /> 
0165         usv1_min = "1";
0166         
0167         </ order=35, name = "User server #1: max", type="number", min=0,
0168                 depend="(::prov.usv1==\"y\")" /> 
0169         usv1_max = "1";
0170         
0171         </ order=36, name = "User server #1: srvid", type="number", min=200,
0172                 depend="(::prov.usv1==\"y\")" /> 
0173         usv1_srvid = "2000";
0174         
0175         </ order=37, name = "User server #1: cctag", type="string",
0176                 depend="(::prov.usv1==\"y\")" /> 
0177         usv1_cctag = "";
0178         
0179         </ order=38, name = "User server #1: sysopt", type="string", min=1,
0180                 depend="(::prov.usv1==\"y\")" /> 
0181         usv1_sysopt = "";
0182         
0183         </ order=39, name = "User server #1: appopt", type="string",
0184                 depend="(::prov.usv1==\"y\")" /> 
0185         usv1_appopt = "";
0186         
0187         
0188         ////////////////////////////////////////////////////////////////////////
0189         //User client blocks
0190         ////////////////////////////////////////////////////////////////////////
0191         </ order=50, name = "Configure User client #1", 
0192                         type="yn"/> 
0193         ucl1 = "n";
0194         </ order=51, name = "User client #1: cmdline", type="string", min=1,
0195                 depend="(::prov.ucl1==\"y\")" /> 
0196         usv1_cmdline = "";
0197         
0198         </ order=52, name = "User client #1: tag", type="string", min=1,
0199                 depend="(::prov.ucl1==\"y\")" /> 
0200         usv1_tag = "";
0201         
0202         </ order=53, name = "User client #1: subsect", type="string",
0203                 depend="(::prov.ucl1==\"y\")" /> 
0204         usv1_subsect = "";
0205         
0206         </ order=54, name = "User client #1: logfile", type="string", min=1,
0207                 depend="(::prov.ucl1==\"y\")" /> 
0208         usv1_log = "";
0209         ////////////////////////////////////////////////////////////////////////
0210         ////////////////////////////////////////////////////////////////////////
0211         
0212         </ order=55, name = "Additional UBFTAB files (comma separated), can be empty", type="string", min=0 /> 
0213         addubf = "";
0214 
0215         </ order=56, name = "Max IPC message size", 
0216                         type="number", min=1024 /> 
0217         msgsizemax="56000";
0218 
0219         </ order=57, name = "Max IPC messages in queue", 
0220                         type="number", min=1 /> 
0221         msgmax = "100";
0222 
0223         ////////////////////////////////////////////////////////////////////////
0224         //Views
0225         ////////////////////////////////////////////////////////////////////////
0226 
0227         </ order=70, name = "Configure views", type = "yn"/> 
0228         viewInstall = "n";
0229 
0230         </ order=71, name = "View definitions sub-folder of Apphome", 
0231                         type = "path", depend="(::prov.viewInstall==\"y\")"/> 
0232         viewDir = "views";
0233 
0234         </ order=72, name = "View files to active", type="string", min=1,
0235                         depend="(::prov.viewInstall==\"y\")"/> 
0236         viewFiles = "";
0237 
0238         ////////////////////////////////////////////////////////////////////////
0239         // Shared libraries and etc paths..
0240         ////////////////////////////////////////////////////////////////////////
0241         </ order=80, name = "Additional shared libraries path", type="string", min=0 /> 
0242         shLibs = "";
0243         
0244         //Install handler
0245         install = null;
0246         
0247         mk_mq_dev = false;
0248         
0249 
0250         //Get the output files to write to
0251         //So we will need following:
0252         //1. ndrxconfig.xml
0253         //2. app.ini
0254         //3. setqprefix
0255         
0256         ndrxconfig = "";
0257         appini = "";
0258         setfile = "";
0259         
0260         function getOutputFiles()
0261         {
0262                 ndrxconfig = appHome+"/"+confDir+"/ndrxconfig.xml";
0263                 appini = appHome+"/"+confDir+"/app.ini";
0264                 setfile = appHome+"/"+confDir+"/set"+qprefix;
0265                 
0266                 print("ndrxconfig: ["+ndrxconfig+"]\n");
0267                 userlog("ndrxconfig: ["+ndrxconfig+"]");
0268                 
0269                 print("appini: ["+appini+"]\n");
0270                 userlog("appini: ["+appini+"]");
0271                 
0272                 print("setfile: ["+setfile+"]\n");
0273                 userlog("setfile: ["+setfile+"]");
0274         }
0275         
0276         
0277         //Build the ndrxconfig value
0278         ndrxconfigXmlVal = "";
0279         function buildNdrxconfig()
0280         {
0281         
0282                 ndrxconfigXmlVal = @"<?xml version=""1.0"" ?>
0283 <endurox>
0284         <!--
0285                 *** For more info see ndrxconfig.xml(5) man page. ***
0286         -->
0287         <appconfig>
0288                 <!-- 
0289                         ALL BELLOW ONES USES <sanity> periodical timer
0290                         Sanity check time, sec
0291                 -->
0292                 <sanity>1</sanity>
0293                 
0294                 <!--
0295                         Seconds in which we should send service refresh to other node.
0296                 -->
0297                 <brrefresh>5</brrefresh>
0298                 
0299                 <!-- 
0300                         Do process reset after 1 sec 
0301                 -->
0302                 <restart_min>1</restart_min>
0303                 
0304                 <!-- 
0305                         If restart fails, then boot after +5 sec of previous wait time
0306                 -->
0307                 <restart_step>1</restart_step>
0308                 
0309                 <!-- 
0310                         If still not started, then max boot time is a 30 sec. 
0311                 -->
0312                 <restart_max>5</restart_max>
0313                 
0314                 <!--  
0315                         <sanity> timer, usage end
0316                 -->
0317                 
0318                 <!-- 
0319                         Time (seconds) after attach when program will start do sanity & respawn checks,
0320                         starts counting after configuration load 
0321                 -->
0322                 <restart_to_check>20</restart_to_check>
0323                 
0324                 
0325                 <!-- 
0326                         Setting for pq command, should ndrxd collect service 
0327                         queue stats automatically If set to Y or y, 
0328                         then queue stats are on. Default is off.
0329                 -->
0330                 <gather_pq_stats>Y</gather_pq_stats>
0331 
0332         </appconfig>
0333         <defaults>
0334 
0335                 <min>1</min>
0336                 <max>2</max>
0337                 <!-- 
0338                         Kill the process which have not started in <start_max> time
0339                 -->
0340                 <autokill>1</autokill>
0341                 
0342                 <!-- 
0343                         The maximum time while process can hang in 'starting' state i.e.
0344                         have not completed initialization, sec X <= 0 = disabled  
0345                 -->
0346                 <start_max>10</start_max>
0347                 
0348                 <!--
0349                         Ping server in every X seconds (step is <sanity>).
0350                 -->
0351                 <pingtime>100</pingtime>
0352                 
0353                 <!--
0354                         Max time in seconds in which server must respond.
0355                         The granularity is sanity time.
0356                         X <= 0 = disabled 
0357                 -->
0358                 <ping_max>800</ping_max>
0359                 
0360                 <!--
0361                         Max time to wait until process should exit on shutdown
0362                         X <= 0 = disabled 
0363                 -->
0364                 <end_max>10</end_max>
0365                 
0366                 <!-- 
0367                         Interval, in seconds, by which signal sequence -2, -15, -9, -9.... will be sent
0368                         to process until it have been terminated.
0369                 -->
0370                 <killtime>1</killtime>
0371                 
0372         </defaults>
0373         <servers>";
0374         
0375                 //Install config server
0376                 if (configSv=="y")
0377                 {
0378                 
0379                         ndrxconfigXmlVal=ndrxconfigXmlVal+
0380                 @"
0381                 <server name=""cconfsrv"">
0382                         <min>2</min>
0383                         <max>2</max>
0384                         <srvid>1</srvid>
0385                         <sysopt>-e ${NDRX_ULOG}/cconfsrv.log -r</sysopt>
0386                 </server>";
0387                 
0388                 }
0389                 
0390                 //Have admin server by default enabled
0391                 ndrxconfigXmlVal=ndrxconfigXmlVal+
0392                 @"
0393                 <server name=""tpadmsv"">
0394                         <min>2</min>
0395                         <max>2</max>
0396                         <srvid>10</srvid>
0397                         <sysopt>-e ${NDRX_ULOG}/tpadmsv.log -r</sysopt>
0398                 </server>";
0399                 
0400                 //Install event server
0401                 if (eventSv=="y")
0402                 {
0403                         ndrxconfigXmlVal=ndrxconfigXmlVal+
0404                 @"
0405                 <server name=""tpevsrv"">
0406                         <min>1</min>
0407                         <max>1</max>
0408                         <srvid>20</srvid>
0409                         <sysopt>-e ${NDRX_ULOG}/tpevsrv.log -r</sysopt>
0410                 </server>";
0411                 }
0412                 
0413                 
0414                 ////////////////////////////////////////////////////////////////
0415                 //Install event server
0416                 //So we need:
0417                 // - TMSRV log folder for 
0418                 // - Data folder
0419                 // - Q space name
0420                 // We need to make a rm1 folder!!!
0421                 ////////////////////////////////////////////////////////////////
0422                 if (installQ=="y")
0423                 {
0424                         ndrxconfigXmlVal=ndrxconfigXmlVal+
0425                 @"
0426                 <server name=""tmsrv"">
0427                         <min>3</min>
0428                         <max>3</max>
0429                         <srvid>40</srvid>
0430                         <cctag>RM1TMQ</cctag>
0431                         <sysopt>-e ${NDRX_ULOG}/tmsrv-rm1.log -r -- -t1 -l${NDRX_APPHOME}/"+tmDir+@"/rm1</sysopt>
0432                 </server>
0433                 <server name=""tmqueue"">
0434                         <min>1</min>
0435                         <max>1</max>
0436                         <srvid>60</srvid>
0437                         <cctag>RM1TMQ</cctag>
0438                         <sysopt>-e ${NDRX_ULOG}/tmqueue-rm1.log -r -- -s1</sysopt>
0439                 </server>";
0440                 }
0441                 
0442                 //Install XA driver for Q
0443                 
0444                 //Cluster bridge connection
0445                 if (bridge=="y")
0446                 {
0447                         local ip = ipl;
0448                         
0449                         if (prov.bridgeRole=="A" || prov.bridgeRole=="a")
0450                         {
0451                                 ip = ipc;
0452                         }
0453                         
0454                         ndrxconfigXmlVal=ndrxconfigXmlVal+
0455                 @"
0456                 <server name=""tpbridge"">
0457                         <min>1</min>
0458                         <max>1</max>
0459                         <srvid>150</srvid>
0460                         <sysopt>-e ${NDRX_ULOG}/tpbridge_"+otherNodeId+@".log -r</sysopt>
0461                         <appopt>-f -n"+otherNodeId+@" -r -i "+ip+" -p "+port+" -t"+bridgeRole.toupper()+@" -z30</appopt>
0462                 </server>";
0463                 }
0464                 
0465                 //Install user server 1
0466                 if (usv1=="y")
0467                 {
0468                         local _cctag="";
0469                         if (usv1_cctag!="")
0470                         {
0471                                 _cctag=@"
0472                         <cctag>"+usv1_cctag+@"</cctag>"
0473                         }
0474                         
0475                         local _appopt = "";
0476                         if (usv1_appopt!="")
0477                         {
0478                                 _appopt=@"
0479                         <appopt>"+usv1_appopt+@"</appopt>"
0480                         }
0481                         
0482                         ndrxconfigXmlVal=ndrxconfigXmlVal+
0483                 @"
0484                 <server name="""+usv1_name+@""">"+_cctag+@"
0485                         <min>"+usv1_min+@"</min>
0486                         <max>"+usv1_max+@"</max>
0487                         <srvid>"+usv1_srvid+@"</srvid>
0488                         <sysopt>"+usv1_sysopt+@"</sysopt>"+_appopt+@"
0489                 </server>";
0490                 }
0491                 
0492                 //Install tmsrecoversv, in case if Q is used
0493                 if (installQ=="y")
0494                 {
0495                         ndrxconfigXmlVal=ndrxconfigXmlVal+
0496                 @"
0497                 <server name=""tmrecoversv"">
0498                         <min>1</min>
0499                         <max>1</max>
0500                         <srvid>9900</srvid>
0501                         <sysopt>-e ${NDRX_ULOG}/tmrecoversv.log -- </sysopt>
0502                 </server>";
0503                 }
0504 
0505                 //Install CPM srv
0506                 if (cpmSv=="y")
0507                 {
0508                         ndrxconfigXmlVal=ndrxconfigXmlVal+
0509                 @"
0510                 <server name=""cpmsrv"">
0511                         <min>1</min>
0512                         <max>1</max>
0513                         <srvid>9999</srvid>
0514                         <sysopt>-e ${NDRX_ULOG}/cpmsrv.log -r -- -k3 -i1</sysopt>
0515                 </server>";
0516                 }
0517                 ndrxconfigXmlVal=ndrxconfigXmlVal+@"
0518         </servers>";
0519                 
0520                 //Add Sample client process...
0521                 if (cpmSv=="y")
0522                 {
0523                         local _ucl1 = "";
0524                         
0525                         if (ucl1=="y")
0526                         {
0527                                 local _subsect1="";
0528                                 
0529                                 if (_subsect1=="")
0530                                 {
0531                                         _subsect1=@"subsect="""+usv1_subsect+@""" ";
0532                                 }
0533                 _ucl1=@"
0534                 <client cmdline="""+usv1_cmdline+@""">
0535                         <exec tag="""+usv1_tag+@""" autostart=""Y"" "+_subsect1+@"log="""+usv1_log+@"""/>
0536                 </client>";
0537                 
0538                         }
0539                 ndrxconfigXmlVal=ndrxconfigXmlVal+
0540         @"
0541         <!-- 
0542                 Client section 
0543         -->
0544         <clients>
0545                 <!--
0546                         Test parameter passing to process 
0547                         - To list clients:$ xadmin pc
0548                         - To stop client: $ xadmin sc -t TAG1 -s SUBSECTION1
0549                         - To boot client: $ xadmin bc -t TAG1 -s SUBSECTION1
0550                 -->
0551                 <client cmdline=""your_test_binary.sh -t ${NDRX_CLTTAG} -s ${NDRX_CLTSUBSECT}"">
0552                         <exec tag=""TAG1"" subsect=""SUBSECTION1"" autostart=""Y"" log=""${NDRX_ULOG}/testbin-1.log""/>
0553                         <exec tag=""TAG2"" subsect=""SUBSECTION2"" autostart=""Y"" log=""${NDRX_ULOG}/testbin-3.log""/>
0554                 </client>
0555                 <client cmdline=""your_test_binary2.sh -t ${NDRX_CLTTAG}"">
0556                         <exec tag=""TAG3"" autostart=""Y"" log=""${NDRX_ULOG}/testbin2-1.log""/>
0557                 </client>"+_ucl1+@"
0558         </clients>";
0559                 }
0560                 
0561                 ndrxconfigXmlVal=ndrxconfigXmlVal+@"
0562 </endurox>
0563 ";
0564                 
0565         }
0566         
0567         //Build the app.ini value
0568         appiniVal = "";
0569         function buildAppini()
0570         {
0571         
0572                 appiniVal=appiniVal+@"[@global]
0573 NDRX_CLUSTERISED=1
0574 NDRX_CMDWAIT=1
0575 NDRX_CONFIG=${NDRX_APPHOME}/"+confDir+@"/ndrxconfig.xml
0576 NDRX_DMNLOG=${NDRX_ULOG}/ndrxd.log
0577 NDRX_DPID=${NDRX_APPHOME}/"+tempDir+@"/ndrxd.pid
0578 NDRX_DQMAX=100
0579 NDRX_IPCKEY="+ipckey+@"
0580 NDRX_LDBAL="+ldbal+@"
0581 NDRX_LEV=5
0582 NDRX_LOG=${NDRX_ULOG}/xadmin.log
0583 NDRX_MSGMAX="+msgmax+@"
0584 NDRX_MSGSIZEMAX="+msgsizemax+@"
0585 NDRX_NODEID="+nodeid+@"
0586 NDRX_QPATH="+qpath+@"
0587 NDRX_QPREFIX=/"+qprefix+@"
0588 NDRX_RNDK=0myWI5nu
0589 NDRX_SRVMAX=10000
0590 NDRX_SVCMAX=20000
0591 NDRX_TOUT="+timeout+@"
0592 NDRX_UBFMAXFLDS=16000
0593 NDRX_THREADSTACKSIZE=8192
0594 NDRX_LIBEXT="+shared_lib_pfx+@"
0595 NDRX_ULOG=${NDRX_APPHOME}/"+logDir+@"
0596 FIELDTBLS=Exfields"+(addubf!=""?(","+addubf):"")+@"
0597 FLDTBLDIR=${NDRX_APPHOME}/"+ubfDir+
0598 (::prov.viewInstall=="y"?@"
0599 VIEWDIR=${NDRX_APPHOME}/"+viewDir+@"
0600 VIEWFILES="+viewFiles:"")+
0601 @"
0602 ";
0603 
0604                 //Configure queue XA driver
0605                 if (installQ=="y")
0606                 {
0607                         appiniVal=appiniVal+@"
0608 ; Environment for Transactional Queue
0609 [@global/RM1TMQ]
0610 NDRX_XA_RES_ID=1
0611 NDRX_XA_OPEN_STR=datadir=""${NDRX_APPHOME}/"+qdata+@""",qspace="""+qSpace+@"""
0612 NDRX_XA_CLOSE_STR=${NDRX_XA_OPEN_STR}
0613 NDRX_XA_DRIVERLIB=libndrxxaqdisks."+shared_lib_pfx+@"
0614 ; dylib needed for osx
0615 NDRX_XA_RMLIB=libndrxxaqdisk."+shared_lib_pfx+@"
0616 NDRX_XA_LAZY_INIT=0
0617 ";
0618                 }
0619 
0620 
0621 appiniVal=appiniVal+@"
0622 [@debug]
0623 ; * - goes for all binaries not listed bellow
0624 *= ndrx="+ndrxlev+@" ubf="+ubflev+@" tp="+tplev+@" file=
0625 xadmin= ndrx="+ndrxlev+@" ubf="+ubflev+@" tp="+tplev+@" file=${NDRX_ULOG}/xadmin.log
0626 ndrxd= ndrx="+ndrxlev+@" ubf="+ubflev+@" tp="+tplev+@" file=${NDRX_ULOG}/ndrxd.log
0627 ";
0628 
0629 
0630 
0631                 if (installQ=="y")
0632                 {
0633         
0634                         appiniVal=appiniVal+@"
0635 ; Queue definitions goes here, see man q.conf(5) for syntax
0636 [@queue]
0637 ; Default manual queue (reserved name '@'), unknown queues are created based on this template:
0638 @=svcnm=-,autoq=n,waitinit=0,waitretry=0,waitretrymax=0,memonly=n,mode=fifo
0639 
0640 [@queue/RM1TMQ]
0641 ; Sample queue (this one is automatic, sends messages to target service)
0642 "+qName+@"=svcnm="+qSvc+@",autoq=y,tries=3,waitinit=1,waitretry=1,waitretrymax=5,memonly=n,mode=fifo
0643 ";
0644 
0645 
0646                 }
0647         
0648                 //print(appiniVal);
0649         }
0650         
0651         //
0652         // Generate set file
0653         // TODO: Might want to add cdpath too...
0654         // 
0655         setfileVal = "";
0656         function buildSetfile()
0657         {
0658                 local shlibstr = "";
0659                 if (::prov.shLibs!="")
0660                 {
0661                     switch (getosname())
0662                     {
0663                         case "AIX":
0664                             shlibstr = "export LIBPATH=$LIBPATH:"+::prov.shLibs;
0665                         break;
0666                         case "DARWIN":
0667                             shlibstr = "export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:"+::prov.shLibs;
0668                         break;
0669                         default:
0670                             shlibstr = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"+::prov.shLibs;
0671                         break;
0672                     }
0673                 }
0674                 setfileVal=setfileVal+@"#/bin/bash
0675 #
0676 # @(#) Load this script in environment
0677 #
0678 export NDRX_APPHOME="+appHome+@"
0679 export NDRX_CCONFIG=$NDRX_APPHOME/"+confDir+@"
0680 export PATH=$PATH:$NDRX_APPHOME/"+binDir+@"
0681 export CDPATH=$CDPATH:.:$NDRX_APPHOME
0682 "+shlibstr+"\n";
0683 
0684                 //create posix queue folder, if needed.
0685                 if (mk_mq_dev)
0686                 {
0687 setfileVal=setfileVal+@"
0688 if [ ! -d """+qpath+@""" ]; then
0689         mkdir """+qpath+@"""
0690 fi
0691 ";
0692                 }
0693 
0694                 //print(setfileVal);
0695         }
0696         
0697         //Create folders..
0698         function createFolders()
0699         {
0700                 userlog("About to create folders");
0701                 try
0702                 {
0703                         if (mk_mq_dev)
0704                         {
0705                                 userlog(format("Creating: [%s]", qpath));
0706                                 mkdir (qpath);
0707                         }
0708                         
0709                         userlog(format("Creating: [%s]", appHome));
0710                         mkdir (appHome);
0711                         
0712                         userlog(format("Creating: [%s]", appHome+"/"+binDir));
0713                         mkdir (appHome+"/"+binDir);
0714                         
0715                         userlog(format("Creating: [%s]", appHome+"/"+confDir));
0716                         mkdir (appHome+"/"+confDir);
0717                         
0718                         userlog(format("Creating: [%s]", appHome+"/"+logDir));
0719                         mkdir (appHome+"/"+logDir);
0720                         
0721                         userlog(format("Creating: [%s]", appHome+"/"+ubfDir));
0722                         mkdir (appHome+"/"+ubfDir);
0723                         
0724                         userlog(format("Creating: [%s]", appHome+"/"+tempDir));
0725                         mkdir (appHome+"/"+tempDir);
0726                         
0727                         if (installQ=="y")
0728                         {
0729                                 userlog(format("Creating: [%s]", appHome+"/"+tmDir));
0730                                 mkdir (appHome+"/"+tmDir);
0731                                 
0732                                 userlog(format("Creating: [%s]", appHome+"/"+tmDir));
0733                                 mkdir (appHome+"/"+tmDir);
0734                                 
0735                                 userlog(format("Creating: [%s]", appHome+"/"+tmDir+"/rm1"));
0736                                 mkdir (appHome+"/"+tmDir+"/rm1");
0737                                 
0738                                 userlog(format("Creating: [%s]", appHome+"/"+qdata));
0739                                 mkdir (appHome+"/"+qdata);
0740                         }
0741 
0742                         if (viewInstall=="y")
0743                         {
0744                                 userlog(format("Creating: [%s]", appHome+"/"+viewDir));
0745                                 mkdir (appHome+"/"+viewDir);
0746                         }
0747                 }
0748                 catch (ex)
0749                 {
0750                         userlog(format("createFolders failed: %s", ex));
0751                         print(format("createFolders failed: %s\n", ex));
0752                         return false;
0753                 }
0754                 
0755                 return true;
0756         }
0757 }
0758 
0759 //Run the mater installer
0760 function install() 
0761 {
0762     local root = getroottable();
0763 
0764     //Create a provision object
0765     root["prov"] <- Provision();
0766 
0767     print("Compiled system type....: " + ::prov.osType + "\n");
0768     print("\n");
0769 
0770     if (!::prov.isDefaulted)
0771     {
0772         ::prov.runInteractive();
0773     }
0774 
0775     if (::prov.validatAndPrintConfig())
0776     {
0777             ::prov.getOutputFiles();
0778             ::prov.buildNdrxconfig();
0779             ::prov.buildAppini();
0780             ::prov.buildSetfile();
0781 
0782             if (!::prov.createFolders())
0783             {
0784                     return false;
0785             }
0786 
0787             if (!::prov.writeFile(::prov.ndrxconfig, ::prov.ndrxconfigXmlVal))
0788             {
0789                     return false;
0790             }
0791 
0792             if (!::prov.writeFile(::prov.appini, ::prov.appiniVal))
0793             {
0794                     return false;
0795             }
0796 
0797             if (!::prov.writeFile(::prov.setfile, ::prov.setfileVal))
0798             {
0799                     return false;
0800             }
0801 
0802             if (!::prov.setExec(::prov.setfile))
0803             {
0804                     return false;
0805             }
0806 
0807             /* write exfields, if have the function in root table */
0808             if (root.rawin("getExfields"))
0809             {
0810                 if (!::prov.writeFile(::prov.appHome+"/"+::prov.ubfDir+"/Exfields", ::getExfields()))
0811                 {
0812                         return false;
0813                 }
0814             }
0815     }
0816     else
0817     {
0818         return false;
0819     }
0820 
0821     return true;
0822 }
0823 
0824 if (::install())
0825 {
0826         print("\n");
0827         print("\n");
0828 
0829         print("To start your system, run following commands:\n");
0830         print("$ cd "+::prov.appHome+"/"+::prov.confDir+"\n");
0831         print("$ source set"+::prov.qprefix+"\n");
0832         print("$ xadmin start -y\n");
0833 
0834         print("\n");
0835         print("\n");
0836 
0837         userlog("Provision succeed!");
0838         print("Provision succeed!\n");
0839 
0840 
0841         return 0;
0842 }
0843 else
0844 {
0845         userlog("Provision failed!");
0846         print("Provision failed!\n");
0847         return -1;
0848 }