summaryrefslogtreecommitdiff
path: root/net-im/ejabberd/files/patch-src::ejabberd.sh
blob: 1a2da91f2894c96c33b7d63d470c5c8ae3322df1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
--- ejabberd.sh.orig	Wed Oct 20 22:16:07 2004
+++ ejabberd.sh	Wed Oct 20 22:14:04 2004
@@ -0,0 +1,90 @@
+#! /bin/sh
+#
+# ejabberd        Start/stop ejabberd server
+#
+#
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
+EJABBERD=/usr/local/bin/ejabberd
+EJABBERDCTL=/usr/local/bin/ejabberdctl
+EJABBERDUSER=ejabberd
+NAME=ejabberd
+DESC=ejabberd
+
+test -f $EJABBERD || exit 0
+test -f $EJABBERDCTL || exit 0
+
+# Include ejabberd defaults if available
+if [ -f %%PREFIX%%/etc/ejabberd.defaults ] ; then
+    . %%PREFIX%%/etc/ejabberd.defaults
+fi
+
+
+set -e
+
+status()
+{
+    $EJABBERDCTL status >/dev/null
+}
+
+start()
+{
+    su $EJABBERDUSER -c "$EJABBERD -noshell -detached"
+}
+
+
+case "$1" in
+    start)
+	    echo -n "Starting $DESC: "
+
+        if status
+        then
+            echo " already running."
+        false
+        else
+            start
+        fi
+
+	    echo "$NAME."
+	;;
+    stop)
+	echo -n "Stopping $DESC: "
+
+       if $EJABBERDCTL stop
+        then
+            cnt=0
+            while status
+            do
+                cnt=`expr $cnt + 1`
+                if [ $cnt -gt 60 ]
+                then
+                    echo -n " failed "
+                    break
+                fi
+                sleep 1
+                echo -n .
+            done
+        else
+            echo -n " failed "
+        fi
+
+	    echo "$NAME."
+	;;
+    restart|force-reload)
+	    echo -n "Restarting $DESC: "
+        if status
+        then
+            $EJABBERDCTL restart
+        else
+            start
+        fi
+
+	    echo "$NAME."
+	;;
+    *)
+	echo "Usage: ejabberd.sh {start|stop|restart|force-reload}" >&2
+	exit 1
+	;;
+esac
+
+exit 0