diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs index 49a359c0..297ef2de 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -857,6 +857,37 @@ public class Utils return false; } + public static bool IsPackagedInstall() + { + try + { + if (IsWindows() || IsOSX()) + { + return false; + } + + if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APPIMAGE"))) + { + return true; + } + + var sp = StartupPath()?.Replace('\\', '/'); + if (!string.IsNullOrEmpty(sp) && sp.StartsWith("/opt/v2rayN", StringComparison.OrdinalIgnoreCase)) + { + return true; + } + + if (Directory.Exists("/opt/v2rayN")) + { + return true; + } + } + catch + { + } + return false; + } + private static async Task GetLinuxUserId() { var arg = new List() { "-c", "id -u" };