Reverted back to only using environment variables
This commit is contained in:
parent
57ce4a90e6
commit
844202f960
@ -3,7 +3,6 @@ import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from typing import Dict, List, Optional
|
||||
@ -24,17 +23,13 @@ logging.basicConfig(
|
||||
|
||||
kp: Optional[PyKeePass] = None
|
||||
|
||||
NOW = datetime.now().strftime('%Y-%m-%d-%s')
|
||||
DATABASE_PATH = f'/exports/vaultwarden-{NOW}.kdbx'
|
||||
|
||||
|
||||
def bitwarden_to_keepass(args):
|
||||
global kp
|
||||
try:
|
||||
kp = PyKeePass(DATABASE_PATH, password=args.database_password, keyfile=args.database_keyfile)
|
||||
kp = PyKeePass(args.database_path, password=args.database_password, keyfile=args.database_keyfile)
|
||||
except FileNotFoundError:
|
||||
logging.info('KeePass database does not exist, creating a new one.')
|
||||
kp = create_database(DATABASE_PATH, password=args.database_password, keyfile=args.database_keyfile)
|
||||
kp = create_database(args.database_path, password=args.database_password, keyfile=args.database_keyfile)
|
||||
except CredentialsError as e:
|
||||
logging.error(f'Wrong password for KeePass database: {e}')
|
||||
return
|
||||
@ -191,6 +186,11 @@ parser.add_argument(
|
||||
help='Session generated from bitwarden-cli (bw login)',
|
||||
**environ_or_required('BW_SESSION'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--database-path',
|
||||
help='Path to KeePass database. If database does not exists it will be created.',
|
||||
**environ_or_required('DATABASE_PATH'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--database-password',
|
||||
help='Password for KeePass database',
|
||||
|
@ -10,9 +10,12 @@ export BW_SESSION
|
||||
BW_PATH="$(which bw)"
|
||||
export BW_PATH
|
||||
|
||||
DATABASE_PATH="/exports/$DATABASE_NAME"
|
||||
export DATABASE_PATH
|
||||
|
||||
# Convert the VaultWarden data to a KeePass file
|
||||
bw sync
|
||||
python3 bitwarden-to-keepass.py
|
||||
bw lock
|
||||
|
||||
echo "KeePass file created successfully!"
|
||||
echo "KeePass file $DATABASE_NAME generated successfully"
|
||||
|
Loading…
x
Reference in New Issue
Block a user