Created
November 5, 2019 04:32
-
-
Save soasme/fdfb4535d864e07edd311187e5ae6012 to your computer and use it in GitHub Desktop.
chmod +x vault; ./vault bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import subprocess | |
from getpass import getpass | |
from pykeepass import PyKeePass | |
kp = PyKeePass(os.environ['VAULT_STORE_PATH'], password=os.environ.get('VAULT_STORE_PASSWORD') or getpass('password:')) | |
for entry in kp.entries: | |
if entry.username: | |
os.putenv(entry.title, f'{entry.username}:{entry.password}') | |
else: | |
os.putenv(entry.title, entry.password) | |
sys.exit(subprocess.check_call(sys.argv[1:])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment