[packages/ejabberd] Startup scripts updated

jajcus jajcus at pld-linux.org
Thu Nov 14 22:48:09 CET 2013


commit fcf4c7a2585bb31c622e13c2d3dfb88e3100a700
Author: Jacek Konieczny <jajcus at jajcus.net>
Date:   Thu Nov 14 21:39:36 2013 +0100

    Startup scripts updated

 ejabberd-inetrc            |  3 ---
 ejabberd-inetrc_path.patch | 24 +++++++++++++++++++
 ejabberd.init              | 48 +++++++++++++++-----------------------
 ejabberd.sh                | 23 ------------------
 ejabberd.spec              | 58 ++++++++++++++++++++++++++++++++--------------
 ejabberd.sysconfig         | 10 +-------
 ejabberdctl.sh             | 18 --------------
 7 files changed, 85 insertions(+), 99 deletions(-)
---
diff --git a/ejabberd.spec b/ejabberd.spec
index 5c17c0f..c8dc501 100644
--- a/ejabberd.spec
+++ b/ejabberd.spec
@@ -1,7 +1,5 @@
 #
 # TODO:
-#	- config migration from old versions
-#	- check/udpate the init script
 #	- add systemd unit
 
 # Conditional build:
@@ -22,9 +20,6 @@ Source0:	http://www.process-one.net/downloads/ejabberd/%{version}/%{realname}-%{
 # Source0-md5:	94ce4fe244ee72771eeafe27209d6d3c
 Source1:	%{realname}.init
 Source2:	%{realname}.sysconfig
-Source3:	%{realname}.sh
-Source4:	%{realname}ctl.sh
-Source5:	%{realname}-inetrc
 #
 # Archives created with the ejabberd-pack_deps.sh script (in this repo)
 Source10:	ejabberd-goldrush-20131108.tar.gz
@@ -63,6 +58,7 @@ Patch0:		%{realname}-makefile.patch
 #Patch1:		%{realname}-vcard-access-get.patch
 # http://www.dp.uz.gov.ua/o.palij/mod_logdb/patch-mod_logdb-2.1.12.diff
 Patch2:		%{realname}-mod_logdb.patch
+Patch3:		%{realname}-inetrc_path.patch
 URL:		http://www.ejabberd.im/
 BuildRequires:	autoconf
 BuildRequires:	automake
@@ -85,6 +81,8 @@ Requires:	expat >= 1.95
 Requires:	rc-scripts
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
+%define		_noautoprovfiles	%{_libdir}/%{name}/priv/lib/
+
 %description
 ejabberd is a Free and Open Source fault-tolerant distributed Jabber
 server. It is written mostly in Erlang.
@@ -108,6 +106,7 @@ Server-side logging module.
 %if %{with logdb}
 %patch2 -p0
 %endif
+%patch3 -p1
 
 %build
 %{__aclocal} -I m4
@@ -166,15 +165,15 @@ sed -e's, at libdir@,%{_libdir},g' -e 's, at EJABBERD_DOC_PATH@,%{_docdir}/%{name}-%{v
 install %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/%{realname}
 
 chmod u+rw $RPM_BUILD_ROOT%{_sbindir}/%{realname}*
-sed -e's, at libdir@,%{_libdir},g' %{SOURCE3} > $RPM_BUILD_ROOT%{_sbindir}/%{realname}
-sed -e's, at libdir@,%{_libdir},g' %{SOURCE4} > $RPM_BUILD_ROOT%{_sbindir}/%{realname}ctl
-install %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/jabber
 
 chmod 755 $RPM_BUILD_ROOT%{_libdir}/ejabberd/priv/lib/*.so
 
 rm -rf _doc 2>/dev/null || :
 mv $RPM_BUILD_ROOT%{_docdir}/%{name} _doc
 
+touch $RPM_BUILD_ROOT%{_sysconfdir}/jabber/ejabberd.cfg
+touch $RPM_BUILD_ROOT/var/lib/ejabberd/.erlang.cookie
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
@@ -185,6 +184,11 @@ if [ -e /etc/jabber/ejabberd.cfg ] ; then
 		echo "this is not supported by this ejabberd version in PLD" >&2
 		exit 1
 	fi
+	%banner -e %{name} <<'EOF'
+Old-style /etc/jabber/ejabberd.cfg configuration file exists. You should
+consider converting it to the new YAML format. You can do this with the
+ejabberctl command.
+EOF
 fi
 
 %post
@@ -192,17 +196,10 @@ if [ -f %{_sysconfdir}/jabber/secret ] ; then
 	SECRET=`cat %{_sysconfdir}/jabber/secret`
 	if [ -n "$SECRET" ] ; then
 		echo "Updating component authentication secret in ejabberd config file..."
-		%{__sed} -i -e "s/>secret</>$SECRET</" /etc/jabber/ejabberd.cfg
+		%{__sed} -i -e "s/>secret</>$SECRET</" /etc/jabber/ejabberd.yml
 	fi
 fi
 
-if [ ! -f %{_sysconfdir}/jabber/cookie ] ; then
-	echo "Generating erl authentication cookie..."
-	umask 066
-	perl -e 'open R,"/dev/urandom"; read R,$r,16;
-		printf "%02x",ord(chop $r) while($r);' > %{_sysconfdir}/jabber/cookie
-fi
-
 /sbin/chkconfig --add ejabberd
 %service ejabberd restart "ejabberd server"
 
@@ -212,17 +209,44 @@ if [ "$1" = "0" ]; then
 	/sbin/chkconfig --del ejabberd
 fi
 
+%triggerpostun -- %{name} < 13.10
+# convert old 'NODENAME' in /etc/sysconfig/ejabberd
+# to 'ERLANG_NODE' in /etc/jabber/ejabberdctl.cfg
+# and move other settings
+NODENAME="$(hostname)"
+if [ -e /etc/sysconfig/ejabberd ] ; then
+	. /etc/sysconfig/ejabberd || :
+fi
+subst="s/^#ERLANG_NODE=.*/ERLANG_NODE=ejabberd@${NODENAME}/"
+if [ -n "$ERL_MAX_PORTS" ] ; then
+	subst="$subst;s/^#ERL_MAX_PORTS=.*/ERL_MAX_PORTS=${ERL_MAX_PORTS}/"
+fi
+sed -i -e"$subst" /etc/jabber/ejabberdctl.cfg || :
+if [ -e /etc/sysconfig/ejabberd ] ; then
+	sed -i.rpmsave \
+		-e'/^[#[:space:]]*NODENAME=/d;/^# Node name/d' \
+		-e'/^[#[:space:]]*ERL_MAX_PORTS=/d;/^# uncomment this to allow more then 1024 connections/d' \
+		-e'/^[#[:space:]]*ERL_FULLSWEEP_AFTER=/d;/^# uncomment this to limit memory usage/d' \
+		/etc/sysconfig/ejabberd || :
+fi
+cp %{_sysconfdir}/jabber/cookie /var/lib/ejabberd/.erlang.cookie || :
+
 %files
 %defattr(644,root,root,755)
 %doc sql _doc/*
 %attr(755,root,root) %{_sbindir}/*
-%attr(640,root,jabber) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/jabber/*
+%attr(640,root,jabber) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/jabber/ejabberd-inetrc
+%attr(640,root,jabber) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/jabber/ejabberd.yml
+%attr(640,root,jabber) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/jabber/ejabberdctl.cfg
+# legacy config may still be there
+%attr(640,root,jabber) %ghost %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/jabber/ejabberd.cfg
 %attr(770,root,jabber) /var/log/ejabberd
 %if %{with logdb}
 %exclude %{_libdir}/ejabberd/ebin/mod_logdb*
 %endif
 %{_libdir}/ejabberd
 %dir %attr(770,root,jabber) /var/lib/ejabberd
+%ghost %attr(400,jabber,jabber) %ghost %config(noreplace) %verify(not md5 mtime size) /var/lib/ejabberd/.erlang.cookie
 %attr(754,root,root) /etc/rc.d/init.d/%{realname}
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{realname}
 
diff --git a/ejabberd-inetrc b/ejabberd-inetrc
deleted file mode 100644
index 1619ee8..0000000
--- a/ejabberd-inetrc
+++ /dev/null
@@ -1,3 +0,0 @@
-{file, hosts, "/etc/hosts"}.
-{file, resolv, "/etc/resolv.conf"}.
-{lookup, [file, dns]}.
diff --git a/ejabberd-inetrc_path.patch b/ejabberd-inetrc_path.patch
new file mode 100644
index 0000000..bd4a7a6
--- /dev/null
+++ b/ejabberd-inetrc_path.patch
@@ -0,0 +1,24 @@
+diff -dur -x '*~' ejabberd-13.10.orig/Makefile.in ejabberd-13.10/Makefile.in
+--- ejabberd-13.10.orig/Makefile.in	2013-11-14 20:21:37.000000000 +0100
++++ ejabberd-13.10/Makefile.in	2013-11-14 20:30:48.745590816 +0100
+@@ -123,7 +123,7 @@
+ 	[ -f $(ETCDIR)/ejabberdctl.cfg ] \
+ 		&& $(INSTALL) -b -m 640 $(G_USER) ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg-new \
+ 		|| $(INSTALL) -b -m 640 $(G_USER) ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg
+-	$(INSTALL) -b -m 644 $(G_USER) inetrc $(ETCDIR)/inetrc
++	$(INSTALL) -b -m 644 $(G_USER) inetrc $(ETCDIR)/ejabberd-inetrc
+ 	#
+ 	# Administration script
+ 	[ -d $(SBINDIR) ] || $(INSTALL) -d -m 755 $(SBINDIR)
+diff -dur -x '*~' ejabberd-13.10.orig/ejabberdctl.template ejabberd-13.10/ejabberdctl.template
+--- ejabberd-13.10.orig/ejabberdctl.template	2013-09-27 11:19:22.000000000 +0200
++++ ejabberd-13.10/ejabberdctl.template	2013-11-14 20:27:04.240688181 +0100
+@@ -104,7 +104,7 @@
+ SASL_LOG_PATH=$LOGS_DIR/erlang.log
+ DATETIME=`date "+%Y%m%d-%H%M%S"`
+ ERL_CRASH_DUMP=$LOGS_DIR/erl_crash_$DATETIME.dump
+-ERL_INETRC=$ETCDIR/inetrc
++ERL_INETRC=$ETCDIR/ejabberd-inetrc
+ HOME=$SPOOLDIR
+ 
+ # define erl parameters
diff --git a/ejabberd.init b/ejabberd.init
index 395801a..f4060c4 100644
--- a/ejabberd.init
+++ b/ejabberd.init
@@ -14,20 +14,25 @@
 # Get service config - may override defaults
 [ -f /etc/sysconfig/ejabberd ] && . /etc/sysconfig/ejabberd
 
-[ -z "$NODENAME" ] && NODENAME=$(hostname)
-
 EJABBERD_DOC_PATH="@EJABBERD_DOC_PATH@"
-export EJABBERD_DOC_PATH
+EJABBERD_PID_PATH=/var/run/jabber/ejabberd.pid
+export EJABBERD_DOC_PATH EJABBERD_PID_PATH
 
 start() {
 	# Check if the service is already running?
 	if [ ! -f /var/lock/subsys/ejabberd ]; then
-		export ERL_MAX_PORTS ERL_FULLSWEEP_AFTER
 		msg_starting ejabberd
-		daemon /usr/sbin/ejabberd
+		/usr/sbin/ejabberdctl start
 		RETVAL=$?
 		if [ $RETVAL -eq 0 ]; then
+			/usr/sbin/ejabberdctl started
+			RETVAL=$?
+		fi
+		if [ $RETVAL -eq 0 ]; then
 			touch /var/lock/subsys/ejabberd
+			ok
+		else
+			fail
 		fi
 	else
 		msg_already_running ejabberd
@@ -37,10 +42,14 @@ start() {
 stop() {
 	# Stop daemons.
 	if [ -f /var/lock/subsys/ejabberd ]; then
-		msg_stopping ejabberd
-		/usr/sbin/ejabberdctl ejabberd@${NODENAME} stop 2>/dev/null
+		msg_stopping ejabberd ; busy
+		/usr/sbin/ejabberdctl stop 2>/dev/null
 		RETVAL=$?
 		if [ $RETVAL -eq 0 ]; then
+			/usr/sbin/ejabberdctl stopped 2>/dev/null
+			RETVAL=$?
+		fi
+		if [ $RETVAL -eq 0 ]; then
 			ok
 		else
 			fail
@@ -61,40 +70,21 @@ case "$1" in
 	;;
   restart)
 	stop
-	sleep 2
 	start
 	;;
   reload|force-reload)
 	if [ -f /var/lock/subsys/ejabberd ]; then
-		msg_reloading ejabberd
-		busy
-		/usr/sbin/ejabberdctl ejabberd@${NODENAME} restart
+		stop
+		start
 		RETVAL=$?
-		if [ $RETVAL -eq 0 ]; then
-		    ok
-		else
-		    RETVAL=1
-		    fail
-		fi
 	else
 		msg_not_running ejabberd
 		RETVAL=7
 	fi
 	;;
   status)
-	EPMDOUT=`@libdir@/erlang/bin/epmd -names`
-	echo "$EPMDOUT" | head -n 1
-	echo "$EPMDOUT" | grep ejabberd
+	status --pidfile $EJABBERD_PID_PATH ejabberd
 	RETVAL=$?
-	if [ "$RETVAL" -ne "0" ] ; then
-		if [ -f /var/lock/subsys/ejabberd ]; then
-			nls "%s dead but subsys locked" "ejabberd"
-			RETVAL=2
-		else
-			nls "%s is stopped" "ejabberd"
-			RETVAL=3
-		fi
-	fi
 	;;
   *)
 	msg_usage "$0 {start|stop|status|restart|reload|force-reload}"
diff --git a/ejabberd.sh b/ejabberd.sh
deleted file mode 100644
index 3949d18..0000000
--- a/ejabberd.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-umask 007 || exit $?
-cd /var/lib/ejabberd || exit $?
-
-COOKIE=`cat /etc/jabber/cookie`
-
-COMMAND="setsid erl -pa @libdir@/ejabberd/ebin \
-      -setcookie $COOKIE \
-      -sname ejabberd \
-      -s ejabberd \
-      -ejabberd config \\\"/etc/jabber/ejabberd.cfg\\\" \
-      log_path \\\"/var/log/ejabberd/ejabberd.log\\\" \
-      -sasl sasl_error_logger \\{file,\\\"/var/log/ejabberd/sasl.log\\\"\\} \
-      -kernel inetrc \\\"/etc/jabber/ejabberd-inetrc\\\" \
-      -heart \
-      -detached"
-
-if [ "`id -u`" -eq "0" ] ; then
-	exec su -s /bin/sh jabber -c "exec $COMMAND"
-else
-	eval "exec $COMMAND"
-fi
diff --git a/ejabberd.sysconfig b/ejabberd.sysconfig
index 3983f47..191b67a 100644
--- a/ejabberd.sysconfig
+++ b/ejabberd.sysconfig
@@ -1,11 +1,3 @@
-# Nice level for jabberd
+# Nice level for ejabberd
 SERVICE_RUN_NICE_LEVEL="+0"
 
-# Node name
-NODENAME="localhost"
-
-# uncomment this to allow more then 1024 connections (increases memory usage)
-#ERL_MAX_PORTS=32000
-
-# uncomment this to limit memory usage (and make ejabberd slower)
-#ERL_FULLSWEEP_AFTER=0
diff --git a/ejabberdctl.sh b/ejabberdctl.sh
deleted file mode 100644
index 1c4c963..0000000
--- a/ejabberdctl.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-cd /var/lib/ejabberd || exit $?
-
-COOKIE=`cat /etc/jabber/cookie`
-
-COMMAND="erl -pa @libdir@/ejabberd/ebin \
-      -setcookie $COOKIE \
-      -noinput \
-      -sname ejabberdctl \
-      -s ejabberd_ctl \
-      -extra $@"
-
-if [ "`id -u`" -eq "0" ] ; then
-	exec su -s /bin/sh jabber -c "exec $COMMAND"
-else
-	eval "exec $COMMAND"
-fi
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/ejabberd.git/commitdiff/9a6073b0a82f0356c3c97a4ecaf387361b0a22b8



More information about the pld-cvs-commit mailing list