#! /bin/sh # # sympa Mailing Lists Management System # # Written by Michel Bouissou 20/07/2000 # # Modified by Olivier Salaun 27/07/2000 # - translations # - lang parameter deleted (defined in sympa.conf) # - introduced parsed by Makefile # - no more sympauser since sympa sets its UID # Modified by Michel Bouissou 27/07/2000 # # chkconfig: 345 95 05 # description: sympa is a powerfull mailing lists management system. # Source function library. . /etc/rc.d/init.d/functions # Get config. . /etc/sysconfig/network # Sympa parameters # Sympa binaries directory sympadir="/usr/lib/sympa/bin" # Sympa config files directory sympaconf="/etc/sympa/sympa.conf" wwsympaconf="/etc/sympa/wwsympa.conf" # End of parameters # Current state of the module sympa_status() { # Test syntax. if [ $# = 0 ] ; then gprintf "Usage: sympa_status {program}\n" return 1 fi # First try "pidof" pid=`pidof -x $1.pl` if [ "$pid" != "" ] ; then gprintf "%s (pid %s) is active...\n" "$1" "$pid" return 0 fi # Next try "/var/run/*.pid" files if [ -f /var/run/$1.pl.pid ] ; then pid=`head -1 /var/run/$1.pl.pid` if [ "$pid" != "" ] ; then gprintf "%s died, pid file remains.\n" "$1" return 1 fi fi gprintf "%s is stopped.\n" "$1" return 3 } # Start a module sympa_module_start() { if [ $# = 0 ] ; then gprintf "Usage: sympa_module_start {program}\n" return 1 fi # if [ $1 = "sympa" -a $lang != "" ]; then # startparam="-l $lang" # else # startparam="" # fi daemon $sympadir/$1.pl $startparam sleep 1 pid=`pidof -x $sympadir/$1.pl` if [ $pid ]; then echo $pid > /var/run/$1.pl.pid fi echo } # Test state of module before startup sympa_start() { if [ $# = 0 ] ; then gprintf "Usage: sympa_start {program}\n" return 1 fi gprintf "Starting module %s.pl: " "$1" sympa_status $1 > /dev/null case "$?" in 3) sympa_module_start $1 ;; 1) gprintf "Starting %s, overwritting old pid file.\n" "$1" sympa_module_start $1 ;; 0) gprintf "%s seems active. No action will be taken.\n" "$1" gprintf "Try sympa status or sympa restart.\n" ;; esac } # Stop a module sympa_stop() { if [ $# = 0 ] ; then gprintf "Usage: sympa_stop {program}\n" return 1 fi if [ -f /var/run/$1.pl.pid ]; then gprintf "Stopping module %s.pl: " "$1" killproc $1.pl rm -f /var/run/$1.pl.pid echo fi } # Check that networking is up. if [ ${NETWORKING} = "no" ] then exit 0 fi # Check config files [ -d $sympadir ] || exit 0 [ -f $sympaconf ] || exit 0 [ -f $wwsympaconf ] || exit 0 # See how we were called. case "$1" in start) if [ ! -f /var/lock/subsys/sympa ]; then gprintf "Starting Sympa subsystem: \n" sympa_start sympa sympa_start archived sympa_start bounced touch /var/lock/subsys/sympa echo else gprintf "Sympa seems active. No action will be taken.\n" echo "Try \"sympa status\" or \"sympa restart"\". fi ;; stop) gprintf "Stopping Sympa subsystem: \n" sympa_stop bounced sympa_stop archived sympa_stop sympa if [ -f /var/lock/subsys/sympa ]; then rm -f /var/lock/subsys/sympa fi ;; status) gprintf "Status of Sympa subsystem: \n" gprintf "Status file for subsystem " if [ -f /var/lock/subsys/sympa ]; then gprintf "found.\n" else gprintf "NOT found.\n" fi sympa_status sympa sympa_status archived sympa_status bounced ;; restart) gprintf "Restarting Sympa subsystem: \n" $0 stop $0 start echo ;; *) gprintf "Usage: %s {start|stop|status|restart}\n" "$0" exit 1 ;; esac exit 0