mirror of
https://gh.wpcy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-04-23 01:50:05 +08:00
37 lines
1.1 KiB
Bash
Executable file
37 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
#
|
|
# IPs from site names
|
|
#
|
|
# `captaincore dns ips-from-site-names [<site>...] [--skip-follow]`
|
|
#
|
|
# Example output:
|
|
# website1.com 10.124.124.124
|
|
# website2.com 10.124.124.124
|
|
#
|
|
|
|
# Load configuration
|
|
root_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; root_path=${root_path%app*}
|
|
source ${root_path}lib/arguments
|
|
|
|
echo "Running checks on ${#arguments[*]} sites"
|
|
|
|
if [[ "$skip_follow" == "true" ]]; then
|
|
|
|
for website in "${arguments[@]}"; do
|
|
while read site_configs; do declare "$site_configs"; done <<< "$(captaincore site get $website --bash --captain_id=$captain_id)"
|
|
ip=`dig $address a +short | tail -n 1`
|
|
echo "$site $domain $ip"
|
|
done
|
|
|
|
else
|
|
|
|
for website in "${arguments[@]}"; do
|
|
while read site_configs; do declare "$site_configs"; done <<< "$(captaincore site get $website --bash --captain_id=$captain_id)"
|
|
curl_result=`curl -sLI http://$address`
|
|
followed_domain=`echo -e "$curl_result" | perl -wnE'say for /Location: (?:http:\/\/|https:\/\/)?([A-Z|a-z|.|-]+)/g' | tail -n 1`
|
|
ip=`dig $followed_domain a +short | tail -n 1`
|
|
echo "$site $followed_domain $ip"
|
|
done
|
|
|
|
fi
|