winsw3 + update script for singbox windows

This commit is contained in:
mercury
2024-04-14 13:03:23 +04:00
parent dfa9efec7a
commit 332b74e366
10 changed files with 44 additions and 12 deletions
+1 -2
View File
@@ -55,8 +55,7 @@ if ($hash == substr(md5($c['key']), 0, 8)) {
header("Location: $fs");
exit;
case '2':
$link = htmlspecialchars($bot->singboxSubscription($_GET['s'], a: 1), ENT_XML1, 'UTF-8');
file_put_contents('/singbox/winsw.xml', preg_replace('#~url~#', $link, file_get_contents('/singbox/winsw.xml')));
file_put_contents('/singbox/update.cmd', preg_replace('#~url~#', $bot->singboxSubscription($_GET['s'], a: 1), file_get_contents('/singbox/update.cmd')));
$zip = new ZipArchive();
$n = "singbox_$v.zip";
$zip->open($n, ZipArchive::CREATE | ZipArchive::OVERWRITE);
+1 -1
View File
@@ -1,2 +1,2 @@
winsw.exe install
winsw3.exe install
pause
+1 -1
View File
@@ -1 +1 @@
winsw.exe start
winsw3.exe start
+1 -1
View File
@@ -1,2 +1,2 @@
winsw.exe status
winsw3.exe status
pause
+1 -1
View File
@@ -1 +1 @@
winsw.exe stop
winsw3.exe stop
+1 -1
View File
@@ -1,2 +1,2 @@
winsw.exe uninstall
winsw3.exe uninstall
pause
+35
View File
@@ -0,0 +1,35 @@
@echo off
setlocal
set "exe_path=sing-box.exe"
set "URL=~url~"
set "FileName=config.json"
set "PreviousHash="
taskkill /IM "%exe_path%" /F
powershell -command "(New-Object System.Net.WebClient).DownloadFile('%URL%', '%FileName%')"
for /F "skip=1 delims=" %%H in ('2^>nul CertUtil -hashfile "%FileName%" SHA256') do (
if not defined PreviousHash set "PreviousHash=%%H"
)
start "" /B "%CD%\%exe_path%" run -c "%FileName%"
echo "%PreviousHash%"
:loop
powershell -command "(New-Object System.Net.WebClient).DownloadFile('%URL%', '%FileName%')"
for /F "skip=1 delims=" %%H in ('2^>nul CertUtil -hashfile "%FileName%" SHA256') do (
if not defined HASH set "HASH=%%H"
)
set "CurrentHash=%HASH%"
set "HASH="
echo "%CurrentHash%"
if "%CurrentHash%" NEQ "%PreviousHash%" (
echo "change"
set "PreviousHash=%CurrentHash%"
taskkill /IM "%exe_path%" /F
start "" /B "%CD%\%exe_path%" run -c "%FileName%"
) else (
echo "not change"
)
timeout /t 15 /nobreak
goto :loop
@@ -2,8 +2,7 @@
<id>singbox</id>
<name>singbox</name>
<description>singbox</description>
<executable>%BASE%\sing-box.exe</executable>
<arguments>run -c %BASE%\config.json</arguments>
<executable>%BASE%\update.cmd</executable>
<logmode>rotate</logmode>
<onfailure action="restart" delay="10 sec" />
<onfailure action="restart" delay="20 sec" />
@@ -13,7 +12,4 @@
<onexit action="restart" />
<onexit action="restart" />
<onexit action="none" />
<configuration>
<download from="~url~" to="%BASE%\config.json" interval="1 minute" />
</configuration>
</service>
+2
View File
@@ -1,3 +1,5 @@
14.04.2024 v1.27.1
- singbox windows: замена winsw на winsw3, + скрипт обновления подписки
13.04.2024 v1.27
- архив сингбокса для windows, работает как служба
12.04.2024 v1.26