A System V init daemon script for Iguana

A System V init daemon script for Iguana

Rob Ayer of Benchmark Revenue Management, one of our customers, kindly donated this script for Iguana. We have not tried using it in production ourselves, but provide it as a resource to any Linux customers we have.

It generally makes sense under Linux to run Iguana:

  1. Under a specific user ID rather than root. This is better for security.
  2. Make sure the $HOME environment variable is set for that user account since the source code control system Iguana uses will not function without this variable being set.
#!/bin/sh

# chkconfig: - 90 15
# description: Iguana Service

# init file for iguana_service
# Author: Rob Ayer robayer@gmail.com

# Copyright (C) 2011 by Rob Ayer
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

#
# Define system-specific variables here
#

# The root directory where the Iguana installation is located
IGUANA_ROOT=/usr/local/iguana

# The Iguana binary within the root directory
PROG=iguana_service

# The local system user to execute the binary as
# NOTE: If this local user is !=root then you will need to modify the web server
# port to something greater than 1024 so the service can bind and listen. This
# user must also have write permissions to the IGUANA_ROOT directory and files beneath
IGUANA_USER=iguana

# End system-specific variables

# The values are derived from the above definitions - do not modify them
IGUANA_BIN=${IGUANA_ROOT}/${PROG}
PIDFILE=${IGUANA_ROOT}/Iguana.pid

# test for root directory
[ ! -d ${IGUANA_ROOT} ] && echo "The directory ${IGUANA_ROOT} does not exist!" && exit 1

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

RETVAL=0

start()
{
	echo -n $"Starting ${PROG}: "
	cd ${IGUANA_ROOT} # This allows for .pid creation in the same directory
	daemon --user=${IGUANA_USER} ${IGUANA_BIN}
	RETVAL=$?
	echo
	[ ${RETVAL} = 0 ] && touch ${PIDFILE}
	return ${RETVAL}
}

stop()
{
	echo -n $"Shutting down ${PROG}: "
	killproc ${IGUANA_BIN}
	RETVAL=$?
	echo
	rm -f ${PIDFILE}
	return ${RETVAL}
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		stop
		start
		;;
	status)
		status ${PROG}
		RETVAL=$?
		;;
	*)
		echo $"Usage: $0 {start|stop|restart|status}"
		RETVAL=3
esac

exit ${RETVAL}

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.