Skip to content

Commit

Permalink
ps1 self elevate & minify
Browse files Browse the repository at this point in the history
  • Loading branch information
yxnan committed Dec 3, 2023
1 parent 7d7de1f commit 3f59958
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
API_KEY: ${{ secrets.api_key }}
run: ./build-rpglist.sh "$API_KEY"

- name: Minify Powershell script
uses: StartAutomating/[email protected]

- name: Set date env
run: echo "TODAY=$(date '+%Y/%m/%d')" >> $GITHUB_ENV

Expand All @@ -33,4 +36,5 @@ jobs:
files: |
rpglist.json
BlockRpg.ps1
BlockRpg.min.ps1
block-rpg.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

下列两种方法任选其一:

1. Release获取`BlockRpg.ps1`使用管理员权限执行即可
1. Release获取`BlockRpg.ps1`右键使用Powershell执行,如果有提示需要确认,输入R然后回车即可
2. Release获取`rpglist.json`,导入火绒或者其他类似能提供IP过滤名单的软件即可

### Linux
Expand Down
7 changes: 6 additions & 1 deletion build-rpglist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ iplist_ps1=$(cat rpglist.json | jq --raw-output '
')

echo '
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}
$rulename = "Block L4D2 RPG Servers"
$iplist = @("'"$iplist_ps1"'")
Expand All @@ -86,7 +91,7 @@ if ( Get-NetFirewallRule -DisplayName $rulename 2>$null ) {
-RemoteAddress $iplist
}
echo "Done."
Read-Host -Prompt "------------- Done. -------------" | Out-Null
' \
> BlockRpg.ps1

Expand Down

0 comments on commit 3f59958

Please sign in to comment.