[snmp] Configure snmp docker hostname from config DB (#2773)

* [snmp] Configure snmp docker hostname from config DB
* Fixed reviewer comments
This commit is contained in:
Vitaliy Senchyshyn 2019-04-16 21:09:05 +03:00 committed by Qi Luo
parent 1aa258d3cb
commit 16927f5844

View File

@ -9,6 +9,17 @@ sonic-cfggen -d -y /etc/sonic/snmp.yml -t /usr/share/sonic/templates/snmpd.conf.
mkdir -p /var/sonic mkdir -p /var/sonic
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status
CURRENT_HOSTNAME=`hostname`
HOSTNAME=`sonic-cfggen -d -v DEVICE_METADATA[\'localhost\'][\'hostname\']`
if [ "$?" == "0" ] && [ "$HOSTNAME" != "" ]; then
echo $HOSTNAME > /etc/hostname
hostname -F /etc/hostname
sed -i "/\s$CURRENT_HOSTNAME$/d" /etc/hosts
echo "127.0.0.1 $HOSTNAME" >> /etc/hosts
fi
rm -f /var/run/rsyslogd.pid rm -f /var/run/rsyslogd.pid
supervisorctl start rsyslogd supervisorctl start rsyslogd