mirror of
https://github.com/bytedream/scripts.git
synced 2025-05-09 12:15:12 +02:00
Add nameavability
This commit is contained in:
parent
6399cfedbd
commit
df7c7dc433
@ -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
12
nameavability/README.md
Normal 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
39
nameavability/nameavability.sh
Executable 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 $@
|
Loading…
x
Reference in New Issue
Block a user