[satlab] Use satlab hostname variable created by upstart config

BUG=b:214092523

Change-Id: Id73ec25e6a7ae5e37525396f3a3f915bd4a5ce7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/satlab/+/3449699
Reviewed-by: Otabek Kasimov <otabek@google.com>
Reviewed-by: Gregory Nisbet <gregorynisbet@google.com>
Commit-Queue: Anh Le <anhdle@chromium.org>
Tested-by: Anh Le <anhdle@chromium.org>
diff --git a/src/dockerfiles/compose/compose_startup.sh b/src/dockerfiles/compose/compose_startup.sh
index ad9d5b3..6367db2 100644
--- a/src/dockerfiles/compose/compose_startup.sh
+++ b/src/dockerfiles/compose/compose_startup.sh
@@ -56,12 +56,17 @@
     docker-compose -f ./docker-compose.watchtower.yaml pull
     docker-compose -f ./docker-compose.watchtower.yaml up -d
 
+    # if DRONE_HOSTNAME is not set via upstart. Create hostname from product ID.
+    if [[ -z "${DRONE_HOSTNAME}" ]]; then
+      DRONE_HOSTNAME="satlab"
+      MACADDR=$(echo "$(get_host_identifier)" | awk '{print tolower($0)}')
+      DRONE_HOSTNAME="${DRONE_HOSTNAME}-${MACADDR}"
+      echo "Drone Name: ${DRONE_HOSTNAME}"
+    fi
+    export DRONE_HOSTNAME
+
     docker-compose pull dns
     docker-compose up -d dns
-    DRONE_HOSTNAME="satlab"
-    MACADDR=$(echo "$(get_host_identifier)" | awk '{print tolower($0)}')
-    export DRONE_HOSTNAME="${DRONE_HOSTNAME}-${MACADDR}"
-    echo "Drone Name: ${DRONE_HOSTNAME}"
     docker-compose pull drone gsa_server openssh_server nginx
     docker-compose up -d drone gsa_server openssh_server nginx