Merge pull request #5 from rogsme/add-custom-bitwarden-instances
Add custom bitwarden instances
This commit is contained in:
commit
ceefe4a025
4
.env
4
.env
@ -1,4 +0,0 @@
|
|||||||
DATABASE_PASSWORD=CHANGE_ME
|
|
||||||
#DATABASE_KEYFILE=
|
|
||||||
BW_PATH=/usr/local/bin/bw
|
|
||||||
DATABASE_PATH=/exports/bitwarden-export.kdbx
|
|
@ -18,3 +18,5 @@ RUN pip install --no-cache-dir --upgrade pip && \
|
|||||||
pip install --no-cache-dir -r requirements.txt
|
pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
CMD ["./entrypoint.sh"]
|
||||||
|
44
entrypoint.sh
Executable file
44
entrypoint.sh
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Check that the database password is set
|
||||||
|
if [ -z "$DATABASE_PASSWORD" ]; then
|
||||||
|
echo "DATABASE_PASSWORD is not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If BITWARDEN_URL is not empty, set a custom Bitwarden instance
|
||||||
|
if [ "$BITWARDEN_URL" ]; then
|
||||||
|
echo "Connecting to Bitwarden instance at $BITWARDEN_URL"
|
||||||
|
bw config server "$BITWARDEN_URL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
BW_SESSION="$(bw login --raw)"
|
||||||
|
export BW_SESSION
|
||||||
|
|
||||||
|
if [ -z "$BW_SESSION" ]; then
|
||||||
|
echo "Failed to log in to Bitwarden"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set environment variables for the script
|
||||||
|
BW_PATH="$(which bw)"
|
||||||
|
export BW_PATH
|
||||||
|
|
||||||
|
if [ -z "$DATABASE_NAME" ]; then
|
||||||
|
DATABASE_NAME="bitwarden.kdbx"
|
||||||
|
fi
|
||||||
|
|
||||||
|
DATABASE_PATH="/exports/$DATABASE_NAME"
|
||||||
|
export DATABASE_PATH
|
||||||
|
|
||||||
|
|
||||||
|
# Convert the Bitwarden data to a KeePass file
|
||||||
|
bw sync || { echo "Failed to sync Bitwarden data"; exit 1; }
|
||||||
|
echo "Generating KeePass file $DATABASE_PATH"
|
||||||
|
python3 bitwarden-to-keepass.py || { echo "Failed to convert to KeePass"; exit 1; }
|
||||||
|
bw lock
|
||||||
|
|
||||||
|
echo "KeePass file $DATABASE_PATH generated successfully"
|
||||||
|
|
||||||
|
# Log out of Bitwarden
|
||||||
|
bw logout
|
Loading…
x
Reference in New Issue
Block a user