# PowerShell Script to Download the latest release file 'xxx.zip' from a GitHub repository
# Set your GitHub repository details $UserOrOrg = "SagerNet"# Replace with the GitHub username or organization $Repository = "sing-box"# Replace with the GitHub repository name
# GitHub API URL for the latest release $ApiUrl = "https://api.github.com/repos/$UserOrOrg/$Repository/releases/latest"
# Use Invoke-RestMethod to call the GitHub API $LatestRelease = Invoke-RestMethod-Uri$ApiUrl Write-Host"Latest release is $($LatestRelease.tag_name)"
# Ask user whether to continue $userResponse = Read-Host"Do you want to download and extract this version? (y/n)" if ($userResponse-ne'y') { Write-Host"Operation cancelled by user." exit }
# Find the download URL for the specific file $FileName = "sing-box-$($LatestRelease.tag_name -replace 'v', '')-windows-amd64.zip" $FileUrl = ($LatestRelease.assets | Where-Object { $_.name -eq$FileName }).browser_download_url
# Check if the file URL was found if ($FileUrl-eq$null) { Write-Host"File $FileName not found in the latest release." exit }
# Download the file $OutputPath = ".\$FileName"# Specify the path where the file will be saved Invoke-WebRequest-Uri$FileUrl-OutFile$OutputPath Write-Host"Downloaded $FileName to $OutputPath"
# 如果进程存在,结束它 if ($process) { Stop-Process-Name sing-box-Force Write-Host"Terminated sing-box" }
update-geo-db.ps1: 更新geoip和geosite数据库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# Define the URLs for the files to download $geoipUrl = "https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip.db" $geositeUrl = "https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geosite.db"
# Define the destination directory $destinationDirectory = "你放sing-box的地方"