Exemple #1
0
        public static void Stop()
        {
            var conf        = Application.CurrentConfiguration.Network.WpaSupplicant;
            var serviceName = CommonString.Append("wpa_supplicant@", conf.Interface, ".service");

            Systemctl.Stop(serviceName);
        }
Exemple #2
0
        public static void Set()
        {
            var options = Application.CurrentConfiguration.Cluster.SharedFs;

            if (options == null)
            {
                return;
            }
            Systemctl.Enable(serviceName);
            Systemctl.Start(serviceName);
            var nodes = Application.CurrentConfiguration.Cluster.Nodes;

            for (var i = 0; i < nodes.Length; i++)
            {
                IncludeNode(nodes[i].Hostname);
            }

            for (var i = 0; i < options.VolumesLabels.Length; i++)
            {
                var currentLabel = options.VolumesLabels[i];
                //creo e avvio il volume di Gluster sui vari nodi in cui è configurato
                StartVolume(currentLabel, nodes);
            }
            ConsoleLogger.Log("[gluster] start");
        }
Exemple #3
0
 public static void Start()
 {
     if (Systemctl.IsEnabled(ServiceName1) == false)
     {
         Systemctl.Enable(ServiceName1);
     }
     if (Systemctl.IsActive(ServiceName1) == false)
     {
         Systemctl.Restart(ServiceName1);
     }
     if (Systemctl.IsEnabled(ServiceName2) == false)
     {
         Systemctl.Enable(ServiceName2);
     }
     if (Systemctl.IsActive(ServiceName2) == false)
     {
         Systemctl.Restart(ServiceName2);
     }
     if (Systemctl.IsEnabled(ServiceName3) == false)
     {
         Systemctl.Enable(ServiceName3);
     }
     if (Systemctl.IsActive(ServiceName3) == false)
     {
         Systemctl.Restart(ServiceName3);
     }
     ConsoleLogger.Log("[samba] start");
 }
Exemple #4
0
 public static void Stop()
 {
     Systemctl.Stop(ServiceName1);
     Systemctl.Stop(ServiceName2);
     Systemctl.Stop(ServiceName3);
     ConsoleLogger.Log("[samba] stop");
 }
Exemple #5
0
        private static void SaveKeepalived(ClusterNetwork networkConfig, ClusterNode[] nodesConfig)
        {
            if (networkConfig == null)
            {
                ConsoleLogger.Log("[cluster] keepalived not configured: missing network parameters");
                return;
            }
            if (!networkConfig.Active)
            {
                ConsoleLogger.Log("[cluster] shared network is disabled");
                return;
            }
            var ports = networkConfig.PortMapping;

            if (!ports.Any())
            {
                ConsoleLogger.Log("[cluster] exit: !ports.Any()");
                return;
            }

            ConsoleLogger.Log("[cluster] init keepalived");
            const string keepalivedService = "keepalived.service";

            if (Systemctl.IsActive(keepalivedService))
            {
                ConsoleLogger.Log("[cluster] stop service");
                Systemctl.Stop(keepalivedService);
            }
            ConsoleLogger.Log("[cluster] set configuration file");
            var lines = new string[] {
                "vrrp_script chk_haproxy {",
                "    script \"killall -0 haproxy\"",
                "    interval 30",
                "    weight 2",
                "}",
                "",
                "vrrp_instance RH_INT {",
                $"    interface {networkConfig.NetworkInterface}",
                "    state MASTER",
                "    virtual_router_id 51",
                $"    priority 100",
                "    virtual_ipaddress {",
                $"        {networkConfig.VirtualIpAddress}",
                "    }",
                "    track_script {",
                "        chk_haproxy",
                "    }",
                "}",
            };

            File.WriteAllLines(keepalivedFileOutput, lines);
            Keepalived.Stop();
            Keepalived.Start(keepalivedFileOutput);
        }
Exemple #6
0
 public static void Start()
 {
     if (Systemctl.IsEnabled(ServiceName) == false)
     {
         Systemctl.Enable(ServiceName);
     }
     if (Systemctl.IsActive(ServiceName) == false)
     {
         Systemctl.Restart(ServiceName);
     }
     ConsoleLogger.Log("[nginx] start");
 }
Exemple #7
0
        public static bool Set()
        {
            var currentConfig          = Application.CurrentConfiguration.Network.InternalNetwork;
            var parsedNetworkParameter = LukeSkywalker.IPNetwork.IPNetwork.Parse(currentConfig.IpAddress, currentConfig.NetworkRange);
            var network = parsedNetworkParameter.Network.ToString();
            var mask    = parsedNetworkParameter.Netmask.ToString();
            var lines   = new string[] {
                "interface ignore wildcard",
                $"interface listen {currentConfig.IpAddress}",
                $"restrict {network} mask {mask} nomodify",
                "",
                "server 0.it.pool.ntp.org",
                "server 1.it.pool.ntp.org",
                "server 2.it.pool.ntp.org",
                "server 3.it.pool.ntp.org",
                "server 193.204.114.232",
                "server 193.204.114.233",
                "server ntp1.ien.it",
                "server ntp2.ien.it",
                "",
                "statistics loopstats",
                "driftfile /var/lib/ntp/ntp.drift",
                "logfile /var/log/ntp/ntpd.log",
                "statsdir /var/log/ntp/",
                "filegen peerstats file peers type day link enable",
                "filegen loopstats file loops type day link enable"
            };

            File.WriteAllLines(ntpConfFileTmp, lines);
            if (File.Exists(ntpConfFile))
            {
                var existingFileHash = CommonFile.GetHash(ntpConfFile);
                var newFileHash      = CommonFile.GetHash(ntpConfFileTmp);
                if (CommonString.AreEquals(existingFileHash, newFileHash) == true)
                {
                    return(true);
                }
                else
                {
                    File.Copy(ntpConfFileTmp, ntpConfFile, true);
                }
            }
            else
            {
                File.WriteAllLines(ntpConfFile, lines);
            }
            if (File.Exists(ntpConfFileTmp))
            {
                File.Delete(ntpConfFileTmp);
            }
            Systemctl.Start(ntpdService);
            return(true);
        }
Exemple #8
0
 public static void Start()
 {
     if (Systemctl.IsEnabled(serviceName) == false)
     {
         Systemctl.Enable(serviceName);
     }
     if (Systemctl.IsActive(serviceName) == false)
     {
         Systemctl.Restart(serviceName);
     }
     ConsoleLogger.Log("[syslogng] start service");
 }
Exemple #9
0
 public static void Setup()
 {
     if (IsTargetActive())
     {
         return;
     }
     ConsoleLogger.Log($"[{applicativeTarget}] setup");
     if (!Directory.Exists("/usr/lib64/systemd/system/"))
     {
         return;
     }
     Directory.CreateDirectory("/etc/systemd/system/");
     Directory.CreateDirectory("/etc/systemd/system/applicative.target.wants");
     Directory.CreateDirectory("/mnt/cdrom/Units/applicative.target.wants");
     WriteTimerTargetFile();
     WriteTimerServiceFile();
     WriteTimerMountFile();
     Bash.Execute("ln -s ../../../../usr/lib64/systemd/system/applicative.service applicative.service", "/etc/systemd/system/multi-user.target.wants", false);
     Systemctl.Start(applicativeService);
     Systemctl.Start(applicativeTarget);
     Systemctl.DaemonReload();
 }
Exemple #10
0
 public static void Stop()
 {
     Systemctl.Stop(serviceName);
     ConsoleLogger.Log("[gluster] stop");
 }
Exemple #11
0
 public static void Stop()
 {
     Systemctl.Stop(ServiceName);
     ConsoleLogger.Log("[nginx] stop");
 }
Exemple #12
0
 public static void Prepare()
 {
     Systemctl.Enable(ntpdService);
 }
Exemple #13
0
 public static void Start()
 {
     Systemctl.Start(ntpdService);
 }
Exemple #14
0
 public static void Start()
 {
     Systemctl.Start(applicativeTarget);
 }
Exemple #15
0
        public static bool Set()
        {
            var current = Application.CurrentConfiguration.Services.Sshd;

            if (!current.Active)
            {
                return(true);
            }
            var lines = new string[] {
                $"Port {current.Port}",
                $"PermitRootLogin {current.PermitRootLogin}",
                $"PermitTunnel {current.PermitTunnel}",
                $"MaxAuthTries {current.MaxAuthTries}",
                $"MaxSessions {current.MaxSessions}",
                $"RsaAuthentication {current.RsaAuthentication}",
                $"PubkeyAuthentication {current.PubkeyAuthentication}",
                $"UsePam {current.UsePam}",
                "#AddressFamily any",
                "#ListenAddress 0.0.0.0",
                "#ListenAddress ::",
                "#Protocol 2",
                "#HostKey /etc/ssh/ssh_host_key",
                "#HostKey /etc/ssh/ssh_host_rsa_key",
                "#HostKey /etc/ssh/ssh_host_dsa_key",
                "#HostKey /etc/ssh/ssh_host_ecdsa_key",
                "#HostKey /etc/ssh/ssh_host_ed25519_key",
                "#KeyRegenerationInterval 1h",
                "#ServerKeyBits 1024",
                "#RekeyLimit default none",
                "#SyslogFacility AUTH",
                "#LogLevel INFO",
                "#LoginGraceTime 2m",
                "#StrictModes yes",
                "#AuthorizedKeysFile .ssh/authorized_keys",
                "#AuthorizedPrincipalsFile none",
                "#AuthorizedKeysCommand none",
                "#AuthorizedKeysCommandUser nobody",
                "#RhostsRSAAuthentication no",
                "#HostbasedAuthentication no",
                "#IgnoreUserKnownHosts no",
                "#IgnoreRhosts yes",
                "PasswordAuthentication no",
                "#PermitEmptyPasswords no",
                "#ChallengeResponseAuthentication yes",
                "#KerberosAuthentication no",
                "#KerberosOrLocalPasswd yes",
                "#KerberosTicketCleanup yes",
                "#KerberosGetAFSToken no",
                "#GSSAPIAuthentication no",
                "#GSSAPICleanupCredentials yes",
                "#AllowAgentForwarding yes",
                "#AllowTcpForwarding yes",
                "#GatewayPorts no",
                "#X11Forwarding no",
                "#X11DisplayOffset 10",
                "#X11UseLocalhost yes",
                "#PermitTTY yes",
                "PrintMotd no",
                "PrintLastLog no",
                "#TCPKeepAlive yes",
                "#UseLogin no",
                "#UsePrivilegeSeparation sandbox",
                "#PermitUserEnvironment no",
                "#Compression delayed",
                "#ClientAliveInterval 0",
                "#ClientAliveCountMax 3",
                "#UseDNS no",
                "#PidFile /run/sshd.pid",
                "#MaxStartups 10:30:100",
                "#PermitTunnel no",
                "#ChrootDirectory none",
                "#VersionAddendum none",
                "#Banner none",
                "#UseLPK yes",
                "#LpkLdapConf /etc/ldap.conf",
                "#LpkServers ldap://10.1.7.1/ ldap://10.1.7.2/",
                "#LpkUserDN ou=users,dc=phear,dc=org",
                "#LpkGroupDN ou=groups,dc=phear,dc=org",
                "#LpkBindDN cn=Manager,dc=phear,dc=org",
                "#LpkBindPw secret",
                "#LpkServerGroup mail",
                "#LpkFilter (hostAccess=master.phear.org)",
                "#LpkForceTLS no",
                "#LpkSearchTimelimit 3",
                "#LpkBindTimelimit 3",
                "#LpkPubKeyAttr sshPublicKey",
                "Subsystem sftp /usr/lib64/misc/sftp",
                "AcceptEnv LANG LC_*",
            };

            File.WriteAllLines(sshdEtcFile, lines);
            Systemctl.Restart(sshdService);
            return(true);
        }