Following script can be used to manage the iRODS service. It should be added by the root user to /etc/init.d/. It works with:
- Debian/Ubuntu
- Sles
- Opensuse
/etc/init.d/irods
#!/bin/bash
# chkconfig: 345 97 5
# description: irods server
# author: Benedikt von St. Vieth (b.von.st.vieth@fz-juelich.de)
### BEGIN INIT INFO
# Provides: irods
# Required-Start: $syslog $ALL
# Required-Stop: $syslog $remote_fs $local_fs
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Short-Description: irods server startup, with postgres if you want to
# Description: The goal of this script ist to manage the coming
# up of the irods server. This server is installed in a
# definable IRODS_HOME directory. It is also possible to
# start postgres with iRODS.
### END INIT INFO
###
### These are some variables we need. Please read the informations! ###
# The linux user which starts irods.
USER=irods
# The directory where irods is installed. In this directory there is the "irodsctl" script.
IRODS_HOME=/home/irods/iRODS
# Start irods builtin postgres together with iRODS= 1=yes, 0=no?
PGSTART=0
# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
IRODS_BIN=$IRODS_HOME/irodsctl
test -x $IRODS_BIN || { echo "$IRODS_BIN not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
# Use the SUSE rc_ init script functions;
# emulate them on LSB, RH and other systems
# Default: Assume sysvinit binaries exist
start_daemon() { /sbin/start_daemon ${1+"$@"}; }
killproc() { /sbin/killproc ${1+"$@"}; }
pidofproc() { /sbin/pidofproc ${1+"$@"}; }
checkproc() { /sbin/checkproc ${1+"$@"}; }
if test -e /etc/rc.status; then
# SUSE rc script library
. /etc/rc.status
else
export LC_ALL=POSIX
_cmd=$1
declare -a _SMSG
if test "${_cmd}" = "status"; then
_SMSG=(running dead dead unused unknown reserved)
_RC_UNUSED=3
else
_SMSG=(done failed failed missed failed skipped unused failed failed reserved)
_RC_UNUSED=6
fi
if test -e /lib/lsb/init-functions; then
# LSB
. /lib/lsb/init-functions
echo_rc()
{
if test ${_RC_RV} = 0; then
log_success_msg " [${_SMSG[${_RC_RV}]}] "
else
log_failure_msg " [${_SMSG[${_RC_RV}]}] "
fi }
# TODO: Add checking for lockfiles
checkproc() { return pidofproc ${1+"$@"} >/dev/null 2>&1;
}
elif test -e /etc/init.d/functions; then
# RHAT
. /etc/init.d/functions
echo_rc()
{
#echo -n " [${_SMSG[${_RC_RV}]}] "
if test ${_RC_RV} = 0; then
success " [${_SMSG[${_RC_RV}]}] "
else
failure " [${_SMSG[${_RC_RV}]}] "
fi
}
checkproc()
{
return status ${1+"$@"};
}
start_daemon()
{
return daemon ${1+"$@"};
}
else
# emulate it
echo_rc() {
echo " [${_SMSG[${_RC_RV}]}] "; }
fi
rc_reset() { _RC_RV=0; }
rc_failed() {
if test -z "$1"; then
_RC_RV=1;
elif test "$1" != "0"; then _RC_RV=$1;
fi
return ${_RC_RV} }
rc_check() { return rc_failed $? }
rc_status() { rc_failed $? if test "$1" = "-r"; then _RC_RV=0; shift; fi
if test "$1" = "-s"; then rc_failed 5; echo_rc; rc_failed 3; shift; fi
if test "$1" = "-u"; then rc_failed ${_RC_UNUSED}; echo_rc; rc_failed 3; shift; fi
if test "$1" = "-v"; then echo_rc; shift; fi,
if test "$1" = "-r"; then _RC_RV=0; shift; fi,
return ${_RC_RV} }
rc_exit() { exit ${_RC_RV}; }
rc_active()
{
if test -z "$RUNLEVEL"; then read RUNLEVEL REST < <(/sbin/runlevel); fi
if test -e /etc/init.d/S[0-9][0-9]${1}; then return 0; fi
return 1
}
fi
# Reset status of this service
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - user had insufficient privileges
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
# 8 -- 199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
# # Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signaling is not supported) are
# considered a success.
case "$1" in
start)
if [ $PGSTART -eq 1 ] then echo "Start iRODS Server together with PostgreSQL Server through init-script!"
su --command="$IRODS_BIN start" $USER
#start_daemon -u $USER $IRODS_BIN start
else echo "Start iRODS Server through init-script!"
su --command="$IRODS_BIN istart" $USER
#start_daemon -u $USER $IRODS_BIN istart
fi
rc_status -v
;;
stop) if [ $PGSTART -eq 1 ] then
echo "Stop iRODS-Server and PostgreSQL-Server through init-script!"
su --command="$IRODS_BIN stop" $USER
#start_daemon -u $USER $IRODS_BIN stop else echo "Stop iRODS Server through init-script!"
su --command="$IRODS_BIN istop" $USER
#start_daemon -u $USER $IRODS_BIN istop
fi
rc_status -v
;;
try-restart|condrestart) echo "This command is not defined yet!"
rc_status -u ;;
restart) $0 stop $0 start rc_status ;; force-reload) echo "This command is not defined yet!"
rc_status -u ;;
reload) ;; status) echo "Status of iRODS Server"
su --command="$IRODS_BIN status" $USER
#start_daemon -u $USER $IRODS_BIN status ;; probe) echo "This command is not defined yet!" rc_status -u ;; *)
echo "Usage: $0 {start|stop|status|restart}" exit 1 ;;
esac
rc_exit
