All pastes #2820 Raw Edit

AgiNamu

public text v1 · immutable
#2820 ·published 2004-12-09 06:19 UTC
rendered paste body
#!/bin/bash
#
# Startup script for xsp server
#
# chkconfig: 3 84 16
# description: xsp is a asp.net server
#
 
ARGS=`cat /etc/xsp.conf | grep -v \# `

. /etc/init.d/functions

start() {
	echo -n $"Starting xsp: "
	
	#Check PID/existence
	pid=""
	if [ -f /var/run/xsp.pid ] ; then
	        read pid < /var/run/xsp.pid
	        if [ -n "$pid" ]; then
			rm /var/run/xsp.pid
		else
			echo -n $"xsp is already running."
			failure
			echo
			return 1
	        fi
	fi

	mono /usr/bin/xsp.exe --nonstop $ARGS > /dev/null &
	RETVAL=$?
	if [ $RETVAL != 0 ]; then
		failure
		echo
		return $RETVAL
 	fi
	PID=$!
	echo $PID > /var/run/xsp.pid
	success
	echo
	return 0
}	

stop() {
	echo -n $"Shutting down xsp: "

	if [ ! -f /var/run/xsp.pid ]; then 
		echo -n $"xsp not running"
		failure 
		echo
		return 1
	fi

	kill -15 `cat /var/run/xsp.pid`
	RETVAL=$?

	if [ $RETVAL = 0 ]; then
		rm /var/run/xsp.pid
		success
		echo
		return 0
	else
		failure
		echo
		return $RETVAL
	fi	
}	

restart() {
	stop
	start
}	


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

exit $?