3 ### Issue cards containing a bunch of keeper secrets
5 ### (c) 2011 Mark Wooding
8 ###----- Licensing notice ---------------------------------------------------
10 ### This file is part of the distorted.org.uk key management suite.
12 ### distorted-keys is free software; you can redistribute it and/or modify
13 ### it under the terms of the GNU General Public License as published by
14 ### the Free Software Foundation; either version 2 of the License, or
15 ### (at your option) any later version.
17 ### distorted-keys is distributed in the hope that it will be useful,
18 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ### GNU General Public License for more details.
22 ### You should have received a copy of the GNU General Public License
23 ### along with distorted-keys; if not, write to the Free Software Foundation,
24 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 case "${KEYSLIB+t}" in t) ;; *) echo >&2 "$0: KEYSLIB unset"; exit 1 ;; esac
28 . "$KEYSLIB"/keyfunc.sh
31 [-pt] KEEPER [INDICES ...]
32 Typeset cards for a set of keeper secrets.
34 This program creates a set of printable cards containing key nubs from the
35 keeper set KEEPER, specifically the keys with the given INDICES. Elements of
36 the list are either simple integers or ranges [LOW]-[HIGH]; if LOW is
37 omitted, it means 0, and if HIGH is omitted, it means the highest possible
38 index. If no INDICES are given then all secret keys are written.
40 The public keys are found in $KEYS/keeper/KEEPER/I.pub;
41 key nubs are read from the safe place where \`keys new-keeper' left
44 If the \`-p' option is given, then the output is a PostScript file which
45 can be printed immediately. If the \`-t' option is given, then the output
46 is a \`tar' archive containing a TeX source file and images, which must
47 be processed using \`latex' and \`dvips'. The default is \`-t'.
52 while getopts "pt" opt; do
59 shift $(( $OPTIND - 1 ))
61 ## Parse the command line.
62 case $# in 0) usage_err ;; esac
64 checkword "keeper set label" "$keeper"
66 ## Find out about the set.
67 if [ ! -f $KEYS/keeper/$keeper/meta ]; then
68 echo >&2 "$quis: unknown keeper set \`$keeper'"
71 read n hunoz <$KEYS/keeper/$keeper/meta
73 ## Check that nubs are available for the keeper set.
75 if [ ! -d $SAFE/keys.keeper/$keeper/ ]; then
76 echo >&2 "$quis: no nubs available for keeper set \`$keeper'"
79 cd $SAFE/keys.keeper/$keeper/
81 ## Build a colon-separated list of the indices we actually want.
83 case $# in 0) set 0- ;; esac
86 *[!-0-9]* | *[!0-9]*-* | *-*[!0-9]*)
87 echo >&2 "$quis: bad index range \`$range'"
91 low=${range%-*} high=${range#*-}
94 low=$range high=$range
97 case "$low" in ?*) ;; *) low=0 ;; esac
98 case "$high" in ?*) ;; *) high=$(( $n - 1 )) ;; esac
99 if [ 0 -gt $low -o $low -gt $high -o $high -ge $n ]; then
100 echo >&2 "$quis: invalid index range \`$range'"
104 while [ $i -le $high ]; do
105 case $want in *:"$i":*) ;; *) want=$want$i: ;; esac
110 ## Start working on the output file. This will contain deep secrets, so
111 ## don't leave stuff easily readable.
114 exec 3>$tmp/$keeper.tex
115 cat >&3 $ETC/keeper-cards.tex
117 ## Write the basic configuration stuff.
120 %% General configuration for the cards.
125 ## Start the document body.
128 %% The actual content.
132 ## Work through the requested indices.
134 while [ $i -lt $n ]; do
138 tr -d '\n' <$i | qrencode -m0 -s1 -o$tmp/$i.png
139 convert $tmp/$i.png $tmp/$i.eps
147 ## Wrap up and build the document.
156 exec </dev/null >tex.out 2>&1
157 latex $keeper.tex && dvips -o$keeper.ps $keeper.dvi); then
158 echo >&2 "$quis: document formatting failed"
159 sed >&2 's/^/| /' $tmp/tex.out
165 (cd $tmp; tar cf - $keeper.tex *.eps)
169 ###----- That's all, folks --------------------------------------------------