-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[snmp] Configure snmp docker hostname from config DB #2773
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,15 @@ sonic-cfggen -d -y /etc/sonic/snmp.yml -t /usr/share/sonic/templates/snmpd.conf. | |
mkdir -p /var/sonic | ||
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status | ||
|
||
CURRENT_HOSTNAME=`hostname` | ||
HOSTNAME=`sonic-cfggen -d -v DEVICE_METADATA[\'localhost\'][\'hostname\']` | ||
|
||
echo $HOSTNAME > /etc/hostname | ||
hostname -F /etc/hostname | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In this case /etc/hostname will contain the old hostname. #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @qiluo-msft Or you meant only this line: "hostname -F /etc/hostname"? If yes, this can be changed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
sed -i "/\s$CURRENT_HOSTNAME$/d" /etc/hosts | ||
echo "127.0.0.1 $HOSTNAME" >> /etc/hosts | ||
|
||
rm -f /var/run/rsyslogd.pid | ||
|
||
supervisorctl start rsyslogd | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you handle command error or empty hostname cases? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added validation. Please check.