#!/bin/sh

#script to install the webmail client

VER=2.7.9

REMOTE_FILE=http://files.directadmin.com/services/all/webmail-${VER}.tar.gz
FILE=/usr/local/directadmin/scripts/packages/webmail-${VER}.tar.gz;
DEST=/var/www/html;
TMPDIR=${DEST}/webmail/tmp

OS=`uname`
TAR=/bin/tar
MKDIR=/bin/mkdir
CHMOD=/bin/chmod
CHOWN=/bin/chown

if [ "$OS" = "FreeBSD" ]; then
	TAR=/usr/bin/tar
	CHOWN=/usr/sbin/chown
fi

if [ ! -e ${FILE} ]; then
	wget -O $FILE $REMOTE_FILE
fi

if [ ! -e ${FILE} ]; then
	echo "Unable to find ${FILE}, make sure it exists.";
	exit -1;
fi

$TAR xzf ${FILE} -C ${DEST}
$MKDIR -p $TMPDIR
$CHMOD -f -R 700 $TMPDIR;
$CHOWN -f -R apache:apache $TMPDIR;

if [ ! -e $TMPDIR/.htaccess ]; then
	echo "Deny from All" >> $TMPDIR/.htaccess
fi

############
# If you can't access /webmail from any domain, add:
#
# Alias /webmail /var/www/html/webmail/
#
# to your httpd.conf
#
# also, make sure that .inc is a valid php handler (along with .php .php3 etc)

