Skip to content
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

Configure dhcp_relay container hostname from config DB #2820

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions dockers/docker-dhcp-relay/start.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#!/usr/bin/env bash

CURRENT_HOSTNAME=`hostname`
HOSTNAME=`sonic-cfggen -d -v DEVICE_METADATA[\'localhost\'][\'hostname\']`

if [ "$?" == "0" ] && [ "$HOSTNAME" != "" ]; then
echo $HOSTNAME > /etc/hostname
hostname -F /etc/hostname

tempfile=`mktemp -q -t hosts.XXXX`
sed "/\s$CURRENT_HOSTNAME$/d" /etc/hosts > $tempfile
echo "127.0.0.1 $HOSTNAME" >> $tempfile
cat $tempfile > /etc/hosts && rm $tempfile
fi

# Remove stale rsyslog PID file if it exists
rm -f /var/run/rsyslogd.pid

Expand Down
6 changes: 4 additions & 2 deletions dockers/docker-snmp-sv2/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ 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
tempfile=`mktemp -q -t hosts.XXXX`
sed "/\s$CURRENT_HOSTNAME$/d" /etc/hosts > $tempfile
echo "127.0.0.1 $HOSTNAME" >> $tempfile
cat $tempfile > /etc/hosts && rm $tempfile
Copy link
Collaborator

@qiluo-msft qiluo-msft Apr 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& [](start = 31, length = 2)

Better use ; #Closed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

fi

rm -f /var/run/rsyslogd.pid
Expand Down