42 lines
1,019 B
Nix
42 lines
1,019 B
Nix
{pkgs, ...}: {
|
|
home.file."bin/git-credential-rbw".text = ''
|
|
#${pkgs.bash}/bin/bash
|
|
|
|
declare -A params
|
|
|
|
if [ "x$1" == "xget" ]; then
|
|
read line
|
|
while [ -n "$line" ]; do
|
|
key=''${line%%=*}
|
|
value=''${line#*=}
|
|
params[$key]=$value
|
|
read line
|
|
done
|
|
|
|
if [ "''${params['protocol']}" != "xhttps" ]; then
|
|
exit
|
|
fi
|
|
|
|
if [ -z "''${params["host"]}" ]; then
|
|
exit
|
|
fi
|
|
|
|
rbw ls > /dev/null 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
echo "Please login to rbw to use git credential helper" > /dev/stderr
|
|
exit
|
|
fi
|
|
|
|
user=`rbw get --full ''${params["host"]} | grep "Username:" | cut -d' ' -f2-`
|
|
pass=`rbw get ''${params["host"]}`
|
|
|
|
if [ "x$user" == "x" ] || [ "x$pass" == "x" ]; then
|
|
echo "Couldn't find host in rbw DB." > /dev/stderr
|
|
exit
|
|
fi
|
|
|
|
echo username=$user
|
|
echo password=$pass
|
|
fi
|
|
'';
|
|
}
|