Add nameavability

This commit is contained in:
bytedream 2022-04-05 20:07:01 +02:00
parent 6399cfedbd
commit df7c7dc433
3 changed files with 52 additions and 1 deletions

View File

@ -9,6 +9,6 @@ This repository contains some (linux) scripts I am using to simplify my daily wo
- [Rename files random](/randomize-filename)
- [Rename files based on their MD5 hashsum](/hashify-filename)
- [Beautify java source code](/java-beautifier)
- [Name availability check (websites & github)](/nameavability)
If you want to use any of the scripts globally, execute [globalize.sh](globalize.sh)

12
nameavability/README.md Normal file
View File

@ -0,0 +1,12 @@
## Nama availability check
Checks if a name has free domains and a free github name
#### Usage
```shell
$ ./nameavability.sh <name1> <name2> ...
```
#### Example
```shell
$ ./nameavability.sh bytedream
```

39
nameavability/nameavability.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash
check_commands() {
failure=false
for cmd in "dig" "curl"; do
if ! command -v $cmd &> /dev/null; then
echo "'$cmd' must be installed"
failure=true
fi
done
if $failure; then
exit 1
fi
}
main() {
for name in $@; do
echo "---> $name"
for tld in "com" "org" "net" "io"; do
dst_ip=`dig 1.1.1.1 +short $name.$tld | tail -n 1`
if [ ! $dst_ip ]; then
echo -e "\t$name.$tld: AVAILABLE"
else
echo -e "\t$name.$tld: NOT available"
fi
done
github_availability=`curl -o /dev/null -s -w "%{http_code}" https://github.com/$name`
if [ "$github_availability" == "200" ]; then
echo -e "\tGitHub: NOT available"
else
echo -e "\tGitHub: AVAILABLE"
fi
done
}
check_commands
main $@