]> pd.if.org Git - zpackage/blob - zpm-sequence
added program to output the elf type of a file
[zpackage] / zpm-sequence
1 #!/bin/sh
2
3 set -e
4
5 SPOOL=${SPOOL:-/var/lib/admin/notes}
6 DB=$SPOOL/.sequence.db
7 SQL="sqlite3 -bail $DB"
8
9 #rm -f $DB
10 test -f $DB || {
11 sqlite3 $DB <<EOS
12 create table sequence ( sequence text not null primary key, val integer not null default 0);
13 EOS
14 }
15
16 case $1 in
17         -c)
18                 $SQL "insert into sequence (sequence) values ('$2')"
19                 exit 0
20                 ;;
21         -d)
22                 $SQL "delete from sequence where sequence = '$2'"
23                 exit 0
24                 ;;
25         -v)
26                 val=$($SQL "select val from sequence where sequence = '$2'")
27                 echo $val
28                 exit 0
29                 ;;
30         -l)
31                 $SQL 'select * from sequence'
32                 exit 0
33                 ;;
34         -s)
35                 $SQL "begin;update sequence set val = $3 where sequence = '$seq'; commit;"
36                 exit 0
37                 ;;
38         -n)
39                 shift
40                 ;;
41 esac
42
43 seq=$1
44
45 num=$(sqlite3 $DB "begin; update sequence set val = val + 1 where sequence = '$seq'; commit;select val from sequence where sequence = '$seq';")
46
47 echo $num