root/10kz/shell/get-secret-keys.jm3

Revision 45, 1.0 kB (checked in by jm3, 2 years ago)
  • added additional config file variable and removed some hardcoded references to the root dir.
  • Nb. there are *still* some hardcoded paths inside the perl file... *we have* to fix these before we can beta!!!
  • added additional error dump to gm script
  • Property svn:executable set to *
  • Property svn:keywords set to Id
Line 
1 #!/bin/bash
2 # $Id$
3
4 # pull in config params like KEY_HOME, GPG_HOME, and app ROOT
5 . configure.sh
6
7 HOMEDIR=$KEY_HOME
8 gpg=$GPG_HOME/gpg
9
10 echo Content-type: text/XML
11 echo
12 echo '<?xml version="1.0"?>'
13
14 echo "<keys>"
15
16 # regexes in order:
17 #    remove leading "sec "
18 #    remove angle brackets
19 #    ...
20 #    strip any invalid chars to ensure well-formed XML
21 #    include the key ID in the attribute AND in the text child node
22 #    change the separators to /'s for readability
23 num_keys=`$gpg --list-secret-keys --no-permission-warning --homedir $HOMEDIR | grep \^sec | wc -l | awk '{print $1}'`
24 return_val=$?
25
26 if [ $num_keys -eq 0 ]
27 then
28         echo "<error>no keys or GPG error: $return_val</error>"
29         echo "</keys>"
30         exit 1
31 fi
32
33 $gpg --list-secret-keys --no-permission-warning --homedir $HOMEDIR | grep '^sec' \
34         | sed "s:^sec .*/::" \
35         | sed "s:<:(:g" \
36         | sed "s:>:):g" \
37         | sed "s:[^0-9a-zA-Z@() -]:.:g" \
38         | sed "s/^\([0-9A-F]*\) \(.*\)$/<option value='\1'>\1 \/ \2<\/option>/" \
39         | sed "s:\(-[0-9][0-9] \):\1 / :"
40 ret_val=$?
41
42 echo "</keys>"
43 echo
44
Note: See TracBrowser for help on using the browser.