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