private async Task MakeBootable(WindowsVolumes volumes, Phone phone, InstallOptions options)
        {
            Log.Information("Making Windows installation bootable...");

            var bcdPath         = Path.Combine(volumes.Boot.RootDir.Name, "EFI", "Microsoft", "Boot", "BCD");
            var bcd             = new BcdInvoker(bcdPath);
            var windowsPath     = Path.Combine(volumes.Windows.RootDir.Name, "Windows");
            var bootDriveLetter = volumes.Boot.Letter;
            await ProcessUtils.RunProcessAsync(BcdBootPath, $@"{windowsPath} /f UEFI /s {bootDriveLetter}:");

            bcd.Invoke("/set {default} testsigning on");
            bcd.Invoke("/set {default} nointegritychecks on");

            await PatchBootIfNecessary(volumes.Boot, options);

            await volumes.Boot.Partition.SetGptType(PartitionType.Esp);

            var updatedBootVolume = await phone.GetBootVolume();

            if (updatedBootVolume != null)
            {
                Log.Verbose("We shouldn't be able to get a reference to the Boot volume.");
                Log.Verbose("Updated Boot Volume: {@Volume}", new { updatedBootVolume.Label, updatedBootVolume.Partition, });
                if (!Equals(updatedBootVolume.Partition.PartitionType, PartitionType.Esp))
                {
                    Log.Warning("The system partition should be {Esp}, but it's {ActualType}", PartitionType.Esp, updatedBootVolume.Partition.PartitionType);
                }
            }
        }
示例#2
0
        public static void Run(InstallOptions options)
        {
            Logo.Print();
            ApplySettings(options);

            if (Packsly.Launcher.CanEmbed && !IsPackslyEmbeded(options.Workspace))
            {
                logger.Info("Embedding packsly to launcher directory...");
                EmbedPacksly(options.Workspace);
            }

            if (!options.IsSourceSpecified)
            {
                logger.Info("Using modpack source from configuration.");
                options.Source = Packsly.Configuration.DefaultModpackSource;
            }

            logger.Info($"Current modpack source: {options.Source}");
            if (options.IsSourceLocalFile)
            {
                logger.Info("Beginning installation from local modpack definition file...");
                Packsly.Launcher.CreateInstanceFromModpack(new FileInfo(options.Source));
            }
            else if (options.IsSourceUrl)
            {
                logger.Info("Beginning installation from remote modpack definition source...");
                Packsly.Launcher.CreateInstanceFromModpack(new Uri(options.Source));
            }
            else
            {
                throw new ConfigurationErrorsException($"Specified modpack source '{options.Source}' is not valid file path or URL address.");
            }

            logger.Info("Thank you for using Packsly3!");
        }
示例#3
0
        public static string GenerateString(this InstallOptions options)
        {
            string optionsString = string.Empty;

            if ((options & InstallOptions.WithForwardLock) != 0)
            {
                optionsString += " -l";
            }
            if ((options & InstallOptions.ReinstallKeepingData) != 0)
            {
                optionsString += " -r";
            }
            if ((options & InstallOptions.InstallToShared) != 0)
            {
                optionsString += " -s";
            }
            if ((options & InstallOptions.InstallToInternal) != 0)
            {
                optionsString += " -f";
            }
            if ((options & InstallOptions.AllowDowngrade) != 0)
            {
                optionsString += " -d";
            }
            if ((options & InstallOptions.GrantAllPermissions) != 0)
            {
                optionsString += " -g";
            }
            if ((options & InstallOptions.AllowTestAPKs) != 0)
            {
                optionsString += " -t";
            }

            return(optionsString);
        }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebManager"/> class.
 /// </summary>
 /// <param name="options">The install options.</param>
 /// <param name="variables">A cache of install variables.</param>
 /// <param name="installLogger">Logs installation results.</param>
 public WebManager(InstallOptions options, InstallVariables variables, InstallLogger installLogger)
 {
     this.installOptions = options;
     this.installVariables = variables;
     this.installLogger = installLogger;
     this.siteName = this.installOptions.RootSite != null ? string.Format("{0}/{1}", this.installOptions.HostName, this.installOptions.WebsiteName) : this.installOptions.WebsiteName;
 }
示例#5
0
        /// <inheritdoc />
        protected override InstallOptions GetInstallOptions(PackageVersionId version)
        {
            InstallOptions options = base.GetInstallOptions(version);

            options.AllowUpgradeToUnknownVersion = this.IncludeUnknown.ToBool();
            return(options);
        }
        private async Task ApplyWindowsImage(WindowsVolumes volumes, InstallOptions options, IObserver <double> progressObserver = null)
        {
            Log.Information("Applying Windows Image...");
            await windowsImageService.ApplyImage(volumes.Windows, options.ImagePath, options.ImageIndex, progressObserver);

            progressObserver?.OnNext(double.NaN);
        }
示例#7
0
        /// <summary>
        ///     Compile the installer.
        /// </summary>
        /// <param name="installOptions">The install options.</param>
        private void CompileInstaller(InstallOptions installOptions)
        {
            // Ask to close and restart to update files with installer
            var _references = new List <string>
            {
                "System.dll",
                "System.Windows.Forms.dll"
            };

            ResourcesManager.CreateSettingsResource(installOptions.ResourceSettingsPath, installOptions);

            var _resources = new List <string>
            {
                installOptions.ResourceSettingsPath
            };

            var _sources = new[] { Resources.MainEntryPoint, Resources.ConsoleManager, Resources.Installer, Resources.ResourceSettings };

            string _updaterFileName = Application.StartupPath + @"\\Updater.exe";

            CompilerResults _results = CodeDomCompiler.Build(_references, _sources, _updaterFileName, _resources);

            if (_results.Errors.Count > 0)
            {
                VisualCompileErrorDialog.Show(_results);
            }
            else
            {
                Process.Start(_updaterFileName);
            }

            File.Delete(installOptions.ResourceSettingsPath);
        }
示例#8
0
        /// <summary>
        /// Main method that runs the install program.
        /// </summary>
        /// <param name="args">Command line arguments.</param>
        private static void Main(string[] args)
        {
            InstallOptions installOptions = new InstallOptions();
            Environment.CurrentDirectory = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;

            if (args.Contains("--help"))
            {
                Console.Write(installOptions.GetUsage());
                Environment.Exit(0);
            }

            installLogger = new InstallLogger(installOptions.Quiet);

            Parser parser = new Parser(settings => { settings.MutuallyExclusive = true; });
            if (!parser.ParseArguments(args, installOptions))
            {
                installLogger.LogErrorLine("Invalid command line parameters");
                Environment.Exit(1);
            }

            JsonConvert.DefaultSettings = () => new JsonSerializerSettings
                                                {
                Formatting = Formatting.None,
                ContractResolver = new DiscretionalContractResolver(),
                Converters = new JsonConverter[] { new JsonKnownTypeConverter() }
            };

            new Program().Run(installOptions);
        }
示例#9
0
        public async Task DeployCoreAndWindows(InstallOptions options, RaspberryPi device, IObserver <double> progressObserver = null)
        {
            await EnsureValidCoreWindowsDeployment();

            await CreateInitialPartitionLayout(device, progressObserver);
            await DeployUefi(device);
            await DeployWindows(options, device, progressObserver);
        }
示例#10
0
 public static void DoInstall(DirectoryInfo source, DirectoryInfo target, InstallOptions options)
 {
     CopyFiles(source.GetFiles().ToList(), target);
     foreach (DirectoryInfo di in source.GetDirectories())
     {
         DoInstall(di, new DirectoryInfo(target.FullName + "\\" + di.Name), options);
     }
 }
示例#11
0
        public Installer(InstallOptions options)
        {
            _options = options;

            // Loads package info
            using var fr = new StreamReader(_options.PackagePath);
            _packageInfo = JsonConvert.DeserializeObject <PackageInfo>(fr.ReadToEnd());
        }
示例#12
0
        /// <summary>
        /// Installs MSI package on remote server using the URI to the MSI package.
        /// ConDep will first download the MSI package to the server and then install the package.
        /// </summary>
        /// <param name="install"></param>
        /// <param name="packageName">A uniqe package name (DisplayName in Windows Registry) to make this
        /// operation idempotent. If this package name is not correct, ConDep will install this package
        /// on every execution. ConDep looks in these three registry keys for installed software packages:
        /// HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
        /// HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall
        /// HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall</param>
        /// <param name="srcMsiUri">A URI to the MSI package</param>
        /// <param name="options">Additional options to pass in to msiexec.</param>
        /// <returns></returns>
        public static IOfferRemoteInstallation Msi(this IOfferRemoteInstallation install, string packageName, Uri srcMsiUri, Action <IOfferInstallOptions> options)
        {
            var msiOptions = new InstallOptions();

            options(msiOptions);
            var msiOperation = new MsiOperation(packageName, srcMsiUri, msiOptions.Values);

            OperationExecutor.Execute((RemoteBuilder)install, msiOperation);
            return(install);
        }
示例#13
0
 /// <summary>
 /// Updates a package from the pipeline or from the local system.
 /// </summary>
 protected override void ProcessRecord()
 {
     base.ProcessRecord();
     this.GetPackageAndExecute(CompositeSearchBehavior.LocalCatalogs, (package, version) =>
     {
         InstallOptions options = this.GetInstallOptions(version);
         InstallResult result   = this.UpgradePackage(package, options);
         this.WriteObject(result);
     });
 }
示例#14
0
        private InstallResult UpgradePackage(
            CatalogPackage package,
            InstallOptions options)
        {
            var operation = PackageManager.Value.UpgradePackageAsync(package, options);

            return(this.RegisterCallbacksAndWait(operation, string.Format(
                                                     Utilities.ResourceManager.GetString("ProgressRecordActivityUpdating"),
                                                     package.Name)));
        }
示例#15
0
    public void StartDownloading()
    {
        InstallOptions InstallOptions = GameObject.Find("InstallOptions").GetComponent <InstallOptions>();

        InstallOptions.gameObject.GetComponent <Canvas>().enabled    = true;
        InstallOptions.GetComponent <InstallOptions>().RequiredSpace = RequiredSpace;
        GameNameText.text       = GameName;
        SpecialScripts.ThisGame = gameObject.name;
        InstallOptions.OpenOptions();
    }
        /// <summary>
        /// Installs MSI package on remote server using the URI to the MSI package.
        /// ConDep will first download the MSI package to the server and then install the package.
        /// </summary>
        /// <param name="install"></param>
        /// <param name="packageName">A uniqe package name (DisplayName in Windows Registry) to make this
        /// operation idempotent. If this package name is not correct, ConDep will install this package
        /// on every execution. ConDep looks in these three registry keys for installed software packages:
        /// HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
        /// HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall
        /// HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall</param>
        /// <param name="srcMsiUri">A URI to the MSI package</param>
        /// <param name="options">Additional options to pass in to msiexec.</param>
        /// <returns></returns>
        public static IOfferRemoteInstallation Msi(this IOfferRemoteInstallation install, string packageName, Uri srcMsiUri, Action <IOfferInstallOptions> options)
        {
            var msiOptions = new InstallOptions();

            options(msiOptions);
            var msiOperation = new MsiOperation(packageName, srcMsiUri, msiOptions.Values);

            Configure.Operation(install, msiOperation);
            return(install);
        }
示例#17
0
 /// <summary>Initializes a new instance of the <see cref="UpdaterStateEventArgs" /> class.</summary>
 /// <param name="assembly">The assembly.</param>
 /// <param name="installOptions">The install Options.</param>
 /// <param name="packagePath">The package path.</param>
 /// <param name="state">The update state.</param>
 public UpdaterStateEventArgs(Assembly assembly, InstallOptions installOptions, Uri packagePath, UpdaterState state)
 {
     Assembly         = assembly;
     AssemblyLocation = assembly.Location;
     InstallOptions   = installOptions;
     PackagePath      = packagePath;
     Package          = new Package(packagePath);
     State            = state;
     UpdateAvailable  = ApplicationManager.CheckForUpdate(assembly, packagePath);
     Version          = assembly.GetName().Version;
 }
示例#18
0
        public ChangeLogPanel(InstallOptions installOptions, Package package, Version currentVersion)
        {
            InitializeComponent();

            StringBuilder _versionInfo = new StringBuilder();

            _versionInfo.AppendLine(@"The version of " + package.Name + @" installed on this computer is: v" + currentVersion);
            _versionInfo.AppendLine(@"The latest version is: v" + package.Version);

            LVersion.Text    = _versionInfo.ToString();
            TbChangeLog.Text = package.ChangeLog;
        }
示例#19
0
        public async Task DeployWindows(InstallOptions options, Phone phone, IObserver <double> progressObserver = null)
        {
            await EnsureValidWindowsDeployment();

            Log.Information("Deploying Windows 10 ARM64...");

            await EnsureNoDualBootMenu(phone);

            await windowsDeployer.Deploy(options, phone, progressObserver);

            Log.Information("Deployment successful");
        }
示例#20
0
        private static void InstallUpdate(InstallOptions options)
        {
            var installer = new Installer(options);

            installer
            .ExtractPackage()
            .CopyNewVersion();
            if (options.RemoveAfterInstall)
            {
                installer.RemovePackages();
            }
        }
        private async Task PatchBootIfNecessary(Volume boot, InstallOptions partitionsBoot)
        {
            if (partitionsBoot.PatchBoot)
            {
                Log.Information("Patching boot...");
                var source = new DirectoryInfo(deploymentPaths.BootPatchFolder);
                var dest   = new DirectoryInfo(Path.Combine(boot.RootDir.FullName, "EFI", "Boot"));
                await FileUtils.CopyDirectory(source, dest);

                Log.Information("Boot patched");
            }
        }
        /// <summary>
        /// Use this for installing packages that are not an MSI (.msi extension). Typically an
        /// executable (.exe) followed by a set of parameters to make the installation
        /// non-interactive (silent).
        /// </summary>
        /// <param name="install"></param>
        /// <param name="packageName">A uniqe package name (DisplayName in Windows Registry) to make this
        /// operation idempotent. If this package name is not correct, ConDep will install this package
        /// on every execution. ConDep looks in these three registry keys for installed software packages:
        /// HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
        /// HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall
        /// HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall</param>
        /// <param name="srcExecutableUri">A URI to the custom package</param>
        /// <param name="exeParams">Parameters needed by the package to install silently, logging etc.</param>
        /// <returns></returns>
        public static IOfferRemoteInstallation Custom(this IOfferRemoteInstallation install, string packageName, Uri srcExecutableUri, string exeParams, Action <IOfferInstallOptions> options = null)
        {
            var installOptions = new InstallOptions();

            if (options != null)
            {
                options(installOptions);
            }
            var exeOperation = new InstallExecutableOperation(packageName, srcExecutableUri, exeParams, installOptions.Values);

            Configure.Operation(install, exeOperation);
            return(install);
        }
示例#23
0
        /// <summary>
        /// Use this for installing packages that are not an MSI (.msi extension). Typically an
        /// executable (.exe) followed by a set of parameters to make the installation
        /// non-interactive (silent).
        /// </summary>
        /// <param name="install"></param>
        /// <param name="packageName">A uniqe package name (DisplayName in Windows Registry) to make this
        /// operation idempotent. If this package name is not correct, ConDep will install this package
        /// on every execution. ConDep looks in these three registry keys for installed software packages:
        /// HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
        /// HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall
        /// HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall</param>
        /// <param name="srcExecutableFilePath">A local file path to the custom package (not a path on target server).</param>
        /// <param name="exeParams">Parameters needed by the package to install silently, logging etc.</param>
        /// <returns></returns>
        public static IOfferRemoteInstallation Custom(this IOfferRemoteInstallation install, string packageName, string srcExecutableFilePath, string exeParams, Action <IOfferInstallOptions> options = null)
        {
            var installOptions = new InstallOptions();

            if (options != null)
            {
                options(installOptions);
            }
            var exeOperation = new InstallExecutableOperation(packageName, srcExecutableFilePath, exeParams, installOptions.Values);

            OperationExecutor.Execute((RemoteBuilder)install, exeOperation);
            return(install);
        }
示例#24
0
        /// <summary>
        ///     Create the resource settings.
        /// </summary>
        /// <param name="filename">The filename.</param>
        /// <param name="installOptions">The install options.</param>
        public static void CreateSettingsResource(string filename, InstallOptions installOptions)
        {
            using (ResourceWriter _resourceWriter = new ResourceWriter(filename))
            {
                _resourceWriter.AddResource("Logging", false); // TODO: On true it won't display the contents like ExtractFolder in the console.
                _resourceWriter.AddResource("ProductName", installOptions.ProductName);
                _resourceWriter.AddResource("ExecutablePath", installOptions.ExecutablePath);
                _resourceWriter.AddResource("InstallDirectory", installOptions.InstallDirectory);
                _resourceWriter.AddResource("RestartApplicationAfterInstall", installOptions.RestartApplicationAfterInstall);

                _resourceWriter.Generate();
                _resourceWriter.Close();
            }
        }
    public static void InstallDone() // dont change this
    {
        Unzipper Unzipper = GameObject.Find("Unzipper").GetComponent <Unzipper>();

        Unzipper.GetComponent <Unzipper>().InstallText.text = ("Afronden van installatie");
        DownloadGame   downloader     = GameObject.Find("Downloader").GetComponent <DownloadGame>();
        InstallOptions installoptions = GameObject.Find("InstallOptions").GetComponent <InstallOptions>();

        installoptions.ResetShortcut();
        downloader.GetComponent <DownloadGame>().CleanUp();
        Unzipper.GetComponent <Unzipper>().InstallText.text = ("Installatie Voltooid !");
        Gamebuttons.Enable();
        ExitButtonStatic.SetActive(true);
    }
示例#26
0
        public WelcomePage(InstallOptions installOptions, Package package, Version currentVersion)
        {
            InitializeComponent();

            LTitle.Text = $@"Welcome to the {package.Name} Update Wizard";

            StringBuilder _headerText = new StringBuilder();

            _headerText.AppendLine($@"This wizard will guide you through the update of {package.Name}.");
            _headerText.Append(Environment.NewLine);
            _headerText.AppendLine($@"It is recommended that you close all other applications before continuing.");
            _headerText.Append(Environment.NewLine);
            _headerText.AppendLine($@"Click Next to continue, or Cancel to exit the update.");
            LHeader.Text = _headerText.ToString();
        }
示例#27
0
        public async Task Deploy(InstallOptions options, RaspberryPi phone, IObserver <double> progressObserver = null)
        {
            Log.Information("Deploying Windows 10 ARM64...");

            await RemoveExistingWindowsPartitions(phone);
            await CreateWindowsPartition(phone);

            var windowsVolumes = new WindowsVolumes(await phone.GetBootVolume(), await phone.GetWindowsVolume());

            await ApplyWindowsImage(windowsVolumes, options, progressObserver);
            await InjectDrivers(windowsVolumes.Windows);
            await MakeBootable(windowsVolumes, phone);

            Log.Information("Windows Image deployed");
        }
        public async Task Deploy(InstallOptions options, Phone phone, IObserver <double> progressObserver = null)
        {
            Log.Information("Deploying Windows 10 ARM64...");

            await RemoveExistingWindowsPartitions(phone);
            await AllocateSpace(phone, options.SizeReservedForWindows);

            var partitions = await CreatePartitions(phone);

            await ApplyWindowsImage(partitions, options, progressObserver);
            await InjectDrivers(partitions.Windows);
            await MakeBootable(partitions, phone, options);

            Log.Information("Windows Image deployed");
        }
示例#29
0
        public async Task Install(InstallOptions options, string expected)
        {
            // arrange
            var processManager = new TestProcessManager();

            processManager.AddProcess(new[] { "Success" });
            var adb = new Adb(processManager);

            // act
            var deviceAdb = adb.SingleDevice;
            await deviceAdb.Install("test.apk", options);

            // assert
            processManager.Stub.AssertWasCalled(_ => _.CreateProcess(Arg <string> .Is.Anything, Arg <string> .Matches(c => c.Contains(expected))));
        }
        public void should_create_dic_from_options()
        {
            var installCommand = new InstallOptions()
            {
                Interactive = true,
                Package     = "vlc",
            };

            var dic = installCommand.ToDictionary();

            dic["cmd_package"].Should().Be(installCommand.Package);
            dic["cmd_interactivity"].Should().Be("interactive");
            dic["cmd_force"].Should().Be("False");
            dic["cmd_tag"].Should().Be(null);
            dic["cmd_commandname"].Should().Be("install");
        }
示例#31
0
        /// <summary>Initializes a new instance of the <see cref="CometUpdater" /> class.</summary>
        public CometUpdater()
        {
            _updateServerPackagePath = new Uri("https://www.site.com/update.package");
            _autoUpdate                 = false;
            _notifyUpdateAvailable      = true;
            _notifyUpdateReadyToInstall = true;
            _state          = UpdaterState.NotChecked;
            _installOptions = new InstallOptions(string.Empty, true, true);
            _opened         = false;

            _backgroundUpdateChecker = new BackgroundWorker
            {
                WorkerSupportsCancellation = true
            };

            _backgroundUpdateChecker.DoWork             += BackgroundUpdateCheckerDoWork;
            _backgroundUpdateChecker.RunWorkerCompleted += BackgroundUpdateChecker_Completed;
        }
示例#32
0
        public CommandLineParserTests(ITestOutputHelper output)
        {
            _output = output;

            _parser = CommandLineParser.Create(
                new ServiceCollection(),
                startServer: (options, invocationContext) =>
            {
                _startOptions = options;
            },
                demo: (options, console, context, startOptions) =>
            {
                _demoOptions = options;
                return(Task.CompletedTask);
            },
                tryGithub: (options, c) =>
            {
                _tryGitHubOptions = options;
                return(Task.CompletedTask);
            },
                pack: (options, console) =>
            {
                _packOptions = options;
                return(Task.CompletedTask);
            },
                install: (options, console) =>
            {
                _installOptions       = options;
                _installPackageSource = options.AddSource;
                return(Task.CompletedTask);
            },
                verify: (options, console, startupOptions) =>
            {
                _verifyOptions = options;
                return(Task.FromResult(0));
            },
                telemetry: new FakeTelemetry(),
                publish: (options, console, startupOptions) =>
            {
                _publishOptions = options;
                return(Task.FromResult(0));
            },
                firstTimeUseNoticeSentinel: new NopFirstTimeUseNoticeSentinel());
        }
示例#33
0
        /// <summary>
        /// Checks all required parameters are supplied, and requests
        /// them from the user when they are missing.
        /// </summary>
        /// <param name="installOptionsToUse">The install options.</param>
        private void CheckParameters(InstallOptions installOptionsToUse)
        {
            if (installOptionsToUse.Quiet)
            {
                if (installOptionsToUse.Mode == InstallerMode.Unknown)
                {
                    installOptionsToUse.Install = true;
                }

                return;
            }

            if (installOptionsToUse.Mode == InstallerMode.Unknown)
            {
                Menu menu = new Menu();
                menu.AddMenuItem("I", "Install", (Action)delegate { installOptionsToUse.Install = true; }, new object[] { });
                menu.AddMenuItem("R", "Repair / Upgrade Database", (Action)delegate { installOptionsToUse.Repair = true; }, new object[] { });
                menu.AddMenuItem("U", "Uninstall", (Action)delegate { installOptionsToUse.Uninstall = true; }, new object[] { });
                menu.AddMenuItem("Q", "Quit", (Action<int>)Environment.Exit, new object[] { 0 });
                menu.DisplayMenu();
            }

            if (installOptionsToUse.Mode == InstallerMode.Install || installOptionsToUse.Mode == InstallerMode.Uninstall)
            {
                Menu menu = new Menu();
                menu.AddMenuItem("S", string.Format("Standard {0}", installOptionsToUse.Mode), (Action)delegate { installOptionsToUse.Api = false; }, new object[] { });
                menu.AddMenuItem("A", string.Format("API {0}", installOptionsToUse.Mode), (Action)delegate { installOptionsToUse.Api = true; }, new object[] { });
                menu.AddMenuItem("Q", "Quit", (Action<int>)Environment.Exit, new object[] { 0 });
                menu.DisplayMenu();

                menu = new Menu();
                menu.AddMenuItem("R", string.Format("Root {0}", installOptionsToUse.Mode), (Action)delegate { installOptionsToUse.RootSite = null; }, new object[] { });
                menu.AddMenuItem("S", string.Format("Subsite {0}", installOptionsToUse.Mode), new Action<InstallOptions>(this.DisplaySubsiteMenu), new object[] { installOptionsToUse });
                menu.AddMenuItem("Q", "Quit", (Action<int>)Environment.Exit, new object[] { 0 });
                menu.DisplayMenu();

                string descriptionText = installOptionsToUse.Api ? Strings.APIDescription : Strings.StandardDescription;

                string exampleUrl = installOptionsToUse.Api ? Strings.APIExampleURL : Strings.StandardExampleURL;
                if (installOptionsToUse.RootSite != null && string.IsNullOrEmpty(installOptionsToUse.WebsiteName))
                {
                    var binding = installOptionsToUse.RootSite.Bindings.FirstOrDefault(b => !string.IsNullOrEmpty(b.Host));
                    var hostname = binding != null ? binding.Host : Strings.DefaultBinding;
                    installOptionsToUse.HostName = hostname;

                    if (binding == null)
                    {
                        // Show the user a warning if the default bindings Host value is blank.
                        installLogger.LogWarningLine(Strings.DefaultBindingWarning);
                    }

                    installLogger.LogLine(null);
                    installLogger.LogWarningLine(string.Format(Strings.SubsiteDescription, hostname));
                    installLogger.LogLine(null);
                    installOptionsToUse.WebsiteName = this.ReadValidSiteName("Subsite Path (no slashes)");
                }
                else if (string.IsNullOrEmpty(installOptionsToUse.WebsiteName))
                {
                    installLogger.LogLine(null);
                    installLogger.LogWarningLine(descriptionText);
                    installLogger.LogLine(null);
                    installOptionsToUse.WebsiteName = this.ReadValidSiteName(string.Format("Website Name (eg. {0})", exampleUrl));
                }

                if (installOptionsToUse.Mode == InstallerMode.Install && installOptionsToUse.Api && string.IsNullOrEmpty(installOptionsToUse.IapplyWebsiteName))
                {
                    installLogger.LogLine(null);
                    installLogger.LogWarningLine(Strings.BaseWebsiteDescription);
                    installLogger.LogLine(null);
                    installOptionsToUse.IapplyWebsiteName = this.ReadValidSitePath(string.Format("iApply Website Name (eg. {0} - blank for {1})", Strings.StandardExampleURL, installOptionsToUse.WebsiteName));
                }
            }

            if (installOptionsToUse.Mode != InstallerMode.Install && installOptionsToUse.Mode != InstallerMode.Repair)
            {
                return;
            }

            bool connectionStringSpecified = !string.IsNullOrEmpty(installOptionsToUse.MongoHost) && !string.IsNullOrEmpty(installOptionsToUse.MongoDatabase);

            if (string.IsNullOrEmpty(installOptionsToUse.MongoHost))
            {
                installOptionsToUse.MongoHost = this.ReadInput("MongoDB Host", "LOCALHOST");
            }

            if (!installOptionsToUse.MongoPort.HasValue)
            {
                installOptionsToUse.MongoPort = Convert.ToInt32(this.ReadInput("MongoDB Port ", "27017"));
            }

            if (string.IsNullOrEmpty(installOptionsToUse.MongoDatabase))
            {
                installOptionsToUse.MongoDatabase = this.ReadInput("MongoDB Database Name");
            }

            if (!connectionStringSpecified && string.IsNullOrEmpty(installOptionsToUse.MongoUsername))
            {
                installOptionsToUse.MongoUsername = this.ReadInput("MongoDB Username (blank for none)");
            }

            if (!string.IsNullOrEmpty(installOptionsToUse.MongoUsername) && string.IsNullOrEmpty(installOptionsToUse.MongoPassword))
            {
                installOptionsToUse.MongoPassword = this.ReadPassword("MongoDB Password");
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScheduledTaskManager"/> class.
 /// </summary>
 /// <param name="options">The install options.</param>
 /// <param name="variables">A cache of install variables.</param>
 /// <param name="installLogger">Logs installation results.</param>
 public ScheduledTaskManager(InstallOptions options, InstallVariables variables, InstallLogger installLogger)
 {
     this.installOptions = options;
     this.installVariables = variables;
     this.installLogger = installLogger;
 }
示例#35
0
        /// <summary>
        /// Displays the subsite menu.
        /// </summary>
        /// <param name="installOptionsToUse">The install options to use.</param>
        private void DisplaySubsiteMenu(InstallOptions installOptionsToUse)
        {
            Menu rootSiteSelection = new Menu();
            var iisManager = new ServerManager();
            SiteCollection sites = iisManager.Sites;

            for (int i = 0; i < sites.Count; i++)
            {
                int iVal = i;
                var site = sites[iVal];
                var firstBinding = site.Bindings.FirstOrDefault();
                var hostname = firstBinding != null
                    ? (!string.IsNullOrEmpty(firstBinding.Host) ? firstBinding.Host : Strings.DefaultBinding)
                    : Strings.DefaultBinding;

                rootSiteSelection.AddMenuItem(
                    Convert.ToString(iVal + 1),
                    string.Format("{0} ({1})", site.Name, hostname),
                    (Action)delegate { installOptionsToUse.RootSite = sites[iVal]; },
                    new object[] { });
            }

            rootSiteSelection.DisplayMenu(true);
        }
示例#36
0
        /// <summary>
        /// Run the installation / uninstallation process.
        /// </summary>
        /// <param name="options">The install options.</param>
        private void Run(InstallOptions options)
        {
            int exitCode = 0;
            this.installOptions = options;

            try
            {
                if (string.IsNullOrEmpty(this.installOptions.LogFileRelative))
                {
                    this.installOptions.LogFileAbsolute = this.installOptions.Mode + ".log";
                }

                installLogger.SetLogFile(options.LogFileAbsolute);
                if (!this.IsUserAdministrator())
                {
                    throw new UnauthorizedAccessException(Messages.MAIN_AdminRequired);
                }

                this.installVariables.BasePath = this.FindBasePath();
                this.CheckParameters(options);

                this.webManager = new WebManager(this.installOptions, this.installVariables, installLogger);
                this.taskManager = new ScheduledTaskManager(this.installOptions, this.installVariables, installLogger);

                if (options.Mode != InstallerMode.Uninstall)
                {
                    IMongoConfiguration mongoConfiguration = new MongoConfiguration
                                                             {
                        Host = this.installOptions.MongoHost,
                        Port = this.installOptions.MongoPort.Value,
                        Database = this.installOptions.MongoDatabase,
                        Username = this.installOptions.MongoUsername,
                        Password = this.installOptions.MongoPassword
                    };

                    var websiteName = this.installOptions.WebsiteName;

                    if (this.installOptions.RootSite != null)
                    {
                        websiteName = string.Format("{0}/{1}", this.installOptions.HostName, this.installOptions.WebsiteName);
                    }

                    DatabaseInitialiserOptions dbInitOptions = new DatabaseInitialiserOptions
                    {
                        WebsiteName = websiteName,
                        OrgName = this.installOptions.OrgName,
                        AdminEmail = this.installOptions.AdminEmail,
                        AdminPassword = this.installOptions.AdminPassword
                    };

                    this.dbManager = new DatabaseInitialiser(mongoConfiguration, dbInitOptions, this.installVariables, installLogger)
                                     {
                                         ReadInput = this.ReadInput,
                                         ReadPassword = this.ReadInput
                                     };
                }

                if (options.Mode == InstallerMode.Install)
                {
                    this.RunInstall(options.Type);
                }

                if (options.Mode == InstallerMode.Repair)
                {
                    this.dbManager.Run();
                }

                if (options.Mode != InstallerMode.Uninstall)
                {
                    if (options.Api && !string.IsNullOrEmpty(this.installOptions.IapplyWebsiteName))
                    {
                        this.installOptions.WebsiteName = this.installOptions.IapplyWebsiteName;
                    }

                    ConfigurationUpdater updater = new ConfigurationUpdater(this.installOptions, this.installVariables);
                    updater.UpdateXmlConfig(options.Type);
                    updater.UpdateJsConfig(options.Type);
                    updater.WriteDbConfig();

                    if (options.Mode != InstallerMode.Repair)
                    {
                        updater.GenerateNewCryptoKeys();
                    }

                    installLogger.LogLine(Messages.MAIN_InstallationComplete);
                }

                if (options.Mode == InstallerMode.Uninstall)
                {
                    this.RunUninstall(options.Type);
                }
            }
            catch (Exception e)
            {
                installLogger.LogError(e);
                exitCode = 1;
            }

            if (!this.installOptions.Quiet)
            {
                Console.Write(Environment.NewLine + Strings.PressAnyKey);
                Console.ReadKey();
            }

            Environment.Exit(exitCode);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationUpdater"/> class.
 /// </summary>
 /// <param name="installOptions">The install options.</param>
 /// <param name="installVariables">A cache of install variables.</param>
 public ConfigurationUpdater(InstallOptions installOptions, InstallVariables installVariables)
 {
     this.installOptions = installOptions;
     this.installVariables = installVariables;
 }