diff --git a/src/Jackett.Server/Services/FilePermissionService.cs b/src/Jackett.Server/Services/FilePermissionService.cs index ba17ace46..3528e9b55 100644 --- a/src/Jackett.Server/Services/FilePermissionService.cs +++ b/src/Jackett.Server/Services/FilePermissionService.cs @@ -1,4 +1,7 @@ using System; +#if ISLINUXMUSL +using System.Diagnostics; +#endif using Jackett.Common.Services.Interfaces; using Mono.Unix; using NLog; @@ -16,10 +19,35 @@ namespace Jackett.Server.Services logger.Debug($"Attempting to give execute permission to: {path}"); try { +#if ISLINUXMUSL + // Fix this error in Alpine Linux + // Error System.DllNotFoundException: Unable to load shared library 'Mono.Unix' or one of its dependencies. + // In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: + // Error loading shared library libMono.Unix: No such file or directory + var process = new Process + { + StartInfo = new ProcessStartInfo + { + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true, + WindowStyle = ProcessWindowStyle.Hidden, + FileName = "chmod", + Arguments = $"+x \"{path}\"" + } + }; + process.Start(); + var stdErr = process.StandardError.ReadToEnd(); + process.WaitForExit(); + if (process.ExitCode != 0) + throw new Exception(stdErr); +#else var jackettUpdaterFI = new UnixFileInfo(path) { - FileAccessPermissions = FileAccessPermissions.UserReadWriteExecute | FileAccessPermissions.GroupRead | FileAccessPermissions.OtherRead + FileAccessPermissions = FileAccessPermissions.UserReadWriteExecute | FileAccessPermissions.GroupRead + | FileAccessPermissions.OtherRead }; +#endif } catch (Exception ex) {