<commit_before>#!/bin/bash

#
# This file is part of the FreeInstallServer.
# (c) 2011  <NAME> <<EMAIL>>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#

#
# Installation d'apache
#
function lamp_install_apache()
{
    # Installation de la base d'apache
    execute "${INSTALL_BIN} install apache2 apache2-utils"
    
    # Installation des modules de base
    execute "${INSTALL_BIN} install apache2-suexec libapache2-mod-evasive libapache-mod-security"
}


#
# Installation de MySQL
#
function lamp_install_mysql()
{
    # Configuration des options par défaut (évite d'avoir les fenêtres qui pose les questions)
    ## Ajout du mot de passe root de MySQL
    debconf-set-selections <<< "mysql-server-5.1 mysql-server/root_password password ${lamp_mysql_pass}"
    debconf-set-selections <<< "mysql-server-5.1 mysql-server/root_password_again password ${lamp_mysql_pass}"
    
    execute "${INSTALL_BIN} install mysql-server-5.1 mysql-client"
}

#
# Installation des dépendances de PHP
#
function lamp_install_deps()
{   
    # PHP 5.4
    execute "${INSTALL_BIN} install libxml2-dev libssl-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng-dev libxpm-dev libfreetype6-dev libc-client-dev libicu-dev libmcrypt-dev libxslt-dev"
    
    # PHP 5.3 (à ajouter à PHP 5.4)
    execute "${INSTALL_BIN} install libmysqlclient-dev"
    
    # PHP 5.2 (à ajouter à PHP 5.3)
    execute "${INSTALL_BIN} install libmhash-dev"
    
    # PHP 4 (à ajouter à PHP 5.2)
    execute "${INSTALL_BIN} install flex bison m4"
}


#
# Téléchargement et extraction de l'archive PHP
# @param    string      Le numéro de version de PHP
#
function lamp_install_download_extract_php()
{
    version="$1"
    
    execute "wget http://fr2.php.net/get/php-${version}.tar.bz2/from/this/mirror -O ${TEMPORARY_DIRECTORY}/php-${version}.tar.bz2"
    execute "tar -xjf ${TEMPORARY_DIRECTORY}/php-${version}.tar.bz2 -C ${COMPILATION_DIRECTORY} "
    execute "rm -f ${TEMPORARY_DIRECTORY}/php-${version}.tar.bz2"
}


#
# Compilation de PHP
# @param    string      Le numéro de version de PHP
# @param    string      la ligne de configuration de PHP
#
function lamp_install_compile_php()
{
    version="$1"
    configure="$2"
    current_dir=`pwd`
    
    cd "${COMPILATION_DIRECTORY}/php-${version}"
    execute "${COMPILATION_DIRECTORY}/php-${version}/${configure}"
    execute "make -f ${COMPILATION_DIRECTORY}/php-${version}/Makefile"
    execute "make -f ${COMPILATION_DIRECTORY}/php-${version}/Makefile install"
    
    cd "${current_dir}"
}

#
# Installation de PHP
#
function lamp_install_php()
{   
    # On installe chaque version voulue
    suphp_handler=""
    suphp_mod_apache=""
    
    # Installation des dépendances
    lamp_install_deps
    
    for version in ${lamp_php_versions}; do
        version=$(echo ${version} | sed 's/"//g')
        
        # PHP 5.4
        if [ "${version}" == "5_4" ]; then
            lamp_install_download_extract_php "${lamp_php54_version}"
            lamp_install_compile_php "${lamp_php54_version}" "${lamp_php54_configure}"
            php_path="\/usr\/local\/php54\/bin\/php-cgi"
        
        # PHP 5.3
        elif [ "${version}" == "5_3" ]; then
            lamp_install_download_extract_php "${lamp_php53_version}"
            lamp_install_compile_php "${lamp_php53_version}" "${lamp_php53_configure}"
            php_path="\/usr\/local\/php54\/bin\/php-cgi"
        
        # PHP 5.2
        elif [ "${version}" == "5_2" ]; then
            lamp_install_download_extract_php "${lamp_php52_version}"
            lamp_install_compile_php "${lamp_php52_version}" "${lamp_php52_configure}"
            php_path="\/usr\/local\/php54\/bin\/php-cgi"
        
        # PHP 4
        elif [ "${version}" == "4" ]; then
            lamp_install_download_extract_php "${lamp_php4_version}"
            lamp_install_compile_php "${lamp_php4_version}" "${install_php4}"
            php_path="\/usr\/local\/php4\/bin\/php-cgi"
            
            # Pour garder une cohérence, on renomme le CGI et on place le CLI
            execute "mv /usr/local/php4/bin/php /usr/local/php4/bin/php-cgi"
            execute "cp -p ${COMPILATION_DIRECTORY}/php-${lamp_php4_version}/sapi/cli/php /usr/local/php4/bin/php"
        fi
        
        # Handler suPHP
        current_handler="application\/x-httpd-suphp-${version}=\"php:${php_path}\""
        if [ "${suphp_handler}" == "" ]; then
            suphp_handler="${current_handler}"
        else
            suphp_handler="${suphp_handler}\n${current_handler}"<commit_msg>Modification des chemins de PHP<commit_after>#!/bin/bash

#
# This file is part of the FreeInstallServer.
# (c) 2011  <NAME> <<EMAIL>>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#

#
# Installation d'apache
#
function lamp_install_apache()
{
    # Installation de la base d'apache
    execute "${INSTALL_BIN} install apache2 apache2-utils"
    
    # Installation des modules de base
    execute "${INSTALL_BIN} install apache2-suexec libapache2-mod-evasive libapache-mod-security"
}


#
# Installation de MySQL
#
function lamp_install_mysql()
{
    # Configuration des options par défaut (évite d'avoir les fenêtres qui pose les questions)
    ## Ajout du mot de passe root de MySQL
    debconf-set-selections <<< "mysql-server-5.1 mysql-server/root_password password ${lamp_mysql_pass}"
    debconf-set-selections <<< "mysql-server-5.1 mysql-server/root_password_again password ${lamp_mysql_pass}"
    
    execute "${INSTALL_BIN} install mysql-server-5.1 mysql-client"
}

#
# Installation des dépendances de PHP
#
function lamp_install_deps()
{   
    # PHP 5.4
    execute "${INSTALL_BIN} install libxml2-dev libssl-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng-dev libxpm-dev libfreetype6-dev libc-client-dev libicu-dev libmcrypt-dev libxslt-dev"
    
    # PHP 5.3 (à ajouter à PHP 5.4)
    execute "${INSTALL_BIN} install libmysqlclient-dev"
    
    # PHP 5.2 (à ajouter à PHP 5.3)
    execute "${INSTALL_BIN} install libmhash-dev"
    
    # PHP 4 (à ajouter à PHP 5.2)
    execute "${INSTALL_BIN} install flex bison m4"
}


#
# Téléchargement et extraction de l'archive PHP
# @param    string      Le numéro de version de PHP
#
function lamp_install_download_extract_php()
{
    version="$1"
    
    execute "wget http://fr2.php.net/get/php-${version}.tar.bz2/from/this/mirror -O ${TEMPORARY_DIRECTORY}/php-${version}.tar.bz2"
    execute "tar -xjf ${TEMPORARY_DIRECTORY}/php-${version}.tar.bz2 -C ${COMPILATION_DIRECTORY} "
    execute "rm -f ${TEMPORARY_DIRECTORY}/php-${version}.tar.bz2"
}


#
# Compilation de PHP
# @param    string      Le numéro de version de PHP
# @param    string      la ligne de configuration de PHP
#
function lamp_install_compile_php()
{
    version="$1"
    configure="$2"
    current_dir=`pwd`
    
    cd "${COMPILATION_DIRECTORY}/php-${version}"
    execute "${COMPILATION_DIRECTORY}/php-${version}/${configure}"
    execute "make -f ${COMPILATION_DIRECTORY}/php-${version}/Makefile"
    execute "make -f ${COMPILATION_DIRECTORY}/php-${version}/Makefile install"
    
    cd "${current_dir}"
}

#
# Installation de PHP
#
function lamp_install_php()
{   
    # On installe chaque version voulue
    suphp_handler=""
    suphp_mod_apache=""
    
    # Installation des dépendances
    lamp_install_deps
    
    for version in ${lamp_php_versions}; do
        version=$(echo ${version} | sed 's/"//g')
        
        # PHP 5.4
        if [ "${version}" == "5_4" ]; then
            lamp_install_download_extract_php "${lamp_php54_version}"
            lamp_install_compile_php "${lamp_php54_version}" "${lamp_php54_configure}"
            php_path="\/usr\/local\/php54\/bin\/php-cgi"
        
        # PHP 5.3
        elif [ "${version}" == "5_3" ]; then
            lamp_install_download_extract_php "${lamp_php53_version}"
            lamp_install_compile_php "${lamp_php53_version}" "${lamp_php53_configure}"
            php_path="\/usr\/local\/php53\/bin\/php-cgi"
        
        # PHP 5.2
        elif [ "${version}" == "5_2" ]; then
            lamp_install_download_extract_php "${lamp_php52_version}"
            lamp_install_compile_php "${lamp_php52_version}" "${lamp_php52_configure}"
            php_path="\/usr\/local\/php52\/bin\/php-cgi"
        
        # PHP 4
        elif [ "${version}" == "4" ]; then
            lamp_install_download_extract_php "${lamp_php4_version}"
            lamp_install_compile_php "${lamp_php4_version}" "${install_php4}"
            php_path="\/usr\/local\/php4\/bin\/php-cgi"
            
            # Pour garder une cohérence, on renomme le CGI et on place le CLI
            execute "mv /usr/local/php4/bin/php /usr/local/php4/bin/php-cgi"
            execute "cp -p ${COMPILATION_DIRECTORY}/php-${lamp_php4_version}/sapi/cli/php /usr/local/php4/bin/php"
        fi
        
        # Handler suPHP
        current_handler="application\/x-httpd-suphp-${version}=\"php:${php_path}\""
        if [ "${suphp_handler}" == "" ]; then
            suphp_handler="${current_handler}"
        else
            suphp_handler="${suphp_handler}\n${current_handler}"
{'fraction_non_alphanumeric': 0.12877480586712683, 'fraction_numerical': 0.018550474547023296, 'mean_word_length': 2.9143098353735755, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '328487', 'n_tokens_mistral': 3157, 'n_tokens_neox': 3044, 'n_words': 667}