Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var conf = "conf/ffcm_c.properties";

            if (args.Length > 0)
            {
                conf = args[0];
            }
            var cfg = new FCfg();

            cfg.Load(conf, true);
            cfg.Print();
            var addr = cfg.Val("srv_addr", "");

            if (addr.Length < 1)
            {
                Console.WriteLine("the srv_addr is not setted");
                Environment.Exit(1);
                return;
            }
            L.I("starting ffcm...");

            //Samba.
            var lambah = new LambdaEvnH();
            var ffcm   = new DocCov("FFCM", cfg, new SckDailer(addr).Dail, lambah);
            var ffcmh  = new FFCM(ffcm, ffcm.Srv);

            ffcm.InitConfig();
            ffcm.StartMonitor();
            ffcm.StartWindowCloser();
            ffcm.Start();
            ffcm.StartProcSrv();
            var activated = false;

            if (cfg.Val("samba", "N") == "Y")
            {
                L.I("start initial samba...");
                var samba = Samba.AddVolume2(cfg.Val("samba_vol", ""), cfg.Val("samba_uri", ""),
                                             cfg.Val("samba_user", ""), cfg.Val("samba_pwd", ""),
                                             cfg.Val("samba_paths", ""));
                samba.Fail = (s, e) =>
                {
                    ffcm.ChangeStatus(DTM_C.DCS_UNACTIVATED);
                    activated = false;
                };
                samba.Success = (s) =>
                {
                    if (!activated)
                    {
                        ffcm.ChangeStatus(DTM_C.DCS_ACTIVATED);
                        activated = true;
                    }
                };
                new Thread(run_samba).Start();
            }
            else
            {
                activated = true;
            }
            lambah.OnLogin = (nr, token) =>
            {
                if (activated)
                {
                    ffcm.ChangeStatus(DTM_C.DCS_ACTIVATED);
                }
            };
            lambah.EndCon = (nr) =>
            {
                ffcm.ChangeStatus(DTM_C.DCS_UNACTIVATED);
            };
            var reboot = cfg.Val("reboot", "");

            if (reboot.Length > 0)
            {
                ProcKiller.Shared.OnHavingNotKill = (c) =>
                {
                    string output;
                    Exec.exec(out output, reboot);
                };
            }
            new Thread(run_hb).Start(ffcm);
            ffcm.Wait();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var conf = "conf/ffcm_c.properties";
            if (args.Length > 0)
            {
                conf = args[0];
            }
            var cfg = new FCfg();
            cfg.Load(conf, true);
            cfg.Print();
            var addr = cfg.Val("srv_addr", "");
            if (addr.Length < 1)
            {
                Console.WriteLine("the srv_addr is not setted");
                Environment.Exit(1);
                return;
            }
            L.I("starting ffcm...");

            //Samba.
            var lambah = new LambdaEvnH();
            var ffcm = new DocCov("FFCM", cfg, new SckDailer(addr).Dail, lambah);
            var ffcmh = new FFCM(ffcm, ffcm.Srv);
            ffcm.InitConfig();
            ffcm.StartMonitor();
            ffcm.StartWindowCloser();
            ffcm.Start();
            ffcm.StartProcSrv();
            var activated = false;
            if (cfg.Val("samba", "N") == "Y")
            {
                L.I("start initial samba...");
                var samba = Samba.AddVolume2(cfg.Val("samba_vol", ""), cfg.Val("samba_uri", ""),
                    cfg.Val("samba_user", ""), cfg.Val("samba_pwd", ""),
                    cfg.Val("samba_paths", ""));
                samba.Fail = (s, e) =>
                {
                    ffcm.ChangeStatus(DTM_C.DCS_UNACTIVATED);
                    activated = false;
                };
                samba.Success = (s) =>
                {
                    if (!activated)
                    {
                        ffcm.ChangeStatus(DTM_C.DCS_ACTIVATED);
                        activated = true;
                    }
                };
                new Thread(run_samba).Start();
            }
            else
            {
                activated = true;
            }
            lambah.OnLogin = (nr, token) =>
            {
                if (activated)
                {
                    ffcm.ChangeStatus(DTM_C.DCS_ACTIVATED);
                }
            };
            lambah.EndCon = (nr) =>
            {
                ffcm.ChangeStatus(DTM_C.DCS_UNACTIVATED);
            };
            var reboot = cfg.Val("reboot", "");
            if (reboot.Length > 0)
            {
                ProcKiller.Shared.OnHavingNotKill = (c) =>
                {
                    string output;
                    Exec.exec(out output, reboot);
                };
            }
            new Thread(run_hb).Start(ffcm);
            ffcm.Wait();
        }