cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [09/50] git commit: updated refs/heads/master to 1290e10
Date Mon, 22 Sep 2014 19:44:08 GMT
CLOUDSTACK-7143: cleanup configure_networking.sh code


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/71c913c6
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/71c913c6
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/71c913c6

Branch: refs/heads/master
Commit: 71c913c658583844a57c53ad5b997b4f1b414ea2
Parents: a533de7
Author: Leo Simons <lsimons@schubergphilis.com>
Authored: Mon Jul 21 11:42:27 2014 +0200
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Mon Sep 22 21:34:47 2014 +0200

----------------------------------------------------------------------
 .../systemvmtemplate/configure_networking.sh    | 43 +++++++++++++++-----
 1 file changed, 32 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/71c913c6/tools/appliance/definitions/systemvmtemplate/configure_networking.sh
----------------------------------------------------------------------
diff --git a/tools/appliance/definitions/systemvmtemplate/configure_networking.sh b/tools/appliance/definitions/systemvmtemplate/configure_networking.sh
index 4d1fcce..1d9f6b9 100644
--- a/tools/appliance/definitions/systemvmtemplate/configure_networking.sh
+++ b/tools/appliance/definitions/systemvmtemplate/configure_networking.sh
@@ -1,25 +1,46 @@
+#!/bin/bash
+
+set -e
+set -x
+
 HOSTNAME=systemvm
 
-echo "Adding a 2 sec delay to the interface up, to make the dhclient happy"
-echo "pre-up sleep 2" >> /etc/network/interfaces
+# Adding a 2 sec delay to the interface up, to make the dhclient happy
+function set_interface_sleep() {
+  grep "pre-up sleep 2" /etc/network/interfaces && return
+
+  echo "pre-up sleep 2" >> /etc/network/interfaces
+}
+
+function configure_resolv_conf() {
+  grep 8.8.8.8 /etc/resolv.conf && grep 8.8.4.4 /etc/resolv.conf && return
 
-fix_nameserver() {
-  # Replace /etc/resolv.conf also
   cat > /etc/resolv.conf << EOF
 nameserver 8.8.8.8
 nameserver 8.8.4.4
 EOF
 }
 
-fix_hostname() {
-  # Fix hostname in openssh-server generated keys
+# Delete entry in /etc/hosts derived from dhcp
+function delete_dhcp_ip() {
+  result=$(grep 127.0.1.1 /etc/hosts || true)
+  [ "${result}" == "" ] && return
+
+  sed -i '/127.0.1.1/d' /etc/hosts
+}
+
+function configure_hostname() {
   sed -i "s/root@\(.*\)$/root@$HOSTNAME/g" /etc/ssh/ssh_host_*.pub
-  # Fix hostname to override one provided by dhcp during vm build
+
   echo "$HOSTNAME" > /etc/hostname
   hostname $HOSTNAME
-  # Delete entry in /etc/hosts derived from dhcp
-  sed -i '/127.0.1.1/d' /etc/hosts
 }
 
-fix_hostname
-fix_nameserver
+function configure_networking() {
+  set_interface_sleep
+  configure_resolv_conf
+  delete_dhcp_ip
+  configure_hostname
+}
+
+return 2>/dev/null || configure_networking


Mime
View raw message