get SLICE and ZSLICE from group name
[cloudstore.git] / init.d / _start_stop
index 8018d2e..c712d4d 100755 (executable)
@@ -1,9 +1,23 @@
+# by default, detach from terminal
+BACKGROUND=1
+# deduce name from script name
+NAME=`basename $0`
+# generate ZSLICE and SLICE from group name
+SLICE_GROUP=`echo $NAME | cut -d\- -f1`
+export SLICE=`grep $SLICE_GROUP /var/lib/extrausers/group | cut -d: -f2`
+export ZSLICE=`echo $SLICE | sed 's;^;;'`
+
 _start_stop() {
 
 case $1 in
        start)
-               cd /srv/cloudstore && ( $DAEMON 2>&1 ) > /tmp/$NAME.log &
-               echo $! > /tmp/$NAME.pid
+               cd /srv/cloudstore
+               if [ "$BACKGROUND" -eq 1 ] ; then
+                       ( $DAEMON 2>&1 ) >> /tmp/$NAME.log &
+                       echo $! > /tmp/$NAME.pid
+               else
+                       $DAEMON
+               fi
                ;;
        stop)  
                kill `cat /tmp/$NAME.pid` ;;