adding script dir, vault scripts

This commit is contained in:
2025-05-22 10:52:56 +02:00
parent a9f91bb31c
commit 4b0ac8ea10
10 changed files with 230 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#!/usr/bin/env python3
import json
import sys
def env_to_json(file_path):
# Open dotenv file
with open(file_path, 'r') as file:
# Store dotenv variables in a dict
data = {}
for line in file:
# Ignore comment and empty lines
if line.startswith('#') or not line.strip():
continue
# Split key from value
key, value = line.strip().split("=", 1)
data[key] = value.replace('\'', '').replace('"', '')
# Convert to json
json_data = json.dumps(data, indent=4)
return json_data
def main():
print(env_to_json(sys.argv[1]))
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,18 @@
#!/usr/bin/env python3
import json
import sys
def json_to_env(json_string):
# Load json to dict
data = json.loads(json_string)
# Store value to string and print corresponding key
env_string = ""
for key, value in data.items():
env_string += f'{key}={value}\n'
return env_string
def main():
print(json_to_env(sys.argv[1]))
if __name__ == "__main__":
main()