Exemplo n.º 1
0
        /// <summary>
        /// Define download list
        /// </summary>
        /// <param name="rows1">String array containig rows read from reo descriptor file</param>
        /// <param name="peer_type">Type of the peer (Trial (Full), RH only, Client only - </param>
        /// <param name="inst_type">Type of the insallation - prod, dev, master.</param>
        /// <returns></returns>
        public static string[] rows2download(ref string[] rows1, string peer_type, string inst_type)
        {
            List <string> rows     = new List <string>();
            List <string> rows_new = new List <string>();

            foreach (string row in rows1)
            {
                string[] folderFile = row.Split(new[] { "|" }, StringSplitOptions.None);

                string folder      = folderFile[0].Trim();
                string file        = folderFile[1].Trim();
                string need_rh     = folderFile[2].Trim();
                string need_mh     = folderFile[3].Trim();
                string need_client = folderFile[4].Trim();
                string need_prod   = folderFile[5].Trim();
                string need_dev    = folderFile[6].Trim();
                string need_master = folderFile[7].Trim();

                int pLen    = peerTypes.Length;
                int iLen    = instTypes.Length;
                int start_i = 2;
                int start_j = start_i + pLen;

                for (int i = start_i; i < start_i + pLen; i++)         //find i for peer type
                {
                    if (peer_type.Contains(peerTypes[i - (pLen - 1)])) //found i
                    {
                        if (folderFile[i].Contains("1"))               //need file
                        {
                            for (int j = start_j; j < start_j + iLen; j++)
                            {
                                if (inst_type.Contains(instTypes[j - (iLen + pLen - 1)]))
                                {
                                    if (folderFile[j].Contains("1"))
                                    {
                                        rows.Add(row);
                                        logger.Info("file to download:{0}\\{1}", folder, file);
                                    }
                                }
                            }
                        }
                    }
                }
            }


            foreach (string row in rows)
            {
                if (row.Contains("chrome") && Inst.app_installed("Clients\\StartMenuInternet\\Google Chrome") == 1)
                {
                    continue;
                }

                if (row.Contains("virtualbox") && Inst.app_installed("Oracle\\VirtualBox") == 1)
                {
                    continue;
                }

                if (row.Contains("tap") && Inst.app_installed("TAP-Windows") == 1)
                {
                    continue;
                }
                rows_new.Add(row);
            }

            var rows_unique = rows_new.Distinct();

            string[] arows = rows_unique.ToArray();
            return(arows);
        }
Exemplo n.º 2
0
        //[STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            AppDomain current_domain = AppDomain.CurrentDomain;

            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            //Add installation type command line parameter to parameter string
            inst_type = InstType(cmd_args[1]);
            string repo_desc        = cmd_args[2];
            string if_installer_run = cmd_args[3];
            string kurjunURL        = cmd_args[4];

            inst_args = $"type={inst_type} network-installation=true kurjunUrl={kurjunURL} repo_descriptor={repo_desc}";

            logger.Info("Argument string: {0}", inst_args);
            //Check if_installer_run - if "Installer", will run application in new process - to close installer

            if (if_installer_run.Equals("Installer"))
            {
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.UseShellExecute  = true;
                startInfo.WorkingDirectory = Environment.CurrentDirectory;
                startInfo.FileName         = Application.ExecutablePath;
                startInfo.Arguments        = $"{cmd_args[1]} {cmd_args[2]} Run {kurjunURL}";
                startInfo.Verb             = "runas";
                try
                {
                    Thread.Sleep(3000);
                    Process p = Process.Start(startInfo);
                    Environment.Exit(0);
                }
                catch (System.ComponentModel.Win32Exception)
                {
                    MessageBox.Show("This utility requires elevated priviledges to complete correctly.", "Error: UAC Authorisation Required", MessageBoxButtons.OK);
                    return;
                }
            }
            inst_Dir = Inst.subutai_path();
            form_    = new f_confirm();
            form_.ShowDialog();
            if (stRun)
            {
                form1 = new f_install(inst_args);
                form2 = new InstallationFinished("complete", "");

                Application.Run(form1);
            }
            else
            {
                if (inst_Dir.Equals("") || inst_Dir.Equals("\"\""))
                {
                    inst_Dir = Inst.subutai_path();
                }

                string cmd = $"{inst_Dir}bin\\uninstall-clean.exe";
                cmd = FD.path_with_commas(cmd);
                var startInfo = new ProcessStartInfo
                {
                    CreateNoWindow  = true,
                    UseShellExecute = false,
                    FileName        = cmd,
                    WindowStyle     = ProcessWindowStyle.Hidden,
                    Arguments       = "Silent NoAll"
                };
                var exeProcess = Process.Start(startInfo);
                Environment.Exit(1);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Task factory to perform all installation steps
        /// with TaskContinuationOptions.OnlyOnRanToCompletion for each step
        /// so tasks are chained. On complete (failed or successful) runs InstallationFinished form
        /// </summary>
        /// <param name="sender">object sender</param>
        /// <param name="e">AsyncCompletedEventArgs e</param>
        public void TaskFactory(object sender, AsyncCompletedEventArgs e)
        {
            Deploy.dwldTimer.Enabled = false;
            Deploy.dwldTimer.Dispose();
            //var token = tokenSource.Token;
            object state = "";

            Task.Factory.StartNew(() =>
            {
                logger.Info("Starting task factory");
            })
            .ContinueWith((prevTask) =>
            {
                Deploy.StageReporter("Checking files", "");
                //Checking if files downloaded without errors
                logger.Info("Stage: {0} {1}", _arguments["network-installation"].ToLower(), "checkmd5");
                if (_arguments["network-installation"].ToLower() == "true")
                {
                    TC.check_md5();
                }
                stage_counter++;
                logger.Info("Stage checkmd5: {0}", stage_counter);
            }, TaskContinuationOptions.OnlyOnRanToCompletion)

            .ContinueWith((prevTask) =>
            {
                //Unzipping .zip
                Exception ex = prevTask.Exception;
                if (prevTask.IsFaulted)
                {
                    // faulted with exception
                    while (ex is AggregateException && ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    logger.Error(ex.Message, "checkmd5 faulted");
                    finished = 3;
                }
                Deploy.StageReporter("Extracting files", "");
                if (_arguments["network-installation"].ToLower() == "true")
                {
                    TC.unzip_extracted();
                    logger.Info("Stage unzip: {0}", "unzip-extracted");
                }
                stage_counter++;
                logger.Info("Stage unzip: {0}", stage_counter);
            }, TaskContinuationOptions.OnlyOnRanToCompletion)

            .ContinueWith((prevTask) =>
            {
                //Installing prerequisites
                Exception ex = prevTask.Exception;
                if (prevTask.IsFaulted)
                {
                    //unzipping faulted with exception
                    while (ex is AggregateException && ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                        logger.Error(ex.Message, "unzipping faulted");
                    }
                    finished = 3;
                    Program.ShowError(ex.Message, "unzipping faulted");
                    throw new InvalidOperationException();
                }
                Deploy.StageReporter("Installing redistributables", "");
                TC.deploy_redist();
                logger.Info("Stage deploy-redist: {0}", "deploy-redist");
                stage_counter++;
                logger.Info("Stage deploy redistributables: {0}", stage_counter);
            }, TaskContinuationOptions.OnlyOnRanToCompletion)

            .ContinueWith((prevTask) =>
            {
                //Prepare vbox
                Exception ex = prevTask.Exception;
                if (prevTask.IsFaulted)
                {
                    //deploy redist faulted with exception
                    while (ex is AggregateException && ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                        logger.Error(ex.Message, "deploy redist faulted");
                    }
                    finished = 3;
                    Program.ShowError(ex.Message, "deploy redist faulted");
                    throw new InvalidOperationException();
                }
                Deploy.StageReporter("Preparing Virtual machine", "");
                //not "client-only")
                if (_arguments["peer"].Contains("MH") || _arguments["peer"].Contains("RH"))
                {
                    TC.prepare_vbox();
                    logger.Info("Stage prepare vbox: {0}", "prepare-vbox");
                }
                stage_counter++;
                logger.Info("Stage prepate-vbox: {0}", stage_counter);
            }, TaskContinuationOptions.OnlyOnRanToCompletion)

            .ContinueWith((prevTask) =>
            {
                //Prepare RH
                Exception ex = prevTask.Exception;
                if (prevTask.IsFaulted)
                {
                    //prepare-vbox faulted with exception
                    while (ex is AggregateException && ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                        logger.Error(ex.Message, "prepare vbox faulted");
                    }
                    finished = 3;
                    Program.ShowError(ex.Message, "prepare vbox faulted");
                    throw new InvalidOperationException();
                }
                Deploy.StageReporter("Preparing Resource Host", "");
                //not "client-only")
                if (_arguments["peer"].Contains("MH") || _arguments["peer"].Contains("RH"))
                {
                    TC.prepare_rh();
                    Deploy.StageReporter("Preparing Management Host", "");
                    TC.prepare_peer();
                }

                stage_counter++;
                logger.Info("Stage prepare-rh: {0}", stage_counter);
            }, TaskContinuationOptions.OnlyOnRanToCompletion)


            .ContinueWith((prevTask) =>
            {
                //Install and configure P2P
                Exception ex = prevTask.Exception;
                if (prevTask.IsFaulted)
                {
                    //prepare rh faulted with exception
                    while (ex is AggregateException && ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                        logger.Error(ex.Message, "prepare peer faulted");
                    }
                    finished = 3;
                    Program.ShowError(ex.Message, "prepare peer faulted");
                    throw new InvalidOperationException();
                }
                Deploy.StageReporter("Setting up P2P Service", "");
                //not "rh-only")
                if (_arguments["peer"] != "RH,")
                {
                    if (!Inst.imported && _arguments["peer"].Contains("MH"))
                    {
                        finished = 3;
                        Program.ShowError("Import was not completed, please check network and VM state and reinstall", "prepare rh faulted");
                    }

                    TC.deploy_p2p();
                    finished = 1;
                    logger.Info("Stage: {0}", "deploy-p2p");
                }
                stage_counter++;
                logger.Info("Stage deploy-p2p: {0}", stage_counter);
            }, TaskContinuationOptions.OnlyOnRanToCompletion)

            .ContinueWith((prevTask) =>
            {
                //Create shortcuts
                Exception ex = prevTask.Exception;
                if (prevTask.IsFaulted)
                {
                    //deploy p2p faulted with exception
                    while (ex is AggregateException && ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                        logger.Error(ex.Message, "deploy p2p faulted");
                    }
                    finished = 3;
                    //Program.ShowError(ex.Message, "deploy p2p faulted");
                }

                //not "rh-only")
                if (_arguments["peer"] != "RH,")
                {
                    //Create shortcuts and put in registry "run tray on login"
                    _deploy.createAppShortCuts(true);
                    Inst.rg_run_on_login("SubutaiTray", "bin\\tray\\SubutaiTray.exe");
                }
                else
                {
                    _deploy.createAppShortCuts(false);
                }

                stage_counter++;
                logger.Info("Stage create shortcuts: {0}", stage_counter);
            }, TaskContinuationOptions.OnlyOnRanToCompletion)

            .ContinueWith((prevTask) =>
            {
                Exception ex = prevTask.Exception;
                if (prevTask.IsFaulted)
                {
                    //create shortcuts faulted with exception
                    while (ex is AggregateException && ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                        logger.Error(ex.Message, "create shortcuts faulted");
                    }
                    finished = 3;
                }

                logger.Info("stage_counter = {0}", stage_counter);
                Program.form1.Invoke((MethodInvoker) delegate
                {
                    logger.Info("form1.invoke");
                    Program.form1.Visible = false;
                });
            }, TaskContinuationOptions.OnlyOnRanToCompletion)
            .ContinueWith((prevTask) =>
            {
                logger.Info("finished = {0}", finished);
                //if (finished == 11 && st == "complete" && _arguments["peer"] != "rh-only")
                if (finished == 11 && st == "complete" && _arguments["peer"] != "RH,")
                {
                    Deploy.LaunchCommandLineApp($"{Program.inst_Dir}bin\\tray\\{Deploy.SubutaiTrayName}", "");
                }
            });
        }