On 12/31/2011 12:18 PM, Chris Wiegand wrote:

So we switched successfully to sipXecs, which is stable and people are pretty impressed, but one issue we've run into is that although users can get their voicemails emailed to them, it's still in the system as well, so they have to still login to the VM system (or visit the website) and remove their voicemails from there, making the emails a little redundant. Our old system, sucky though it was, had an option to remove them when it emailed them to the user -- anything I'm doing wrong here? I can't find any checkbox to enable that functionality. If it's not there, is there any plan to add it to 4.6 or a future release? Or, is there a way for me to remove them after a period of time / in batches?


This script moves inbox messages to the deleted folder if they are order than 90 days (there is a var to change the number of days it you want).
Here is a little thing we drop into /etc/cron.daily:

#!/bin/sh
# voicemail_inbox_clean.sh: moves voicemail messages older than n days to the deleted folder.
# where a day is defined as a 24 hour period.

check_prop_file_exists() {
    local exists=0
    if ! test -f "$1"
    then
        echo "Property file not found: '$1'" >&2
        exists=1
    fi
    return ${exists}
}
get_prop_value() {
# ensure property file exists and then pull out the
# requested property value
    check_prop_file_exists "$1" \
&& perl -n \
        -e 'use English;' \
        -e 's/#.*$//;' \
-e "/^\\s*$2\\s*=\\s*/ && print join( ' ', split( /[\\s,]+/, \$POSTMATCH ));" \
        $1
}

MAILSTORE_DIR=/var/sipxdata/mediaserver/data/mailstore
DAYS=90
# Override the DAYS variable with optional command line argument
if [ "$1" == "--days" ]; then
  if [[ "$2" == [1-9] ]]; then
    if [[ "$2" < "$DAYS" ]]; then
      DAYS=$2
    fi
  fi
fi

CleanList=`mktemp -t voicemail_inbox_clean.XXXXXX`
trap "rm ${CleanList} 2>/dev/null" 0

if [ -d ${MAILSTORE_DIR} ]
then
for deleted_dir in `find ${MAILSTORE_DIR} -maxdepth 2 -type d -name inbox `
    do
        if cd "${deleted_dir}" > /dev/null 2>&1
        then
# Find all voice messages that are more than $DAYS old. Base the test # on the last modified date for the voice message "envelope" file.
            # echo ${deleted_dir}
            cat /dev/null > ${CleanList}
for name_prefix in `find . -mtime +${DAYS} -name "*-*.xml" | cut -d - -f 1`
            do
# Remove all files with a .sta, .wav or .xml extension that have the
                # same filename prefix as the old voice message envelope.
                for expired in ${name_prefix}-*.{sta,wav,xml}
                do
                  test -f $expired && echo $expired >> ${CleanList}
                done
            done

            if [ -s ${CleanList} ]
            then
# Now that we've deleted messages, the summary.xml file is no longer # accurate. Delete it so that it gets recreated next time it is accessed.
                test -f summary.xml && echo summary.xml >> ${CleanList}
                # rm -f `cat ${CleanList}`
                # cat $CleanList
                touch -cm `cat ${CleanList}`
                mv -t ../deleted `cat ${CleanList}`

            fi
        else
            echo "failed to cd to '${deleted_dir}'" 1>&2
        fi
    done

else
    echo "Mailstore '${MAILSTORE_DIR}' not found" 1>&2
    exit 1
fi

--
Regards
--------------------------------------
Gerald Drouillard
Technology Architect
Drouillard&  Associates, Inc.
http://www.Drouillard.biz

_______________________________________________
sipx-users mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-users/

Reply via email to