update 2024-11-24 09:42:42
This commit is contained in:
parent
40f3577664
commit
24663b8d32
|
@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
|||
|
||||
PKG_MAINTAINER:=Thaolga <https://github.com/Thaolga/luci-app-nekobox>
|
||||
PKG_NAME:=luci-app-nekobox
|
||||
PKG_VERSION:=1.5.4
|
||||
PKG_VERSION:=1.5.5
|
||||
PKG_RELEASE:=cn
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
@ -60,8 +60,6 @@ endef
|
|||
define Package/$(PKG_NAME)/postinst
|
||||
#!/bin/sh
|
||||
if [ -f "/tmp/neko/neko.bak" ]; then
|
||||
cp -rf "/tmp/neko/core/mihomo" "/etc/neko/core/mihomo"
|
||||
chmod 0755 /etc/neko/core/mihomo
|
||||
cp -rf "/tmp/neko/geoip.metadb" "/etc/neko/geoip.metadb"
|
||||
cp -rf "/tmp/neko/geosite.db" "/etc/neko/geosite.db"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="186" height="20" role="img" aria-label="Current Version: v1.5.4">
|
||||
<title>Current Version: v1.5.4</title>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="186" height="20" role="img" aria-label="Current Version: v1.5.5">
|
||||
<title>Current Version: v1.5.5</title>
|
||||
<linearGradient id="s" x2="0" y2="100%">
|
||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
|
@ -15,7 +15,7 @@
|
|||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
|
||||
<text aria-hidden="true" x="495" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="700" style="letter-spacing: -5;">Current Version</text>
|
||||
<text x="495" y="140" transform="scale(.1)" fill="#fff" textLength="700" style="letter-spacing: -5;">Current Version</text>
|
||||
<text aria-hidden="true" x="1405" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="600" style="letter-spacing: -3;">v1.5.4</text>
|
||||
<text x="1405" y="140" transform="scale(.1)" fill="#fff" textLength="600" style="letter-spacing: -3;">v1.5.4</text>
|
||||
<text aria-hidden="true" x="1405" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="600" style="letter-spacing: -3;">v1.5.5</text>
|
||||
<text x="1405" y="140" transform="scale(.1)" fill="#fff" textLength="600" style="letter-spacing: -3;">v1.5.5</text>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
@ -3,7 +3,7 @@
|
|||
// NEKO CONFIGURATION
|
||||
$neko_dir="/etc/neko";
|
||||
$neko_www="/www/nekobox";
|
||||
$neko_bin="$neko_dir/core/mihomo";
|
||||
$neko_bin="/usr/bin/mihomo";
|
||||
$neko_theme= exec("cat $neko_www/lib/theme.txt");
|
||||
$neko_status=exec("uci -q get neko.cfg.enabled");
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@ function getCurrentVersion() {
|
|||
|
||||
function getLatestVersion() {
|
||||
$url = "https://github.com/Thaolga/openwrt-nekobox/releases";
|
||||
$html = shell_exec("curl -m 10 -s $url");
|
||||
$output = shell_exec("wget -qO- $url");
|
||||
|
||||
if ($html === null || empty($html)) {
|
||||
if ($output === null || empty($output)) {
|
||||
return "Error";
|
||||
}
|
||||
|
||||
preg_match('/\/releases\/tag\/([\d\.]+)/', $html, $matches);
|
||||
preg_match('/\/releases\/tag\/([\d\.]+)/', $output, $matches);
|
||||
if (isset($matches[1])) {
|
||||
return cleanVersion($matches[1]);
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ function getLatestVersion() {
|
|||
}
|
||||
|
||||
function cleanVersion($version) {
|
||||
$version = explode('-', $version)[0];
|
||||
return preg_replace('/[^0-9\.]/', '', $version);
|
||||
$version = explode('-', $version)[0];
|
||||
return preg_replace('/[^0-9\.]/', '', $version);
|
||||
}
|
||||
|
||||
$currentVersion = getCurrentVersion();
|
||||
|
|
|
@ -60,7 +60,7 @@ if (json_last_error() !== JSON_ERROR_NONE) {
|
|||
$latest_version = $data['tag_name'] ?? '';
|
||||
|
||||
$current_version = '';
|
||||
$install_path = '/etc/neko/core/mihomo';
|
||||
$install_path = '/usr/bin/mihomo';
|
||||
$temp_file = '/tmp/mihomo.gz';
|
||||
|
||||
if (file_exists($install_path)) {
|
||||
|
|
|
@ -190,7 +190,7 @@ if (isset($_POST['update'])) {
|
|||
|
||||
if (!empty($url)) {
|
||||
$finalPath = $subscriptionPath . $customFileName;
|
||||
$command = "curl -fsSL -o {$finalPath} {$url}";
|
||||
$command = "wget -q --show-progress -O {$finalPath} {$url}";
|
||||
exec($command . ' 2>&1', $output, $return_var);
|
||||
|
||||
if ($return_var === 0) {
|
||||
|
|
|
@ -197,7 +197,7 @@ if (isset($_POST['saveSubscription'])) {
|
|||
if (!empty($url)) {
|
||||
$finalPath = $configPath . $customFileName;
|
||||
$command = sprintf(
|
||||
"curl -fsSL -o %s %s",
|
||||
"wget -q --show-progress -O %s %s",
|
||||
escapeshellarg($finalPath),
|
||||
escapeshellarg($url)
|
||||
);
|
||||
|
@ -222,7 +222,6 @@ $updateCompleted = isset($_POST['saveSubscription']);
|
|||
<?php
|
||||
$subscriptionPath = '/etc/neko/config/';
|
||||
$dataFile = $subscriptionPath . 'subscription_data.json';
|
||||
|
||||
$message = "";
|
||||
$defaultSubscriptions = [
|
||||
[
|
||||
|
@ -269,23 +268,27 @@ if (isset($_POST['update_index'])) {
|
|||
|
||||
$originalContent = file_exists($finalPath) ? file_get_contents($finalPath) : '';
|
||||
|
||||
$ch = curl_init($subscriptionUrl);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
$fileContent = curl_exec($ch);
|
||||
$error = curl_error($ch);
|
||||
curl_close($ch);
|
||||
$command = sprintf(
|
||||
"wget -q --header='Accept-Charset: utf-8' -O %s %s",
|
||||
escapeshellarg($finalPath),
|
||||
escapeshellarg($subscriptionUrl)
|
||||
);
|
||||
|
||||
if ($fileContent === false) {
|
||||
$message = "订阅 $index 无法下载文件。cURL 错误信息: " . $error;
|
||||
exec($command . ' 2>&1', $output, $return_var);
|
||||
|
||||
if ($return_var !== 0) {
|
||||
$message = "订阅 $index 无法下载文件。wget 错误信息: " . implode("\n", $output);
|
||||
} else {
|
||||
$fileContent = str_replace("\xEF\xBB\xBF", '', $fileContent);
|
||||
$fileContent = file_get_contents($finalPath);
|
||||
$fileContent = str_replace("\xEF\xBB\xBF", '', $fileContent);
|
||||
|
||||
if (!isUtf8($fileContent)) {
|
||||
$fileContent = utf8_encode($fileContent);
|
||||
}
|
||||
|
||||
$parsedData = json_decode($fileContent, true);
|
||||
if ($parsedData === null && json_last_error() !== JSON_ERROR_NONE) {
|
||||
file_put_contents($finalPath, $originalContent);
|
||||
file_put_contents($finalPath, $originalContent);
|
||||
$message = "订阅 $index 解析 JSON 数据失败!错误信息: " . json_last_error_msg();
|
||||
} else {
|
||||
if (isset($parsedData['inbounds'])) {
|
||||
|
@ -300,29 +303,29 @@ if (isset($_POST['update_index'])) {
|
|||
}
|
||||
|
||||
$newInbounds[] = [
|
||||
"tag" => "tun",
|
||||
"type" => "tun",
|
||||
"inet4_address" => "172.19.0.0/30",
|
||||
"inet6_address" => "fdfe:dcba:9876::0/126",
|
||||
"stack" => "system",
|
||||
"auto_route" => true,
|
||||
"strict_route" => true,
|
||||
"sniff" => true,
|
||||
"platform" => [
|
||||
"http_proxy" => [
|
||||
"enabled" => true,
|
||||
"server" => "0.0.0.0",
|
||||
"server_port" => 7890
|
||||
"tag" => "tun",
|
||||
"type" => "tun",
|
||||
"inet4_address" => "172.19.0.0/30",
|
||||
"inet6_address" => "fdfe:dcba:9876::0/126",
|
||||
"stack" => "system",
|
||||
"auto_route" => true,
|
||||
"strict_route" => true,
|
||||
"sniff" => true,
|
||||
"platform" => [
|
||||
"http_proxy" => [
|
||||
"enabled" => true,
|
||||
"server" => "0.0.0.0",
|
||||
"server_port" => 7890
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$newInbounds[] = [
|
||||
"tag" => "mixed",
|
||||
"type" => "mixed",
|
||||
"listen" => "0.0.0.0",
|
||||
"listen_port" => 7890,
|
||||
"sniff" => true
|
||||
"tag" => "mixed",
|
||||
"type" => "mixed",
|
||||
"listen" => "0.0.0.0",
|
||||
"listen_port" => 7890,
|
||||
"sniff" => true
|
||||
];
|
||||
|
||||
$parsedData['inbounds'] = $newInbounds;
|
||||
|
@ -349,6 +352,11 @@ if (isset($_POST['update_index'])) {
|
|||
file_put_contents($dataFile, json_encode($subscriptionData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
|
||||
function isUtf8($string) {
|
||||
$encoded = utf8_encode($string);
|
||||
return $encoded === $string;
|
||||
}
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
|
|
|
@ -20,37 +20,27 @@ function downloadFile($url, $destination, $retries = 3, $timeout = 30) {
|
|||
mkdir($dir, 0755, true);
|
||||
}
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_TIMEOUT => $timeout,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
|
||||
]);
|
||||
$command = sprintf(
|
||||
"wget -q --timeout=%d --tries=%d --header='Accept-Charset: utf-8' -O %s %s",
|
||||
$timeout,
|
||||
$retries,
|
||||
escapeshellarg($destination),
|
||||
escapeshellarg($url)
|
||||
);
|
||||
|
||||
$content = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$output = [];
|
||||
$return_var = null;
|
||||
exec($command, $output, $return_var);
|
||||
|
||||
if ($content === false) {
|
||||
throw new Exception("下载失败: " . curl_error($ch));
|
||||
if ($return_var !== 0) {
|
||||
throw new Exception("wget 错误信息: " . implode("\n", $output));
|
||||
}
|
||||
|
||||
if ($httpCode !== 200) {
|
||||
throw new Exception("HTTP 响应码错误: $httpCode");
|
||||
}
|
||||
|
||||
if (file_put_contents($destination, $content) === false) {
|
||||
throw new Exception("无法保存文件到 $destination");
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
logMessage(basename($destination), "下载并保存成功");
|
||||
return true;
|
||||
|
||||
} catch (Exception $e) {
|
||||
logMessage(basename($destination), "第 $attempt 次尝试失败: " . $e->getMessage());
|
||||
curl_close($ch);
|
||||
|
||||
if ($attempt === $retries) {
|
||||
logMessage(basename($destination), "所有下载尝试均失败");
|
||||
|
@ -87,4 +77,4 @@ echo "\n配置文件更新完成!\n\n";
|
|||
foreach ($logMessages as $message) {
|
||||
echo $message . "\n";
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -174,22 +174,12 @@
|
|||
"🇰🇷 韩国节点",
|
||||
"🇸🇬 狮城节点",
|
||||
"🇺🇸 美国节点",
|
||||
"🌀 手动切换1",
|
||||
"🌀 手动切换2",
|
||||
"🌀 手动切换",
|
||||
"🐸 其他地区"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "🌀 手动切换1",
|
||||
"type": "selector",
|
||||
"use_all_providers": true,
|
||||
"includes": [
|
||||
|
||||
],
|
||||
"excludes": "(?i)网站|地址|剩余|过期|时间|有效|套餐|到期"
|
||||
},
|
||||
{
|
||||
"tag": "🌀 手动切换2",
|
||||
"tag": "🌀 手动切换",
|
||||
"type": "selector",
|
||||
"use_all_providers": true,
|
||||
"includes": [
|
||||
|
@ -217,8 +207,7 @@
|
|||
"🇰🇷 韩国节点",
|
||||
"🇸🇬 狮城节点",
|
||||
"🇺🇸 美国节点",
|
||||
"🌀 手动切换1",
|
||||
"🌀 手动切换2",
|
||||
"🌀 手动切换",
|
||||
"🐸 其他地区"
|
||||
]
|
||||
},
|
||||
|
@ -233,8 +222,7 @@
|
|||
"🇰🇷 韩国节点",
|
||||
"🇸🇬 狮城节点",
|
||||
"🇺🇸 美国节点",
|
||||
"🌀 手动切换1",
|
||||
"🌀 手动切换2",
|
||||
"🌀 手动切换",
|
||||
"🐸 其他地区"
|
||||
]
|
||||
},
|
||||
|
@ -249,8 +237,7 @@
|
|||
"🇰🇷 韩国节点",
|
||||
"🇸🇬 狮城节点",
|
||||
"🇺🇸 美国节点",
|
||||
"🌀 手动切换1",
|
||||
"🌀 手动切换2",
|
||||
"🌀 手动切换",
|
||||
"🐸 其他地区"
|
||||
]
|
||||
},
|
||||
|
@ -265,8 +252,7 @@
|
|||
"🇰🇷 韩国节点",
|
||||
"🇸🇬 狮城节点",
|
||||
"🇺🇸 美国节点",
|
||||
"🌀 手动切换1",
|
||||
"🌀 手动切换2",
|
||||
"🌀 手动切换",
|
||||
"🐸 其他地区"
|
||||
]
|
||||
},
|
||||
|
@ -281,8 +267,7 @@
|
|||
"🇰🇷 韩国节点",
|
||||
"🇸🇬 狮城节点",
|
||||
"🇺🇸 美国节点",
|
||||
"🌀 手动切换1",
|
||||
"🌀 手动切换2",
|
||||
"🌀 手动切换",
|
||||
"🐸 其他地区"
|
||||
]
|
||||
},
|
||||
|
@ -353,8 +338,7 @@
|
|||
"🇰🇷 韩国节点",
|
||||
"🇸🇬 狮城节点",
|
||||
"🇺🇸 美国节点",
|
||||
"🌀 手动切换1",
|
||||
"🌀 手动切换2",
|
||||
"🌀 手动切换",
|
||||
"🐸 其他地区"
|
||||
]
|
||||
},
|
||||
|
@ -420,6 +404,9 @@
|
|||
"🇰🇷 韩国节点",
|
||||
"🇸🇬 狮城节点",
|
||||
"🇺🇸 美国节点",
|
||||
"🐸 其他地区",
|
||||
"♻️ 自动选择",
|
||||
"🌀 手动切换",
|
||||
"📹 YouTube",
|
||||
"🎵 TikTok",
|
||||
"🎥 Netflix",
|
||||
|
@ -452,8 +439,7 @@
|
|||
"🚀 节点选择",
|
||||
"🎯 全球直连",
|
||||
"🐸 其他地区",
|
||||
"🌀 手动切换1",
|
||||
"🌀 手动切换2"
|
||||
"🌀 手动切换"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -649,6 +635,13 @@
|
|||
],
|
||||
"outbound": "🍎 苹果服务"
|
||||
},
|
||||
{
|
||||
"rule_set": [
|
||||
"geoip-tiktok",
|
||||
"geosite-tiktok"
|
||||
],
|
||||
"outbound": "🎵 TikTok"
|
||||
},
|
||||
{
|
||||
"rule_set": [
|
||||
"google-cn"
|
||||
|
@ -673,13 +666,6 @@
|
|||
],
|
||||
"outbound": "📹 YouTube"
|
||||
},
|
||||
{
|
||||
"rule_set": [
|
||||
"geoip-tiktok",
|
||||
"geosite-tiktok"
|
||||
],
|
||||
"outbound": "🎵 TikTok"
|
||||
},
|
||||
{
|
||||
"rule_set": [
|
||||
"geoip-netflix",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
neko_dir="/etc/neko"
|
||||
neko_tmp_dir="$neko_dir/tmp"
|
||||
neko_core="$neko_dir/core"
|
||||
neko_bin="$neko_dir/core/mihomo"
|
||||
neko_bin="/usr/bin/mihomo"
|
||||
neko_www="/www/nekobox"
|
||||
neko_config=`cat $neko_www/lib/selected_config.txt`
|
||||
|
||||
|
@ -21,31 +21,20 @@ neko_status=`uci -q get neko.cfg.enabled`
|
|||
php_pid_path="$neko_tmp_dir/php_pid.txt"
|
||||
log="$neko_dir/tmp/log.txt"
|
||||
|
||||
singbox_bin="/usr/bin/sing-box"
|
||||
singbox_log="/var/log/singbox_log.txt"
|
||||
singbox_config_dir="/etc/neko/config"
|
||||
singbox_pid_path="$neko_tmp_dir/singbox_pid.txt"
|
||||
|
||||
core_ver="neko"
|
||||
url_core="https://github.com/Thaolga/neko/releases/download/core_neko"
|
||||
url_geo="https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest"
|
||||
|
||||
neko_ver(){
|
||||
neko_version="1.5.4"
|
||||
neko_version="1.5.5"
|
||||
}
|
||||
|
||||
logs() {
|
||||
echo "[ `date +%T` ] $1"
|
||||
echo "[ `date +%T` ] $1" >> $log
|
||||
}
|
||||
|
||||
neko_logs() {
|
||||
echo "[ `date +%T` ] $1" >> $neko_log
|
||||
}
|
||||
|
||||
singbox_logs() {
|
||||
local timestamp=$(date +"%T")
|
||||
echo -e "[ $timestamp ] $1" >> "$neko_dir/tmp/log.txt"
|
||||
if [ -z $2 ]; then
|
||||
echo "[ `date +%T` ] $1" >> $log
|
||||
elif [ $2 -eq 2 ]; then
|
||||
echo "[ `date +%T` ] $1" > $log
|
||||
elif [ $2 -eq 3 ]; then
|
||||
echo "[ `date +%T` ] $1" >> $log
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_depedency() {
|
||||
|
@ -136,129 +125,6 @@ check_depedency() {
|
|||
fi
|
||||
}
|
||||
|
||||
files_check() {
|
||||
arch=`uname -m`
|
||||
geoip_path="${neko_dir}/geoip.metadb"
|
||||
geosite_path="${neko_dir}/geosite.db"
|
||||
case "$arch" in
|
||||
aarch64)
|
||||
arch="arm64"
|
||||
;;
|
||||
arm)
|
||||
arch="armv7"
|
||||
;;
|
||||
x86_64)
|
||||
arch="amd64"
|
||||
;;
|
||||
mips)
|
||||
arch="mips_24"
|
||||
;;
|
||||
*)
|
||||
arch="0"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $arch == "0" ] ; then
|
||||
logs "- ERROR!!! Arch not supported"
|
||||
else
|
||||
if [ -f ${neko_bin} ]; then
|
||||
logs "- Mihomo OK" 1
|
||||
core_version=`$neko_bin -v | head -1 | awk '{print $1 " " $5 " " $3}'`
|
||||
logs "- Core Detected : $core_version"
|
||||
else
|
||||
logs "- Downloading Mihomo Binary - $arch"
|
||||
wget -q --no-check-certificate -O ${neko_dir}/core/mihomo.gz ${url_core}/mihomo-linux-${arch}-${core_ver}.gz
|
||||
gzip -d ${neko_dir}/core/mihomo.gz
|
||||
fi
|
||||
|
||||
if [ -f ${geoip_path} ]; then
|
||||
logs "- GeoIP OK" 1
|
||||
else
|
||||
logs "- Downloading GeoIP"
|
||||
wget -q --no-check-certificate -O ${geoip_path} ${url_geo}/geoip.metadb
|
||||
fi
|
||||
|
||||
if [ -f ${geosite_path} ]; then
|
||||
logs "- GeoSite OK" 1
|
||||
else
|
||||
logs "- Downloading GeoSite"
|
||||
wget -q --no-check-certificate -O ${neko_dir} ${url_geo}/geosite.db
|
||||
fi
|
||||
fi
|
||||
for file in "$neko_core"/*; do
|
||||
if [ ! -x "$file" ]; then
|
||||
chmod +x "$file"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
singbox_start(){
|
||||
singbox_logs() {
|
||||
local timestamp=$(date +"%T")
|
||||
echo -e "[ $timestamp ] - $1" >> "$neko_dir/tmp/log.txt"
|
||||
}
|
||||
|
||||
singbox_logs "Starting Sing-box"
|
||||
singbox_logs "- Auto Restart Firewall : ON"
|
||||
|
||||
local config_file="$singbox_config_dir/config.json"
|
||||
singbox_logs "Config file: $config_file"
|
||||
singbox_logs "Creating start script"
|
||||
create_start_script "$config_file"
|
||||
|
||||
local singbox_version=$($singbox_bin version)
|
||||
singbox_logs "Sing-box version: $singbox_version"
|
||||
|
||||
(while true; do
|
||||
$singbox_bin run -c $config_file 2>&1 | while read line; do
|
||||
singbox_logs "$line"
|
||||
done
|
||||
done) &
|
||||
|
||||
sleep 1
|
||||
singbox_pid=$(pgrep sing-box)
|
||||
if [[ -n $singbox_pid ]]; then
|
||||
singbox_logs "- Sing-box Started. PID : $singbox_pid"
|
||||
echo $singbox_pid > $singbox_pid_path
|
||||
uci set neko.cfg.singbox_enabled='1'
|
||||
uci commit neko
|
||||
else
|
||||
singbox_logs "- Failed to start Sing-box"
|
||||
fi
|
||||
singbox_logs "Done"
|
||||
|
||||
}
|
||||
|
||||
singbox_stop(){
|
||||
logs "Stopping Sing-box" 2
|
||||
local pid=$(pgrep -f "$singbox_bin")
|
||||
if [ -n "$pid" ] ; then
|
||||
logs "- Killing Sing-box PID: $pid"
|
||||
kill -15 $pid
|
||||
pkill -f "while.*sing-box"
|
||||
sleep 2
|
||||
if kill -0 $pid 2>/dev/null; then
|
||||
logs "- Sing-box didn't stop gracefully. Forcing stop."
|
||||
kill -9 $pid
|
||||
pkill -9 -f "while.*sing-box"
|
||||
fi
|
||||
rm -f $singbox_pid_path
|
||||
uci set neko.cfg.singbox_enabled='0'
|
||||
uci commit neko
|
||||
logs "Sing-box has been stopped"
|
||||
else
|
||||
logs "Sing-box is not Running"
|
||||
fi
|
||||
}
|
||||
|
||||
singbox_restart(){
|
||||
logs "Restarting Sing-box" 2
|
||||
singbox_stop
|
||||
sleep 1
|
||||
singbox_start
|
||||
logs "Restarting Sing-box - Done"
|
||||
}
|
||||
|
||||
neko_start(){
|
||||
neko_ver
|
||||
logs "Starting Neko v.$neko_version" 2
|
||||
|
@ -293,6 +159,7 @@ neko_start(){
|
|||
logs "- Restarting Firewall"
|
||||
$firewall restart
|
||||
$neko_bin -f $neko_config -d $neko_dir >> $neko_log &
|
||||
|
||||
sleep 1
|
||||
neko_pid=`pgrep mihomo`
|
||||
if [[ -z $neko_pid ]]; then
|
||||
|
@ -352,7 +219,6 @@ neko_stop(){
|
|||
kill $rpid
|
||||
fi
|
||||
logs "Neko has Disabled"
|
||||
logs "Neko Disabled." > $neko_log
|
||||
else
|
||||
logs "Neko is not Running"
|
||||
fi
|
||||
|
@ -389,21 +255,12 @@ while getopts ":skrpcvh" signal ; do
|
|||
s)
|
||||
neko_start
|
||||
;;
|
||||
S)
|
||||
singbox_start
|
||||
;;
|
||||
k)
|
||||
neko_stop
|
||||
;;
|
||||
K)
|
||||
singbox_stop
|
||||
;;
|
||||
r)
|
||||
neko_restart
|
||||
;;
|
||||
R)
|
||||
singbox_restart
|
||||
;;
|
||||
p)
|
||||
php_start
|
||||
;;
|
||||
|
@ -413,18 +270,18 @@ while getopts ":skrpcvh" signal ; do
|
|||
v)
|
||||
neko_ver
|
||||
neko_checknewver
|
||||
echo "v.$neko_version $strversion"
|
||||
echo "v.$neko_version"
|
||||
;;
|
||||
h)
|
||||
echo "Neko"
|
||||
echo " -s : Start Mihomo Proxy and Sing-box"
|
||||
echo " -s : Start Mihomo Proxy"
|
||||
echo " -p : Start PHP Server"
|
||||
echo " -k : Kill/Stop Mihomo Proxy and Sing-box"
|
||||
echo " -r : Restart Mihomo Proxy and Sing-box"
|
||||
echo " -c : cleanup (kill mihomo, sing-box, and php server)"
|
||||
echo " -k : Kill/Stop Mihomo Proxy"
|
||||
echo " -r : Restart Mihomo Proxy"
|
||||
echo " -c : cleanup (kill mihomo and php server)"
|
||||
echo " -v : Version"
|
||||
echo " -h : help (this text)"
|
||||
echo "Please Use ROOT User"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
|
|
|
@ -5,23 +5,8 @@
|
|||
arch=`uname -m`
|
||||
neko_dir="/etc/neko"
|
||||
tmp_dir="/tmp"
|
||||
log="$neko_dir/tmp/log.txt"
|
||||
|
||||
|
||||
core_ver="neko"
|
||||
url_core="https://github.com/Thaolga/neko/releases/download/core_neko"
|
||||
url_geo="https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest"
|
||||
|
||||
geoip_path="${neko_dir}/geoip.metadb"
|
||||
geosite_path="${neko_dir}/geosite.db"
|
||||
neko_bin="${neko_dir}/core/mihomo"
|
||||
|
||||
rpid=`pgrep "neko/core"`
|
||||
if [[ -n $rpid ]] ; then
|
||||
kill $rpid
|
||||
fi
|
||||
|
||||
echo "[ `date +%T` ] - Checking Files"
|
||||
echo "[ `date +%T` ] - Checking Files..."
|
||||
|
||||
files_check() {
|
||||
uci set uhttpd.main.index_page='index.php'
|
||||
|
@ -29,89 +14,14 @@ files_check() {
|
|||
uci commit uhttpd
|
||||
|
||||
/etc/init.d/uhttpd restart
|
||||
|
||||
case "$arch" in
|
||||
aarch64)
|
||||
arch="arm64"
|
||||
;;
|
||||
arm)
|
||||
arch="armv7"
|
||||
;;
|
||||
x86_64)
|
||||
arch="amd64"
|
||||
;;
|
||||
mips)
|
||||
arch="mips_24"
|
||||
;;
|
||||
*)
|
||||
arch="0"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $arch == "0" ] ; then
|
||||
echo "[ `date +%T` ] - ERROR!!! Arch not supported"
|
||||
else
|
||||
if [ -f ${neko_bin} ]; then
|
||||
echo "[ `date +%T` ] - Mihomo OK"
|
||||
else
|
||||
echo "[ `date +%T` ] - Downloading Mihomo Binary - $arch"
|
||||
echo "[ `date +%T` ] - Downloading Mihomo Binary - $arch" >> $log
|
||||
wget -q --no-check-certificate -O ${neko_dir}/core/mihomo.gz ${url_core}/mihomo-linux-${arch}-${core_ver}.gz
|
||||
gzip -d ${neko_dir}/core/mihomo.gz
|
||||
fi
|
||||
|
||||
if [ -f ${geoip_path} ]; then
|
||||
echo "[ `date +%T` ] - GeoIP OK"
|
||||
else
|
||||
echo "[ `date +%T` ] - Downloading GeoIP"
|
||||
echo "[ `date +%T` ] - Downloading GeoIP" >> $log
|
||||
wget -q --no-check-certificate -O ${geoip_path} ${url_geo}/geoip.metadb
|
||||
fi
|
||||
|
||||
if [ -f ${geosite_path} ]; then
|
||||
echo "[ `date +%T` ] - GeoSite OK"
|
||||
else
|
||||
echo "[ `date +%T` ] - Downloading GeoSite"
|
||||
echo "[ `date +%T` ] - Downloading GeoSite" >> $log
|
||||
wget -q --no-check-certificate -O ${neko_dir} ${url_geo}/geosite.db
|
||||
fi
|
||||
fi
|
||||
chmod +x $neko_dir/core/mihomo
|
||||
}
|
||||
if [ -f "/tmp/neko/neko.bak" ]; then
|
||||
echo "[ `date +%T` ] - Old Files Detected"
|
||||
if [ -f "/tmp/neko/core/mihomo" ]; then
|
||||
cp -rf "/tmp/neko/core/mihomo" "/etc/neko/core/mihomo"
|
||||
else
|
||||
echo "mihomo Not Detected, Downloading"
|
||||
mkdir ${tmp_dir}/neko
|
||||
wget -q --no-check-certificate -O ${tmp_dir}/neko/mihomo.gz ${url_core}/mihomo-linux-${arch}-${core_ver}.gz
|
||||
gzip -d ${tmp_dir}/neko/mihomo.gz
|
||||
cp -rf ${tmp_dir}/neko/mihomo ${neko_dir}/core/mihomo
|
||||
rm -rf ${tmp_dir}/neko/mihomo
|
||||
fi
|
||||
chmod 0755 /etc/neko/core/mihomo
|
||||
|
||||
if [ -f "/tmp/neko/geoip.metadb" ]; then
|
||||
cp -rf "/tmp/neko/geoip.metadb" "/etc/neko/geoip.metadb"
|
||||
else
|
||||
echo "GeoIP Not Detected, Downloading"
|
||||
wget -q --no-check-certificate -O ${geoip_path} ${url_geo}/geoip.metadb
|
||||
fi
|
||||
|
||||
if [ -f "/tmp/neko/geosite.db" ]; then
|
||||
cp -rf "/tmp/neko/geosite.db" "/etc/neko/geosite.db"
|
||||
else
|
||||
echo "GeoSite Not Detected, Downloading"
|
||||
wget -q --no-check-certificate -O ${neko_dir} ${url_geo}/geosite.db
|
||||
fi
|
||||
|
||||
echo "[ `date +%T` ] - Old Configs"
|
||||
echo "[ `date +%T` ] - Restoring..."
|
||||
|
||||
if [ -f "/tmp/neko/cache.db" ]; then
|
||||
cp -rf "/tmp/neko/cache.db" "/etc/neko/cache.db"
|
||||
else
|
||||
echo "Neko Cache Not Detected, Skipped"
|
||||
fi
|
||||
|
||||
cp -rf /tmp/neko/config/* "/etc/neko/config/"
|
||||
cp -rf /tmp/neko/proxy_provider/* "/etc/neko/proxy_provider/"
|
||||
cp -rf /tmp/neko/rule_provider/* "/etc/neko/rule_provider/"
|
||||
|
@ -120,9 +30,5 @@ else
|
|||
files_check
|
||||
fi
|
||||
|
||||
if [ $arch == "mips_24" ]; then
|
||||
sed -i "s/#wget/wget/g" /etc/neko/core/neko
|
||||
fi
|
||||
|
||||
uci set neko.cfg.enabled='0'
|
||||
uci commit neko
|
||||
|
|
|
@ -153,7 +153,7 @@ install_core() {
|
|||
fi
|
||||
|
||||
current_version=''
|
||||
install_path='/etc/neko/core/mihomo'
|
||||
install_path='/usr/bin/mihomo'
|
||||
temp_file='/tmp/mihomo.gz'
|
||||
temp_extract_path='/tmp/mihomo_temp'
|
||||
|
||||
|
|
Loading…
Reference in New Issue