5 # Each note is just a file. Stored under /var/spool/admin/notes/[open|ack]/<package>/<note>
8 # note ack <note> - moves note to "acknowledged" spool
9 # note list [package] show notes for a given package, or all notes
10 # note delete <note> - delete a note from the system
11 # note edit <package> [file] - edit or create a note
14 # discard unchanged new note file
15 # quiet options to suppress new note name echo
16 # semi-quiet to just output the number
17 # renumber? to renumber all notes/reset sequence
19 # clean up unlocked temp files
21 : ${ZPMSPOOL:=/var/lib/admin/notes}
29 #cd $SPOOL || { echo "can't chdir to $SPOOL" ; exit 1; }
31 [ -z "$1" ] && set list
39 file=$(find $ZPMSPOOL -type f -name "$1")
40 if [ -z "$file" ] ; then
41 [ -z "$quiet" ] || printf "no such note $1\n" 1>&2
48 file=$(find $ZPMSPOOL/open -type f -name "$1")
49 if [ -z "$file" ] ; then
50 [ -z "$quiet" ] || printf "no such open note $1\n" 1>&2
58 notefile=$(findnote $1)
59 printf "%s\n" $(basename $(dirname $notefile))
63 -a) find $ZPMSPOOL/ack -type f -printf '%P\n' | sort -n
65 *) find $ZPMSPOOL/open -type f -printf '%P\n' | sort -n
70 len=$(find $ZPMSPOOL/open -type f -printf "%P\n" | awk ' { if ( length > x ) { x = length } }END{ print x }')
71 find $ZPMSPOOL/open -type f -printf "%P\n" | sort -n | while read note ; do
72 subject=$(head -1 $ZPMSPOOL/open/$note)
73 date=$(stat -c '%y' $ZPMSPOOL/open/$note | cut -f1 -d' ')
74 owner=$(stat -c '%U' $ZPMSPOOL/open/$note)
75 printf '%*s %8s %s %s\n' $len $note $owner "$date" "$subject"
80 subfile=$(echo $file | sed -e "s|$ZPMSPOOL/open/||")
81 filedir=$(dirname $subfile)
82 mkdir -p $ZPMSPOOL/ack/$filedir
83 mv $file $ZPMSPOOL/ack/$filedir
86 # new -- edit a new file for package general (or ZPMNOTEPACKAGE)
87 # new package -- edit a new note for package
88 # new package file -- use file for new package note
89 if [ $# -eq 0 ]; then set ${ZPMNOTEPACKAGE:-general}; fi
91 # edit a new file for the note
93 tmp=$(mktemp -p $ZPMSPOOL/open)
95 [ -f $ZPMSPOOL/.template ] && cp $ZPMSPOOL/.template $tmp
97 file=$(zpm sequence notes)
98 mv $tmp $ZPMSPOOL/open/$pkg/$file || { rm -f $tmp; exit 1; }
103 # take note from file or stdin
105 mkdir -p $ZPMSPOOL/open/$pkg
108 tmp=$(mktemp -p $ZPMSPOOL/open)
110 file=$(zpm sequence notes)
111 mv $tmp $ZPMSPOOL/open/$pkg/$file || { rm -f $tmp ; exit 1; }
115 tmp=$(mktemp -p $ZPMSPOOL/open)
117 #flock -n -E3 $tmp vim $tmp
118 #if [ $? -eq 3 ]; then echo already editing $1; exit 1; fi
119 file=$(zpm sequence notes)
120 mv $tmp $ZPMSPOOL/open/$pkg/$file || { rm -f $tmp; exit 1; }
127 flock -n -E3 $file vim $file
128 if [ $? -eq 3 ]; then echo already editing $1; exit 1; fi
143 echo '$0: unknown command ' $cmd 1>&2