summaryrefslogtreecommitdiff
path: root/bin/nwhois.sh
blob: 9f0ea7739997b54b4a8c8baf047ea6429623b542 (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
_do_whois(){

	if [[ $(whois -H -h "$1" "$2" | grep -o "$3") == "$3" ]]; then
		echo "$(tput setaf 3)$(tput bold)$2$(tput sgr0) $(tput setaf 3)is available.$(tput sgr0)"
	else
		echo "$(tput setaf 1)Domain unavailable. ($(tput bold)$2$(tput sgr0)$(tput setaf 1))$(tput sgr0)"
	fi
}

getclick() {
	_do_whois "whois.uniregistry.net" "$1.click" "is available for registration"
}

getclub() {
	_do_whois "whois.nic.club" "$1.club" "Not found:"
}

getlink() {
	_do_whois "whois.uniregistry.net" "$1.link" "is available for registration"
}

getninja() {
	_do_whois "whois.unitedtld.com" "$1.ninja" "Domain not found"
}

gettop() {
	_do_whois "whois.nic.top" "$1.top" "No match"
}

getwork() {
	_do_whois "whois-dub.mm-registry.com" "$1.work" "Not Registered"
}

getxyz() {
	_do_whois "whois.nic.xyz" "$1.xyz" "DOMAIN NOT FOUND"
}

nwhois(){
	tld=$(echo "$1" | cut -d '.' -f 2)
	if [ -z $tld ] || [[ "$tld" == "$1" ]]; then
		#echo "No valid domain." 1>&2
		#return
		tld='all'
	fi
	domain=$(echo "$1" | cut -d '.' -f 1)

	case $tld in
		"click")
			getclick $domain
			;;
		"club")
			getclub $domain
			;;
		"link") 
			getlink $domain
			;;
		"ninja") 
			getninja $domain
			;;
		"top")
			gettop $domain
			;;
		"work")	
			getwork $domain
			;;
		"xyz")	
			getxyz $domain
			;;
		'*'|"all")	
			getclick $domain
			getclub $domain
			getlink $domain
			getninja $domain
			gettop $domain
			getwork $domain
			getxyz $domain
			;;
		*)
			echo "Unknown TLD. Falling back to standard whois."
			whois -H "$1"
			;;
	esac
}