Add linux bash param

This commit is contained in:
2dust 2025-02-23 16:59:22 +08:00
parent aa133bb50b
commit 2f3e409487
4 changed files with 8 additions and 7 deletions

View file

@ -857,7 +857,7 @@ namespace ServiceLib.Common
private static async Task<string?> GetLinuxUserId()
{
var arg = new List<string>() { "-c", "id -u" };
return await GetCliWrapOutput("/bin/bash", arg);
return await GetCliWrapOutput(Global.LinuxBash, arg);
}
public static async Task<string?> SetLinuxChmod(string? fileName)
@ -868,14 +868,14 @@ namespace ServiceLib.Common
fileName = fileName.AppendQuotes();
//File.SetUnixFileMode(fileName, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute);
var arg = new List<string>() { "-c", $"chmod +x {fileName}" };
return await GetCliWrapOutput("/bin/bash", arg);
return await GetCliWrapOutput(Global.LinuxBash, arg);
}
public static async Task<string?> GetLinuxFontFamily(string lang)
{
// var arg = new List<string>() { "-c", $"fc-list :lang={lang} family" };
var arg = new List<string>() { "-c", $"fc-list : family" };
return await GetCliWrapOutput("/bin/bash", arg);
return await GetCliWrapOutput(Global.LinuxBash, arg);
}
public static string? GetHomePath()
@ -888,7 +888,7 @@ namespace ServiceLib.Common
public static async Task<string?> GetListNetworkServices()
{
var arg = new List<string>() { "-c", $"networksetup -listallnetworkservices" };
return await GetCliWrapOutput("/bin/bash", arg);
return await GetCliWrapOutput(Global.LinuxBash, arg);
}
#endregion Platform

View file

@ -71,6 +71,7 @@ namespace ServiceLib
public const string V2RayLocalAsset = "V2RAY_LOCATION_ASSET";
public const string XrayLocalAsset = "XRAY_LOCATION_ASSET";
public const int SpeedTestPageSize = 1000;
public const string LinuxBash = "/bin/bash";
public static readonly List<string> IEProxyProtocols =
[

View file

@ -177,7 +177,7 @@ namespace ServiceLib.Handler
if (File.Exists(launchAgentPath))
{
var args = new[] { "-c", $"launchctl unload -w \"{launchAgentPath}\"" };
await Utils.GetCliWrapOutput("/bin/bash", args);
await Utils.GetCliWrapOutput(Global.LinuxBash, args);
File.Delete(launchAgentPath);
}
@ -197,7 +197,7 @@ namespace ServiceLib.Handler
await File.WriteAllTextAsync(launchAgentPath, plistContent);
var args = new[] { "-c", $"launchctl load -w \"{launchAgentPath}\"" };
await Utils.GetCliWrapOutput("/bin/bash", args);
await Utils.GetCliWrapOutput(Global.LinuxBash, args);
}
catch (Exception ex)
{

View file

@ -116,7 +116,7 @@ namespace ServiceLib.Services.CoreConfig
//enable tun mode
if (_config.TunModeItem.EnableTun)
{
string tun = EmbedUtils.GetEmbedText(Global.ClashTunYaml);
var tun = EmbedUtils.GetEmbedText(Global.ClashTunYaml);
if (Utils.IsNotEmpty(tun))
{
var tunContent = YamlUtils.FromYaml<Dictionary<string, object>>(tun);