#!/bin/sh #---------------------------------------------------------------------------------- # /var/install/bin/vbox-cleanup-incoming-dirs - cleanup directory content # # Copyright (c) 2002-2019 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2007-11-28 jed # Last Update: $Id$ # # Usage: vbox-cleanup-incoming-dirs [number-of-days-in-the-past] # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------------- # read eislib . /var/install/include/eislib . /var/install/include/jedlib # set variables vbox_spooldir=/var/spool/vbox pgmname=`basename $0` num_days='14' if [ -n "$1" ] then if `is_numeric $1` then num_days=$1 fi fi . /etc/config.d/vbox # get date in the past (seconds since 01.01.1970 UTC) del_timesec=`date -d "${num_days} days ago UTC" +"%s"` idx=1 while [ ${idx} -le ${VBOX_USER_N} ] do # process mailboxes eval vbox_active='$VBOX_USER_'${idx}'_ACTIVE' if [ "${vbox_active}" = "yes" ] then # active, go on ... eval vbox_name='$VBOX_USER_'${idx}'_NAME' # check if files exist ... ls ${vbox_spooldir}/${vbox_name}/incoming/000* >/dev/null 2>/dev/null if [ $? -eq 0 ] then # process files ... for FNAME in `ls ${vbox_spooldir}/${vbox_name}/incoming/000*` do # extract date from file name (seconds since 01.01.1970 UTC) s_name=`basename ${FNAME}` timesec=`echo ${s_name} | cut -d- -f1` if [ ${timesec} -lt ${del_timesec} ] then # delete file echo "- file to delete: ${s_name}" rm -f ${FNAME} fi done fi fi idx=`expr ${idx} + 1` done