update 2024-11-15 20:40:29

This commit is contained in:
kenzok8 2024-11-15 20:40:29 +08:00
parent 405af11cc7
commit b90ede25b8
10 changed files with 110 additions and 15 deletions

View File

@ -2,7 +2,7 @@
include $(TOPDIR)/rules.mk
PKG_VERSION:=0.0.1-1
PKG_VERSION:=0.0.2-1
PKG_RELEASE:=
LUCI_TITLE:=LuCI support for arcadia

View File

@ -11,7 +11,8 @@ m = taskd.docker_map("arcadia", "arcadia", "/usr/libexec/istorec/arcadia.sh",
translate("Arcadia one-stop code operation and maintenance platform.")
.. translate("Official website:") .. ' <a href=\"https://arcadia.cool\" target=\"_blank\">https://arcadia.cool</a>'
.. "<dl><dt>" .. translate("Arcadia is mainly aimed at scripting language programming and is suitable for development and operation environments of small and medium-sized teams and individuals.") .. "</dt>"
.. translate("In addition to code maintenance, Arcadia is also a powerful scheduled task maintenance platform with a comprehensive file system and underlying CLI command design.")
.. "<dt>" .. translate("In addition to code maintenance, Arcadia is also a powerful scheduled task maintenance platform with a comprehensive file system and underlying CLI command design.") .. "</dt>"
.. "<dt>" .. translate("The initial username and password are 'useradmin' and 'passwd' respectively.") .. "</dt>"
.. "</dl>")
s = m:section(SimpleSection, translate("Service Status"), translate("Arcadia status:"))

View File

@ -13,6 +13,9 @@ msgstr "Arcadia 主要面向于脚本语言编程,适用于中小型团队与
msgid "In addition to code maintenance, Arcadia is also a powerful scheduled task maintenance platform with a comprehensive file system and underlying CLI command design."
msgstr "除了代码运维外 Arcadia 还是一个强大的定时任务运维平台并且有着完善的文件系统和底层CLI命令设计。"
msgid "The initial username and password are 'useradmin' and 'passwd' respectively."
msgstr "初始的用户名和密码分别是'useradmin'和'passwd'。"
msgid "Image"
msgstr "镜像"

View File

@ -38,11 +38,6 @@ do_install_detail() {
[ -z "$port" ] && port=5678
local cmd="docker run --restart=unless-stopped -d -v \"$config/config:/arcadia/config\" -v \"$config/log:/arcadia/log\" -v \"$config/scripts:/arcadia/scripts\" -v \"$config/repo:/arcadia/repo\" -v \"$config/raw:/arcadia/raw\" -v \"$config/tgbot:/arcadia/tgbot\" "
if [ -d /dev/dri ]; then
cmd="$cmd\
-v /dev/dri:/dev/dri \
--privileged "
fi
if [ "$hostnet" = 1 ]; then
cmd="$cmd\
--dns=127.0.0.1 \

View File

@ -16,7 +16,7 @@ define Package/$(PKG_NAME)
SUBMENU:=3. Applications
TITLE:=LuCI support for mihomo
PKGARCH:=all
DEPENDS:=+kmod-tun +bash +curl +jq +php8 +php8-cgi +php8-mod-curl +php8-mod-zip
DEPENDS:=+kmod-tun +bash +curl +jq +php8 +php8-cgi +php8-mod-curl +php8-mod-zip +php8-cli
endef
define Package/$(PKG_NAME)/description

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@ -222,12 +222,49 @@ function writeToLog($message) {
}
}
function rotateLogs($logFile, $maxSize = 1048576) {
if (file_exists($logFile) && filesize($logFile) > $maxSize) {
rename($logFile, $logFile . '.old');
touch($logFile);
chmod($logFile, 0644);
}
function createCronScript() {
$log_rotate_script = '/nekobox/rotate_logs.php';
$cron_schedule = "0 1 * * * /usr/bin/php8-cli $log_rotate_script";
$cronScriptPath = '/etc/neko/core/set_cron.sh';
$cronScriptContent = <<<EOL
#!/bin/bash
LOG_ROTATE_SCRIPT="$log_rotate_script"
CRON_SCHEDULE="0 1 * * * /usr/bin/php8-cli \$LOG_ROTATE_SCRIPT"
crontab -l | grep -q "\$LOG_ROTATE_SCRIPT"
if [ \$? -ne 0 ]; then
(crontab -l 2>/dev/null; echo "\$CRON_SCHEDULE") | crontab -
echo "Cron job added to run log rotation daily at 1 AM."
else
echo "Cron job already exists."
fi
EOL;
file_put_contents($cronScriptPath, $cronScriptContent);
chmod($cronScriptPath, 0755);
shell_exec("sh $cronScriptPath");
writeToLog("Cron job setup script created and executed to add a daily log rotation task.");
}
function rotateLogs($logFile, $maxSize = 5048576, $maxOldLogs = 3) {
if (file_exists($logFile) && filesize($logFile) > $maxSize) {
$oldLogFile = $logFile . '.old';
rename($logFile, $oldLogFile);
shell_exec("gzip $oldLogFile");
$oldLogs = glob($logFile . '.old.gz');
if (count($oldLogs) > $maxOldLogs) {
array_multisort(array_map('filemtime', $oldLogs), SORT_ASC, $oldLogs);
$logsToDelete = array_slice($oldLogs, 0, count($oldLogs) - $maxOldLogs);
foreach ($logsToDelete as $logToDelete) {
unlink($logToDelete);
}
}
touch($logFile);
chmod($logFile, 0644);
file_put_contents($logFile, '');
}
}
function isSingboxRunning() {
@ -327,6 +364,7 @@ if (isset($_POST['singbox'])) {
rotateLogs($singbox_log);
createStartScript($config_file);
createCronScript();
$output = shell_exec("sh $start_script_path >> $singbox_log 2>&1 &");
writeToLog("Shell output: " . ($output ?: "No output"));

View File

@ -0,0 +1,28 @@
<?php
$singbox_log = '/var/log/singbox_log.txt';
$maxSize = 1048576;
$maxOldLogs = 5;
function rotateLogs($logFile, $maxSize = 1048576, $maxOldLogs = 5) {
if (file_exists($logFile) && filesize($logFile) > $maxSize) {
$oldLogFile = $logFile . '.old';
rename($logFile, $oldLogFile);
shell_exec("gzip $oldLogFile");
$oldLogs = glob($logFile . '.old.gz');
if (count($oldLogs) > $maxOldLogs) {
array_multisort(array_map('filemtime', $oldLogs), SORT_ASC, $oldLogs);
$logsToDelete = array_slice($oldLogs, 0, count($oldLogs) - $maxOldLogs);
foreach ($logsToDelete as $logToDelete) {
unlink($logToDelete);
}
}
touch($logFile);
chmod($logFile, 0644);
file_put_contents($logFile, '');
}
}
rotateLogs($singbox_log);
?>

View File

@ -426,10 +426,16 @@ install_php() {
PHP_CGI_URL="https://github.com/Thaolga/neko/releases/download/core_neko/php8-cgi_8.3.10-1_aarch64_generic.ipk"
PHP_URL="https://github.com/Thaolga/neko/releases/download/core_neko/php8_8.3.10-1_aarch64_generic.ipk"
PHP_MOD_CURL_URL="https://github.com/Thaolga/neko/releases/download/core_neko/php8-mod-curl_8.3.10-1_aarch64_generic.ipk"
PHP_MOD_ZIP_URL="https://github.com/Thaolga/neko/releases/download/core_neko/php8-mod-zip_8.2.21-1_aarch64_generic.ipk"
JQ_URL="https://github.com/Thaolga/neko/releases/download/core_neko/jq_1.6-2_aarch64_generic.ipk"
PHP_CLI_URL="https://github.com/Thaolga/neko/releases/download/core_neko/php8-cli_8.3.12-r1_aarch64_generic.ipk"
elif [ "$ARCH" == "x86_64" ]; then
PHP_CGI_URL="https://github.com/Thaolga/neko/releases/download/core_neko/php8-cgi_8.3.10-1_x86_64.ipk"
PHP_URL="https://github.com/Thaolga/neko/releases/download/core_neko/php8_8.3.10-1_x86_64.ipk"
PHP_MOD_CURL_URL="https://github.com/Thaolga/neko/releases/download/core_neko/php8-mod-curl_8.3.10-1_x86_64.ipk"
PHP_MOD_ZIP_URL="https://github.com/Thaolga/neko/releases/download/core_neko/php8-mod-zip_8.2.21-1_x86_64.ipk"
JQ_URL="https://github.com/Thaolga/neko/releases/download/core_neko/jq_1.6-2_x86_64.ipk"
PHP_CLI_URL="https://github.com/Thaolga/neko/releases/download/core_neko/php8-cli_8.3.12-r1_x86_64.ipk"
else
echo -e "${RED}Unsupported architecture: $ARCH${RESET}"
exit 1
@ -459,7 +465,31 @@ install_php() {
echo -e "${RED}PHP curl module installation failed.${RESET}"
fi
rm -f /tmp/php8-cgi.ipk /tmp/php8.ipk /tmp/php8-mod-curl.ipk
echo -e "${GREEN}Downloading and installing PHP zip module...${RESET}"
wget "$PHP_MOD_ZIP_URL" -O /tmp/php8-mod-zip.ipk
if opkg install --force-reinstall --force-overwrite /tmp/php8-mod-zip.ipk; then
echo -e "${GREEN}PHP zip module installed successfully.${RESET}"
else
echo -e "${RED}PHP zip module installation failed.${RESET}"
fi
echo -e "${GREEN}Downloading and installing jq...${RESET}"
wget "$JQ_URL" -O /tmp/jq.ipk
if opkg install --force-reinstall --force-overwrite /tmp/jq.ipk; then
echo -e "${GREEN}jq installed successfully.${RESET}"
else
echo -e "${RED}jq installation failed.${RESET}"
fi
echo -e "${GREEN}Downloading and installing PHP CLI...${RESET}"
wget "$PHP_CLI_URL" -O /tmp/php8-cli.ipk
if opkg install --force-reinstall --force-overwrite /tmp/php8-cli.ipk; then
echo -e "${GREEN}PHP CLI installed successfully.${RESET}"
else
echo -e "${RED}PHP CLI installation failed.${RESET}"
fi
rm -f /tmp/php8-cgi.ipk /tmp/php8.ipk /tmp/php8-mod-curl.ipk /tmp/php8-mod-zip.ipk /tmp/php8-cli.ipk
echo -e "${GREEN}Installation complete.${RESET}"
echo -e "${YELLOW}Please restart the server to apply changes.${RESET}"