#!/bin/bash

if [ "$(CreoleGet activer_apache)" = 'oui' ];then
    # gestion des modes apache
    ENMOD="ssl rewrite authnz_ldap"
    DISMOD=""
    # gestion des cas particuliers (rpaf: #2570, jappix: #3151)
    if [ "$(CreoleGet activer_web_behind_revproxy)" = 'oui' ];then
        ENMOD="$ENMOD rpaf"
    else
        DISMOD="$DISMOD rpaf"
    fi
    if [ "$(CreoleGet activer_jappix non)" = 'oui' ];then
        ENMOD="$ENMOD proxy headers proxy_http"
    fi
    if [ "$(CreoleGet activer_eop non)" = 'oui' ];then
        ENMOD="$ENMOD proxy proxy_http"
    fi
    CreoleRun "/usr/sbin/a2enmod $ENMOD >/dev/null" web
    [ ! -z $DISMOD ] && CreoleRun "/usr/sbin/a2dismod $DISMOD >/dev/null" web
fi

# désactivation du shell pour www-data
container_path_web=$(CreoleGet container_path_web)
if [ -n "$container_path_web" ];then
    CHROOT="chroot $container_path_web"
else
    CHROOT=""
fi
TUSER="www-data"
NEWSHELL="/bin/false"
OLDSHELL="`$CHROOT getent passwd $TUSER|awk -F: '{ print $7 }'`"
[ ! "$OLDSHELL" = "$NEWSHELL" ] && $CHROOT usermod -s $NEWSHELL $TUSER

exit 0
