diff options
Diffstat (limited to 'files/common/sbin/p2ptbl')
| -rwxr-xr-x | files/common/sbin/p2ptbl | 22 | 
1 files changed, 22 insertions, 0 deletions
diff --git a/files/common/sbin/p2ptbl b/files/common/sbin/p2ptbl index 2048e37..0a5bae3 100755 --- a/files/common/sbin/p2ptbl +++ b/files/common/sbin/p2ptbl @@ -17,6 +17,21 @@ show () {      cut -f1,3- "$1"  } +filter () { +    tbl="$1" +    shift 1 +    cut -f1,2  "$tbl" \ +	| while read key version; do +	    echo -e "$key\t$(($version+$RANDOM))" +        done > "$tbl".ver +    cut -f1,3- "$tbl" \ +	| "$@" \ +	| join -t$'\t' "$tbl".ver  - \ +	> "$tbl"~ +    mv "$tbl"~ "$tbl" +    rm "$tbl".ver +} +  update () {      [ -n "$2" -a -n "$3" ] || printArgs      oldversion=$(grep "^$2"$'\t' "$1" | cut -f2) @@ -86,6 +101,7 @@ $0 init   table  $0 get    table key  $0 show   table  $0 update table key value [interface] +$0 filter table program [args]  $0 merge  table foreign-table  $0 gossip table target-size interface"      exit 1 @@ -117,6 +133,12 @@ case "$1" in  	lockTable -s "$2"  	show "$2"  	;; +    filter) +	tbl="$2" +	shift 2 +	lockTable -x "$tbl" +	filter "$tbl" "$@" +	;;      update)  	lockTable -s "$2"  	update "$2" "$3" "$4" "$5"  | 
