Created
May 8, 2014 12:59
-
-
Save shillem/3bb067eeab9ab8e1ba5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: domino | |
# Required-Start: $remote_fs $syslog $named $network $time | |
# Required-Stop: $remote_fs $syslog $named $network | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: IBM Domino Server | |
# Description: IBM Domino Server | |
### END INIT INFO | |
# Using the lsb functions to perform the operations. | |
. /lib/lsb/init-functions | |
# Process name ( For display ) | |
NAME=domino | |
# Daemon name, where the actual executable is | |
DAEMON_EXEC=/opt/ibm/domino/bin/server | |
DAEMON_PROC=/opt/ibm/domino/notes/latest/linux/server | |
# Directory from where to run the script | |
DAEMON_DIR=/var/ibm/domino/data | |
# User to run the script | |
DAEMON_USER=notes | |
# pid file for the daemon | |
PIDFILE=/var/run/domino.pid | |
# If the daemon is not there, then exit. | |
test -x $DAEMON_EXEC || exit 5 | |
# Check whether the process is running | |
# The global -$out- variable gets set for later reference | |
process() { | |
case $1 in | |
now) | |
out=`ps auxww | grep "$DAEMON_PROC" | grep -v grep | awk '{print $2}'` | |
;; | |
started) | |
local sec=0 | |
local timeout=10 | |
while [ $sec -lt $timeout ] | |
do | |
process "now" | |
if [ ! -z "$out" ]; then | |
break | |
fi | |
sec=`expr $sec + 1` | |
sleep 1 | |
done | |
;; | |
stopped) | |
local sec=0 | |
local timeout=600 | |
while [ $sec -lt $timeout ] | |
do | |
process "now" | |
if [ -z "$out" ]; then | |
break | |
fi | |
sec=`expr $sec + 1` | |
sleep 1 | |
done | |
;; | |
esac | |
} | |
pid() { | |
case $1 in | |
create) | |
echo $2 > $PIDFILE | |
;; | |
delete) | |
if [ -f $PIDFILE ]; then | |
rm -rf $PIDFILE | |
fi | |
;; | |
esac | |
} | |
case $1 in | |
now) | |
process "now" | |
;; | |
start) | |
# Setting the -global- variable | |
out="" | |
# If the process is found exit the script | |
process "now" | |
if [ ! -z "$out" ]; then | |
$0 status | |
exit | |
fi | |
# Start the daemon. | |
log_daemon_msg "Starting server" "$NAME" | |
su - $DAEMON_USER -c "$0 'server' 'start'" | |
# Log the message appropriately | |
if [ $? = 0 ]; then | |
# Check whether the process is started | |
process "started" | |
if [ ! -z "$out" ]; then | |
pid "create" "$out" | |
log_end_msg 0 | |
exit 0 | |
fi | |
fi | |
log_end_msg 1 | |
;; | |
stop) | |
# Setting the -global- variable | |
out="" | |
# If the process is not found exit the script | |
process "now" | |
if [ -z "$out" ]; then | |
exit | |
fi | |
# Stop the daemon. | |
log_daemon_msg "Stopping server" "$NAME" | |
su - $DAEMON_USER -c "$0 'server' 'quit'" | |
if [ $? = 0 ]; then | |
# Check whether the process has stopped | |
process "stopped" | |
if [ -z "$out" ]; then | |
pid "delete" | |
log_end_msg 0 | |
exit 0 | |
fi | |
fi | |
log_end_msg 1 | |
;; | |
restart) | |
# Restart the daemon. | |
$0 stop && $0 start | |
;; | |
status) | |
# Check the status of the process. | |
status_of_proc $DAEMON_PROC "$NAME" | |
;; | |
reload) | |
exit 3 | |
;; | |
server) | |
case $2 in | |
start) | |
cd $DAEMON_DIR | |
$DAEMON_EXEC > /dev/null 2>&1 & | |
exit $? | |
;; | |
quit) | |
cd $DAEMON_DIR | |
$DAEMON_EXEC -q > /dev/null 2>&1 & | |
exit $? | |
;; | |
esac | |
;; | |
*) | |
# For invalid arguments, print the usage message. | |
echo "Usage: $0 {start|stop|restart|reload|status}" | |
exit 2 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment