Developing lightweight computation at the DSG edge

Commit 3fa358b6 authored by p4u's avatar p4u
Browse files

Added condition to qmp_set_host to do not rewrite hosts file if the entry already exists

parent a769cbf2
......@@ -793,9 +793,11 @@ qmp_set_hosts() {
return
fi
cat /etc/hosts | grep -v qmpadmin > /tmp/hosts.tmp
echo "$ip $hn admin.qmp qmpadmin" >> /tmp/hosts.tmp
cp /tmp/hosts.tmp /etc/hosts
if [ $(cat /etc/hosts | grep qmpadmin | grep "^$ip" -c) -eq 0 ]; then
cat /etc/hosts | grep -v qmpadmin > /tmp/hosts.tmp
echo "$ip $hn admin.qmp qmpadmin" >> /tmp/hosts.tmp
cp /tmp/hosts.tmp /etc/hosts
fi
echo "done"
}
......
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