#!/bin/sh
#
#
#LocINFO Fetchmail and return
#

# run fetchmail in the foreground and wait for them all to finish.
# Always exit with an error so that we revert to the base location
#
case "$1" in
'start')
	if [ -f /etc/fetchmail.users ]
	then
		while read User
		do
		    if id $User >/dev/null 2>&1
		    then
			/bin/su $User -c "/usr/local/bin/fetchmail -d 0 >/tmp/$User.fetchmail.log 2>&1"
		    fi
		done </etc/fetchmail.users
		wait
	fi
	exit 1
	;;
'stop')
	;;
*)
	echo "Usage: /etc/init.d/fmail { start | stop }"
	;;
esac
exit 0
