Automatic Policyd Zcs8.5
Automatic Policyd Zcs8.5
Automatic Policyd Zcs8.5
# Date
waktu=`date +%y%m%d%H%M%S`
echo -e
"########################################################################
##"
echo -e "# Script Automatic Configure PolicyD
#"
echo -e "# Rate Limit Sending Message & Reject Unlisted Domain
#"
echo -e "# Ahmad Imanudin - http://www.imanudin.net
#"
echo -e "# If any question, please feel free to contact us at below
#"
echo -e "# Contact at ahmad@imanudin.com
#"
echo -e "# iman@imanudin.net
#"
echo -e
"########################################################################
##"
echo ""
cd /opt/zimbra/cbpolicyd/share/webui/
touch .htaccess
echo 'AuthUserFile /opt/zimbra/cbpolicyd/share/webui/.htpasswd' >
/opt/zimbra/cbpolicyd/share/webui/.htaccess
echo 'AuthGroupFile /dev/null' >>
/opt/zimbra/cbpolicyd/share/webui/.htaccess
echo 'AuthName "User and Password"' >>
/opt/zimbra/cbpolicyd/share/webui/.htaccess
echo 'AuthType Basic' >> /opt/zimbra/cbpolicyd/share/webui/.htaccess
echo '' >> /opt/zimbra/cbpolicyd/share/webui/.htaccess
echo '<LIMIT GET>' >> /opt/zimbra/cbpolicyd/share/webui/.htaccess
echo 'require valid-user' >> /opt/zimbra/cbpolicyd/share/webui/.htaccess
echo '</LIMIT>' >> /opt/zimbra/cbpolicyd/share/webui/.htaccess
cp /opt/zimbra/conf/httpd.conf $lokasibackup
echo 'Alias /webui /opt/zimbra/cbpolicyd/share/webui/' >>
/opt/zimbra/conf/httpd.conf
echo '<Directory /opt/zimbra/cbpolicyd/share/webui/>' >>
/opt/zimbra/conf/httpd.conf
echo 'AllowOverride AuthConfig' >> /opt/zimbra/conf/httpd.conf
echo 'Order Deny,Allow' >> /opt/zimbra/conf/httpd.conf
echo 'Allow from all' >> /opt/zimbra/conf/httpd.conf
echo '</Directory>' >> /opt/zimbra/conf/httpd.conf
touch /tmp/policyd.sql
echo "delete from 'policy_groups' where id=100;" > /tmp/policyd.sql
echo "delete from 'policy_group_members' where id=100;" >>
/tmp/policyd.sql
echo "delete from 'policies' where id=100;" >> /tmp/policyd.sql
echo "delete from 'policy_members' where id=100;" >> /tmp/policyd.sql
echo "delete from 'access_control' where id=100;" >> /tmp/policyd.sql
echo "delete from 'policies' where id=101;" >> /tmp/policyd.sql
echo "delete from 'policy_members' where id=101;" >> /tmp/policyd.sql
echo "delete from 'policy_members' where id=102;" >> /tmp/policyd.sql
echo "delete from 'quotas' where id=101;" >> /tmp/policyd.sql
echo "delete from 'quotas_limits' where id=101;" >> /tmp/policyd.sql
echo "insert into 'policy_groups' values(100,'list_domain',0,0);" >>
/tmp/policyd.sql
echo "insert into 'policy_group_members' values(100,100,'@$DOMAIN',0,0);"
>> /tmp/policyd.sql
echo "insert into 'policies' values(100,'Reject Unlisted
Domain',20,'Reject Unlisted Domain',0);" >> /tmp/policyd.sql
echo "insert into 'policy_members'
values(100,100,'!%list_domain','!%list_domain',0,0);" >> /tmp/policyd.sql
echo "insert into 'access_control' values(100,100,'Reject Unlisted
Domain','REJECT','Sorry, you are not authorized to sending
email','Reject Unlisted Domain',0);" >> /tmp/policyd.sql
echo "insert into 'policies' values(101,'Rate Limit Sending
Message',21,'Rate Limit Sending Message',0);" >> /tmp/policyd.sql
echo "insert into 'policy_members'
values(101,101,'%list_domain','!%list_domain',0,0);" >> /tmp/policyd.sql
echo "insert into 'policy_members'
values(102,101,'!%list_domain','any',0,0);" >> /tmp/policyd.sql
echo "insert into 'quotas' values(101,101,'Rate Limit Sending
Message','Sender:user@domain',3600,'DEFER','Max sending email has been
full at last 3600s',0,'Rate Limit Sending Message',0);" >>
/tmp/policyd.sql
echo "insert into 'quotas_limits' values(101,101,'MessageCount',300,'Rate
Limit',0);" >> /tmp/policyd.sql
su - zimbra -c "sqlite3 /opt/zimbra/data/cbpolicyd/db/cbpolicyd.sqlitedb
< /tmp/policyd.sql"
su - zimbra -c "zmcbpolicydctl restart"
echo ""
echo "Configure PolicyD has been finished, please try to access via
browser PolicyD WebUI on url http://$namaserver:7780/webui/index.php"