MASNODE='master'
PIDFILE=/Opt/LDAP/var/slapd.pid
APP=/Opt/LDAP/libexec/slapd
SLURP=/Opt/LDAP/libexec/slurpd
MASTER=/Opt/LDAP/etc/openldap/slapd.master.conf
SLAVE=/Opt/LDAP/etc/openldap/slapd.slave.conf
. /opt/ha/etc/ha.d/shellfuncs
test_start () {
# first we kill everything possible
ha_log "info: $0: Starting"
if [ -f $PIDFILE ]; then
PID=`head -1 $PIDFILE`
ha_log "info: $0: Appears to already be running, killing [$PID]"
kill -9 $PID > /dev/null
rm $PIDFILE
fi
# slurpd should die when the slapd process does, but just in case:
for i in `ps -ef | grep slurp | grep -v grep | awk '{print $2}' `
do
kill -9 $i
done
# slight delay to allow for stability
sleep 2
# now we will attempt to start as a master
$APP -f $MASTER //启动slapd
if [ ! -f $PIDFILE ]; then
ha_log "warn: $0: Slapd did not start properly"
#exit 1
fi
# Now we determine if this is the primary or secondary node
# first wait a bit for stability
sleep 10
# if we are secondary, do nothing: otherwise
if [ $HA_CURHOST == $MASNODE ]; then
/usr/bin/rsh slave '/opt/ha/etc/ha.d/resource.d/slapd.slave '
&//启动从服务器上的LDAP
/usr/bin/rsh mailserver '/opt/sbin/midd -m master -s slave' & //启动midd
$SLURP -f $MASTER //启动主服务器上的复制进程
else
ha_log "warn: $0: slave node is not responding"
fi
}
test_stop () {
ha_log "info: $0: Shutting down"
if [ -f $PIDFILE ]; then
PID=`head -1 $PIDFILE`
kill -9 $PID > /dev/null
rm $PIDFILE
fi
# Let's be sure it's dead, Jim
for i in `ps -ef | grep slap | grep -v grep | awk '{print $2}' `
do
kill -9 $i
done
for i in `ps -ef | grep slurp | grep -v grep | awk '{print $2}' `
do
kill -9 $i
done
}
# See how we were called.
case "$1" in
start)
test_start
;;
stop)
test_stop
;;
restart)
$0 stop
$0 start
;;
status)
if [ -f $PIDFILE ]; then
echo running
else
echo stopped
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0 |