[PATCH] Add importer script for chrome csv.
Jeff Mendoza
jlm at jlm.name
Sat Mar 19 22:57:25 UTC 2022
---
contrib/importers/chromecsv2pass.sh | 43 +++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100755 contrib/importers/chromecsv2pass.sh
diff --git a/contrib/importers/chromecsv2pass.sh b/contrib/importers/chromecsv2pass.sh
new file mode 100755
index 0000000..872fdaa
--- /dev/null
+++ b/contrib/importers/chromecsv2pass.sh
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+# Copyright (C) 2022 Jeff Mendoza <jlm at jlm.name>. All Rights Reserved.
+# Copyright (C) 2013 Tom Hendrikx <tom at whyscream.net>. All Rights Reserved.
+# This file is licensed under the GPLv2+. Please see COPYING for more information.
+
+# Expect first argument to be a csv file with colums:
+# 'name,url,username,password'. Creates entries with name from 'name'
+# column. If that already exists: creates $name/2, $name/3, and so on.
+# Puts 'password' in first line with no prefix. Puts 'username' in
+# second line with 'login: ' prefix if that exists. Ignores 'url'
+# column. Skips any entry with empty 'name' or 'password'. The gpg key
+# must be unlocked for this to work.
+
+set -e
+
+export=$1
+
+IFS="," # comma
+cat "$export" | while read name url username password; do
+ [[ "$name" == "name" ]] && continue
+ [[ -z "$name" ]] && continue
+ [[ -z "$password" ]] && continue
+
+ entry="$password\n"
+ [[ -n "$username" ]] && entry="${entry}login: $username\n"
+
+ echo Adding entry for "$name":
+ rv=0
+ pass ls "$name" > /dev/null 2>&1 || rv=$?
+ if (( rv == 2 )); then
+ echo "Please unlock the key"
+ exit 1
+ fi
+ num=1
+ ogname="$name"
+ while (( rv == 0 )); do
+ (( num += 1 ))
+ name="${ogname}/${num}"
+ pass ls "$name" > /dev/null 2>&1 || rv=$?
+ done
+ echo -ne "$entry" | pass insert --multiline "$name"
+ echo "Added!"
+done
--
2.30.2
More information about the Password-Store
mailing list