#!/bin/bash - 
#===============================================================================
#
#          FILE:  ctasd-setfile
# 
#         USAGE:  ./ctasd-setfile
# 
#   DESCRIPTION:  This is to set all files in qmail control folder for ctasd service
# 
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR: Jithesh B (jithesh@glowtouch.com), 
#  ORGANIZATION: Glowtouch
#       CREATED: 01/03/2012 02:58:16 PM PST
#      REVISION:  ---
#===============================================================================
CHOWN="$(which chown)"
CHMOD="$(which chmod)"
TOUCH="$(which touch)"
CAT="$(which echo)"
controlpath='/var/qmail/control'
control=('ctasd_check_outbound' 'ctasd_queue_binary' 'ctasd_onsession_out_block_bulk' 'ctasd_onsession_out_block_spam' 'ctasd_onsession_out_block_vhigh' 'ctasd_onsession_out_block_virus' 'ctasd_onsession_out_totmsgs_num' 'ctasd_onsession_out_totspam_action' 'ctasd_onsession_out_totspam_num' 'ctasd_onsession_out_totsusp_action' 'ctasd_onsession_out_totsusp_num' 'ctasd_onsession_out_totvirus_action' 'ctasd_onsession_out_totvirus_num' 'ctasd_report_imap_folder' 'ctasd_require_scan' 'ctasd_senderid_senderip' 'ctasd_senderid_smtpauth' 'ctasd_onsession_out_totmsgs_action')
for name in ${control[@]}
do
	pathtoc='/dev/null'
	pathtocs=$controlpath'/'$name
	if [ -f $pathtocs ]
	then
			$CHOWN psaadm:root $pathtocs
		elif [ $name == 'ctasd_onsession_out_totmsgs_num' ]
			then
					$CAT   "1
" > $pathtoc
			elif [ $name == 'ctasd_onsession_out_totspam_num' ]
			then
					$CAT  "1
" > $pathtoc
			elif [ $name == 'ctasd_onsession_out_totsusp_num' ]
			then
					$CAT  "1
" > $pathtoc
			elif [ $name == 'ctasd_onsession_out_totvirus_num' ]
			then
					$CAT  "1
" > $pathtoc
			elif [ $name == 'ctasd_senderid_senderip' ]
			then
					$CAT  "1
" > $pathtoc
			elif [ $name == 'ctasd_report_imap_folder' ]
			then
					$TOUCH $pathtoc
			elif [ $name == 'ctasd_queue_binary' ]
			then
					$CAT  "bin/qmail-queue.plesk.ctch" > $pathtocs
$CHOWN psaadm:root $pathtocs
			else
					$CAT  "0
" > $pathtoc
		#	$CHOWN psaadm:root $pathtocs
	fi
done

