summarylogtreecommitdiffstats
path: root/vxray-rules-dat-updater
blob: 80f72ccdca6c16094d760728a8d47556dc73886f (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
30
31
32
33
34
35
36
37
38
#!/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/"
CfCDN="https://cfgit.cern.ga/Loyalsoldier/v2ray-rules-dat/releases/latest/download"

download_files() {
  echo "Fetching geoip.dat"
  curl -LO "${1}/geoip.dat"
  curl -LO "${1}/geoip.dat.sha256sum"
  sha256sum --check "geoip.dat.sha256sum"

  echo "Fetching geosite.dat"
  curl -LO "${1}/geosite.dat"
  curl -LO "${1}/geosite.dat.sha256sum"
  sha256sum --check "geosite.dat.sha256sum"

  rm -v "geosite.dat.sha256sum" "geoip.dat.sha256sum"
  cp -f /var/lib/vxray-rules-dat/geoip.dat /usr/share/xray/geoip.dat && cp -f /var/lib/vxray-rules-dat/geoip.dat /usr/share/v2ray/geoip.dat && cp -f /var/lib/vxray-rules-dat/geosite.dat /usr/share/xray/geosite.dat && cp -f /var/lib/vxray-rules-dat/geosite.dat /usr/share/v2ray/geosite.dat
}

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