#!/bin/env sh

addApplications bitwarden-cli zenity openbsd-netcat

addGitInstall "bitwarden-daemon" "ssh://git@git.php.fail:2222/neintonine/bitwarden-daemon.git" setupBitwardenDaemon

setupBitwardenDaemon() {
  npm install
  npm run build
  sudo npm install -g .
}

setupBitwardenCli() {
  url=$(bw status | jq ".serverUrl" -r)
  if [[ $url != "null" ]]; then
    return 0
  fi

  read -p "-- Which server do you want to use for bitwarden? " -r BW_SERVER
  bw config server $BW_SERVER
}

addActions setupBitwardenCli
