fix ZSLICE exported to scripts
[cloudstore.git] / init.d / _start_stop
1 # by default, detach from terminal
2 BACKGROUND=1
3 # deduce name from script name
4 NAME=`basename $0`
5 # generate ZSLICE and SLICE from group name
6 export SLICE_GROUP=`echo $NAME | cut -d\- -f1`
7 export SLICE=`grep $SLICE_GROUP /var/lib/extrausers/group | cut -d: -f2`
8 export ZSLICE=`echo $SLICE | sed 's;^/;;'`
9
10 _start_stop() {
11
12 case $1 in
13         start)
14                 cd /srv/cloudstore
15                 if [ "$BACKGROUND" -eq 1 ] ; then
16                         ( $DAEMON 2>&1 ) >> $SLICE/log/$NAME.log &
17                         echo $! > /tmp/$NAME.pid
18                 else
19                         $DAEMON
20                 fi
21                 ;;
22         stop)  
23                 kill `cat /tmp/$NAME.pid` ;;
24         *)  
25                 echo "usage: $0 {start|stop}" ;;
26         esac
27 exit 0
28
29 }