Add cert expiration check to offline image

Docker cert will expire after 90d of offline image generation,
we have to regenerate it in order to start docker-swarm service.

PROD-21676
PROD-36329

Change-Id: I5568bda90c54264625e65803f207dc16271695db
diff --git a/mirror-image/template.json b/mirror-image/template.json
index 59e477c..94e9b69 100644
--- a/mirror-image/template.json
+++ b/mirror-image/template.json
@@ -93,8 +93,7 @@
         "scripts/security.sh",
         "scripts/info.sh",
         "scripts/cleanup.sh",
-        "scripts/cleanup_salt.sh",
-        "scripts/flush_disk.sh"
+        "scripts/cleanup_salt.sh"
       ]
     },
     {
@@ -106,6 +105,31 @@
       "type": "file",
       "source": "files/etc/cloud/cloud.cfg",
       "destination": "/etc/cloud/cloud.cfg"
+    },
+    {
+      "type": "file",
+      "source": "files/usr/local/bin/dockerswarm_cert.sh",
+      "destination": "/tmp/dockerswarm_cert.sh"
+    },
+    {
+      "type": "shell",
+      "inline": ["mkdir -p /usr/local/bin",
+                 "mv /tmp/dockerswarm_cert.sh /usr/local/bin/dockerswarm_cert.sh",
+                 "chmod +x /usr/local/bin/dockerswarm_cert.sh"]
+    },
+    {
+      "type": "file",
+      "source": "files/etc/systemd/system/dockerswarm_cert.service",
+      "destination": "/etc/systemd/system/dockerswarm_cert.service"
+    },
+    {
+      "type": "shell",
+      "inline": ["systemctl enable dockerswarm_cert.service"]
+    },
+    {
+      "type": "shell",
+      "pause_before": "60s",
+      "scripts": ["scripts/flush_disk.sh"]
     }
   ],
   "builders": [