Instalación de Freeswitch desde los fuentes sobre Ubuntu 8.04LTS + FusionPBX

En realidad lo instalo sobre un equipo con eBox (http://www.ebox-platform.com)

Desde los fuentes.

Freeswitch 1.0.6
FusionPBX 1.1
eBox 1.4.3

-------------------------------------------------------------------
---                1.-   Instalación desde los sources          ---
-------------------------------------------------------------------
Si tienes algún resto de otra instalación de freeswitch es mejor que la quites de enmedio:
(ojo que pierdes la configuración)

$sudo apt-get purge freeswitch
$sudo apt-get autoremove freeswitch
$sudo dpkg --purge freeswitch

1.- Instalamos las dependencias necesarias (todo en una linea o con la barra inclinada)
    $sudo apt-get install subversion autoconf automake libtool gcc-3.4 libncurses5-dev \
        make libexpat1-dev zlibc zlib-bin git-core libiodbc2-dev  libgnutls-dev libogg-dev \
        libvorbis-dev libcurl4-openssl-dev g++

2.- Descargamos en un directorio temporal de nuestra cuenta los fuentes de la última versión:
    $ wget http://files.freeswitch.org/freeswitch-1.0.6.tar.gz
     $ tar xvfz freeswitch-1.0.6.tar.gz
    $ cd freeswitch-1.0.6/

3.- Pasamos a la compilación
   
    $ ./configure

    $ sudo make

Un mensaje del tipo:
+---------- FreeSWITCH Build Complete ----------+
 + FreeSWITCH has been successfully built.       +
 + Install by running:                           +
 +                                               +
 +                make install                   +
 +-----------------------------------------------+

Nos indica que el make está ok, ahora el:

    $ sudo make install
   
Otro mensaje nos indica el éxito de la operación:

+---------- FreeSWITCH install Complete ----------+
 + FreeSWITCH has been successfully installed.     +
 +                                                 +
 +       Install sounds:                           +
 +       (uhd-sounds includes hd-sounds, sounds)   +
 +       (hd-sounds includes sounds)               +
 +       ------------------------------------      +
 +                make cd-sounds-install           +
 +                make cd-moh-install              +
 +                                                 +
 +                make uhd-sounds-install          +
 +                make uhd-moh-install             +
 +                                                 +
 +                make hd-sounds-install           +
 +                make hd-moh-install              +
 +                                                 +
 +                make sounds-install              +
 +                make moh-install                 +
 +                                                 +
 +       Install non english sounds:               +
 +       replace XX with language                  +
 +       (ru : Russian)                            +
 +       ------------------------------------      +
 +                make cd-sounds-XX-install        +
 +                make uhd-sounds-XX-install       +
 +                make hd-sounds-XX-install        +
 +                make sounds-XX-install           +
 +                                                 +
 +       Upgrade to latest:                        +
 +       ----------------------------------        +
 +                make current                     +
 +                                                 +
 +       Rebuild all:                              +
 +       ----------------------------------        +
 +                make sure                        +
 +                                                 +
 +       Install/Re-install default config:        +
 +       ----------------------------------        +
 +                make samples                     +
 +                                                 +
 +                                                 +
 +       Additional resources:                     +
 +       ----------------------------------        +
 +       http://www.freeswitch.org                 +
 +       http://wiki.freeswitch.org                +
 +       http://jira.freeswitch.org                +
 +       http://lists.freeswitch.org               +
 +                                                 +
 +       irc.freenode.net / #freeswitch            +
 +                                                 +
 +       Register For ClueCon:                     +
 +       ----------------------------------        +
 +       http://www.cluecon.com                    +
 +                                                 +
 +-------------------------------------------------+

Por último instalamos los archivos de audio, por ahora sólo en Ingles, nada de spanish:
(Baja los archivos de audio en ingles y la música en espera de calidad 8000)

    $ sudo make sounds-install && sudo make moh-install

Bien, pues una vez instalado, para activarlo edito /etc/default/freeswitch y cambio:

    $sudo nano /etc/default/freeswitch
    FREESWITCH_ENABLED="true"

Despues de esto ya puedo iniciar a mano el freeswitch:

    $ sudo /usr/local/freeswitch/bin/freeswitch

freeswitch@ebox> ...            Tres puntos para salir de freeswitch

Si no queremos arrancar en el modo consola o CLI del freeswitch, podemos (-nc no console):
    $ sudo /usr/local/freeswitch/bin/freeswitch -nc           

Luego podremos entrar en el CLI mediante:

    $ sudo /usr/local/freeswitch/bin/fs_cli -H 127.0.0.1

Para salir del CLI (pero ésta vez no se cierra el servicio):   ...   e INTRO

Cuando instalas desde los fuentes, los ficheros init.d de inicio no se crean.
Tampoco se actualizan los niveles rcd para iniciar el servicio cuando reiniciamos.

Podemos mirar http://wiki.freeswitch.org/wiki/Freeswitch_init

Para crear el fichero /etc/init.d/freeswitch:

    $ sudo nano /etc/init.d/freeswitch

Y este es el código que tienes que poner:

#Principio del fichero
#! /bin/sh
### BEGIN INIT INFO
# Provides:          skeleton
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Description:       Freeswitch debian init script.
# Author: Matthew Williams
#

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DESC="Freeswitch"
NAME=freeswitch
DAEMON=/usr/local/freeswitch/bin/$NAME
DAEMON_ARGS="-nc"
PIDFILE=/usr/local/freeswitch/log/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

FS_USER=freeswitch
FS_GROUP=freeswitch

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
    # Set user to run as
        if [ $FS_USER ] ; then
      DAEMON_ARGS="`echo $DAEMON_ARGS` -u $FS_USER"
        fi
    # Set group to run as
        if [ $FS_GROUP ] ; then
          DAEMON_ARGS="`echo $DAEMON_ARGS` -g $FS_GROUP"
        fi

        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null -- \
                || return 1
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
                $DAEMON_ARGS \
                || return 2
        # Add code here, if necessary, that waits for the process to be ready
        # to handle requests from services started subsequently which depend
        # on this one.  As a last resort, sleep for some time.
}

#
# Function that stops the daemon/service
#
do_stop()
{
        # Return
        #   0 if daemon has been stopped
        #   1 if daemon was already stopped
        #   2 if daemon could not be stopped
        #   other if a failure occurred
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
        RETVAL="$?"
        [ "$RETVAL" = 2 ] && return 2
        # Wait for children to finish too if this is a daemon that forks
        # and if the daemon is only ever run from this initscript.
        # If the above conditions are not satisfied then add some other code
        # that waits for the process to drop all resources that could be
        # needed by services started subsequently.  A last resort is to
        # sleep for some time.
        start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
        [ "$?" = 2 ] && return 2
        # Many daemons don't delete their pidfiles when they exit.
        rm -f $PIDFILE
        return "$RETVAL"
}

#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
        #
        # If the daemon can reload its configuration without
        # restarting (for example, when it is sent a SIGHUP),
        # then implement that here.
        #
        start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
        return 0
}

case "$1" in
  start)
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
        do_start
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  stop)
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
        do_stop
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  #reload|force-reload)
        #
        # If do_reload() is not implemented then leave this commented out
        # and leave 'force-reload' as an alias for 'restart'.
        #
        #log_daemon_msg "Reloading $DESC" "$NAME"
        #do_reload
        #log_end_msg $?
        #;;
  restart|force-reload)
        #
        # If the "reload" option is implemented then remove the
        # 'force-reload' alias
        #
        log_daemon_msg "Restarting $DESC" "$NAME"
        do_stop
        case "$?" in
          0|1)
                do_start
                case "$?" in
                        0) log_end_msg 0 ;;
                        1) log_end_msg 1 ;; # Old process is still running
                        *) log_end_msg 1 ;; # Failed to start
                esac
                ;;
          *)
                # Failed to stop
                log_end_msg 1
                ;;
        esac
        ;;
  *)
        #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
        exit 3
        ;;
esac

##########################EOF        Final del fichero

No debemos olvidar los permisos para el fichero recien creado:

    $ sudo chmod +x /etc/init.d/freeswitch

Actualizamos para que arranque el servicio cuando reiniciemos:

    $ sudo update-rc.d freeswitch defaults

Tambien necesitamos crear el usuario y grupo freeswitch y establecer permisos:

    $ sudo adduser freeswitch

    $ sudo chown -R freeswitch:freeswitch /usr/local/freeswitch

-------------------------------------------------------------------
---              FusionPBX                                                   ---
-------------------------------------------------------------------
Ahora instalamos FusionPBX (y dependencias):

FusionPBX requiere php5 y eBox trae php4, asi que para instalarlo:

    $sudo apt-get install subversion php-db php5-sqlite php-xml-parser \
apache2-mpm-prefork libapache2-mod-php5 libtiff-tools sqlite

    $cd /var/www

Tambien he instalado sqlite por siquieres usarla como bdd en vez de mysql o postgresql (además es mas fácil con sqlite)

O bien desde los fuentes:
    $ wget http://fusionpbx.com/downloads/fusionpbx-1.1.tar.gz

Establecemos los permisos:

    $ sudo chown -R www-data:www-data fusionpbx

    $ sudo chown -R freeswitch:www-data /usr/local/freeswitch/

Verifica que tenga 775 para que el grupo tenga pleno acceso o bien:

    $sudo chmod 775 -R /usr/local/freeswitch

Para acceder a fusionpbx:

http://ip_ebox/fusionpbx

Y comienza la instalación del fusionpbx.

Con elegir sqlite y boton install lo tendremos ok.

OJO porque:

FusionPBX:
    1.- elimina toda tu configuración actual, aunque guarda un backup en conf.orig
    2.- añade un asterisco a las extensiones predefinidas, pero eso puede causar conflictos con algunos telefonos
        que incluyen sus propios códigos y tambien empiezan por *
        La forma de arreglarlo es cambiar los dialplan desde fusionpbx
    3.- elimina modifica o añade las extensiones por defecto de la instalación de freeswitch:
 

Basic
------

    * Dial *67[phone number] to activate call privacy.
    * Dial *69 for last call return.
    * Dial *2 can be pressed during a call to start recording again to stop recording press *2 again. Recordings are can be         downloaded from Features -> Recordings.
    * Dial *870 redial
    * Dial *3472 (disa) followed by the admin pin number to use DISA (direct inward outward system access)
    * Dial *732673 (record) make a recording.
    * Dial *347 (dir) to dial by name.
    * Talking Date (to do)
    * Talking Time (to do)
    * Talking Date and Time (to do)
    * Dial *5900 to park a call
    * Dial *5901 to un-park a call
    * Valet Park (to do)
    * Valet UnPark (to do)
    * WakeUp Call (to do)

Voicemail
---------

    * Dial *97 or *4000 general voicemail access, prompts for the id (extension number) and password
    * Dial *98 detects the extension and requires only the password.
    * Dial *99[extension number] can be used to send a call directly to voicemail.

Conference
----------

    * Dial *3001-*3099 conference channel 8khz
    * Dial *3101-*3199 conference channel 16khz
    * Dial *3201-*3299 conference channel 32khz
    * Dial *3301-*3399 conference channel 48khz

Additional Conference numbers can be added in the graphical interface.

Group
-----

    * Dial *8 to use group intercept
    * Dial **81[2 digit group id] add extension to a group
    * Dial **80[2 digit group id] delete the extension from the group
    * Dial **82[2 digit group id] to ring the entire group simultaneously
    * Dial *83[2 digit group id] to ring the group in sequence
    * Dial *2001 group dial billing
    * Dial *2002 group dial support

Miscellaneous
-------------
    * Dial *9992 Info test sends information to the console
    * Dial *9993 video record
    * Dial *9994 video playback
    * Dial *9995 delay echo
    * Dial *9996 echo test
    * Dial *9997 play milliwatt tone
    * Dial *9998 to test tone
    * Dial *9999 to test music on hold
    * Dial *5000 the default auto attendant

Advanced
--------
    * Dial *8[extension number] to use a phones intercom.
    * Dial *88[extension number] eavesdrop to listen in on a call (can be limited to certain extensions).
          o Press 1 to barge in with the distant party.
          o Press 2 to barge in with the local party.
          o Press 3 to barge in on both parties.
    * Dial *886 global-intercept an call that is ringing.
    * Dial **8[extension number] intercept an extension.

-------------------------------------------------------------------

Bueno, con esto ya tenemos las últimas versiones funcionando con nuestro eBox.

Un saludo
Juanjo A.

Distribuir contenido Distribuir contenido