Example #1
0
        static public CLIManager CreateManager(CLIContext context)
        {
            var manager = new CLIManager(context);

            if (context.Settings.IsMockSystemCtl)
            {
                var mockSystemCtl = new MockSystemCtlHelper(context);
                manager.PostInstall.ArduinoPlugAndPlay.Verifier.SystemCtl = mockSystemCtl;
                manager.PostInstall.Docker.Verifier.SystemCtl             = mockSystemCtl;

                manager.PostInstall.Supervisor.Verifier.SystemCtl = mockSystemCtl;
                manager.PostInstall.WWW.Verifier.SystemCtl        = mockSystemCtl;
                manager.PostInstall.Mqtt.SystemCtl     = mockSystemCtl;
                manager.PostInstall.Verifier.SystemCtl = mockSystemCtl;
                manager.PostInstall.Verifier.ArduinoPlugAndPlay.SystemCtl = mockSystemCtl;
                manager.PostInstall.Verifier.Docker.SystemCtl             = mockSystemCtl;
                manager.PostInstall.Verifier.Supervisor.SystemCtl         = mockSystemCtl;
                manager.PostInstall.Verifier.WWW.SystemCtl = mockSystemCtl;
            }

            if (context.Settings.IsMockDocker)
            {
                var mockDocker = new MockDockerHelper(context);
                manager.PostInstall.Mqtt.Docker               = mockDocker;
                manager.PostInstall.Mqtt.Verifier.Docker      = mockDocker;
                manager.PostInstall.Verifier.Mosquitto.Docker = mockDocker;
            }

            return(manager);
        }
Example #2
0
        public CLIManager(CLIContext context)
        {
            Console.WriteLine("  Working directory: " + context.IndexDirectory);

            Context = context;
            Starter = new ProcessStarter();
            Starter.WorkingDirectory = Context.IndexDirectory;

            PostInstall = new Installers.PostInstaller(context);

            Devices = new DeviceManager(context);

            MqttBridge = new MqttBridgeStarter(context);

            Verifier = new Verifier(context);
        }
Example #3
0
 public PostInstaller(CLIContext context)
 {
     Context = context;
     Prepare = new Installers.PostInstaller(context);
 }
Example #4
0
 public PathHelper(CLIContext context)
 {
   Context = context;
 }
Example #5
0
 public DockerHelper(CLIContext context)
 {
     Context = context;
     Starter = new ProcessStarter(context.IndexDirectory);
 }
Example #6
0
        public static void Main(string[] args)
        {
            Console.WriteLine("===== GrowSense CLI Console =====");

            var arguments = new Arguments(args);

            var workingDirectory = Path.GetFullPath("/");

            if (arguments.Contains("dir"))
            {
                workingDirectory = Path.GetFullPath(arguments["dir"]);
            }

            var settings = GetSettings(workingDirectory, arguments);

            var context = new CLIContext(workingDirectory, settings);

            var manager = CreateManager(context);

            try
            {
                if (arguments.KeylessArguments.Length > 0)
                {
                    var command = arguments.KeylessArguments[0];

                    Console.WriteLine("  Command: " + command);

                    switch (command)
                    {
                    case "post-install":
                        //Console.WriteLine("Post install");
                        manager.PostInstallActions();
                        break;

                    case "stop":
                        //Console.WriteLine("Stop");
                        manager.Stop();
                        break;

                    case "start":
                        //Console.WriteLine("Stop");
                        manager.Start();
                        break;

                    case "verify":
                        //Console.WriteLine("Verify");
                        manager.Verify();
                        break;

                    case "config":
                        //Console.WriteLine("Config");
                        var verify = true;
                        if (arguments.Contains("verify"))
                        {
                            verify = Convert.ToBoolean(arguments["verify"]);
                        }
                        manager.ApplySettings(verify);
                        break;

                    case "add-device":
                        var port = arguments["port"];
                        manager.AddDevice(port);
                        break;

                    case "start-mqtt-bridge":
                        var deviceName = arguments["name"];
                        manager.StartMqttBridge(deviceName);
                        break;

                    default:
                        Console.WriteLine("Unknown command: " + command);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Environment.Exit(1);
            }
        }
Example #7
0
 public DeviceManager(CLIContext context)
 {
     Context = context;
     Starter = new ProcessStarter(context.IndexDirectory);
 }