diff --git a/README.md b/README.md index 020f9cc..f584368 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/nameavability/README.md b/nameavability/README.md new file mode 100644 index 0000000..6b194f7 --- /dev/null +++ b/nameavability/README.md @@ -0,0 +1,12 @@ +## Nama availability check +Checks if a name has free domains and a free github name + +#### Usage +```shell +$ ./nameavability.sh ... +``` + +#### Example +```shell +$ ./nameavability.sh bytedream +``` diff --git a/nameavability/nameavability.sh b/nameavability/nameavability.sh new file mode 100755 index 0000000..7c33696 --- /dev/null +++ b/nameavability/nameavability.sh @@ -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 $@