mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-29 06:06:32 +00:00
ejabberd: simplify init script by patching ejabberdctl
Let a user modify environment variables used in ejabberdctl by loading a default configuration file. Signed-off-by: Johan Oudinet <johan.oudinet@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
parent
390e778db2
commit
4ef5bcde94
21
package/ejabberd/0009-fix-ejabberdctl.patch
Normal file
21
package/ejabberd/0009-fix-ejabberdctl.patch
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
Description: fix ejabberdctl
|
||||||
|
Change default values so ejabberdctl run commands as ejabberd user
|
||||||
|
Also add a way for the user to change default values.
|
||||||
|
Signed-off-by: Johan Oudinet <johan.oudinet@gmail.com>
|
||||||
|
|
||||||
|
diff --git a/ejabberdctl.template b/ejabberdctl.template
|
||||||
|
index 79f4438..df0abba 100755
|
||||||
|
--- a/ejabberdctl.template
|
||||||
|
+++ b/ejabberdctl.template
|
||||||
|
@@ -14,7 +14,10 @@ SCRIPT_DIR=`cd ${0%/*} && pwd`
|
||||||
|
ERL={{erl}}
|
||||||
|
IEX={{bindir}}/iex
|
||||||
|
EPMD={{bindir}}/epmd
|
||||||
|
-INSTALLUSER={{installuser}}
|
||||||
|
+INSTALLUSER=ejabberd
|
||||||
|
+
|
||||||
|
+# Read default configuration file if present.
|
||||||
|
+[ ! -r /etc/default/ejabberd ] || . /etc/default/ejabberd
|
||||||
|
|
||||||
|
# check the proper system user is used if defined
|
||||||
|
if [ "$INSTALLUSER" != "" ] ; then
|
@ -3,30 +3,26 @@
|
|||||||
# Start/stop ejabberd
|
# Start/stop ejabberd
|
||||||
#
|
#
|
||||||
|
|
||||||
NAME=ejabberd
|
CTL=/usr/sbin/ejabberdctl
|
||||||
USER=ejabberd
|
DEFAULT=/etc/default/ejabberd
|
||||||
|
INSTALLUSER=ejabberd
|
||||||
RUNDIR=/var/run/ejabberd
|
RUNDIR=/var/run/ejabberd
|
||||||
SPOOLDIR=/var/lib/ejabberd
|
|
||||||
|
|
||||||
# Read configuration variable file if it is present.
|
# Read default configuration file if present.
|
||||||
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
[ -r "$DEFAULT" ] && . "$DEFAULT"
|
||||||
|
|
||||||
|
# Create RUNDIR.
|
||||||
mkrundir() {
|
mkrundir() {
|
||||||
install -d -o "$USER" -g "$USER" "$RUNDIR" "$SPOOLDIR"
|
install -d -o "$INSTALLUSER" -g "$INSTALLUSER" "$RUNDIR"
|
||||||
}
|
|
||||||
|
|
||||||
# Run ejabberdctl as user $USER.
|
|
||||||
ctl() {
|
|
||||||
su $USER -c "ejabberdctl $*"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
mkrundir || exit 1
|
mkrundir || exit 1
|
||||||
echo -n "Starting ejabberd... "
|
echo -n "Starting ejabberd... "
|
||||||
ctl start --spool "$SPOOLDIR"
|
"$CTL" start
|
||||||
# Wait until ejabberd is up and running.
|
# Wait until ejabberd is up and running.
|
||||||
if ctl started; then
|
if "$CTL" started; then
|
||||||
echo "done"
|
echo "done"
|
||||||
else
|
else
|
||||||
echo "failed"
|
echo "failed"
|
||||||
@ -34,23 +30,23 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
echo -n "Stopping ejabberd... "
|
echo -n "Stopping ejabberd... "
|
||||||
ctl stop > /dev/null
|
"$CTL" stop > /dev/null
|
||||||
if [ $? -eq 3 ] || ctl stopped; then
|
if [ $? -eq 3 ] || "$CTL" stopped; then
|
||||||
echo "OK"
|
echo "OK"
|
||||||
else
|
else
|
||||||
echo "failed"
|
echo "failed"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
ctl status
|
"$CTL" status
|
||||||
;;
|
;;
|
||||||
restart|force-reload)
|
restart|force-reload)
|
||||||
"$0" stop
|
"$0" stop || true
|
||||||
"$0" start
|
"$0" start
|
||||||
;;
|
;;
|
||||||
live)
|
live)
|
||||||
mkrundir || exit 1
|
mkrundir || exit 1
|
||||||
ctl live
|
"$CTL" live
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {start|stop|status|restart|force-reload|live}"
|
echo "Usage: $0 {start|stop|status|restart|force-reload|live}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user