Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: image_to_live.sh

Issue 3829002: Change hostname to ip address if we can get it from ifconfig. (Closed) Base URL: http://git.chromium.org/git/crosutils.git
Patch Set: Cleanup Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: image_to_live.sh
diff --git a/image_to_live.sh b/image_to_live.sh
index 26a52997dee7e5768086241fdf924fa402b94826..6329cafc2f93b66dbd3e3816d4a31311e3682d6e 100755
--- a/image_to_live.sh
+++ b/image_to_live.sh
@@ -69,6 +69,20 @@ function remote_reboot_sh {
remote_sh "$@"
}
+# Returns the hostname of this machine.
+# It tries to find the ipaddress using ifconfig, however, it will
+# default to $HOSTNAME on failure. We try to use the ip address first as
+# some targets may have dns resolution issues trying to contact back
+# to us.
+function get_hostname {
+ local hostname
+ # Try to parse ifconfig for ip address
+ hostname=$(ifconfig eth0 \
+ | grep 'inet addr' \
+ | sed 's/.\+inet addr:\(\S\+\).\+/\1/') || hostname=${HOSTNAME}
+ echo ${hostname}
+}
+
# Reinterprets path from outside the chroot for use inside.
# $1 - The path to reinterpret.
function reinterpret_path_for_chroot() {
@@ -169,7 +183,7 @@ function get_devserver_url {
local devserver_url=""
if [ ${FLAGS_ignore_hostname} -eq ${FLAGS_TRUE} ]; then
if [ -z ${FLAGS_update_url} ]; then
- devserver_url="http://$HOSTNAME:${FLAGS_devserver_port}/update"
+ devserver_url="http://$(get_hostname):${FLAGS_devserver_port}/update"
else
devserver_url="${FLAGS_update_url}"
fi
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698