#!/bin/sh -e name=`basename $0` op=$2 test -z "$op" && op="get" tmp_file="/mnt/narada/rootfs/tmp/${name}_${op}" pid_file="${tmp_file}.pid" log_file="${tmp_file}.log" echo "# $name $op" >> $log_file if [ "$1" = "get" ] ; then while read uid ; do echo -n "get $uid = " >> $log_file quota --raw-grace --no-wrap -u $uid | tail -1 \ | awk '{ print $2 " " $3 }' | tee -a $log_file \ | grep '^[0-9][0-9]*' done elif [ "$1" = "set" ] ; then while read uid quota ; do echo "set $uid $quota" >> $log_file setquota -u $uid $quota 0 0 0 /mnt/narada/ quota --raw-grace --no-wrap -u $uid | tail -1 done elif [ "$1" = "start" ] ; then test -e $pid_file && kill `cat $pid_file` || true; LD_PRELOAD=/mnt/narada/rootfs/usr/lib/libgearman.so.4 /mnt/narada/rootfs/usr/bin/gearman \ -h 10.60.0.244 -p 4730 -i $pid_file \ -n -f ${name}_${op} -w `pwd`/$0 $op & elif [ "$1" = "stop" ] ; then kill `cat $pid_file` && rm $pid_file elif [ "$1" = "status" ] ; then kill -s 0 `cat $pid_file` && echo "$name $op OK"; fi