Add more paths and check_domain script
This commit is contained in:
parent
245cac8b77
commit
b3c5152019
2 changed files with 71 additions and 0 deletions
70
scripts/bin/check_domain
Executable file
70
scripts/bin/check_domain
Executable file
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# suggested usage: ./check_domain | tee /tmp/chkdmn && sort /tmp/chkdmn
|
||||
|
||||
# constants
|
||||
AVAIL_REGEX='^No match|^NOT FOUND|^Not fo|AVAILABLE|^No Data Fou|has not been regi|No entri'
|
||||
TIMEOUT_REGEX='^Timeout'
|
||||
|
||||
COLOR_RESET="\x1b[0m"
|
||||
COLOR_GREEN="\x1b[32m"
|
||||
COLOR_YELLOW="\x1b[33m"
|
||||
COLOR_RED="\x1b[31m"
|
||||
|
||||
DOMAINS=( \
|
||||
'.com' '.net' '.org' '.eu' '.in' '.it' '.sk' '.ac' '.ae' '.af' '.ag' '.al' \
|
||||
'.am' '.as' '.at' '.ax' '.be' '.bi' '.bo' '.by' '.bz' '.cc' '.cd' '.cf' '.cg' \
|
||||
'.ch' '.ci' '.cl' '.cm' '.cn' '.co' '.cr' '.cx' '.cz' '.dk' '.dm' '.do' '.ec' \
|
||||
'.ee' '.es' '.fi' '.fm' '.fo' '.ga' '.gd' '.gf' '.gg' '.gl' '.gp' '.gq' '.gr' \
|
||||
'.gs' '.gt' '.gy' '.hk' '.hm' '.hn' '.ht' '.id' '.im' '.in' '.io' '.ir' '.is' \
|
||||
'.je' '.ke' '.kg' '.kz' '.la' '.lc' '.li' '.lt' '.lu' '.lv' '.ly' '.me' '.mg' \
|
||||
'.mk' '.ml' '.mn' '.mq' '.ms' '.mu' '.mw' '.mx' '.na' '.ne' '.ng' '.nl' '.nu' \
|
||||
'.nz' '.pe' '.ph' '.pk' '.pl' '.pr' '.pt' '.pw' '.qa' '.ro' '.rs' '.ru' '.rw' \
|
||||
'.sb' '.sc' '.sd' '.se' '.sh' '.si' '.sl' '.sr' '.st' '.su' '.sx' '.sg' '.tk' \
|
||||
'.tl' '.to' '.tv' '.tw' '.ug' '.vc' '.ve' '.vg' '.vn' '.vu' '.ws' \
|
||||
)
|
||||
|
||||
# check dependencies
|
||||
if command -v whois >/dev/null 2>&1; then
|
||||
:
|
||||
else
|
||||
echo "You need to install whois before proceeding!"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# check arguments
|
||||
if [ "$#" == "0" ]; then
|
||||
echo "You need to supply at least one argument!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# main function
|
||||
check_domain() {
|
||||
if [ "$#" == "0" ]; then
|
||||
echo "No domain specified."
|
||||
return
|
||||
fi
|
||||
|
||||
DOMAIN="$1"
|
||||
TMP=$(mktemp "check_domain_whois_${DOMAIN}_XXX")
|
||||
whois "$DOMAIN" > "$TMP" 2>&1
|
||||
if egrep -q "$AVAIL_REGEX" "$TMP"; then
|
||||
echo -e "$COLOR_GREEN$DOMAIN / available$COLOR_RESET"
|
||||
elif egrep -q "$TIMEOUT_REGEX" "$TMP"; then
|
||||
echo -e "$COLOR_YELLOW$DOMAIN / timed out$COLOR_RESET"
|
||||
else
|
||||
echo -e "$COLOR_RED$DOMAIN / unavailable$COLOR_RESET"
|
||||
fi
|
||||
}
|
||||
|
||||
# iterate all provided domain names combined with all TLDs and check them
|
||||
# concurrently
|
||||
elements=${#DOMAINS[@]}
|
||||
while (( "$#" )); do
|
||||
for (( i=0; i<$ELEMENTS; i++ )); do
|
||||
D="$1${DOMAINS[${i}]}"
|
||||
check_domain "${D}" &
|
||||
done
|
||||
shift
|
||||
done
|
||||
wait
|
|
@ -6,6 +6,7 @@ export GOPATH="$HOME/.go"
|
|||
export PATH=$PATH:"$GOPATH/bin"
|
||||
export PATH=$PATH:"$DOTFILES_PATH/scripts/bin"
|
||||
export PATH=$PATH:"$DOTFILES_PATH/scripts/env_bin"
|
||||
export PATH=$PATH:"$HOME/.env_bin"
|
||||
export PATH=$PATH:"$HOME/.cargo/bin"
|
||||
export PATH=$PATH:"$HOME/.yarn/bin"
|
||||
|
||||
|
|
Reference in a new issue