summarylogtreecommitdiffstats
path: root/v2ray-rules-dat-autoupdate
blob: 66ae30495d1348dd3e8ad9a7adc4694c2a98cad0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash

set -e

FastGit="https://hub.fastgit.org/Loyalsoldier/v2ray-rules-dat/releases/latest"
GitHub="https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download"
JsDelivr="https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release"

download_files() {
  echo "Fetching rules.zip"
  curl -LO "${1}/rules.zip{,.sha256sum}"
  sha256sum --check "rules.zip.sha256sum"

  bsdtar -xf ./rules.zip
  
  rm -vf $(find . -maxdepth 1 -type f ! -name "geo*.dat")
}

case "${1}" in
"fastgit" | "fg")
  download_files $FastGit
  ;;
"jsdelivr" | "js")
  download_files $JsDelivr
  ;;
*)
  download_files $GitHub
  ;;
esac