[Pkg-sympa-commits] [SCM] sympa Debian packaging branch, master, updated. debian/6.1.7_dfsg-1-14-g351ae33
Emmanuel Bouthenot
kolter at openics.org
Sun Dec 4 19:25:37 UTC 2011
The following commit has been merged in the master branch:
commit ec86043857f9eb4b92c1962d43fbc44564937cfe
Author: Emmanuel Bouthenot <kolter at openics.org>
Date: Sat Nov 26 20:06:23 2011 +0000
Full rewrite of init script to be more robust and more verbose (#568543)
diff --git a/debian/init b/debian/init
deleted file mode 100644
index 4f39d94..0000000
--- a/debian/init
+++ /dev/null
@@ -1,126 +0,0 @@
-#!/bin/sh
-
-### BEGIN INIT INFO
-# Provides: sympa
-# Required-Start: $remote_fs $syslog
-# Required-Stop: $remote_fs $syslog
-# Should-Start: mysql postgresql
-# Should-Stop: mysql postgresql
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: start and stop the SYMPA mailing list manager
-# Description: SYMPA is a mailing list manager
-### END INIT INFO
-
-PATH=/bin:/usr/bin:/sbin:/usr/sbin
-
-DAEMON=/usr/lib/sympa/bin/sympa.pl
-RUNDIR=/var/run/sympa
-PIDFILE=/var/run/sympa/sympa.pid
-
-ARCHIVED_DAEMON=/usr/lib/sympa/bin/archived.pl
-ARCHIVED_PIDFILE=/var/run/sympa/archived.pid
-
-BOUNCED_DAEMON=/usr/lib/sympa/bin/bounced.pl
-BOUNCED_PIDFILE=/var/run/sympa/bounced.pid
-
-BULK_DAEMON=/usr/lib/sympa/bin/bulk.pl
-BULK_PIDFILE=/var/run/sympa/bulk.pid
-
-TASK_MANAGER_DAEMON=/usr/lib/sympa/bin/task_manager.pl
-TASK_MANAGER_PIDFILE=/var/run/sympa/task_manager.pid
-
-OWNER="sympa:sympa"
-
-. /lib/lsb/init-functions
-
-use_db()
-{
- conf=/etc/sympa/sympa.conf
-
- grep -q "^[[:space:]]*db_name" $conf &&\
- grep -q "^[[:space:]]*db_type" $conf &&\
- return 0
-
- return 1
-}
-
-test -f $DAEMON || exit 0
-test -f $ARCHIVED_DAEMON || exit 0
-test -f $BOUNCED_DAEMON || exit 0
-test -f $BULK_DAEMON || exit 0
-test -f $TASK_MANAGER_DAEMON || exit 0
-
-case "$1" in
- start)
- # check for /var/run/sympa/ which maybe have only been on a tempfs
- if [ ! -d $RUNDIR ]; then
- mkdir -p $RUNDIR
- chown $OWNER $RUNDIR
- chmod 755 $RUNDIR
- fi
-
- log_daemon_msg "Starting Sympa mailing list manager" "sympa"
- start-stop-daemon --start --quiet --pidfile $PIDFILE \
- --chuid $OWNER --exec $DAEMON
- log_end_msg 0
-
- if use_db ; then
- # only sympa itself works without RDBMS
- log_daemon_msg "Starting Sympa bulk daemon" "bulk"
- start-stop-daemon --start --quiet --pidfile $BULK_PIDFILE \
- --chuid $OWNER --exec $BULK_DAEMON
- log_end_msg 0
-
- log_daemon_msg "Starting Sympa mailing list archive manager" "archived"
- start-stop-daemon --start --quiet --pidfile $ARCHIVED_PIDFILE \
- --chuid $OWNER --exec $ARCHIVED_DAEMON
- log_end_msg 0
-
- log_daemon_msg "Starting Sympa task manager" "task_manager"
- start-stop-daemon --start --quiet --pidfile $TASK_MANAGER_PIDFILE \
- --chuid $OWNER --exec $TASK_MANAGER_DAEMON
- log_end_msg 0
-
- log_daemon_msg "Starting Sympa bounce manager" "bounced"
- start-stop-daemon --start --quiet --pidfile $BOUNCED_PIDFILE \
- --chuid $OWNER --exec $BOUNCED_DAEMON
- log_end_msg 0
- fi
- ;;
- stop)
- if use_db ; then
- # only sympa itself works without RDBMS
- log_daemon_msg "Stopping Sympa bounce manager" "bounced"
- start-stop-daemon --stop --quiet --pidfile $BOUNCED_PIDFILE
- log_end_msg 0
-
- log_daemon_msg "Stopping Sympa task manager" "task_manager"
- start-stop-daemon --stop --quiet --pidfile $TASK_MANAGER_PIDFILE
- log_end_msg 0
-
- log_daemon_msg "Stopping Sympa mailing list archive manager" "archived"
- start-stop-daemon --stop --quiet --pidfile $ARCHIVED_PIDFILE
- log_end_msg 0
-
- log_daemon_msg "Stopping Sympa bulk daemon" "bulk"
- start-stop-daemon --stop --quiet --pidfile $BULK_PIDFILE
- log_end_msg 0
- fi
-
- log_daemon_msg "Stopping Sympa mailing list manager" "sympa"
- start-stop-daemon --stop --quiet --pidfile $PIDFILE
- log_end_msg 0
- ;;
- restart|force-reload|reload)
- $0 stop
- sleep 3
- $0 start
- ;;
- *)
- echo "Usage: /etc/init.d/sympa {start|stop|restart|reload|force-reload}"
- exit 1
- ;;
-esac
-
-exit 0
diff --git a/debian/sympa.init b/debian/sympa.init
new file mode 100644
index 0000000..72126f1
--- /dev/null
+++ b/debian/sympa.init
@@ -0,0 +1,149 @@
+#!/bin/sh
+
+set -e
+
+### BEGIN INIT INFO
+# Provides: sympa
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Should-Start: mysql postgresql
+# Should-Stop: mysql postgresql
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: start and stop the SYMPA mailing list manager
+# Description: SYMPA is a mailing list manager
+### END INIT INFO
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+RUNDIR=/var/run/sympa
+EXECPATH=/usr/lib/sympa/bin
+USER=sympa
+GROUP=sympa
+
+NAME="sympa"
+DESC="Sympa mailing list manager"
+
+DAEMONS="sympa task_manager bulk bounced archived"
+
+if [ -f /etc/default/sympa ]; then
+ . /etc/default/sympa
+fi
+
+for daemon in $DAEMONS ; do
+ if [ ! -f "${EXECPATH}/${daemon}.pl" ]; then
+ exit 0
+ fi
+done
+
+. /lib/lsb/init-functions
+
+reverse_order() {
+ RET=
+ for elem in $1 ; do
+ RET="$elem $RET"
+ done
+ echo $RET
+}
+
+create_rundir() {
+ if [ ! -d "$RUNDIR" ]; then
+ mkdir -p "$RUNDIR"
+ fi
+ chown "${USER}:${GROUP}" "$RUNDIR"
+ chmod 0755 "$RUNDIR"
+}
+
+get_daemon_pid() {
+ ps -eo pid,user,cmd|egrep "^[0-9]+ ${USER} .* ${EXECPATH}/${1}.pl" | cut -d ' ' -f1
+}
+
+isrunning_sympa() {
+ RET=1
+ for daemon in $DAEMONS ; do
+ if [ "$(get_daemon_pid "$daemon")" != "" ]; then
+ RET=0
+ break
+ fi
+ done
+ return $RET
+}
+
+status_sympa() {
+ log_daemon_msg "Status of $DESC"
+ for daemon in $DAEMONS ; do
+ pid=$(get_daemon_pid "$daemon")
+ if [ "$pid" != "" ]; then
+ log_progress_msg "$daemon (pid $pid)"
+ else
+ log_progress_msg "$daemon (not running)"
+ fi
+ done
+ log_end_msg 0
+}
+
+start_sympa() {
+ ERRORS=
+ create_rundir
+ log_daemon_msg "Starting $DESC"
+ if ! isrunning_sympa ; then
+ for daemon in $DAEMONS ; do
+ log_progress_msg "$daemon"
+ start-stop-daemon --start --quiet --chuid "${USER}:${GROUP}" \
+ --pidfile "${RUNDIR}/${daemon}.pid" \
+ --exec "${EXECPATH}/${daemon}.pl" || ERRORS="$ERRORS $daemon"
+ done
+ log_end_msg 0
+ if [ "$ERRORS" != "" ]; then
+ log_daemon_msg "Some daemons failed to be started:$ERRORS"
+ log_end_msg 1
+ fi
+ else
+ log_progress_msg "$NAME is already running (see status command)"
+ log_end_msg 1
+ fi
+}
+
+stop_sympa() {
+ ERRORS=
+ log_daemon_msg "Stoping $DESC"
+ for daemon in $(reverse_order "$DAEMONS") ; do
+ log_progress_msg "$daemon"
+ start-stop-daemon --stop --quiet \
+ --pidfile "${RUNDIR}/${daemon}.pid" || ERRORS="$ERRORS $daemon"
+ done
+ log_end_msg 0
+ if [ "$1" != "--quiet" ]; then
+ if [ "$ERRORS" != "" ]; then
+ log_daemon_msg "Some daemons failed to be stopped (not running?):$ERRORS"
+ log_end_msg 1
+ fi
+ fi
+}
+
+case "$1" in
+ start)
+ start_sympa
+ ;;
+ stop)
+ stop_sympa
+ ;;
+ restart)
+ stop_sympa --quiet
+ start_sympa
+ ;;
+ reload|force-reload)
+ if isrunning_sympa ; then
+ stop_sympa || true
+ start_sympa
+ fi
+ ;;
+ status)
+ status_sympa
+ ;;
+ *)
+ echo "Usage: $(readlink -f "$0") {start|stop|restart|reload|force-reload|status}"
+ exit 1
+ ;;
+esac
+
+exit 0
--
sympa Debian packaging
More information about the Pkg-sympa-commits
mailing list