blob: a27b6e0026b5394b6cf39dc8890e4574aa916f65 [file] [log] [blame]
Ratan Gupta07a08c92018-09-03 08:41:52 +05301#!/bin/sh
2
3set -x
4
5NAME="nslcd"
6CONFIG="/etc/nslcd.conf"
7DAEMON="/usr/sbin/nslcd"
8DESC="LDAP connection daemon"
9STATEDIR="/var/run/$NAME"
10PIDFILE="$STATEDIR/$NAME.pid"
11
12start()
13{
14 if [ -e $PIDFILE ]; then
15 PIDDIR=/proc/$(cat $PIDFILE)
16 if [ -d ${PIDDIR} ]; then
17 echo "$DESC already running."
18 exit 1
19 else
20 echo "Removing stale PID file $PIDFILE"
21 rm -f $PIDFILE
22 fi
23 fi
24
25 echo -n "Starting $DESC..."
26
27 start-stop-daemon --start --oknodo \
28 --pidfile $PIDFILE --startas $DAEMON
29
30 if [ $? -eq 0 ]; then
31 echo "done."
32 else
33 echo "failed."
34 fi
35}
36
37stop()
38{
39 echo -n "Stopping $DESC..."
40 start-stop-daemon --stop --quiet --pidfile $PIDFILE \
41 --name $NAME
42 if [ $? -eq 0 ]; then
43 echo "done."
44 else
45 echo "failed."
46 fi
47 rm -f $PIDFILE
48}
49
50status()
51{
52 if [ -f $PIDFILE ]; then
53 if $DAEMON --check
54 then
55 echo "$DESC is running (pid `cat $PIDFILE`"
56 else
57 echo "$DESC stopped"
58 fi
59 else
60 echo "$DESC stopped"
61 fi
62}
63
64case "$1" in
65 start)
66 start
67 ;;
68 stop)
69 stop
70 ;;
71 restart|force-reload|reload)
72 stop
73 start
74 ;;
75 status)
76 status
77 ;;
78 *)
79 echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
80 exit 1
81 ;;
82esac
83
84exit 0