summaryrefslogtreecommitdiffstats
path: root/network/openldap-server/rc.openldap
diff options
context:
space:
mode:
author Giuseppe Di Terlizzi2017-04-07 18:45:04 +0200
committer Willy Sudiarto Raharjo2017-04-08 01:57:49 +0200
commit683caa309d82c7207ad08816627cf69ee99dd1a7 (patch)
treedc66f6ad1b13d5f560c16565ccf617d7ae7e2a72 /network/openldap-server/rc.openldap
parent09859e3dfe4158fcdcebcbe6e928fa86e06af433 (diff)
downloadslackbuilds-683caa309d82c7207ad08816627cf69ee99dd1a7.tar.gz
network/openldap-server: Added (OpenLDAP server).
Signed-off-by: David Spencer <idlemoor@slackbuilds.org>
Diffstat (limited to 'network/openldap-server/rc.openldap')
-rw-r--r--network/openldap-server/rc.openldap100
1 files changed, 100 insertions, 0 deletions
diff --git a/network/openldap-server/rc.openldap b/network/openldap-server/rc.openldap
new file mode 100644
index 0000000000..0e64c219fc
--- /dev/null
+++ b/network/openldap-server/rc.openldap
@@ -0,0 +1,100 @@
+#!/bin/sh
+
+# OpenLDAP Server start/stop script
+
+
+. /etc/default/slapd
+
+PID_FILE=/var/run/openldap/slapd.pid
+EXEC=/usr/sbin/slapd
+
+
+# re-create /var/run/openldap directory
+if [ ! -d /var/run/openldap ]; then
+ mkdir -p /var/run/openldap
+ chown ldap:ldap /var/run/openldap
+fi
+
+
+slapd_start() {
+
+ echo -n "Starting OpenLDAP server..."
+
+ if [ -e $PID_FILE ]; then
+
+ if ps axc | grep slapd >/dev/null 2>&1 ; then
+ echo "already running!"
+ return 1
+ else
+ rm $PID_FILE
+ fi
+
+ fi
+
+ $EXEC -u ldap -h "$SLAPD_URLS" $SLAPD_OPTIONS > /dev/null 2>&1
+ echo "done!"
+
+}
+
+
+slapd_stop() {
+
+ echo -n "Stopping OpenLDAP server..."
+
+ if [ -e $PID_FILE ]; then
+ if ps axc | grep slapd >/dev/null 2>&1; then
+ kill -INT $(cat $PID_FILE)
+ else
+ echo "already stopped!"
+ fi
+ fi
+
+ rm $PID_FILE >/dev/null 2>&1
+ echo "done!"
+
+}
+
+
+slapd_restart() {
+ slapd_stop
+ sleep 1
+ slapd_start
+}
+
+
+slapd_status() {
+
+ if [ -e $PID_FILE ]; then
+ if ps axc | grep slapd >/dev/null 2>&1; then
+ echo "OpenLDAP is running!"
+ return 0
+ fi
+
+ echo "OpenLDAP PID file exists but the service is down!"
+ return 1
+
+ else
+ echo "OpenLDAP is stopped!"
+ return 0
+ fi
+
+}
+
+
+case "$1" in
+ 'start')
+ slapd_start
+ ;;
+ 'stop')
+ slapd_stop
+ ;;
+ 'restart')
+ slapd_restart
+ ;;
+ 'status')
+ slapd_status
+ ;;
+ *)
+ echo "usage $0 start|stop|restart"
+esac
+