eid-mw: fix and improve eid-nssdb helper script

Now works. Good to know no-one else is using this :-)
This commit is contained in:
Tobias Geerinckx-Rice 2015-04-20 17:03:28 +02:00
parent 8eef55b0e0
commit 2454b943d7

View File

@ -3,12 +3,13 @@
rootdb="/etc/pki/nssdb"
userdb="$HOME/.pki/nssdb"
dbentry="Belgium eID"
libfile="/run/current-system/sw/libbeidpkcs11.so"
libfile="/run/current-system/sw/lib/libbeidpkcs11.so"
dbdir="$userdb"
case "$1" in
--help) cat << EOF
while true; do
case "$1" in
--help|"") cat << EOF
(Un)register $dbentry with NSS-compatible browsers.
Usage: `basename "$0"` [OPTION] ACTION [LIBRARY]
@ -27,14 +28,20 @@ Actions:
Default arguments if unspecified:
LIBRARY $libfile
EOF
exit ;;
--db) dbdir="$2"
shift 2 ;;
--user) shift ;;
--system)
dbdir="$rootdb"
shift ;;
esac
exit ;;
--db) dbdir="$2"
shift 2 ;;
--user) dbdir="$userdb"
shift ;;
--system)
dbdir="$rootdb"
shift ;;
-*) echo "$0: unknown option: '$1'" >&2
echo "Try --help for usage information."
exit 1 ;;
*) break ;;
esac
done
if [ "$2" ]; then
libfile="$2"
@ -50,9 +57,6 @@ if ! [ -d "$dbdir" ]; then
exit 1
fi
echo "NSS database: $dbdir"
echo "BEID library: $libfile"
dbdir="sql:$dbdir"
case "$1" in
@ -63,6 +67,7 @@ remove) echo "Removing $dbentry from database:"
modutil -dbdir "$dbdir" -delete "$dbentry" ;;
show) echo "Displaying $dbentry database entry, if any:"
echo "Note: this may fail if you don't have the correct permissions." ;;
'') exec "$0" --help ;;
*) echo "$0: unknown action: '$1'" >&2
echo "Try --help for usage information."
exit 1 ;;
@ -70,6 +75,9 @@ esac
ret=$?
echo "NSS database: $dbdir"
echo "BEID library: $libfile"
modutil -dbdir "$dbdir" -list "$dbentry" 2>/dev/null
exit $ret