diff --git a/setup.sh b/setup.sh index 7451d49..db892c2 100644 --- a/setup.sh +++ b/setup.sh @@ -35,7 +35,8 @@ echo "==> Installing dependencies..." dnf install -y git-crypt dnf module install -y nodejs:20/common -if ! command -v bw &>/dev/null; then +BW_CLI="$(npm config get prefix)/bin/bw" +if [ ! -x "$BW_CLI" ]; then echo "==> Installing Bitwarden CLI..." npm install -g @bitwarden/cli fi @@ -47,16 +48,16 @@ cd "$REPO_DIR" && git checkout -- . echo "==> Unlocking git-crypt via Bitwarden..." echo " Log in to Bitwarden when prompted." -if bw status 2>/dev/null | grep -q '"status":"unauthenticated"'; then - bw login +if "$BW_CLI" status 2>/dev/null | grep -q '"status":"unauthenticated"'; then + "$BW_CLI" login fi -BW_SESSION=$(bw unlock --raw) -bw sync --session "$BW_SESSION" -bw get notes hantim-git-crypt-key --session "$BW_SESSION" | base64 -d > /tmp/git-crypt-key +BW_SESSION=$("$BW_CLI" unlock --raw) +"$BW_CLI" sync --session "$BW_SESSION" +"$BW_CLI" get notes hantim-git-crypt-key --session "$BW_SESSION" | base64 -d > /tmp/git-crypt-key cd "$REPO_DIR" git-crypt unlock /tmp/git-crypt-key rm /tmp/git-crypt-key -bw lock +"$BW_CLI" lock # --- Install Docker ---