#!/bin/sh
#
# Install cron job
# Copyright 2005-2006 Florian Daeumling <jam@qv90.de>, Jaballa Software
# Licensed under the GNU GPL. For full terms see the file COPYING.
#

# terminate script in case of error
set -e

if [ "$1" != "" ]; then
 # parameter provided
 sm_path=$1
 cron_path=$2
else
 # get parameter from user
 tmp="/usr/share/squirrelmail/config"
 echo "# Enter full path to SquirrelMail configuration directory"
 read -p "(default: $tmp)> " sm_path
 if [ "$sm_path" == "" ]; then
  sm_path=$tmp
 fi
 tmp="/etc/cron.daily"
 echo "# Enter full path to daily cronjob directory"
 echo "# (for more information - 'man 5 contab')"
 read -p "(default: $tmp)> " cron_path
 if [ "$cron_path" == "" ]; then
  cron_path=$tmp
 fi
 cron_path=$cron_path/mail-expire
fi

sed s"<<SM_PATH>>""$sm_path"g ./mail-expire > $cron_path
chown root $cron_path
chmod a+x $cron_path

echo "Daily cron job mail-expire installed to $cron_path."
