#!/bin/bash
#
# Copyright (c) 2005 rPath, Inc.
#
# This program is distributed under the terms of the Common Public License,
# version 1.0. A copy of this license should have been distributed with this
# source file in a file called LICENSE. If it is not present, the license
# is always available at http://www.opensource.org/licenses/cpl.php.
#
# This program is distributed in the hope that it will be useful, but
# without any waranty; without even the implied warranty of merchantability
# or fitness for a particular purpose. See the Common Public License for
# full details.
#

# This is a temporary compatibility wrapper around the new commitaction
# script and its changemail module.

DN=$(dirname $0)
ADDRS=""
ARGS=""
COMMITARGS=""

while [ $# -gt 0 ] ; do
    case $1 in
        --email)
            shift
            ADDRS="$ADDRS $1"
            shift
            ;;
        --*user)
            ARGS="$ARGS $1 $2"
            shift; shift
            ;;
        --*)
            COMMITARGS="$COMMITARGS $1 $2"
            shift; shift
            ;;
        *)
            ADDRS="$ADDRS $1"
            shift
            ;;
    esac
done

# Uncomment this after a few releases
logger -p daemon.err -t changemail "Deprecated changemail script; use commitaction --module \"$DN/changemail ARGS\" instead"

exec $DN/commitaction $COMMITARGS --module "$DN/changemail $ARGS" $ADDRS
