Beispiel #1
0
        public PostgresBinaryLocator(string searchPatternOverride)
        {
            if (string.IsNullOrEmpty(searchPatternOverride))
            {
                switch (RecognizedOSPlatform.Determine())
                {
                case RecognizedOSPlatformEnum.Linux:
                    _searchPattern = DefaultLinuxSearchPattern;
                    break;

                case RecognizedOSPlatformEnum.OSX:
                    throw new UnsupportedPlatformException("Cannot locate Postgres binaries when running on OSX platform. OSX platform is not supported.");

                case RecognizedOSPlatformEnum.Windows:
                    _searchPattern = DefaultWindowsSearchPattern;
                    break;

                default:
#if NETSTANDARD2_0
                    throw new PostgresBinariesNotFoundException($"Unknow OS:{RuntimeInformation.OSDescription}");
#endif
                    throw new PostgresBinariesNotFoundException("Unknow OS. This library is only compatible with Microsoft Windows");
                }
            }
            else
            {
                _searchPattern = searchPatternOverride;
            }
        }
Beispiel #2
0
        public static IPortWatcher CreatePortWatcher()
        {
            switch (RecognizedOSPlatform.Determine())
            {
            case RecognizedOSPlatformEnum.Linux:
                return((IPortWatcher) new UnixPortWatcher());

            case RecognizedOSPlatformEnum.OSX:
                throw new UnsupportedPlatformException($"Cannot create {nameof(IPortWatcher)} when running on OSX platform. OSX platform is not supported.");

            case RecognizedOSPlatformEnum.Windows:
            default:
                return((IPortWatcher) new WindowsPortWatcher());
            }
        }
Beispiel #3
0
        internal static void Start(string pgBinDirectoryPath)
        {
            switch (RecognizedOSPlatform.Determine())
            {
            case RecognizedOSPlatformEnum.Linux:
                new PostgresLinuxSetup().Start(pgBinDirectoryPath);
                break;

            case RecognizedOSPlatformEnum.OSX:
                throw new UnsupportedPlatformException($"Cannot grant executable right to Postgres binaries when running on OSX platform. OSX platform is not supported.");

            case RecognizedOSPlatformEnum.Windows:
            default:
                break;
            }
        }
        internal static void AssertCanExecute(string pgBinDirectoryPath)
        {
            switch (RecognizedOSPlatform.Determine())
            {
            case RecognizedOSPlatformEnum.Linux:
                FileSystem.FileSystem.GrantExecutablePermission(Path.Combine(pgBinDirectoryPath, PostgresDefaults.ServerControllerExecutable));
                FileSystem.FileSystem.GrantExecutablePermission(Path.Combine(pgBinDirectoryPath, PostgresDefaults.ServerExecutable));
                FileSystem.FileSystem.GrantExecutablePermission(Path.Combine(pgBinDirectoryPath, PostgresDefaults.ServerInitializatorExecutable));
                break;

            case RecognizedOSPlatformEnum.OSX:
                throw new UnsupportedPlatformException($"Cannot grant executable right to Postgres binaries when running on OSX platform. OSX platform is not supported.");

            case RecognizedOSPlatformEnum.Windows:
            default:
                break;
            }
        }