From 84ed477ec2f1ae9ff0a43b0d0fbd2cbbe1a3608c Mon Sep 17 00:00:00 2001
From: Benjamin Brahmer <info@b-brahmer.de>
Date: Fri, 21 Oct 2022 15:50:14 +0200
Subject: [PATCH] add conditon to check for existing key and crt

Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
---
 Makefile | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 08b9dc45e..a67191f79 100644
--- a/Makefile
+++ b/Makefile
@@ -176,9 +176,12 @@ appstore:
 	cp js/build/news-admin-settings.js* $(appstore_sign_dir)/$(app_name)/js/build
 
 	# export the key and cert to a file
-	mkdir -p $(cert_dir)
-	php ./bin/tools/file_from_env.php "app_private_key" "$(cert_dir)/$(app_name).key"
-	php ./bin/tools/file_from_env.php "app_public_crt" "$(cert_dir)/$(app_name).crt"
+	@if [ ! -f $(cert_dir)/$(app_name).key ] || [ ! -f $(cert_dir)/$(app_name).crt ]; then \
+		echo "Key and cert do not exist"; \
+		mkdir -p $(cert_dir); \
+		php ./bin/tools/file_from_env.php "app_private_key" "$(cert_dir)/$(app_name).key"; \
+		php ./bin/tools/file_from_env.php "app_public_crt" "$(cert_dir)/$(app_name).crt"; \
+	fi
 
 	@if [ -f $(cert_dir)/$(app_name).key ]; then \
 		echo "Signing app files…"; \