1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
#!/bin/sh
# check if any of the systemwide RC files contains a database statement
# Patch provided by ravenx99 at users.sourceforge.net
for RCFILE in ${HOME}/.cpmrc /etc/cpm/cpmrc /etc/cpmrc; do
if [ -r ${RCFILE} ]; then
FILE=`grep "^DatabaseFile" ${RCFILE} |cut --delimiter=" " --field="2"`
break
fi
done
FILE="${FILE:-${HOME}/.cpmdb}"
# we keep the original arguments
ARGUMENTS="${*}"
# we parse the options to find the database file we are about to process
TEMP=`getopt -n "$0" --options c:e:f:hirs --long config:,configtest,encoding:,file:,help,ignore,key:,noencryption,noignore,readonly,regex,regular,security,version -- "$@"`
if [ ${?} != 0 ]; then
echo "Syntax error." >&2
exit 1
fi
eval set -- "$TEMP"
while true; do
case "${1}" in
-c|--config)
shift
;;
--configtest)
;;
-e|--encoding)
shift
;;
-f|--file)
FILE="${2}"
shift
;;
-h|--help)
;;
-i|--ignore)
;;
--key)
shift
;;
--noencryption)
;;
--noignore)
;;
--readonly)
;;
-r|--regex)
;;
--regular)
;;
-s|--security)
;;
--version)
;;
--) # finished parsing options
shift
break
;;
*)
echo "Internal error." >&2
exit 1
;;
esac
shift
done
# now that we know the file, we can ask gpg to tell us about the recipients
# used in the file.
KEYS=""
for KEYID in `gpg --list-only --status-fd=1 "${FILE}" 2> /dev/null | \
grep "ENC_TO" | cut --delimiter=" " --field="3"`; do
KEYNAME=`gpg --list-key "${KEYID}" | grep uid | sed -e 's/^.*<\([^>]\+\)>.*$/\1/'`
KEYS="${KEYS} --key=${KEYNAME}"
done
cpm.bin ${KEYS} ${ARGUMENTS}
|