diff --git a/env_setup b/env_setup new file mode 100644 index 0000000000000000000000000000000000000000..c00cdd3ce434449c3fb8ef3446be0670ca1fd093 --- /dev/null +++ b/env_setup @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +# jsonenv reads a json object as input and produces +# escaped shell commands for setting environment vars + +import json +import pipes +import os +import sys + + + +for k, v in json.load(sys.stdin).items(): + k = pipes.quote(k) + v = pipes.quote(v) + print("%s=%s" % (k, v)) \ No newline at end of file diff --git a/setup_env.sh b/setup_env.sh new file mode 100644 index 0000000000000000000000000000000000000000..a034647deb314ac6c163cb8397d9b1773a35972b --- /dev/null +++ b/setup_env.sh @@ -0,0 +1,11 @@ +#!/bin/sh +chmode +x env_setup +cat > /run/secrets/my_secret > secrets.json +./env_setup <secrets.json >secrets.csv + + +IFS="=" +while read key value ; do + export $key=$value + echo "${key}=${value}" +done < secrets.csv