Commit f8f60b78 authored by amnesia's avatar amnesia
Browse files

NM htp hook: cleanup /etc/hosts before leaving.

parent f3742057
......@@ -54,8 +54,26 @@ fi
echo "Will use these nameservers: ${NAME_SERVERS}" >>$LOG
cleanup_etc_hosts() {
echo "FIXME: cleanup /etc/hosts" >>$LOG
true
echo "Cleaning /etc/hosts" >>$LOG
local tempfile
tempfile=`mktemp --tmpdir=/tmp nm-htp.XXXXXXXX`
echo "tempfile: ${tempfile}" >>$LOG
where=outside
cat /etc/hosts | while read line ; do
if [ "$where" = inside ]; then
if [ "$line" = "$END_MAGIC" ]; then
where=outside
fi
else
if [ "$line" = "$BEGIN_MAGIC" ]; then
where=inside
else
echo "$line" >> $tempfile
fi
fi
done
chmod 644 "$tempfile"
mv "$tempfile" /etc/hosts
}
echo "${BEGIN_MAGIC}" >> /etc/hosts
......
Supports Markdown
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