test file_size with send to different shard
[cloudstore.git] / gearman / narada_s1_quota
1 #!/bin/sh -e
2
3 name=`basename $0`
4 op=$2
5 test -z "$op" && op="get"
6 tmp_file="/mnt/narada/rootfs/tmp/${name}_${op}"
7 pid_file="${tmp_file}.pid"
8 log_file="${tmp_file}.log"
9 echo "# $name $op" >> $log_file
10
11 if [ "$1" = "get" ] ; then
12         while read uid ; do
13                 echo -n "get $uid = " >> $log_file
14                 quota --raw-grace --no-wrap -u $uid | tail -1 \
15                         | awk '{ print $2 " " $3 }' | tee -a $log_file \
16                         | grep '^[0-9][0-9]*'
17         done
18 elif [ "$1" = "set" ] ; then
19         while read uid quota ; do
20                 echo "set $uid $quota" >> $log_file
21                 setquota -u $uid $quota 0 0 0 /mnt/narada/
22                 quota --raw-grace --no-wrap -u $uid | tail -1
23         done
24 elif [ "$1" = "start" ] ; then
25         test -e $pid_file && kill `cat $pid_file` || true;
26         LD_PRELOAD=/mnt/narada/rootfs/usr/lib/libgearman.so.4 /mnt/narada/rootfs/usr/bin/gearman \
27         -h 10.60.0.244 -p 4730 -i $pid_file \
28         -n -f ${name}_${op} -w `pwd`/$0 $op &
29 elif [ "$1" = "stop" ] ; then
30         kill `cat $pid_file` && rm $pid_file
31 elif [ "$1" = "status" ] ; then
32         kill -s 0 `cat $pid_file` && echo "$name $op OK";
33 fi
34