Exemple #1
0
        /// <summary>
        /// Prepare and initiate install of Redis to Azure
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            if (!IsElevated)
            {
                Console.WriteLine("RedisInstWA must be run as an Administrator");
                Environment.Exit(1);
            }
            if (args == null || args.Count() == 0)
            {
                Console.WriteLine("No parameters were provided\r\n");
                Usage();
                Environment.Exit(1);
            }
            else
            {
                if (!ValidateArgs(args))
                {
                    Console.WriteLine("Usage:");
                    Usage();
                    Environment.Exit(1);
                }
                // create work directory for copying files
                string curpath = Directory.GetCurrentDirectory();
                WorkPath = Path.Combine(curpath, WorkDir);
                if (!FolderHelper.MakeFolder(WorkPath))
                {
                    Console.WriteLine("Failed to make folder for staging the installation");
                    Environment.Exit(2);
                }



                RedisInstExePath = Assembly.GetExecutingAssembly().Location;
                RedisInstExePath = Path.GetDirectoryName(RedisInstExePath);
                // Download and extract exe from zip file or copy local exe
                if (!PrepareBinaries(WorkPath))
                {
                    Console.WriteLine("Failed to copy redis executable files to staging directory");
                    Environment.Exit(2);
                }

                // Parse the ServiceDefinition to extract roles and ports
                if (!ParseConfiguration())
                {
                    Console.WriteLine("Failed to parse the ServiceDefinition file");
                    Environment.Exit(3);
                }

                // Prepare instances and xml file for Inst4WA
                if (!PrepareInstaller())
                {
                    Console.WriteLine("Failed to create the XML Configuration file for the installer");
                    Environment.Exit(4);
                }

                // run Inst4WA to do install
                if (!RunInstaller())
                {
                    Console.WriteLine("Failed to execute Inst4WA process to install Redis");
                    Environment.Exit(5);
                }
            }
            Environment.Exit(0);
        }
Exemple #2
0
        public int DownloadAndExtract(string zipurl, string workPath, string binfolder, bool isX64)
        {
            string zippath = Path.Combine(workPath, "zipfile");

            if (!FolderHelper.MakeFolderReset(zippath))
            {
                return(5);
            }

            try
            {
                string zipfile = Path.Combine(zippath, "redis.zip");
                Download(zipurl, zipfile);
                IEnumerable <string> subfiles = Directory.EnumerateFiles(zippath);
                if (!File.Exists(zipfile))
                {
                    // download did nothing
                    Console.WriteLine("Downloading zip file failed");
                    return(1);
                }

                // unzip the downloaded file
                ExtractFilesFromZip(zipfile, zippath);

                string binzip      = isX64 ? "redisbin64.zip" : "redisbin.zip";
                string embeddedzip = FindBinZip(zippath, binzip);
                if (embeddedzip == null)
                {
                    // binaries zip not found
                    Console.WriteLine("Did not find {0} in downloaded zip file", binzip);
                    return(2);
                }
                string binpath = Path.Combine(workPath, binfolder);
                if (!FolderHelper.MakeFolderReset(binpath))
                {
                    return(5);
                }

                ExtractFilesFromZip(embeddedzip, binpath);

                IEnumerable <string> exefiles = Directory.EnumerateFiles(binpath, "redis-server.exe", SearchOption.AllDirectories);
                if (exefiles == null || exefiles.Count() == 0)
                {
                    // executable not found
                    Console.WriteLine("Extracting redis-server from zip failed");
                    return(3);
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    Console.WriteLine(ex.InnerException.Message);
                }
                else
                {
                    Console.WriteLine(ex.Message);
                }
                return(4);
            }

            return(0);
        }