In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Joey Hess) writes:
> I lookd at how smail currently does it: it uses the crontab command to add a > crontab for the mail user. However, it doesn't check to see if the mail user > already has a crontab. Seems very broken to me. Try looking at how exim does it---it adds a crontab for the mail user, but does correctly handle the mail user's existing crontab. To install it does this: # Install in crontab for user mail if not there oldcrontab=$(crontab -u mail -l|tail +4) if [ "$(echo "$oldcrontab"|grep exim)" == "" ]; then cat <<EOM | crontab -u mail - $oldcrontab 23 * * * * /usr/sbin/exim -q EOM fi # Uncomment crontab entry if it's commented crontab -u mail -l | tail +4 | sed 's/^#\(.*exim\)/\1/' \ | crontab -u mail - On remove (prerm) it does: # Comment out crontab entry crontab -u mail -l | tail +4 | sed 's/^\(.*exim\)/#\1/' \ | crontab -u mail - And on purge it does: # Remove from mail user's crontab crontab -u mail -l | tail +4 | grep -v exim | crontab -u mail - The tail +4 in each case is to get rid of the header. (By the way, I'd like to apologise for the ^Ms on the end of the lines of this and other postings I've made to the debian lists. This is a bug in knews which I'm in the middle of trying to fix. Obviously I'll file a bug report with my patch when I've got it working). .