dotfiles/recipes/browserpass

61 lines
2.1 KiB
Bash

#!/bin/bash
# Description: A browser plugin for the pass password store
set -e
function _browserpass {
local browser=$1
local _prefix=$HOME/.local
case $_PLATFORM in
darwin)
_prefix=/usr/local/opt/browserpass
;;
arch)
_prefix=/usr
;;
esac
_run "[browserpass] Installing native messaging host to $browser" \
make PREFIX=$_prefix hosts-$browser-user \
-f $_prefix/lib/browserpass/Makefile
}
case $_PLATFORM in
darwin)
_recipe brew
_brew_tap amar1729/formulae
_brew browserpass
test -e /Applications/Google\ Chrome.app && _browserpass chrome
test -e /Applications/Firefox.app && _browserpass firefox
;;
arch)
_recipe _arch
if command -v chromium 2>&1 >/dev/null \
|| command -v google-chrome 2>&1 >/dev/null \
|| command -v google-chrome-stable 2>&1 >/dev/null; then
_pacman browserpass-chromium
fi
if command -v firefox 2>&1 >/dev/null \
|| command -v firedragon 2>&1 >/dev/null; then
_pacman browserpass-firefox
fi
if command -v google-chrome 2>&1 >/dev/null \
|| command -v google-chrome-stable 2>&1 >/dev/null; then
_browserpass chrome
fi
;;
*)
if ! test -d ~/.local/lib/browserpass; then
echo "[curl] Downloading browserpass native"
local tempdir=$(mktemp -d)
curl -sL https://github.com/browserpass/browserpass-native/releases/download/3.0.6/browserpass-linux64-3.0.6.tar.gz \
| tar xz -C "$tempdir" --strip-components=1
pushd "$tempdir" >/dev/null
_run "[make] Install browserpass" make PREFIX=$HOME/.local BIN=browserpass-linux64 configure install
popd >/dev/null
rm -rf "$tempdir"
fi
command -v chromium-browser 2>&1 >/dev/null && _browserpass chromium
command -v google-chrome 2>&1 >/dev/null && _browserpass chrome
command -v firefox 2>&1 >/dev/null && _browserpass firefox
esac