static void Main(string[] args) { try { _notificationSystem = NotificationSystem.Default; switch (OS.GetCurrent()) { case "win": _bridgeSystem = BridgeSystem.Bat; _colorify = new Format(Theme.Dark); break; case "gnu": _bridgeSystem = BridgeSystem.Bash; _colorify = new Format(Theme.Dark); break; case "mac": _bridgeSystem = BridgeSystem.Bash; _colorify = new Format(Theme.Light); break; } _shell = new ShellConfigurator(_bridgeSystem, _notificationSystem); Menu(); _colorify.ResetColor(); _colorify.Clear(); } catch (ArgumentOutOfRangeException) { MessageException("Ahh my eyes! Why this console is too small?"); } catch (Exception ex) { MessageException(ex.ToString()); } }
/// <summary> /// Installs the app in <paramref name="downloadedFileName"/> on Linux. /// </summary> /// <param name="downloadedFileName">The downloaded application files to install.</param> private void InstallOnLinux(string downloadedFileName) { Log.Information("Installing on Linux"); _executable = Path.Combine(this.InstallationPath, "SQRLDotNetClientUI"); if (!Directory.Exists(this.InstallationPath)) { Directory.CreateDirectory(this.InstallationPath); } this.DownloadPercentage = 20; //File.Move(downloadedFileName, Executable, true); ExtractZipFile(downloadedFileName, string.Empty, this.InstallationPath); try { Log.Information("Copying installer into installation location (for auto update)"); //Copy the installer but don't over-write the one included in the zip since it will likely be newer File.Copy(Process.GetCurrentProcess().MainModule.FileName, Path.Combine(this.InstallationPath, Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName)), false); } catch (Exception fc) { Log.Warning($"File copy exception: {fc}"); } using (StreamWriter sw = new StreamWriter(Path.Combine(this.InstallationPath, "sqrlversion.json"))) { sw.Write(Newtonsoft.Json.JsonConvert.SerializeObject(this.SelectedRelease.tag_name)); sw.Close(); } this.DownloadPercentage += 20; _bridgeSystem = BridgeSystem.Bash; _shell = new ShellConfigurator(_bridgeSystem); Log.Information("Creating Linux desktop icon, application and registering SQRL invokation scheme"); GitHubHelper.DownloadFile(@"https://github.com/sqrldev/SQRLDotNetClient/raw/master/SQRLDotNetClientUI/Assets/SQRL_icon_normal_64.png", Path.Combine(this.InstallationPath, "SQRL.png")); StringBuilder sb = new StringBuilder(); sb.AppendLine($"[Desktop Entry]"); sb.AppendLine("Name=SQRL"); sb.AppendLine("Type=Application"); sb.AppendLine($"Icon={(Path.Combine(this.InstallationPath, "SQRL.png"))}"); sb.AppendLine($"Exec={_executable} %u"); sb.AppendLine("Categories=Internet"); sb.AppendLine("Terminal=false"); sb.AppendLine("MimeType=x-scheme-handler/sqrl"); File.WriteAllText(Path.Combine(this.InstallationPath, "sqrldev-sqrl.desktop"), sb.ToString()); _shell.Term($"chmod -R 755 {this.InstallationPath}", Output.Internal); _shell.Term($"chmod a+x {_executable}", Output.Internal); _shell.Term($"chmod +x {Path.Combine(this.InstallationPath, "sqrldev-sqrl.desktop")}", Output.Internal); _shell.Term($"chmod a+x {Path.Combine(this.InstallationPath, Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName))}", Output.Internal); _shell.Term($"xdg-desktop-menu install {Path.Combine(this.InstallationPath, "sqrldev-sqrl.desktop")}", Output.Internal); _shell.Term($"gio mime x-scheme-handler/sqrl sqrldev-sqrl.desktop", Output.Internal); _shell.Term($"xdg-mime default sqrldev-sqrl.desktop x-scheme-handler/sqrl", Output.Internal); _shell.Term($"update-desktop-database ~/.local/share/applications/", Output.Internal); }
static ConvertController() { _notificationSystem = NotificationSystem.Default; switch (OS.GetCurrent()) { case "win": _bridgeSystem = BridgeSystem.Bat; break; case "gnu": _bridgeSystem = BridgeSystem.Bash; break; case "mac": _bridgeSystem = BridgeSystem.Bash; break; } _shell = new ShellConfigurator(_bridgeSystem, _notificationSystem); }
private async void InstallinLinux(string downloadedFileName) { this.InstallStatus = "Installing..."; Executable = Path.Combine(this.InstallationPath, "SQRLDotNetClientUI"); await Task.Run(() => { if (!Directory.Exists(this.InstallationPath)) { Directory.CreateDirectory(this.InstallationPath); } this.DownloadPercentage = 20; //File.Move(downloadedFileName, Executable, true); ExtractZipFile(downloadedFileName, string.Empty, this.InstallationPath); File.Copy(Process.GetCurrentProcess().MainModule.FileName, Path.Combine(this.InstallationPath, Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName)), true); this.DownloadPercentage += 20; }); _bridgeSystem = BridgeSystem.Bash; _shell = new ShellConfigurator(_bridgeSystem); wc.DownloadFile(@"https://github.com/sqrldev/SQRLDotNetClient/raw/master/SQRLDotNetClientUI/Assets/SQRL_icon_normal_64.png", Path.Combine(this.InstallationPath, "SQRL.png")); StringBuilder sb = new StringBuilder(); sb.AppendLine($"[Desktop Entry]"); sb.AppendLine("Name=SQRL"); sb.AppendLine("Type=Application"); sb.AppendLine($"Icon={(Path.Combine(this.InstallationPath,"SQRL.png"))}"); sb.AppendLine($"Exec={Executable} %u"); sb.AppendLine("Categories=Internet"); sb.AppendLine("Terminal=false"); sb.AppendLine("MimeType=x-scheme-handler/sqrl"); File.WriteAllText(Path.Combine(this.InstallationPath, "sqrldev-sqrl.desktop"), sb.ToString()); _shell.Term($"chmod -R 777 {this.InstallationPath}", Output.Internal); _shell.Term($"chmod a+x {Executable}", Output.Internal); _shell.Term($"chmod +x {Path.Combine(this.InstallationPath,"sqrldev-sqrl.desktop")}", Output.Internal); _shell.Term($"xdg-desktop-menu install {Path.Combine(this.InstallationPath,"sqrldev-sqrl.desktop")}", Output.Internal); _shell.Term($"gio mime x-scheme-handler/sqrl sqrldev-sqrl.desktop", Output.Internal); _shell.Term($"xdg-mime default sqrldev-sqrl.desktop x-scheme-handler/sqrl", Output.Internal); _shell.Term($"update-desktop-database ~/.local/share/applications/", Output.Internal); }
private void InstallinMac(string downloadedFileName) { string fileName = Path.GetTempFileName().Replace(".tmp", ".zip"); wc.DownloadFile("https://github.com/sqrldev/SQRLDotNetClient/raw/PlatformInstaller/Installers/MacOsX/SQRL.app.zip", fileName); //System.IO.Compression.ZipFile.ExtractToDirectory(fileName, this.InstallationPath,true); ExtractZipFile(fileName, string.Empty, this.InstallationPath); Executable = Path.Combine(this.InstallationPath, "SQRL.app/Contents/MacOS", "SQRLDotNetClientUI"); this.DownloadPercentage = 20; ExtractZipFile(downloadedFileName, string.Empty, Path.Combine(this.InstallationPath, "SQRL.app/Contents/MacOS")); //File.Move(downloadedFileName, Executable, true); File.Copy(Process.GetCurrentProcess().MainModule.FileName, Path.Combine(this.InstallationPath, "SQRL.app/Contents/MacOS", Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName)), true); this.DownloadPercentage += 20; _bridgeSystem = BridgeSystem.Bash; _shell = new ShellConfigurator(_bridgeSystem); _shell.Term($"chmod a+x {Executable}", Output.Internal); }
/// <param name="logger"></param> /// <inheritdoc /> public ExternalProcesses(IManagerLogger logger) { _logger = logger; NotificationSystem = ToolBox.Notification.NotificationSystem.Default; switch (OS.GetCurrent()) { case "win": BridgeSystem = ToolBox.Bridge.BridgeSystem.Bat; break; case "mac": case "gnu": BridgeSystem = ToolBox.Bridge.BridgeSystem.Bash; break; default: throw new NotImplementedException(); } Shell = new ShellConfigurator(BridgeSystem, NotificationSystem); }
/// <summary> /// Launches the freshly installed SQRL client app. /// </summary> private void LaunchSQRL() { Log.Information($"Launching client from installer"); // On Linux, the installer is run as root, so we need to "downgrade" // the client launch to the "real" user account. if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { ShellConfigurator shell = new ShellConfigurator(BridgeSystem.Bash); string user = shell.Term("logname", Output.Hidden).stdout.Trim(); SystemAndShellUtils.LaunchClientAsUser(_clientExePath, user); return; } var process = new Process(); process.StartInfo.FileName = _clientExePath; process.StartInfo.WorkingDirectory = Path.GetDirectoryName(_clientExePath); process.StartInfo.UseShellExecute = true; process.Start(); }
private static void Factory() { _fileSystem = FileSystem.Default; _notificationSystem = new ConsoleNotificationSystem(); _disk = new DiskConfigurator(_fileSystem, _notificationSystem); switch (OS.GetCurrent()) { case "win": _path = new PathsConfigurator(CommandSystem.Win, _fileSystem); _bridgeSystem = BridgeSystem.Bat; _colorify = new Format(Theme.Dark); break; case "mac": _path = new PathsConfigurator(CommandSystem.Mac, _fileSystem); _bridgeSystem = BridgeSystem.Bash; _colorify = new Format(Theme.Light); break; } _shell = new ShellConfigurator(_bridgeSystem, _notificationSystem); _logSystem = new FileLogTxt(_fileSystem, _path.Combine("~"), ".hardhat.log"); }
/// <summary> /// Installs the app in <paramref name="downloadedFileName"/> on MacOSX. /// </summary> /// <param name="downloadedFileName">The downloaded application files to install.</param> private void InstallOnMac(string downloadedFileName) { Log.Information("Installing on MacOSX"); string fileName = Path.GetTempFileName().Replace(".tmp", ".zip"); Log.Information("Downloading Mac app folder structure from Github"); GitHubHelper.DownloadFile("https://github.com/sqrldev/SQRLDotNetClient/raw/PlatformInstaller/Installers/MacOsX/SQRL.app.zip", fileName); Log.Information("Creating initial SQRL application template"); ExtractZipFile(fileName, string.Empty, this.InstallationPath); _executable = Path.Combine(this.InstallationPath, "SQRL.app/Contents/MacOS", "SQRLDotNetClientUI"); Log.Information($"Excecutable location:{_executable}"); this.DownloadPercentage = 20; ExtractZipFile(downloadedFileName, string.Empty, Path.Combine(this.InstallationPath, "SQRL.app/Contents/MacOS")); //File.Move(downloadedFileName, Executable, true); try { Log.Information("Copying installer into installation location (for auto update)"); File.Copy(Process.GetCurrentProcess().MainModule.FileName, Path.Combine(this.InstallationPath, "SQRL.app/Contents/MacOS", Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName)), false); } catch (Exception fc) { Log.Error($"File copy exception: {fc}"); } using (StreamWriter sw = new StreamWriter(Path.Combine(this.InstallationPath, "SQRL.app/Contents/MacOS", "sqrlversion.json"))) { Log.Information($"Finished installing SQRL version: {this.SelectedRelease.tag_name}"); sw.Write(Newtonsoft.Json.JsonConvert.SerializeObject(this.SelectedRelease.tag_name)); sw.Close(); } this.DownloadPercentage += 20; _bridgeSystem = BridgeSystem.Bash; _shell = new ShellConfigurator(_bridgeSystem); Log.Information("Changing executable file to be executable a+x"); _shell.Term($"chmod a+x {_executable}", Output.Internal); _shell.Term($"chmod a+x {Path.Combine(this.InstallationPath, "SQRL.app/Contents/MacOS", Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName))}", Output.Internal); }