Browse code

Merge "Use cat instead of read<file"

Jenkins authored on 2014/03/07 01:24:12
Showing 1 changed files
... ...
@@ -57,6 +57,18 @@ function configure_nova_hypervisor {
57 57
     iniset $GLANCE_API_CONF DEFAULT container_formats ami,ari,aki,bare,ovf,docker
58 58
 }
59 59
 
60
+# is_docker_running - Return 0 (true) if Docker is running, otherwise 1
61
+function is_docker_running {
62
+    local docker_pid
63
+    if [ -f "$DOCKER_PID_FILE" ]; then
64
+        docker_pid=$(cat "$DOCKER_PID_FILE")
65
+    fi
66
+    if [[ -z "$docker_pid" ]] || ! ps -p "$docker_pid" | grep [d]ocker; then
67
+        return 1
68
+    fi
69
+    return 0
70
+}
71
+
60 72
 # install_nova_hypervisor() - Install external components
61 73
 function install_nova_hypervisor {
62 74
     # So far this is Ubuntu only
... ...
@@ -69,19 +81,15 @@ function install_nova_hypervisor {
69 69
         die $LINENO "Docker is not installed.  Please run tools/docker/install_docker.sh"
70 70
     fi
71 71
 
72
-    local docker_pid
73
-    read docker_pid <$DOCKER_PID_FILE
74
-    if [[ -z $docker_pid ]] || ! ps -p $docker_pid | grep [d]ocker; then
72
+    if ! (is_docker_running); then
75 73
         die $LINENO "Docker not running"
76 74
     fi
77 75
 }
78 76
 
79 77
 # start_nova_hypervisor - Start any required external services
80 78
 function start_nova_hypervisor {
81
-    local docker_pid
82
-    read docker_pid <$DOCKER_PID_FILE
83
-    if [[ -z $docker_pid ]] || ! ps -p $docker_pid | grep [d]ocker; then
84
-        die $LINENO "Docker not running, start the daemon"
79
+    if ! (is_docker_running); then
80
+        die $LINENO "Docker not running"
85 81
     fi
86 82
 
87 83
     # Start the Docker registry container