AndroidLibXrayLite/gen_assets.sh

40 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2023-12-14 18:44:35 +03:30
#!/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)"
2023-12-14 18:44:35 +03:30
DATADIR="${__dir}/data"
2023-12-14 18:44:35 +03:30
# 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; }
}
2023-12-14 18:44:35 +03:30
# 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"
2023-12-14 18:44:35 +03:30
echo "Downloading geosite.dat..."
curl -sL https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat -o "$DATADIR/geosite.dat"
2023-12-14 18:44:35 +03:30
}
# Main execution logic
ACTION="${1:-download}"
2023-12-14 18:44:35 +03:30
check_dependencies
2023-12-14 18:44:35 +03:30
case $ACTION in
"download") download_dat ;;
*) echo "Invalid action: $ACTION" ; exit 1 ;;
2023-12-14 18:44:35 +03:30
esac