1#!/bin/sh 2 3### BEGIN INIT INFO 4# Provides: moosefs-master 5# Required-Start: $network $remote_fs 6# Required-Stop: $remote_fs 7# Default-Start: 2 3 4 5 8# Default-Stop: 0 1 6 9# Short-Description: Start moosefs-master at boot time 10# Description: moosefs-master provides metadata management for MooseFS. 11### END INIT INFO 12 13PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 14DAEMON=/usr/sbin/mfsmaster 15NAME=moosefs-master 16DEFAULT_USER=mfs 17DEFAULT_GROUP=mfs 18DEFAULT_DATADIR=/var/lib/mfs 19DEFAULT_CFG=/etc/mfs/mfsmaster.cfg 20COMPAT_CFG=/etc/mfsmaster.cfg 21 22test -e $DAEMON || exit 0 23 24# Include moosefs-master defaults if available 25. /lib/lsb/init-functions 26MFSMASTER_ENABLE=false 27MFSMASTER_DEFAULTS_FILE=/etc/default/moosefs-master 28MFSMASTER_CONFIG_FILE= 29if [ -s "$MFSMASTER_DEFAULTS_FILE" ]; then 30 . "$MFSMASTER_DEFAULTS_FILE" 31 case "x$MFSMASTER_ENABLE" in 32 xtrue) ;; 33 xfalse) 34 log_warning_msg "$NAME not enabled in \"$MFSMASTER_DEFAULTS_FILE\", exiting..." 35 exit 0 36 ;; 37 *) 38 log_failure_msg "value of MFSMASTER_ENABLE must be either 'true' or 'false';" 39 log_failure_msg "not starting ${NAME}." 40 exit 1 41 ;; 42 esac 43fi 44 45set -e 46 47if [ -n "$MFSMASTER_CONFIG_FILE" ]; then 48 CFGFILE="$MFSMASTER_CONFIG_FILE" 49elif [ -f "$DEFAULT_CFG" -o ! -f "$COMPAT_CFG" ]; then 50 CFGFILE="$DEFAULT_CFG" 51else 52 CFGFILE="$COMPAT_CFG" 53fi 54if [ -s "$CFGFILE" ]; then 55 DATADIR=$(sed -e 's/[ ]#.*$//' -n -e 's/^DATA_PATH[ ]*=[ ]*\([^ ]*\)[ ]*$/\1/p' "$CFGFILE") 56 MFSUSER=$(sed -e 's/[ ]#.*$//' -n -e 's/^WORKING_USER[ ]*=[ ]*\([^ ]*\)[ ]*$/\1/p' "$CFGFILE") 57 MFSGROUP=$(sed -e 's/[ ]#.*$//' -n -e 's/^WORKING_GROUP[ ]*=[ ]*\([^ ]*\)[ ]*$/\1/p' "$CFGFILE") 58else 59 DATADIR= 60 MFSUSER= 61 MFSGROUP= 62fi 63: ${DATADIR:=$DEFAULT_DATADIR} 64: ${MFSUSER:=$DEFAULT_USER} 65: ${MFSGROUP:=$DEFAULT_GROUP} 66 67case "$1" in 68 start) 69 echo "Starting ${NAME}:" 70 $DAEMON ${MFSMASTER_CONFIG_FILE:+-c $MFSMASTER_CONFIG_FILE} start 71 ;; 72 73 stop) 74 echo "Stopping ${NAME}:" 75 $DAEMON ${MFSMASTER_CONFIG_FILE:+-c $MFSMASTER_CONFIG_FILE} stop 76 ;; 77 78 reload|force-reload) 79 echo "Reloading ${NAME}:" 80 $DAEMON ${MFSMASTER_CONFIG_FILE:+-c $MFSMASTER_CONFIG_FILE} reload 81 ;; 82 83 restart) 84 echo "Restarting ${NAME}:" 85 $DAEMON ${MFSMASTER_CONFIG_FILE:+-c $MFSMASTER_CONFIG_FILE} restart 86 ;; 87 88 status) 89 $DAEMON ${MFSMASTER_CONFIG_FILE:+-c $MFSMASTER_CONFIG_FILE} test 2> /dev/null 90 ;; 91 92 *) 93 N=/etc/init.d/$NAME 94 echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2 95 exit 1 96 ;; 97esac 98 99exit 0 100