feat: use --china-mirrors instead of -c

This commit is contained in:
al1cE
2024-11-19 13:30:40 +09:00
committed by GitHub
parent 7b5ac23a4b
commit c434a44bc4

View File

@@ -9,27 +9,57 @@ GITHUB_URL="https://github.com"
GITHUB_API_URL="https://api.github.com" GITHUB_API_URL="https://api.github.com"
# Read command line options # Read command line options
while getopts "k:p:uhc" opt; do TEMP=$(getopt -o 'k:p:uh' --long 'china-mirrors,help' -n 'install-agent.sh' -- "$@")
case $opt in
k) KEY="$OPTARG" ;; if [ $? -ne 0 ]; then
p) PORT="$OPTARG" ;; echo 'Failed to parse command line arguments' >&2
u) UNINSTALL=true ;; exit 1
c) CHINA_MAINLAND=true ;; fi
h)
printf "Beszel Agent installation script\n\n" eval set -- "$TEMP"
printf "Usage: ./install-agent.sh [options]\n\n" unset TEMP
printf "Options: \n"
printf " -k : SSH key (required, or interactive if not provided)\n" while true; do
printf " -p : Port (default: $PORT)\n" case "$1" in
printf " -u : Uninstall Beszel Agent\n" '-k')
printf " -c : Using GitHub mirror sources to resolve network timeout issues in mainland China\n" KEY="$2"
printf " -h : Display this help message\n" shift 2
exit 0 continue
;; ;;
?) '-p')
echo "Invalid option: -$OPTARG" PORT="$2"
exit 1 shift 2
;; continue
;;
'-u')
UNINSTALL=true
shift
continue
;;
'--china-mirrors')
CHINA_MAINLAND=true
shift
continue
;;
'-h'|'--help')
printf "Beszel Agent installation script\n\n"
printf "Usage: ./install-agent.sh [options]\n\n"
printf "Options: \n"
printf " -k : SSH key (required, or interactive if not provided)\n"
printf " -p : Port (default: $PORT)\n"
printf " -u : Uninstall Beszel Agent\n"
printf " --china-mirrors : Using GitHub mirror sources to resolve network timeout issues in mainland China\n"
printf " -h, --help : Display this help message\n"
exit 0
;;
'--')
shift
break
;;
*)
echo "Invalid option: $1" >&2
exit 1
;;
esac esac
done done