diff --git a/ADBForwarder/Program.cs b/ADBForwarder/Program.cs index 5e3841d..fe44740 100644 --- a/ADBForwarder/Program.cs +++ b/ADBForwarder/Program.cs @@ -11,6 +11,7 @@ using SharpAdbClient; using ICSharpCode.SharpZipLib.Zip; using Microsoft.Extensions.Configuration; +using UnixFileMode = System.IO.UnixFileMode; namespace ADBForwarder { @@ -76,7 +77,11 @@ private static void Main() DownloadADB(downloadUri).Wait(); if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - SetExecutable(absoluteAdbPath); + { + Console.WriteLine("Giving adb executable permissions"); + File.SetUnixFileMode(absoluteAdbPath, + UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); + } } Console.WriteLine("Starting ADB Server..."); @@ -161,27 +166,5 @@ private static async Task DownloadADB(string downloadUri) File.Delete("adb.zip"); } - - private static void SetExecutable(string fileName) - { - Console.WriteLine("Giving adb executable permissions"); - - var args = $"chmod u+x {fileName}"; - var escapedArgs = args.Replace("\"", "\\\""); - - using var process = new Process(); - process.StartInfo = new ProcessStartInfo - { - RedirectStandardOutput = true, - UseShellExecute = false, - CreateNoWindow = true, - WindowStyle = ProcessWindowStyle.Hidden, - FileName = "/bin/bash", - Arguments = $"-c \"{escapedArgs}\"" - }; - - process.Start(); - process.WaitForExit(); - } } } \ No newline at end of file