This commit is contained in:
ahmadbilalkhalid 2019-09-02 22:32:45 +05:00
parent a69f3fe299
commit 0169357beb
1 changed files with 23 additions and 0 deletions

View File

@ -79,6 +79,29 @@ setup_dns() {
fi
}
setup_etc_host() {
tput setaf 2; tput bold; echo "Setting up \/etc\/hosts"; tput sgr0;
metadata=$(curl -s http://[2a0a:e5c1:144:1::]:5000)
host_list=$(echo "$metadata" | jq -r '.["host-list"]')
host_list_len=$(echo "$host_list" | jq -r '. | length')
cat > /etc/hosts <<EOF
127.0.0.1 localhost.my.domain localhost localhost.localdomain localhost
::1 localhost localhost.localdomain
$(
for i in $(seq 0 $((host_list_len - 1)));
do
hostname=$(echo $host_list | jq -r ".[$i][0]")
ip=$(echo $host_list | jq -r ".[$i][1]")
printf "%-25s %s\n" $hostname $ip
done
)
EOF
}
# Main Code Starts here
make_script_verbose