freebsd-ports/astro/setiathome/files/setiathome.bin

143 lines
3.6 KiB
Text
Raw Normal View History

version bump to 3.08 w/ the following enhancements : - only one master shell to monitor multiple setiathome instances - wait some time for setiathome server to come up between restarts - xsetiathome comes back - -graphics is now the default (so xsetiathome may be launched) - registration heuristic changed (see comments below) - take care, some variable names have changed (see comments below) - manual page reviewed The setiathome manual page refer to setiathome.conf while it is now named rc.setiathome.conf. also, the manual page has been completed (variables, start/stop scripts, etc.) - gracefull startup script option added Makefile PORTVERSION bumped PORTREVISION deleted FORBIDDEN deleted BROKEN bumped to 4.0 NO_XBIN deleted except for linux_base-6 wrapper added pkg-install registration heuristic changed (don't register if already registered, then automatically start setiathome in either case) pkg-list $FreeBSD$ added libexec/setiathome.bin added pkg-message FreeBSD 5.x a.out comment changed to FreeBSD 4.x comment files/rc.setiathome.conf seti_std_args defaulted to "-email -graphics" seti_proxy_args changed to seti_proxy_server seti_socks_server, seti_socks_user, seti_socks_passwd added seti_sleep changed to seti_sleep_time files/setiathome.1 /usr/local changed to %%PREFIX%% above and below changes described files/setiathome.sh same changes as files/rc.setiathome.conf don't start setiathome if already started su heuristic changed to call an external wrapper gracefull (aka apachectl :) option added using stop_after_send.txt PR: 50723,51759,52297,52709 Submitted by: cyrille.lefevre@laposte.net
2003-06-01 07:45:34 +02:00
#!/bin/sh -T
# $FreeBSD$
# Copyright (c) 2003 Cyrille Lefevre. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. The name of the authors and contributors may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
setistart () { # dir
local dir
dir=$1
# goto the startup dir
cd ${dir} || return
# don't start a dying client
[ -f stop_after_send.txt ] && return
# fire up a setiathome client
${program_path} ${program_args} > /dev/null &
# memorize the startup dir
eval pid_$!=${dir}
# and the client process ID
setipids="${setipids} $!"
}
setikill () { # SIGTERM handler
local pids pid
# save pids to kill
pids="${sleeppid} ${setipids}"
# avoid futher setiathome startup
unset setipids
# kill'em all if any
for pid in ${pids}; do
ps p ${pid} > /dev/null && kill ${pid}
done
}
setirestart () { # SIGCHLD handler
local pids pid dir
# killing in progress
[ -n "${setipids}" ] || return
# restart in process
[ -n "${sleeppids}" ] && return
# wait for setiathome servers to come up
sleep ${seti_sleep_time} &
# wait even if more than one setiathome client dies
sleeppid=$!
while ps p ${sleeppid} > /dev/null; do
wait ${sleeppid}
done
unset sleeppid
# killing while sleeping
[ -n "${setipids}" ] || return
# save pids to restart
pids=${setipids}
# reset the process ID list
unset setipids
for pid in ${pids}; do
if ps p ${pid} > /dev/null; then
# still alive
setipids="${setipids} ${pid}"
else
# backup the startup dir
eval dir=\${pid_${pid}}
# clean the old one
unset pid_${pid}
# launch the dead client
eval setistart ${dir}
fi
done
}
if [ -z "${program_path}" ]; then
case $0 in
/*) rc_dir=${0%/*} ;;
*) rc_dir=${PWD:-$(pwd)} ;;
esac
rc_file=${0##*/}
rc_path=${rc_dir}/${rc_file}
if ! PREFIX=$(expr ${rc_path} : "\(/.*\)/libexec/${rc_file}\$"); then
echo "${rc_file}: Cannot determine PREFIX." >&2
echo "Please use the complete pathname." >&2
exit 64
fi
echo "Don't use this script directly, uses the following one instead :" >&2
echo " ${PREFIX}/etc/rc.d/${rc_file%.bin}.sh start" >&2
exit 1
fi
# save this shell process ID
echo $$ > ${seti_wrkdir}/shpid.sah
# setup handlers
trap setikill TERM
trap setirestart CHLD
# startup setiathome client(s)
for dir in ${seti_wrksuff}; do
setistart ${seti_wrkdir}/${dir}
done
# wait for them until death
while [ -n "${setipids}" ]; do
wait
done