Commit 78c809a4 authored by Cédric BRINER's avatar Cédric BRINER Committed by Cédric BRINER
Browse files

better manage /etc/hosts pointing to ./inet/hosts

parent 6efba2ed
......@@ -353,7 +353,7 @@ eof
echo "------------------------------------------"
echo ""
pb "--"
pb "Add the new hostname in /etc/hosts"
pb "Add the new hostname in /etc/hosts -> ./inet/hosts"
official_hostname_n_aliases=$(grep -w ${ipv4} /etc/hosts | gsed -E "s|^\S+\s+||")
if [[ -z $official_hostname_n_aliases ]]; then
pr "Unable to find official hostname & aliases with:"
......@@ -363,10 +363,18 @@ eof
fi
hosts_bkp=$($DATE "+/etc/hosts.bkp.ipv6-tools_off_to_static_%Y.%m.%d_%Hh%Mm%Ss")
ipv6=${ipv6_n_prefix/%\/*/}
mv /etc/hosts ${hosts_bkp}
cp /etc/hosts ${hosts_bkp}
grep -vw "${ipv6}" ${hosts_bkp} \
| gsed "/${ipv4}/i ${ipv6} ${official_hostname_n_aliases}" \
> /etc/hosts
> /etc/inet/hosts
if [[ $(readlink /etc/hosts) != "./inet/hosts" ]]; then
pr "The command (readlink /etc/hosts) return a value different from ''./inet/hosts'."
pb "The host part did:"
pb " - cp /etc/hosts ${hosts_bkp}"
pb " - create a new /etc/inet/hosts with the ipv6 stuff"
pb "Exit !"
exit 1
fi
pg "done"
#
# à la mano
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment