Skip to content

Commit

Permalink
update 2025-01-12 00:22:09
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzok8 committed Jan 11, 2025
1 parent fdd9385 commit babb00d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 23 deletions.
64 changes: 44 additions & 20 deletions luci-app-nekobox/htdocs/nekobox/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,44 +486,68 @@ function getAvailableConfigFiles() {
date "+%Y-%m-%d %H:%M:%S"
}
MAX_RETRIES=5
RETRY_INTERVAL=5
start_singbox() {
sh /etc/neko/core/start.sh
}
echo "$(timestamp) Sing-box 正在重启..." >> \$LOG_PATH
kill $(pgrep -x "singbox") 2>/dev/null
sleep 2
start_singbox
RETRY_COUNT=0
MAX_RETRIES=5
RETRY_INTERVAL=5
while ! pgrep -x "singbox" > /dev/null && [ \$RETRY_COUNT -lt \$MAX_RETRIES ]; do
echo "$(timestamp) Sing-box 启动失败,正在尝试重新启动... (\$((RETRY_COUNT + 1))/\$MAX_RETRIES)" >> \$LOG_PATH
sleep \$RETRY_INTERVAL
start_singbox
((RETRY_COUNT++))
done
check_singbox() {
pgrep -x "singbox" > /dev/null
return $?
}
if pgrep -x "singbox" > /dev/null; then
echo "$(timestamp) Sing-box 启动成功!" >> \$LOG_PATH
if pgrep -x "singbox" > /dev/null
then
echo "$(timestamp) Sing-box 正在运行,正在重启..." >> \$LOG_PATH
kill $(pgrep -x "singbox")
sleep 2
start_singbox
RETRY_COUNT=0
while ! check_singbox && [ \$RETRY_COUNT -lt \$MAX_RETRIES ]; do
echo "$(timestamp) Sing-box 重启失败,正在尝试重新启动... (\$((RETRY_COUNT + 1))/\$MAX_RETRIES)" >> \$LOG_PATH
sleep \$RETRY_INTERVAL
start_singbox
((RETRY_COUNT++))
done
if check_singbox; then
echo "$(timestamp) Sing-box 重启成功!" >> \$LOG_PATH
else
echo "$(timestamp) Sing-box 重启失败,已达到最大重试次数!" >> \$LOG_PATH
fi
else
echo "$(timestamp) Sing-box 启动失败,已达到最大重试次数!" >> \$LOG_PATH
echo "$(timestamp) Sing-box 没有运行, 启动 Sing-box..." >> \$LOG_PATH
start_singbox
RETRY_COUNT=0
while ! check_singbox && [ \$RETRY_COUNT -lt \$MAX_RETRIES ]; do
echo "$(timestamp) Sing-box 启动失败,正在尝试重新启动... (\$((RETRY_COUNT + 1))/\$MAX_RETRIES)" >> \$LOG_PATH
sleep \$RETRY_INTERVAL
start_singbox
((RETRY_COUNT++))
done
if check_singbox; then
echo "$(timestamp) Sing-box 启动成功!" >> \$LOG_PATH
else
echo "$(timestamp) Sing-box 启动失败,已达到最大重试次数!" >> \$LOG_PATH
fi
fi
EOL;

$scriptPath = '/etc/neko/core/restart_singbox.sh';
file_put_contents($scriptPath, $restartScriptContent);
chmod($scriptPath, 0755);

$cronSchedule = $cronTime . " /bin/bash $scriptPath";
$cronSchedule = $cronTime . " /bin/bash $scriptPath";
exec("crontab -l | grep -v '$scriptPath' | crontab -");
exec("(crontab -l 2>/dev/null; echo \"$cronSchedule\") | crontab -");

$logMessage = "定时任务已设置成功,Sing-box 将在 $cronTime 自动重启。";
file_put_contents('/etc/neko/tmp/log.txt', date('Y-m-d H:i:s') . " - INFO: $logMessage\n", FILE_APPEND);

echo json_encode(['success' => true, 'message' => '定时任务已设置成功']);
exit;
}
Expand Down
2 changes: 1 addition & 1 deletion luci-app-nekobox/htdocs/nekobox/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function getCliverVersion() {

@media (max-width: 576px) {
.btn-custom {
width: 20%;
width: 30%;
margin: 0 auto;
display: block;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,21 @@ o = s:option(Flag, "balancing_enable", translate("Enable Load Balancing"))
o.rmempty = false
o.default = false

---- Console Login Auth
o = s:option(Flag, "console_auth", translate("Console Login Auth"))
o.default = false
o:depends("balancing_enable", true)

---- Console Username
o = s:option(Value, "console_user", translate("Console Username"))
o.default = ""
o:depends("balancing_enable", true)
o:depends("console_auth", true)

---- Console Password
o = s:option(Value, "console_password", translate("Console Password"))
o.password = true
o.default = ""
o:depends("balancing_enable", true)
o:depends("console_auth", true)

---- Console Port
o = s:option(Value, "console_port", translate("Console Port"), translate(
Expand Down
3 changes: 3 additions & 0 deletions luci-app-passwall/po/zh-cn/passwall.po
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,9 @@ msgstr "使用 127.0.0.1 和此端口配置节点"
msgid "Enable Load Balancing"
msgstr "开启负载均衡"

msgid "Console Login Auth"
msgstr "控制台登录认证"

msgid "Console Username"
msgstr "控制台账号"

Expand Down

0 comments on commit babb00d

Please sign in to comment.