50 lines
1.4 KiB
Bash
50 lines
1.4 KiB
Bash
export APP_ENTRYPOINT_VERSION=v4
|
|
APP_DIR="app:/data"
|
|
|
|
insert_vaultwarden_admin_token() {
|
|
if ! command -v argon2 &> /dev/null; then
|
|
echo "argon2 is required on your local machine to hash the admin token."
|
|
echo "It could not be found in your PATH, please install argon2 to proceed."
|
|
echo "For example: On a debian/ubuntu system, run `apt install argon2`"
|
|
exit 1
|
|
fi
|
|
PASS=$(openssl rand 64 | openssl enc -A -base64)
|
|
# -e: output encoded hash, -id: use Argon2id, -k: memory cost, -t: time cost, -p: parallelism
|
|
HASH=$(echo -n "$PASS" | argon2 "$(openssl rand -base64 32)" -e -id -k 65540 -t 3 -p 4)
|
|
|
|
if abra app secret insert -C "$APP_NAME" admin_token v1 "$HASH"; then
|
|
echo "Vaultwarden Admin Token is:"
|
|
echo "$PASS"
|
|
echo "TAKE NOTE OF IT NOW, WILL NEVER BE SHOWN AGAIN!"
|
|
else
|
|
echo "Failed to insert admin token."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
_backup_app() {
|
|
# Copied _abra_backup_dir to make UX better on restore and backup
|
|
{
|
|
abra__src_="$1"
|
|
abra__dst_="-"
|
|
}
|
|
|
|
# shellcheck disable=SC2154
|
|
FILENAME="$(basename "$1").tar"
|
|
|
|
debug "Copying '$1' to '$FILENAME'"
|
|
|
|
silence
|
|
mkdir -p /tmp/abra
|
|
sub_app_cp > /tmp/abra/$FILENAME
|
|
unsilence
|
|
}
|
|
|
|
abra_backup_app() {
|
|
# shellcheck disable=SC2154
|
|
ARK_FILENAME="$ABRA_BACKUP_DIR/${abra__app_}_app_$(date +%F).tar.gz"
|
|
# Cant be FILENAME as that gets changed by something
|
|
_backup_app $APP_DIR
|
|
success "Backed up 'app' to $ARK_FILENAME"
|
|
}
|