GetResinHome() public static method

public static GetResinHome ( String resinHome, String path ) : String
resinHome String
path String
return String
Esempio n. 1
0
        private int Execute()
        {
            _resinHome = Util.GetResinHome(_resinHome, System.Reflection.Assembly.GetExecutingAssembly().Location);

            if (_resinHome == null)
            {
                Error("Can't find RESIN_HOME", null);

                return(1);
            }

            if (_rootDirectory == null)
            {
                _rootDirectory = _resinHome;
            }

            _javaHome = GetJavaHome(_resinHome, _javaHome);


            if (_javaExe == null && _javaHome != null)
            {
                _javaExe = GetJavaExe(_javaHome);
            }

            if (_javaExe == null)
            {
                _javaExe = "java.exe";
            }

            System.Environment.SetEnvironmentVariable("JAVA_HOME", _javaHome);

            Environment.SetEnvironmentVariable("PATH",
                                               String.Format("{0};{1};\\openssl\\bin;.",
                                                             _javaHome + "\\bin",
                                                             Environment.GetEnvironmentVariable("PATH")));

            if (ResinArgs.IsService)
            {
                ServiceBase.Run(new ServiceBase[] { this });

                return(0);
            }
            else
            {
                if (StartResin())
                {
                    Join();
                    if (_process != null)
                    {
                        int exitCode = _process.ExitCode;
                        _process.Dispose();
                        return(exitCode);
                    }
                }

                return(0);
            }
        }
Esempio n. 2
0
        public Setup()
        {
            String path = System.Reflection.Assembly.GetExecutingAssembly().Location;

            this.ResinHome = Util.GetResinHome(null, path);

            this._apacheHomeSet = new DirSet();

            FindResinServices();
            FindResin();

            Apache.FindApache(_apacheHomeSet);
        }
Esempio n. 3
0
        public void FindResin()
        {
            DriveInfo[] drives = DriveInfo.GetDrives();
            foreach (DriveInfo drive in drives)
            {
                if (DriveType.Fixed != drive.DriveType && DriveType.Ram != drive.DriveType)
                {
                    continue;
                }
                DirectoryInfo   root        = drive.RootDirectory;
                DirectoryInfo[] directories = root.GetDirectories();
                foreach (DirectoryInfo directory in directories)
                {
                    if (directory.Name.StartsWith("resin", StringComparison.CurrentCultureIgnoreCase) &&
                        Util.IsResinHome(directory.FullName))
                    {
                        Resin resin = new Resin(Util.Canonicalize(directory.FullName));
                        if (!HasResin(resin))
                        {
                            AddResin(resin);
                        }
                    }
                    else if (directory.Name.Contains("appservers"))
                    {
                        DirectoryInfo[] appserverDirectories = directory.GetDirectories();
                        foreach (DirectoryInfo appserverDir in appserverDirectories)
                        {
                            if (Util.IsResinHome(appserverDir.FullName))
                            {
                                String home  = Util.Canonicalize(appserverDir.FullName);
                                Resin  resin = new Resin(home);
                                if (!HasResin(resin))
                                {
                                    AddResin(resin);
                                }
                            }
                        }
                    }
                }
            }

            String currentResin    = Util.GetCurrentResinFromRegistry();
            Resin  resinInRegistry = null;

            if (currentResin != null)
            {
                currentResin    = Util.Canonicalize(currentResin);
                resinInRegistry = new Resin(currentResin);

                if (!HasResin(resinInRegistry))
                {
                    AddResin(resinInRegistry);
                }
            }

            RegistryKey services = Registry.LocalMachine.OpenSubKey(Setup.REG_SERVICES);

            foreach (String name in services.GetSubKeyNames())
            {
                RegistryKey key = services.OpenSubKey(name);
                try
                {
                    Object imagePathObj = key.GetValue("ImagePath");
                    if (imagePathObj == null && !"".Equals(imagePathObj))
                    {
                        continue;
                    }

                    String imagePath          = (String)imagePathObj;
                    String lowerCaseImagePath = imagePath.ToLower();

                    if (imagePath.IndexOf("resin.exe") != -1)
                    {
                        ResinArgs resinArgs = new ResinArgs(imagePath);
                        Resin     resin     = null;
                        if (resinArgs.ResinHome != null)
                        {
                            resin = new Resin(resinArgs.ResinHome);
                        }
                        else if (resinArgs.Exe != null)
                        {
                            String exe  = resinArgs.Exe;
                            String home = exe.Substring(0, exe.Length - 10);
                            if (Util.IsResinHome(home))
                            {
                                resin = new Resin(home);
                            }
                        }

                        if (resin != null && !HasResin(resin))
                        {
                            AddResin(resin);
                        }
                    }
                }
                catch (Exception e)
                {
                    LogStartupError(e.Message, e);
                }
                finally
                {
                    key.Close();
                }
            }

            services.Close();

            String resinHome = Util.GetResinHome(null, System.Reflection.Assembly.GetExecutingAssembly().Location);

            foreach (Resin resin in _resinList)
            {
                if (resin.Home.Equals(resinHome))
                {
                    Resin = resin;

                    return;
                }
            }

            if (Resin == null && resinInRegistry != null)
            {
                Resin = resinInRegistry;
            }

            if (Resin == null && resinHome != null)
            {
                Resin = new Resin(resinHome);

                AddResin(Resin);
            }

            if (Resin == null && _resinList.Count > 0)
            {
                Resin = _resinList[_resinList.Count - 1];
            }
        }