updated on Tue Jan 10 12:02:00 UTC 2012
[aur-mirror.git] / kfs-svn / kfs-chunkserv.rc
blob3ba01fd22f0e304577c3db07ff8b42adedd99b56
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
5 . /etc/conf.d/kfs
7 CHUNK_DIR=`cat $KFS_CONF 2>/dev/null | grep chunkServer.chunkDir | cut -d '=' -f 2 | sed 's/ //g'`
8 LOG_DIR=`cat $KFS_CONF 2>/dev/null | grep chunkServer.logDir | cut -d '=' -f 2 | sed 's/ //g'`
10 case "$1" in
11 start)
12 stat_busy "Starting KFS ChunkServer"
14 [ -z "$KFS_CONF" ] && { echo "KFS_CONF not set. You need to specify it in /etc/conf.d/kfs file"; stat_fail; exit 0; }
15 [ -z "$KFS_DIR" ] && { echo "KFS_DIR not set. You need to specify it in /etc/conf.d/kfs file"; stat_fail; exit 0; }
17 [ -f "$KFS_CONF" ] || { echo "$KFS_CONF doesn't exist"; stat_fail; exit 0; }
18 [ -d "$KFS_DIR" ] || mkdir -p "$KFS_DIR" || { echo "Could not create $KFS_DIR"; stat_fail; exit 0; }
20 [ -z "$CHUNK_DIR" ] && { echo "$KFS_CONF doesn't have chunkServer.chunkDir set"; stat_fail; exit 0; }
21 [ -z "$LOG_DIR" ] && { echo "$KFS_CONF doesn't have chunkServer.logDir set"; stat_fail; exit 0; }
23 cd "$KFS_DIR"
25 [ -d "$CHUNK_DIR" ] || mkdir -p "$CHUNK_DIR" || { echo "Could not create $CHUNK_DIR directory"; stat_fail; exit 0; }
26 [ -d "$LOG_DIR" ] || mkdir -p "$LOG_DIR" || { echo "Could not create $LOG_DIR directory"; stat_fail; exit 0; }
28 [ -d "bin" ] || ln -s /usr/share/kfs/bin || { echo "Could not create link to /usr/share/kfs/bin in $KFS_DIR"; stat_fail; exit 0; }
29 [ -d "scripts" ] || ln -s /usr/share/kfs/scripts || { echo "Could not create link to /usr/share/kfs/scripts in $KFS_DIR"; stat_fail; exit 0; }
30 [ -d "logs" ] || mkdir -p "logs" || { echo "Could not create $KFS_DIR/logs"; stat_fail; exit 0; }
32 scripts/kfsrun.sh --start --chunk --file "$KFS_CONF"
34 if [ $? -gt 0 ]; then
35 stat_fail
36 else
37 add_daemon kfs-chunkserv
38 stat_done
41 stop)
42 stat_busy "Stopping KFS ChunkServer"
44 cd "$KFS_DIR"
46 scripts/kfsrun.sh --stop --chunk --file "$KFS_CONF"
48 if [ $? -gt 0 ]; then
49 stat_fail
50 else
51 rm_daemon kfs-chunkserv
52 stat_done
55 restart)
56 $0 stop
57 sleep 1
58 $0 start
61 echo "usage: $0 {start|stop|restart}"
62 esac
63 exit 0