#!/bin/sh
##############################################################################
#
#  Copyright (c) 2005, Doremi Labs, Inc.
#    All rights reserved.
#
#  Redistribution in source or binary forms, with or without
#  modification, are NOT permitted.
#
#    Doremi Labs, Inc.
#    306 East Alameda Avenue
#    Burbank, CA 91502
#    Tel : (818) 562 1101
#    Fax : (818) 562 1109
#
#  version 1.0: hmorillon, August 11th 2010
#  
##############################################################################

# Fix PHP post_max_size value if necessary
if grep -q 'post_max_size = 8M' /etc/php5/cgi/php.ini; then
	sed -e 's/post_max_size = 8M/post_max_size = 64M/g' -i /etc/php5/cgi/php.ini
fi

# Fix magic quotes if necessary
if grep -q 'magic_quotes_gpc = On' /etc/php5/cgi/php.ini; then
	sed -e 's/magic_quotes_gpc = On/magic_quotes_gpc = Off/g' -i /etc/php5/cgi/php.ini
fi

# Create symlinks
ln -sf ../conf-available/42-drm-json.conf     /etc/lighttpd/conf-enabled/42-drm-json.conf
ln -sf ../conf-available/42-drm-soap.conf     /etc/lighttpd/conf-enabled/42-drm-soap.conf
ln -sf ../conf-available/42-drm-dax.conf      /etc/lighttpd/conf-enabled/42-drm-dax.conf
ln -sf ../conf-available/42-drm-default.conf  /etc/lighttpd/conf-enabled/42-drm-default.conf
ln -sf ../conf-available/42-drm-sub.conf      /etc/lighttpd/conf-enabled/42-drm-sub.conf
ln -sf ../conf-available/42-drm-web.conf      /etc/lighttpd/conf-enabled/42-drm-web.conf
ln -sf ../conf-available/42-drm-web.conf      /etc/lighttpd/conf-enabled/42-drm-web.conf
ln -sf ../conf-available/42-drm-extra.conf    /etc/lighttpd/conf-enabled/42-drm-extra.conf
ln -sf ../conf-available/42-drm-aux.conf      /etc/lighttpd/conf-enabled/42-drm-aux.conf
ln -sf ../conf-available/42-drm-rpls.conf     /etc/lighttpd/conf-enabled/42-drm-rpls.conf
ln -sf ../conf-available/42-drm-ssl.conf      /etc/lighttpd/conf-enabled/42-drm-ssl.conf

if ! test -e /var/log/lighttpd/error.log ; then
        touch /var/log/lighttpd/error.log
        chown www-data:www-data /var/log/lighttpd/error.log
        chmod 0644 /var/log/lighttpd/error.log
fi

exit 0
