You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2019/01/16 08:08:49 UTC

[cloudstack] 01/02: keystore: restart systemvm cloud.service only when old keystore exist

This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch agent-reconnect-fix
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit 658dae49f25f7875180ace072e59e23e5db03ce9
Author: Rohit Yadav <ro...@shapeblue.com>
AuthorDate: Wed Jan 16 13:31:13 2019 +0530

    keystore: restart systemvm cloud.service only when old keystore exist
    
    This ensures that the systemvm agent (cloud.service) is not restarted
    when old keystore does not exist. However, on subsequent reboots of
    systemvm this will try to restart cloud.service after importing X509
    certificates.
    
    Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
---
 scripts/util/keystore-cert-import | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/scripts/util/keystore-cert-import b/scripts/util/keystore-cert-import
index 96196d9..6a2f1ac 100755
--- a/scripts/util/keystore-cert-import
+++ b/scripts/util/keystore-cert-import
@@ -41,6 +41,12 @@ fi
 # Use a new keystore file
 NEW_KS_FILE="$KS_FILE.new"
 
+# Check/store old KS state
+OLD_KS_FILE_EXISTS=false
+if [ -f $KS_FILE ]; then
+    OLD_KS_FILE_EXISTS=true
+fi
+
 # Import certificate
 if [ ! -z "${CERT// }" ]; then
     echo "$CERT" > "$CERT_FILE"
@@ -98,11 +104,10 @@ if [ -f "$SYSTEM_FILE" ]; then
     chmod 755 /usr/local/share/ca-certificates/cloudstack
     chmod 644 /usr/local/share/ca-certificates/cloudstack/ca.crt
     update-ca-certificates > /dev/null 2>&1 || true
-fi
-
-# Restart cloud service if we're in systemvm
-if [ "$MODE" == "ssh" ] && [ -f $SYSTEM_FILE ]; then
-    systemctl restart cloud > /dev/null 2>&1
+    # Restart cloud service if keystore was changed
+    if [ "$MODE" == "ssh" ] && $OLD_KS_FILE_EXISTS; then
+        systemctl restart cloud > /dev/null 2>&1
+    fi
 fi
 
 # Fix file permission