#!/bin/sh
# change ownership and acl
chown -R root.http /var/services/web/z-push/
chmod 750 /var/services/web/z-push
chmod 640 /var/services/web/z-push/*
chmod 400 /var/services/web/z-push/INSTALL
chmod 400 /var/services/web/z-push/LICENSE
chmod 400 /var/services/web/z-push/*.txt
# make executable admin and top
chmod 750 /var/services/web/z-push/z-push-admin.php
chmod 750 /var/services/web/z-push/z-push-top.php

chmod 750 /var/services/web/z-push/autodiscover
chmod 750 /var/services/web/z-push/backend
chmod 750 /var/services/web/z-push/include
chmod 750 /var/services/web/z-push/lib
# logs and state need write for http, state recursive
chmod 770 /var/services/web/z-push/logs
chmod 660 /var/services/web/z-push/logs/*
chmod 640 /var/services/web/z-push/logs/.htaccess
chmod 770 $(find /var/services/web/z-push/state/ -type d)
chmod 660 $(find /var/services/web/z-push/state/ -type f)
chmod 640 /var/services/web/z-push/state/.htaccess
chmod 750 /var/services/web/z-push/tools

chmod 640 /var/services/web/z-push/autodiscover/*
chmod 400 /var/services/web/z-push/autodiscover/INSTALL
# backend and lib has only dirs
chmod 750 /var/services/web/z-push/backend/*
chmod 640 /var/services/web/z-push/include/*
chmod 750 /var/services/web/z-push/lib/*
chmod 640 /var/services/web/z-push/tools/*
chmod 750 /var/services/web/z-push/tools/dev
chmod 640 /var/services/web/z-push/tools/dev/*
# fix backend and lib sub-dirs
chmod 640 /var/services/web/z-push/backend/combined/*
chmod 640 /var/services/web/z-push/backend/imap/*
chmod 640 /var/services/web/z-push/backend/maildir/*
chmod 640 /var/services/web/z-push/backend/searchldap/*
chmod 640 /var/services/web/z-push/backend/vcarddir/*
chmod 640 /var/services/web/z-push/backend/zarafa/*
# listfolders has to be executable
chmod 750 /var/services/web/z-push/backend/zarafa/listfolders.php
chmod 750 /var/services/web/z-push/backend/zarafa/mapi
chmod 640 /var/services/web/z-push/backend/zarafa/mapi/*

chmod 640 /var/services/web/z-push/lib/core/*
chmod 640 /var/services/web/z-push/lib/default/*
chmod 750 /var/services/web/z-push/lib/default/diffbackend
chmod 640 /var/services/web/z-push/lib/default/diffbackend/*
chmod 640 /var/services/web/z-push/lib/exceptions/*
chmod 640 /var/services/web/z-push/lib/interface/*
chmod 640 /var/services/web/z-push/lib/request/*
chmod 640 /var/services/web/z-push/lib/syncobjects/*
# make executable syncresolverecipient.php
chmod 750 /var/services/web/z-push/lib/syncobjects/syncresolverecipient.php
chmod 640 /var/services/web/z-push/lib/utils/*
chmod 640 /var/services/web/z-push/lib/wbxml/*
chmod 640 /var/services/web/z-push/lib/webservice/*

if [ -f /var/services/web/z-push/.htaccess ]
then
   chmod 640 /var/services/web/z-push/.htaccess 
fi

exit 0
