Public feed #724673

kevev

public text v1 · immutable
Raw Edit
·published 2007-10-03 19:46 UTC
rendered paste body
#!/bin/bash
#
#	/etc/rc.d/init.d/
#
#
#
#
#

# Source function library.
. /etc/init.d/functions

PIDFILE=/var/run/spread/spread.pid

start() {
	echo -n "Starting spread..."
		nohup spread > /var/log/spread/spread.log &
		RETVAL=$?
		[ "$RETVAL" = 0 ] && touch /var/lock/subsys/spread
	echo
	echo -n "Starting wackamole..."
		wackamole
		RETVAL=$?
		[ "$RETVAL" = 0 ] && touch /var/lock/subsys/wackamole
	echo
	echo -n "Starting glusterfsd..."
		glusterfsd
		RETVAL=$?
		[ "$RETVAL" = 0 ] && touch /var/lock/subsys/glusterfsd
	echo
	echo -n "Mounting /etc/httpd..."
		glusterfs -f /etc/glusterfs/glusterfs-client.vol -n centos-etc-httpd /etc/httpd
		RETVAL=$?
		[ "$RETVAL" = 0 ] && touch /var/lock/subsys/etc-httpd
	echo
	echo -n "Mounting /var/www..."
		glusterfs -f /etc/glusterfs/glusterfs-client.vol -n centos-var-www /var/www
		RETVAL=$?
		[ "$RETVAL" = 0 ] && touch /var/lock/subsys/var-www
	echo
	echo -n "Healing /etc/httpd..."
		find /etc/httpd -type f -exec head -n 1 {} \;
	echo
	echo -n "Healing /var/www..."
		find /var/www -type f -exec head -n 1 {} \;
	echo
	echo -n "Starting Apache..."
		/etc/init.d/httpd start
		RETVAL=$?
		[ "$RETVAL" = 0 ]
	echo
}

stop() {
	echo -n "Shutting down Apache..."
	killall httpd
	RETVAL=$?
	[ "$RETVAL" = 0 ]
	echo
	echo -n "Shutting down spread... "
	killall spread
	RETVAL=$?
	[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/spread
	echo
	echo -n "Shutting down wackamole..."
	killproc wackamole
	RETVAL=$?
	[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/wackamole
	echo
	echo -n "Shutting down glusterfsd..."
	killproc glusterfsd
	RETVAL=$?
	[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/glusterfsd
	echo
	echo -n "Dis-Mounting /etc/httpd..."
	umount /etc/httpd
	RETVAL=$?
	[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/etc-httpd
	echo
	echo -n "Dis-Mounting /var/www..."
	umount /var/www
	RETVAL=$?
	[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/var-www
	echo
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		status spread
		;;
	restart)
		stop
		start
		;;
	*)
		echo "Usage:  {start|stop|status|restart}"
		exit 1
		;;
esac
exit $?