From 9917bbe77466b90bed6e3aa18b0954986a6a13b1 Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Sun, 25 Oct 2020 10:30:26 +0100 Subject: Add file_from_env.php Signed-off-by: Benjamin Brahmer --- Makefile | 4 ++-- bin/tools/file_from_env.php | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 bin/tools/file_from_env.php diff --git a/Makefile b/Makefile index 55489464e..aab7591f2 100644 --- a/Makefile +++ b/Makefile @@ -164,8 +164,8 @@ appstore: cp js/admin/Admin.js $(appstore_sign_dir)/$(app_name)/js/admin # export the key and cert to a file - printf "%s" "$(app_private_key)" > "$(cert_dir)/$(app_name).key" - printf "%s" "$(app_public_crt)" > "$(cert_dir)/$(app_name).crt" + 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 ]; then \ echo "Signing app files…"; \ diff --git a/bin/tools/file_from_env.php b/bin/tools/file_from_env.php new file mode 100755 index 000000000..e63cda1c4 --- /dev/null +++ b/bin/tools/file_from_env.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php + + * @copyright Benjamin Brahmer 2020 +*/ + +if ($argc < 2) { + echo "This script expects two parameters:\n"; + echo "./file_from_env.php ENV_VAR PATH_TO_FILE\n"; + exit; +} + +# Read environment variable +$content = getenv($argv[1]); + +file_put_contents($argv[2], $content); + +echo "Done...\n"; \ No newline at end of file -- cgit v1.2.3