-
Notifications
You must be signed in to change notification settings - Fork 278
Expand file tree
/
Copy pathgen_assets.sh
More file actions
42 lines (30 loc) · 1.25 KB
/
gen_assets.sh
File metadata and controls
42 lines (30 loc) · 1.25 KB
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
39
40
41
42
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
# Set magic variables for current file & dir
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename "${__file}" .sh)"
DATADIR="${__dir}/data"
# Check for required dependencies
check_dependencies() {
command -v jq >/dev/null 2>&1 || { echo >&2 "jq is required but it's not installed. Aborting."; exit 1; }
command -v go >/dev/null 2>&1 || { echo >&2 "Go is required but it's not installed. Aborting."; exit 1; }
}
# Download data function
download_dat() {
echo "Downloading geoip.dat..."
curl -sL https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat -o "$DATADIR/geoip.dat"
echo "Downloading geosite.dat..."
curl -sL https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat -o "$DATADIR/geosite.dat"
echo "Downloading geoip-only-cn-private.dat..."
curl -sL https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat -o "$DATADIR/geoip-only-cn-private.dat"
}
# Main execution logic
ACTION="${1:-download}"
check_dependencies
case $ACTION in
"download") download_dat ;;
*) echo "Invalid action: $ACTION" ; exit 1 ;;
esac