cybrid
January 18th, 2009, 08:36 PM
Hi everyone, I have a problem with a bash script I'm trying to code; one of the things I always do in the machine I use as home server, is to build apache and php from sources (using the latests ones) and I also like to try diferent distros, so with the time I became tired of doing the same compilation process all over again each time I tested a new distro, so I said to myself, "Hey you sure can automate it with a bash script, why not try it?", so there I put myself to work, but It crashes just at the very begining and I'm unable to see why...
Does anybody see something wrong in the code?.
#!/usr/bin/env sh
################################################## ##
# Author: xabier.burgos@gmail.com
# Date: 18/01/2009
# Version: 0.1
# License: GPLv3
################################################## ##
############## Initial vars ########################
DEFAULT_PHP_INSTALL_DIR="/usr/local/php"
CONFIGURE_COMMAND="--with-install-dir="
############## Script start ########################
echo "Especifica directorio de instalacion para PHP: "
read PHP_INSTALL_DIR
if [ -n "$PHP_INSTALL_DIR" ]; then
$CONFIGURE_COMMAND="${CONFIGURE_COMMAND}${PHP_INSTALL_DIR}"
else
echo "No has especificado un directorio de instalacion para PHP, se utilizara $DEFAULT_PHP_INSTALL_DIR en su lugar"
mkdir $DEFAULT_PHP_INSTALL_DIR
fi
echo '¿Deseas soporte para GD?: [yes/no]'
read GD
if [ $GD=='yes' ]; then
echo 'Especifica directorio de instalacion de GD:'
read GD_INSTALL_DIR
if [ -n "$GD_INSTALL_DIR" ]; then
$CONFIGURE_COMMAND="${CONFIGURE_COMMAND} --with--gd=${GD_INSTALL_DIR}"
echo 'Especifica directorio de instalacion de libjpeg:'
read LIBJPEG_INSTALL_DIR
if [ -n "$LIBJPEG_INSTALL_DIR" ]; then
$CONFIGURE_COMMAND="${CONFIGURE_COMMAND} --with-jpeg-dir=${LIBJPEG_INSTALL_DIR}"
echo 'Especifica directorio de instalacion de libpng:'
read LIBPNG_INSTALL_DIR
if [ -n "$LIBPNG_INSTALL_DIR" ]; then
$CONFIGURE_COMMAND="${CONFIGURE_COMMAND} --with-png-dir=${LIBPNG_INSTALL_DIR}"
else
echo "libpng es necesario para incluir soporte para GD, la ruta introducida no es valida, luego el soporte para GD sera eliminado"
fi
else
echo "libjpeg es necesario para incluir soporte para GD, la ruta introducida no es valida, luego el soporte para GD sera eliminado"
fi
fi
fi
echo '¿Deseas soporte para CURL?: [yes/no]'
read CURL
if [ $CURL=='yes' ]; then
echo 'Especifica directorio de instalacion de CURL:'
read CURL_INSTALL_DIR
if [ -n "$CURL_INSTALL_DIR" ]; then
$CONFIGURE_COMMAND="${CONFIGURE_COMMAND} --with-curl-dir=${CURL_INSTALL_DIR}"
fi
fi
echo '¿Deseas soporte para MySQL?: [yes/no]'
read MYSQL
if [ $MYSQL=='yes' ]; then
echo 'Especifica directorio de instalacion de MySQLi:'
read MYSQLI_INSTALL_DIR
if [ -n "$MYSQLI_INSTALL_DIR" ]; then
$CONFIGURE_COMMAND="${CONFIGURE_COMMAND} --with-mysql-dir=${MYSQLI_INSTALL_DIR}"
fi
fi
echo '¿Deseas instalar PHP como modulo de Apache 2?: [yes/no]'
read APACHE
if [ $APACHE=='yes' ]; then
echo 'Especifica directorio de instalacion de APACHE:'
read APACHE_INSTALL_DIR
if [ -n "$APACHE_INSTALL_DIR" ]; then
$CONFIGURE_COMMAND="${CONFIGURE_COMMAND' --with-apxs2=${APACHE_INSTALL_DIR}"
fi
fi
echo "Configurando PHP..."
echo "./configure $CONFIGURE_COMMAND"
echo 'Compilando PHP...'
make
echo "Instalando PHP..."
make install
P.S: The script isn't finished yet.
Does anybody see something wrong in the code?.
#!/usr/bin/env sh
################################################## ##
# Author: xabier.burgos@gmail.com
# Date: 18/01/2009
# Version: 0.1
# License: GPLv3
################################################## ##
############## Initial vars ########################
DEFAULT_PHP_INSTALL_DIR="/usr/local/php"
CONFIGURE_COMMAND="--with-install-dir="
############## Script start ########################
echo "Especifica directorio de instalacion para PHP: "
read PHP_INSTALL_DIR
if [ -n "$PHP_INSTALL_DIR" ]; then
$CONFIGURE_COMMAND="${CONFIGURE_COMMAND}${PHP_INSTALL_DIR}"
else
echo "No has especificado un directorio de instalacion para PHP, se utilizara $DEFAULT_PHP_INSTALL_DIR en su lugar"
mkdir $DEFAULT_PHP_INSTALL_DIR
fi
echo '¿Deseas soporte para GD?: [yes/no]'
read GD
if [ $GD=='yes' ]; then
echo 'Especifica directorio de instalacion de GD:'
read GD_INSTALL_DIR
if [ -n "$GD_INSTALL_DIR" ]; then
$CONFIGURE_COMMAND="${CONFIGURE_COMMAND} --with--gd=${GD_INSTALL_DIR}"
echo 'Especifica directorio de instalacion de libjpeg:'
read LIBJPEG_INSTALL_DIR
if [ -n "$LIBJPEG_INSTALL_DIR" ]; then
$CONFIGURE_COMMAND="${CONFIGURE_COMMAND} --with-jpeg-dir=${LIBJPEG_INSTALL_DIR}"
echo 'Especifica directorio de instalacion de libpng:'
read LIBPNG_INSTALL_DIR
if [ -n "$LIBPNG_INSTALL_DIR" ]; then
$CONFIGURE_COMMAND="${CONFIGURE_COMMAND} --with-png-dir=${LIBPNG_INSTALL_DIR}"
else
echo "libpng es necesario para incluir soporte para GD, la ruta introducida no es valida, luego el soporte para GD sera eliminado"
fi
else
echo "libjpeg es necesario para incluir soporte para GD, la ruta introducida no es valida, luego el soporte para GD sera eliminado"
fi
fi
fi
echo '¿Deseas soporte para CURL?: [yes/no]'
read CURL
if [ $CURL=='yes' ]; then
echo 'Especifica directorio de instalacion de CURL:'
read CURL_INSTALL_DIR
if [ -n "$CURL_INSTALL_DIR" ]; then
$CONFIGURE_COMMAND="${CONFIGURE_COMMAND} --with-curl-dir=${CURL_INSTALL_DIR}"
fi
fi
echo '¿Deseas soporte para MySQL?: [yes/no]'
read MYSQL
if [ $MYSQL=='yes' ]; then
echo 'Especifica directorio de instalacion de MySQLi:'
read MYSQLI_INSTALL_DIR
if [ -n "$MYSQLI_INSTALL_DIR" ]; then
$CONFIGURE_COMMAND="${CONFIGURE_COMMAND} --with-mysql-dir=${MYSQLI_INSTALL_DIR}"
fi
fi
echo '¿Deseas instalar PHP como modulo de Apache 2?: [yes/no]'
read APACHE
if [ $APACHE=='yes' ]; then
echo 'Especifica directorio de instalacion de APACHE:'
read APACHE_INSTALL_DIR
if [ -n "$APACHE_INSTALL_DIR" ]; then
$CONFIGURE_COMMAND="${CONFIGURE_COMMAND' --with-apxs2=${APACHE_INSTALL_DIR}"
fi
fi
echo "Configurando PHP..."
echo "./configure $CONFIGURE_COMMAND"
echo 'Compilando PHP...'
make
echo "Instalando PHP..."
make install
P.S: The script isn't finished yet.