3 ### Delete a keeper set
5 ### (c) 2012 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
32 Delete the keeper set named KEEPER.
35 case $# in 1) ;; *) usage_err ;; esac
37 checkword "keeper set label" "$keeper"
40 if [ ! -d $keeper ]; then
41 echo >&2 "$quis: unknown keeper set \`$keeper'"
46 if [ -d $KEYS/recov ]; then
48 for r in $(find . -type l -name current -print); do
49 r=${r#./}; r=${r%/current}
50 if ! expr >/dev/null "Q$r" : "Q$R_LABEL"; then continue; fi
53 case "$i" in *[!0-9]*) continue ;; esac
55 for kp in $r/current/*.param; do
56 k=${kp##*/}; k=${k%.param}
57 case $k in $keeper) this=t ;; *) others=t ;; esac
59 case $this,$others in t,nil) deps="$deps $ri" ;; esac
65 echo >&2 "$quis: deleting keeper \`$keeper' would orphan recovery keys:"
66 for d in $deps; do echo 2>&1 " $d"; done
71 if [ -d $KEYS/recov ]; then
73 for r in $(find . -type l -name current -print); do
74 r=${r#./}; r=${r%/current}
75 if ! expr >/dev/null "Q$r" : "Q$R_LABEL"; then continue; fi
78 case "$i" in *[!0-9]*) continue ;; esac
83 case $k in $keeper) changep=t ;; *) echo "$k $rest" ;; esac
84 done <$r/keepers >$r/keepers.new
86 t) mv $r/keepers.new $r/keepers ;;
87 nil) rm $r/keepers.new ;;
95 ###----- That's all, folks --------------------------------------------------