Skip to content

Instantly share code, notes, and snippets.

@soasme
Created November 5, 2019 04:32
Show Gist options
  • Save soasme/fdfb4535d864e07edd311187e5ae6012 to your computer and use it in GitHub Desktop.
Save soasme/fdfb4535d864e07edd311187e5ae6012 to your computer and use it in GitHub Desktop.
chmod +x vault; ./vault bash
#!/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