Just so I don’t lose it if I forget and wipe my dev box…
This is a Mac OS X StartupItem for Sympa, which is essentially just the standard init script they distribute, but with the non-OS X stuff pulled out and redone with StartService() etc for the StartupItem format.
Note that you need to add “SYMPA=-YES-” to /etc/hostconfig for this to work, and that this assumes sympa is all installed in /usr/local/sympa as per the coming entry…
#!/bin/sh
. /etc/rc.common
sympadir="/usr/local/sympa/bin"
sympaconf="/usr/local/sympa/etc/sympa.conf"
wwsympaconf="/usr/local/sympa/etc/wwsympa.conf"
sympa_status()
{
if [ -f /var/run/$1.pid ] ; then
pid=`head -1 /var/run/$1.pid`
if [ "$pid" != "" ] ; then
running=`ps -A | grep "$pid"`
if [ "$running" != "" ]; then
ConsoleMessage "Sympa: $1 (pid $pid) is active..."
return 0
else
ConsoleMessage "Sympa: $1 died, pid file remains."
return 1
fi
fi
fi
echo "$1 is stopped."
return 3
}
sympa_module_start() {
$sympadir/$1.pl || ConsoleMessage "Sympa: failure starting $1"
}
sympa_start() {
sympa_status $1 > /dev/null
case "$?" in
3)
ConsoleMessage "Sympa: Starting module $1.pl: "
sympa_module_start $1
;;
1)
ConsoleMessage "Sympa: Starting $1, overwritting old pid file."
sympa_module_start $1
;;
0)
ConsoleMessage "Sympa: $1 seems active. No action will be taken."
;;
esac
}
sympa_stop() {
if [ -f /var/run/$1.pid ]; then
ConsoleMessage "Sympa: Stopping module $1.pl: "
pid=`head -1 /var/run/$1.pid`
running=`ps -A | grep "$pid"`
if [ "$running" != "" ]; then
kill -TERM $pid
else
ConsoleMessage "Sympa: $1 died"
fi
else
ConsoleMessage "Sympa: Module $1.pl not running"
fi
}
StartService ()
{
if [ "${SYMPA:=-NO-}" = "-YES-" ]; then
if [ ! -f /var/sympa ]; then
ConsoleMessage "Sympa: Starting service:"
sympa_start sympa
sympa_start archived
sympa_start bounced
sympa_start task_manager
touch /var/sympa
else
ConsoleMessage "Sympa seems active. No action will be taken."
fi
fi
}
StopService ()
{
if [ "${SYMPA:=-NO-}" = "-YES-" ]; then
ConsoleMessage "Sympa: Stopping service:"
sympa_stop bounced
sympa_stop archived
sympa_stop sympa
sympa_stop sympa-distribute
sympa_stop task_manager
if [ -f /var/sympa ]; then
rm -f /var/sympa
fi
fi
}
RestartService ()
{
if [ "${SYMPA:=-NO-}" = "-YES-" ]; then
StopService
StartService
fi
}
RunService "$1"