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"); }
public void Setup() { if (Systemctl.IsEnabled("systemd-networkd.service") == false) { Systemctl.Enable("systemd-networkd.service"); } if (Systemctl.IsActive("systemd-networkd.service") == false) { Systemctl.Start("systemd-networkd.service"); } if (Systemctl.IsEnabled("systemd-resolved.service") == false) { Systemctl.Enable("systemd-resolved.service"); } if (Systemctl.IsActive("systemd-resolved.service") == false) { Systemctl.Start("systemd-resolved.service"); } _bash.Execute("ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf", false); if (!Directory.Exists(NetworkdFolder)) { Directory.CreateDirectory(NetworkdFolder); } }
public void Start() { if (Systemctl.IsEnabled(ServiceName) == false) { Systemctl.Enable(ServiceName); } if (Systemctl.IsActive(ServiceName) == false) { Systemctl.Restart(ServiceName); } ConsoleLogger.Log("[kerberos] start"); }
public void StopService() { var svcs = HostParametersConfiguration.Conf.ServicesStop; foreach (var svc in svcs) { if (Systemctl.IsEnabled(svc)) { Systemctl.Disable(svc); } if (Systemctl.IsActive(svc)) { Systemctl.Stop(svc); } } }
public void StartService() { var svcs = HostParametersConfiguration.Conf.ServicesStart; foreach (var svc in svcs) { if (Systemctl.IsEnabled(svc) == false) { Systemctl.Enable(svc); } if (Systemctl.IsActive(svc) == false) { Systemctl.Start(svc); } } }
public void Start() { if (Systemctl.IsEnabled(ServiceName) == false) { Systemctl.Enable(ServiceName); } if (Systemctl.IsActive(ServiceName) == false) { Systemctl.Restart(ServiceName); } Systemctl.Restart(ServiceName); var remoteHost = _serviceModel.RemoteHost; var r = Handshake(remoteHost); if (!r) { ConsoleLogger.Warn($"[vpn] remote host {remoteHost} is unreachable"); return; } remoteHost = remoteHost.Split(':').FirstOrDefault(); var lsmod = Bash.Execute("lsmod").SplitBash().Grep("tun").FirstOrDefault(); if (lsmod == null) { Bash.Execute("modprobe tun"); } var lsmodRemote = Bash.Execute($"ssh root@{remoteHost} \"modprobe tun\"").SplitBash().Grep("tun").FirstOrDefault(); if (lsmodRemote == null) { Bash.Execute($"ssh root@{remoteHost} \"modprobe tun\""); } Bash.Execute($"ssh root@{remoteHost} \"systemctl restart {ServiceName}\""); var unit = SetUnitForTunnel(remoteHost); if (unit == false) { ConsoleLogger.Warn("[vpn] something went wrong while creating the tunnel"); return; } var localTap = Bash.Execute("ip link show").SplitBash().ToList(); if (!localTap.Any(_ => _.Contains("tap1"))) { ConsoleLogger.Warn("[vpn] something went wrong while setting the local tunnel interface"); return; } Bash.Execute("ip link set dev tap1 up"); Bash.Execute("ip addr flush dev tap1"); Bash.Execute($"ip addr add {_serviceModel.LocalPoint.Address}/{_serviceModel.LocalPoint.Range} dev tap1"); localTap = Bash.Execute("ip link show tap1").SplitBash().ToList(); if (localTap.Any(_ => _.ToLower().Contains("up"))) { ConsoleLogger.Log("[vpn] local tunnel interface is up"); } var remoteTap = Bash.Execute($"ssh root@{remoteHost} \"ip link show\"").SplitBash().ToList(); if (!remoteTap.Any(_ => _.Contains("tap1"))) { ConsoleLogger.Warn("[vpn] something went wrong while setting the remote tunnel interface"); return; } Bash.Execute($"ssh root@{remoteHost} \"ip link set dev tap1 up\""); Bash.Execute($"ssh root@{remoteHost} \"ip addr flush dev tap1\""); Bash.Execute($"ssh root@{remoteHost} \"ip addr add {_serviceModel.LocalPoint.Address}/{_serviceModel.LocalPoint.Range} dev tap1\""); remoteTap = Bash.Execute($"ssh root@{remoteHost} \"ip link show tap1\"").SplitBash().ToList(); if (remoteTap.Any(_ => _.ToLower().Contains("up"))) { ConsoleLogger.Log("[vpn] remote tunnel interface is up"); } ConsoleLogger.Log("[vpn] connection established"); }