Archlinux Setup - rubyists/tiny_call_center GitHub Wiki

Full Setup on Arch Linux

Prerequisites

  • yaourt, or the AUR helper of your choice, examples will use yaourt.
  • Arch Linux installed

Update

yaourt -Syu --aur

Install Runit

Follow Runit-Setup

Install FreeSWITCH

yaourt -S freeswitch-git

IMPORTANT: If you are going to use another DBMS besides SQLite, edit the PKGBUILD:

In the configure section, add --enable-core-odbc-support to the end, like so:

# CONFIGURE
./configure --prefix=/var/lib/freeswitch --without-python \
--bindir=/usr/bin --sbindir=/usr/sbin --localstatedir=/var \
--sysconfdir=/etc/freeswitch --datarootdir=/usr/share \
--libexecdir=/usr/lib/freeswitch --libdir=/usr/lib/freeswitch \
--includedir=/usr/include/freeswitch --enable-core-odbc-support

Set Up and start FreeSWITCH

<youruser@yourhost ~>$ sudo vim /etc/freeswitch/vars.xml

Install Ruby as your callcenter user

<callcenter@yourhost ~>$ \curl -L https://get.rvm.io | bash -s stable --ruby now
<callcenter@yourhost ~>$ source ~/.rvm/scripts/rvm
<callcenter@yourhost ~>$ rvm install ruby-1.9.2-p180

Follow the instructions for how to bring rvm into your environment in a startup script

Install necessary gems

<callcenter@yourhost ~>$ rvm use 1.9.2
<callcenter@yourhost ~>$ gem i freeswitcher sequel sqlite3 innate thin em-websocket

Check out the source

<callcenter@yourhost ~>$ mkdir ~/g
<callcenter@yourhost ~>$ cd ~/g
<callcenter@yourhost ~>$ git clone https://github.com/rubyists/tiny\_call\_center.git

Copy environment directory

<callcenter@yourhost ~/g/tiny\_call\_center>$ cp -a sv/env ~/.tccenv
<callcenter@yourhost ~/g/tiny\_call\_center>$ cd ~/.tccenv

Edit environment variables

Each file in this environment directory represents one variable, the contents of the file is the value that variable will get at runtime. Edit each file, changing the variable to suit your environment. For variables like WebSocketListenerURI, you are only expected to change the ip:port, not the path to the websocket (/websocket). If you want a variable to be unset or use the defaults, you can rm the file from this directory, or for optional variables simply do not create the variable file.

Required (no defaults, you must include this file)

  • TCC_Root => The location of the tiny_call_center tree

Example: /home/callcenter/g/tiny_call_center

Required (with defaults)

  • TCC_ProxyServerFormatString => SIP External Proxy Server Format String (To make calls to PSTN)

Default: 'sofia/gateway/default/%s'

  • TCC_InternalProxy => SIP Internal Proxy Server IP (available via sofia/internal/).

Default: '127.0.0.1'

  • TCC_WebSocketListenerURI => WebSocket server URI for listeners

Default: ws://127.0.0.1:8081/websocket

  • TCC_WebSocketAgentURI => WebSocket server URI for agents

Default: ws://127.0.0.1:8080/websocket

  • TCC_Server => FreeSWITCH Command Server, will originate calls, run mod_callcenter

Default: 127.0.0.1

  • TCC_FsPort => FreeSWITCH Command Server Port

Default: 8021

  • TCC_FsAuth => FreeSWITCH Command Server Authentication

Default: ClueCon

  • TCC_Monitors => FreeSWITCH Registration Servers For Agents

Default: 127.0.0.1

  • TCC_LogLevel => Log Level (DEBUG, DEVEL, INFO, NOTICE, ERROR, CRIT)

Default: INFO

  • TCC_DB => Sequel Database URI (adapter://user:pass@host/database)

Default: sqlite:///home/callcenter/g/tiny_call_center/db/call_center.db

  • TCC_Innate_Port => Port the web server will listen on

Default: 7070

Optional (No Defaults)

  • TCC_ModCallcenterDB => Mod_callcenter postgres database uri (Optional, if you set up mod_callcenter to use postgres db)

Example: 'postgres://callcenter:PASSWORD@localhost/callcenter'

  • TCC_TinyCdrCouchURI => TinyCdr couch db uri

Example: 'http://127.0.0.1:5984/tiny\_cdr'

  • TCC_TinyCdrDB => TinyCdr postgres database uri

Example: 'postgres://callcenter:PASSWORD@localhost/tiny_cdr'

  • TCC_OffHook => Agents Off-Hook instead of On-Hook

Options: true/false (no file implies false)

Set up Databases

By default sqlite will be used, which does not need a server process.
If you want to use postgres instead, set up the database first using Postgresql-Setup

** Migrate the schema into the database **

<callcenter@yourhost ~/g/tiny\_call\_center>$ chpst -e ~/.tccenv rake migrate

** Test the database

<callcenter@yourhost ~/g/tiny\_call\_center>$ chpst -e ~/.tccenv irb -r ./model/init
irb(main):001:0> acc = TCC::Account.create(username: "1500-FirstnameLastname", first\_name: "Firstname", last\_name: "Lastname", extension: '1500', registration\_server: '127.0.0.1', password: 'foo\_pass')                                   
=> #<TinyCallCenter::Account @values={:id=>2, :username=>"1500-FirstnameLastname", :password=>"4493b12324dc5474abb7a9a3bc0771af5583190d", :first\_name=>"Firstname", :last\_name=>"Lastname", :extension=>"1500", :registration\_server=>"127.0.0.1"}>

** Make a manager account

irb(main):002:0> manager = TCC::Manager.create(username: "FirstnameLastname", include: /\d/, exclude: nil)
=> #<TinyCallCenter::Manager @values={:username=>"FirstnameLastname", :include=>"(?-mix:\\d)", :exclude=>nil}>

Set up the service directories

** copy service directories **

<callcenter@yourhost ~/g/tiny\_call\_center>$ mkdir ~/Services
<callcenter@yourhost ~/g/tiny\_call\_center>$ cp -a sv/tcc\_innate sv/fs2ws ~/Services/

** Link the environment directory **

<callcenter@yourhost ~/g/tiny\_call\_center>$ ln -s ~/.tccenv ~/Services/fs2ws/env
<callcenter@yourhost ~/g/tiny\_call\_center>$ ln -s ~/.tccenv ~/Services/tcc\_innate/env

** Test apps **

<callcenter@yourhost ~/g/tiny\_call\_center>$ cd ~/Services/tcc\_innate
<callcenter@yourhost ~/Services/tcc\_innate>$ ./run

Ctrl-C to stop that, then

<callcenter@yourhost ~/Services/tcc\_innate>$ cd ~/Services/fs2ws
<callcenter@yourhost ~/Services/fs2ws>$ ./run

Ctrl-C to stop that, both should have run with no errors, just some debugging

Fix any errors from the above before moving on. Don't worry about the WARN for "No FreeSWITCH install found"

** Symlink the Services/ directories to ~/service so they run continually **

<callcenter@yourhost ~/Services/fs2ws>$ cd ~/Services
<callcenter@yourhost ~/Services>$ for i in *; do ln -s $PWD/$i ~/service; done

** Make sure the services are running **

<callcenter@yourhost ~/Services>$ sv s ~/service/*

You should see

run: /home/callcenter/service/fs2ws: (pid 4381) 2s; run: log: (pid 4321) 2s

run: /home/callcenter/service/tcc_innate: (pid 4387) 2s; run: log: (pid 4011) 2s

Log in to the web interface and test

http://yourhost:7070/

If you used the sample above, your username will be FirstnameLastname, password of foo_pass. Next, go into the Call Center View, and Click on Add Agent. All you need to fill in to add an agent is Extension and Name.

Extension: 1001
Name (First Last): Test Agent