This commit is contained in:
parent
a69f3fe299
commit
0169357beb
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue