/* * //DEVSPACE-1752 - no need * public enum LinuxIBoxOsVersion * { * Unknown, * //Hollow, // iboxOs 1.3.8 - kernel 3.14.6-1 * Vegas, // iboxOs 1.4.2 - kernel 3.14.6-1 * Apollon // iboxOs 1.5.0 - kernel 3.18.6-1 * } */ static HostEnvironment() { var platformNumber = (int)Environment.OSVersion.Platform; //determine if the host is a *nix operating system these numbers take into account historic values, do an internet search for details if (platformNumber == 4 || platformNumber == 6 || platformNumber == 128) { // running on *nix HostOs = HostOsType.Linux; } else { // not running on *nix (this function defaults to windows) HostOs = HostOsType.Windows; } OsVersion = Environment.OSVersion.ToString(); //DEVSPACE-1752 - no need to output this in log - doubling! /* if (IsLinux) * { * // ... see main * * var ver = Environment.OSVersion.Version; * if (ver == new Version(3, 18, 6, 1)) * IBoxOsVersion = LinuxIBoxOsVersion.Apollon; * else * if (ver == new Version(3, 14, 6, 1)) * IBoxOsVersion = LinuxIBoxOsVersion.Vegas; * * ShellConsole.WriteInfo("IBoxOsVersion = {0} kernel=[{1}.{2}.{3}.{4}]", Environment.OSVersion, ver.Major, ver.Minor, ver.Build, ver.Revision); * } * else */ try { var regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion"); // @"SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion" if (regKey != null) { OsVersion = $"{regKey.GetValue("ProductName")} ({OsVersion})"; } } catch (Exception ex) { ShellConsole.WriteError("Read WinOS version from registry: {0}", ex.Message); Debug.Assert(false, "Глянь... " + ex.Message); } LocaleInfo = CultureInfo.InvariantCulture.Clone() as CultureInfo; if (LocaleInfo != null) { LocaleInfo.NumberFormat.NumberDecimalSeparator = "."; } }
/// <summary> /// Настраиваем бридж cp /etc/ppp/peers/life /etc/ppp/peers/mts /// Открываем для редактирования nano -w /etc/ppp/peers/mts /// Меняем connect '/usr/sbin/chat -v -f /etc/chatscript/life-connect' на connect '/usr/sbin/chat -v -f /// /etc/chatscript/mts-connect' /// ( в начале открывшегося файла должен быть указан порт, по которому подключен модем скорее всего dev/ttyS0 ) /// но пишем весь файл /// </summary> public static void CreateBridgeFile(this GprsProvider provider, ModelModem modelModem, string ttyDevice, int speed) { var file = provider.LinuxBridgeFile(true); { var filePreconfig = file + '-' + modelModem.ShortName(); if (File.Exists(filePreconfig)) { File.Copy(filePreconfig, file, true); ShellConsole.WriteInfo("Modem.CreateBridgeFile: Copy {0} to {1}", filePreconfig, file); return; } } try { using (var writer = new StreamWriter(file, false)) { ShellConsole.WriteInfo("Modem.CreateBridgeFile: WriteFile {0}", file); writer.Write(ttyDevice); // tty device writer.Write(" "); writer.WriteLine(speed); // Serial port line speed var preconfig = ReadPreconfig(modelModem); writer.Write(preconfig); writer.WriteLine("connect '/usr/sbin/chat -e -v -f " + provider.LinuxScriptFile(true) + "'"); if (modelModem == ModelModem.Wavecom && preconfig.Contains("user ibox")) { try { using (var writer2 = new StreamWriter("/etc/ppp/pap-secrets", false)) { writer2.WriteLine("# Secrets for authentication using PAP"); writer2.WriteLine("# client server secret IP addresses"); writer2.WriteLine("ibox * 1 *"); } } catch (Exception ex) { ShellConsole.WriteInfo("Modem. CreateBridgeFile: WriterPapSecr: " + ex.Message); } } } } catch (Exception ex) { ShellConsole.WriteInfo("Modem. CreateBridgeFile: WriteFileError: " + ex.Message); } }