#!/bin/bash 
#
# @package      hubzero-metrics
# @file         _setup_permissions_temp
# @author       Swaroop Shivarajapura <swaroop@purdue.edu>
# @copyright    Copyright (c) 2011-2013 HUBzero Foundation, LLC.
# @license      http://www.gnu.org/licenses/lgpl-3.0.html LGPLv3
#
# Copyright (c) 2011-2013 HUBzero Foundation, LLC.
#
# This file is part of: The HUBzero(R) Platform for Scientific Collaboration
#
# The HUBzero(R) Platform for Scientific Collaboration (HUBzero) is free
# software: you can redistribute it and/or modify it under the terms of
# the GNU Lesser General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# HUBzero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# HUBzero is a registered trademark of HUBzero Foundation, LLC.
#

SCRIPT=`readlink -f $0`
SCRIPTPATH=`dirname $SCRIPT`

# These permissions needs to be set in OGRE so it is not changed by log rotate.

if [ -f /etc/hubzero.conf ]
then
  site=$(grep site= /etc/hubzero.conf | sed 's/site=//')
else
  site=hub
fi

mkdir -p /var/log/hubzero/daily
chmod -R 770 /var/log/hubzero/daily
chown -R www-data /var/log/hubzero/daily
chgrp -R www-data /var/log/hubzero/daily

mkdir -p /var/log/hubzero/imported
chmod -R 770 /var/log/hubzero/imported
chown -R www-data /var/log/hubzero/imported
chgrp -R www-data /var/log/hubzero/imported

mkdir -p /var/log/apache2/daily
chmod -R 770 /var/log/apache2/daily
chown -R www-data /var/log/apache2/daily
chgrp -R www-data /var/log/apache2/daily

mkdir -p /var/log/apache2/imported
chmod -R 770 /var/log/apache2/imported
chown -R www-data /var/log/apache2/imported
chgrp -R www-data /var/log/apache2/imported

chmod -R 750 /opt/hubzero/bin/metrics
chown -R www-data /opt/hubzero/bin/metrics
chgrp -R www-data /opt/hubzero/bin/metrics

mkdir -p /www/$site/site/stats/chart_resources
chmod -R 750 /www/$site/site/stats/chart_resources
chown -R www-data /www/$site/site/stats/chart_resources
chgrp -R www-data /www/$site/site/stats/chart_resources

mkdir -p /www/$site/site/stats/plots
chmod -R 750 /www/$site/site/stats/plots
chown -R www-data /www/$site/site/stats/plots
chgrp -R www-data /www/$site/site/stats/plots
