winsw3 + update script for singbox windows
This commit is contained in:
+1
-2
@@ -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,2 +1,2 @@
|
||||
winsw.exe install
|
||||
winsw3.exe install
|
||||
pause
|
||||
@@ -1 +1 @@
|
||||
winsw.exe start
|
||||
winsw3.exe start
|
||||
@@ -1,2 +1,2 @@
|
||||
winsw.exe status
|
||||
winsw3.exe status
|
||||
pause
|
||||
@@ -1 +1 @@
|
||||
winsw.exe stop
|
||||
winsw3.exe stop
|
||||
@@ -1,2 +1,2 @@
|
||||
winsw.exe uninstall
|
||||
winsw3.exe uninstall
|
||||
pause
|
||||
@@ -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
|
||||
Binary file not shown.
@@ -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>
|
||||
Reference in New Issue
Block a user