MFS启动脚本

#!/bin/bash
#
# Init file for the MooseFS master service
#
# chkconfig: - 92 84
#
# description: MooseFS master
#
# processname: mfsmaster

# Source function library.

# Source networking configuration.
. /etc/init.d/functions
. /etc/sysconfig/network

# Source initialization configuration.
prefix="/usr/local/mfs"
pidfile="/var/run/mfsmaster.pid"
# Check that networking is up.
[ "${NETWORKING}" == "no" ] && exit 0
[ -x "$prefix/sbin/mfsmaster" ] || exit 1
[ -r "$prefix/etc/mfsmaster.cfg" ] || exit 1
[ -r "$prefix/etc/mfsexports.cfg" ] || exit 1

RETVAL=0
prog="mfsmaster"
datadir="/opt/mfs/var/mfs"
mfsbin="/usr/local/mfs/sbin/mfsmaster"
mfsrestore="/usr/local/mfs/sbin/mfsmeta"
start () {
    echo -n $"Starting $prog: "
    daemon --pidfile=${pidfile} $mfsbin start #>/dev/null 2>&1
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog &&pidof "$mfsbin" >$pidfile
    return $RETVAL
}

stop () {
    echo -n $"Stopping $prog: "
    $mfsbin -s >/dev/null 2>&1 || killproc $prog #>/dev/null 2>&1
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f $pid_file && rm -f /var/lock/subsys/$prog
    return $RETVAL
}

restart () {
    stop
    start
}
reload () {
     echo -n $"reload $prog: "
    $mfsbin reload  >/dev/null 2>&1 #|| killproc $prog #>/dev/null 2>&1
    RETVAL=$?
    echo
/var/lock/subsys/$prog
    return $RETVAL
}
restore () {
     echo -n $"restore $prog: "
    $mfsrestore -a -d $datadir 
    RETVAL=$?
    echo
/var/lock/subsys/$prog
    return $RETVAL
}
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    restart
    ;;
  reload)
    reload
    ;;
  restore)
    restore
    ;;
  condrestart)
    [ -e /var/lock/subsys/$prog ] && restart
    RETVAL=$?
    ;;
  status)
    status $prog
    RETVAL=$?
    ;;
  *)
    echo $"Usage: $0 {start|stop|restart|condrestart|status}"
    RETVAL=1
esac

exit $RETVAL

你可能感兴趣的:(启动脚本,MFS,moosefs)