#!/bin/ksh
#
# $Revision: 1.2 $ $Date: 2012-07-26 17:11:49-04 $
# $Source: /home/vogelke/bin/RCS/shaid,v $
# $Host: sys7.com $
# $UUID: 827b734d-b1ae-3dee-9253-d5debd9495a3 $
#
#<shaid: use SHA1 to generate a decent message-id.
# should work on stdin or a file.
# requires: hostname shasum

PATH=/usr/local/bin:/opt/sfw/bin:/bin:/usr/bin
export PATH

# Comes from /var/qmail/control/idhost file
case "$IDHOST" in
    "") host=$(hostname 2> /dev/null) ;;
    *)  host="$IDHOST" ;;
esac

case "$host" in
    "") host='localhost' ;;
    *)  ;;
esac

# Redirect stdin if we have a file.
case "$#" in
    0) ;;
    *) exec <"$1" ;;
esac

# Generate a Message-ID based on sha1sum.
set X $(shasum)
echo "Message-ID: <$2@$host>"
exit 0
