Skip to content

Commit

Permalink
[fix] init.d 目录存在其它Sxx文件时,才创建同级链接文件,修正A4-WiFi的init.d中同时有脚本和Sxx文件,导致启动…
Browse files Browse the repository at this point in the history
…两次的问题
  • Loading branch information
nnhy committed Oct 1, 2023
1 parent bd6eb2a commit 46eec07
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions NewLife.Agent/RcInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ public static Boolean Install(String systemdPath, String serviceName, String fil
// 给予可执行权限
Process.Start("chmod", $"+x {file}");

// 创建同级链接文件 [解决某些linux启动必须以Sxx开头的启动文件]
Process.Start("ln", $"-s {systemdPath}/{serviceName} {systemdPath}/S50{serviceName}");
var flag = false;

// 创建链接文件
for (var i = 0; i < 7; i++)
Expand All @@ -148,6 +147,8 @@ public static Boolean Install(String systemdPath, String serviceName, String fil
Process.Start("ln", $"-s {systemdPath}/{serviceName} {dir}K90{serviceName}");
else
Process.Start("ln", $"-s {systemdPath}/{serviceName} {dir}S10{serviceName}");

flag = true;
}
}
// OpenWrt
Expand All @@ -156,9 +157,18 @@ public static Boolean Install(String systemdPath, String serviceName, String fil
if (Directory.Exists(dir))
{
Process.Start("ln", $"-s {systemdPath}/{serviceName} {dir}S50{serviceName}");

flag = true;
}
}

// init.d 目录存在其它Sxx文件时,才创建同级链接文件
if (!flag && systemdPath.AsDirectory().GetFiles().Any(e => e.Name.StartsWith("S")))
{
// 创建同级链接文件 [解决某些linux启动必须以Sxx开头的启动文件]
Process.Start("ln", $"-s {systemdPath}/{serviceName} {systemdPath}/S50{serviceName}");
}

return true;
}

Expand Down

0 comments on commit 46eec07

Please sign in to comment.