Skip to content

Instantly share code, notes, and snippets.

@mhahl
Created August 14, 2014 01:02
Show Gist options
  • Save mhahl/df2343219123cae929ee to your computer and use it in GitHub Desktop.
Save mhahl/df2343219123cae929ee to your computer and use it in GitHub Desktop.
IBM TDS Init script for AIX
#!/bin/bash
#------------------------------------------
# Init script for TDS.
# Author: Mark Hahl
# Date: 28-05-2014
# Likley doesn't even work.
#------------------------------------------
# We only have one instance running anyway.
#
START_SLAPDCMD="/opt/IBM/ldap/V6.3/sbin/idsslapd -I dsrdbm01"
STOP_SLAPDCMD="/opt/IBM/ldap/V6.3/sbin/idsslapd -I dsrdbm01 -k"
USAGE="Usage : $0 [ stop | start | restart | status ]"
function stop() {
$STOP_SLAPDCMD
return $?
}
function start() {
# Make sure the directory admin is running (ALWAYS).
#
/opt/IBM/ldap/V6.3/sbin/idsdiradm
# Check to see if ibmslapd is running. If it is then
# continue, else start the slapd daemon.
#
RUNNING=`ps -efa | grep ibmslapd | grep -v grep | wc -l`
if [ "$RUNNING" -gt 0 ]
then
PID=`ps -ef | grep ibmslapd | grep -v grep | awk '{print $2}'`
echo "ibmslapd (PID $PID) running"
else
$START_SLAPDCMD
return $?
fi
return 0
}
function status() {
RUNNING=`ps -efa | grep ibmslapd | grep -v grep | wc -l`
if [ "$RUNNING" -gt 0 ]
then
PID=`ps -ef | grep ibmslapd | grep -v grep | awk '{print $2}'`
echo "ibmslapd (PID $PID) running"
return 0
else
echo "ibmslapd stopped"
fi
return 1
}
function restart() {
status
if [ $? -eq 0 ]; then
stop && start
else
start
fi
return $?
}
# Process Command Line Parameters
if test $# -ne 1
then
echo $USAGE
exit 1
else
COMMAND=$1
fi
case "$COMMAND" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
*)
echo -e "Invalid option"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment