123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- #!/usr/bin/env bash
- set -e
- set -o pipefail
- GODADDY_KEY="${GODADDY_KEY:-$(pass show godaddy.com/api/key)}"
- GODADDY_SECRET="${GODADDY_SECRET:-$(pass show godaddy.com/api/secret)}"
- GODADDY_COMMAND="${GODADDY_COMMAND:-lexicon godaddy}"
- help_main()
- {
- echo "\
- Usage: godaddy COMMANDS ARGS...
- Run COMMANDS with ARGS
- COMMAND must be one of the sub-commands listed below:
- add
- list
- Report bugs to: go.wigust@gmail.com."
- }
- help_add()
- {
- echo "\
- Usage: godaddy add COMMANDS ARGS...
- Run COMMANDS with ARGS
- COMMAND must be one of the sub-commands listed below:
- a
- cname godaddy add cname githunt guix.duckdns.org
- mx
- Report bugs to: go.wigust@gmail.com."
- }
- help_add_a()
- {
- echo "\
- Usage: godaddy add a subdomain.example.com 1.2.3.4
- Run COMMANDS with ARGS
- Report bugs to: go.wigust@gmail.com."
- }
- help_add_cname()
- {
- echo "\
- Usage: godaddy add cname subdomain.example.com target.domain.com
- Run COMMANDS with ARGS
- Report bugs to: go.wigust@gmail.com."
- }
- help_add_mx()
- {
- echo "\
- Usage: godaddy add mx vm12345 vm12345.wugi.info 10
- or: godaddy add mx vm12345
- Run COMMANDS with ARGS
- Report bugs to: go.wigust@gmail.com."
- }
- help_delete()
- {
- echo "\
- Usage: godaddy delete COMMANDS ARGS...
- Run COMMANDS with ARGS
- COMMAND must be one of the sub-commands listed below:
- a
- cname godaddy delete cname githunt guix.duckdns.org
- Report bugs to: go.wigust@gmail.com."
- }
- help_delete_a()
- {
- echo "\
- Usage: godaddy delete a subdomain.example.com 1.2.3.4
- Run COMMANDS with ARGS
- Report bugs to: go.wigust@gmail.com."
- }
- help_delete_cname()
- {
- echo "\
- Usage: godaddy delete cname subdomain.example.com target.domain.com
- Run COMMANDS with ARGS
- Report bugs to: go.wigust@gmail.com."
- }
- help_list()
- {
- echo "\
- Usage: godaddy list COMMANDS ARGS...
- Run COMMANDS with ARGS
- COMMAND must be one of the sub-commands listed below:
- a
- cname
- mx
- ns
- Report bugs to: go.wigust@gmail.com."
- }
- case "$1" in
- --help)
- help_main
- ;;
- add)
- case "$2" in
- --help)
- help_add
- ;;
- a)
- if [[ -z "$3" ]]
- then
- help_add_a
- exit 1
- fi
- $GODADDY_COMMAND create --auth-key "$GODADDY_KEY" --auth-secret "$GODADDY_SECRET" "$GODADDY_DOMAIN_NAME" A --name "$3" --content "$4"
- ;;
- cname)
- if [[ -z "$3" ]]
- then
- help_add_cname
- exit 1
- fi
- $GODADDY_COMMAND create --auth-key "$GODADDY_KEY" --auth-secret "$GODADDY_SECRET" "$GODADDY_DOMAIN_NAME" CNAME --name "$3" --content "$4"
- ;;
- mx)
- if [[ -z "$3" ]]
- then
- help_add_mx
- exit 1
- fi
- $GODADDY_COMMAND create --auth-key "$GODADDY_KEY" --auth-secret "$GODADDY_SECRET" "$GODADDY_DOMAIN_NAME" MX --name "$3" --content "${4:-$3.wugi.info}" --priority "${5:-10}"
- ;;
- *)
- help_add
- ;;
- esac
- ;;
- delete)
- case "$2" in
- --help)
- help_delete
- ;;
- a)
- if [[ -z "$3" ]]
- then
- help_delete_a
- exit 1
- fi
- $GODADDY_COMMAND delete --auth-key "$GODADDY_KEY" --auth-secret "$GODADDY_SECRET" "$GODADDY_DOMAIN_NAME" A --name "$3" --content "$4"
- ;;
- cname)
- if [[ -z "$3" ]]
- then
- help_delete_cname
- exit 1
- fi
- $GODADDY_COMMAND delete --auth-key "$GODADDY_KEY" --auth-secret "$GODADDY_SECRET" "$GODADDY_DOMAIN_NAME" CNAME --name "$3" --content "$4"
- ;;
- *)
- help_delete
- ;;
- esac
- ;;
- list)
- case "$2" in
- --help)
- help_list
- ;;
- a)
- $GODADDY_COMMAND list --auth-key "$GODADDY_KEY" --auth-secret "$GODADDY_SECRET" "$GODADDY_DOMAIN_NAME" A "${@:3}"
- ;;
- cname)
- $GODADDY_COMMAND list --auth-key "$GODADDY_KEY" --auth-secret "$GODADDY_SECRET" "$GODADDY_DOMAIN_NAME" CNAME "${@:3}"
- ;;
- ns)
- $GODADDY_COMMAND list --auth-key "$GODADDY_KEY" --auth-secret "$GODADDY_SECRET" "$GODADDY_DOMAIN_NAME" NS "${@:3}"
- ;;
- mx)
- $GODADDY_COMMAND list --auth-key "$GODADDY_KEY" --auth-secret "$GODADDY_SECRET" "$GODADDY_DOMAIN_NAME" MX "${@:3}"
- ;;
- *)
- help_list
- ;;
- esac
- ;;
- *)
- help_main
- ;;
- esac
|