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
13 SPOOL=/var/lib/admin/notes
20 #cd $SPOOL || { echo "can't chdir to $SPOOL" ; exit 1; }
22 [ -z "$1" ] && set list
28 file=$(find $SPOOL -type f -name "$1")
29 if [ -z "$file" ] ; then
30 printf "no such note $1\n"
37 file=$(find $SPOOL/open -type f -name "$1")
38 if [ -z "$file" ] ; then
39 printf "no such open note $1\n"
48 -a) find $SPOOL/ack -type f -printf '%P\n' | sort -n
50 *) find $SPOOL/open -type f -printf '%P\n' | sort -n
55 len=$(find $SPOOL/open -type f -printf "%P\n" | awk ' { if ( length > x ) { x = length } }END{ print x }')
56 find $SPOOL/open -type f -printf "%P\n" | sort -n | while read note ; do
57 subject=$(head -1 $SPOOL/open/$note)
58 date=$(stat -c '%y' $SPOOL/open/$note | cut -f1 -d' ')
59 owner=$(stat -c '%U' $SPOOL/open/$note)
60 printf '%*s %8s %s %s\n' $len $note $owner "$date" "$subject"
65 subfile=$(echo $file | sed -e "s|$SPOOL/open/||")
66 filedir=$(dirname $subfile)
67 mkdir -p $SPOOL/ack/$filedir
68 mv $file $SPOOL/ack/$filedir
71 if [ $# -eq 1 ]; then set general $1; fi
73 mkdir -p $SPOOL/open/$pkg
76 tmp=$(mktemp -p $SPOOL/open)
78 file=$(zpm sequence notes)
79 mv $tmp $SPOOL/open/$pkg/$file || { rm -f $tmp ; exit 1; }
83 tmp=$(mktemp -p $SPOOL/open)
85 #flock -n -E3 $tmp vim $tmp
86 #if [ $? -eq 3 ]; then echo already editing $1; exit 1; fi
87 file=$(zpm sequence notes)
88 mv $tmp $SPOOL/open/$pkg/$file || { rm -f $tmp; exit 1; }
95 flock -n -E3 $file vim $file
96 if [ $? -eq 3 ]; then echo already editing $1; exit 1; fi
107 echo '$0: unknown command ' $cmd 1>&2