Archives February 2021

How to – Setup FreePBX 15 & Asterisk 16 on a Raspberry Pi

RaspPi4-8GB

How to – Setup FreePBX 15 & Asterisk 16 on a Raspberry Pi 4

Creating a “Contact Center to Go”

For this setup I used the Raspberry Pi 4 Model B – 8 GB encased in the above casing. I will go over step by step instructions on what I just did to create a little “mini mobile call center to go” with FreePBX 15 and Asterisk 16.


Step 1 – Purchase a Raspberry Pi and micro SD card

Personally I went with Vilros.com for my purchase and was not disappointed.


Step 2 – Download RasPBX

You need to download RasPBX next, I downloaded it from the main source at http://www.raspberry-asterisk.org/downloads/ and then unzipped the file which gave me a raspbx-10-10-2020.img file


Step 3 – Download Win32DiskImager and begin installation

Install Win32DiskImager and then choose the raspbx.img and the drive you have your micro SD card on and click “write”.

32 GB Micro SD card

Step 4 – Start up your Rasperry Pi & updating it

Once you power on your device and let it start up, you will be prompted for a username and password. The user is “Pi” and the password is “raspberry”. After you login and make sure you have an internet connection, run “raspbx-upgrade” to update everything and check if Asterisk is running correctly.

freepbx

Step 5 – FreePBX

Lets get started on FreePBX setup now. Go to http://raspbx.ip and click on Admin > Admin Module and check online for updates

FreePBX
freepbx

You now have a “Contact Center to Go” in your pocket.

If you have any questions or comments, feel free to reply to this post or hit me up on Skype.

How to – Get phpMyAdmin working and secured on a Vicibox 9 installation

phpmyadmin

How to – Get phpMyAdmin working and secured on a Vicibox 9 installation

So you’ve tried to access phpMyAdmin after installing Vicibox 9 iso on your bare metal or virtual server and it’s not working…..and you’re wondering why? Well, as a security precaution, phpMyAdmin is not enabled by default and needs a symbolic link created, so let’s start there. If you don’t have it installed already, “zypper in phpMyAdmin”.

Creating the symbolic link

Type the following command into your Linux CLI:

ln -s /usr/share/phpMyAdmin /srv/www/htdocs/
phpMyAdmin
Type ll(LL) within the /srv/www/htdocs/ directory to make sure the symbolic link was created correctly

Now that we have created the symbolic link, we need to secure this directory to make sure any unwanted access isn’t permitted. We are going to accomplish this using .htaccess


Securing phpMyAdmin using Htaccess

Edit your phpMyAdmin.conf file in /etc/apache2/conf.d

phpmyadmin
phpMyAdmin.conf
nano /etc/apache2/conf.d/phpMyAdmin.conf

### change the following:

<Directory /usr/share/phpMyAdmin>

    Options FollowSymLinks
    AllowOverride All   #This was "None"

    <IfVersion < 2.4>
        Order Deny,Allow
        Allow from all
    </IfVersion>


###  save and exit ###

nano /usr/share/phpMyAdmin/.htaccess

####Enter the following:

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/phpMyAdmin/.htpasswd
Require valid-user

###save and exit

zypper install apache2-utils

htpasswd -c /etc/phpMyAdmin/.htpasswd whatever.username.u.want
Password: enter the password u want

##restart apache
service apache restart or systemctl restart apache

###go to your phpmyadmin

https://server.ip/phpMyAdmin


##Enjoy

Hopefully this will help some of you avoid some easier hacks. For more information on securing your servers, check out our free security audit!

Useful Commands to manage everyday tasks on Asterisk/Vicidial Servers

useful tools

Useful Commands to manage everyday tasks on Asterisk/Vicidial Servers

I wanted to put together a list of commands that I use often or daily that may help other people manage their days easier. If you have anything you use or think others would find useful, please comment below and I will add them with credit to you and your website or blog if you’d like. Ok so these commands will go over things for services such as Apache, MySQL, Vicidial, Asterisk, and more.

MySQL Commands and examples:

### repair a broken Database Table
repair table vicidial_live_agents use_frm;


### get level 9 users in vicidial
mysql asterisk -u cron -p1234 -e "select user,pass,active from vicidial_users where user_level='9'"

### check and repair mysql
mysqlcheck -p --auto-repair --all-databases

### show what IP's are in the Dynamic Portal IP set
use asterisk;
select computer_ip from vicidial_user_log where event = 'VICIBOX' group by computer_ip;


### reset a user whos locked out due to too many login attempts through mysql instead of GUI (Thanks Venkat from vicidial.sh)
mysql -e "use asterisk; update vicidial_users set failed_login_count='0' where user='6666'";


### How to create a user in mysql - change user(cron) and pass(1234)
CREATE USER 'cron'@'localhost' IDENTIFIED BY '1234';
GRANT SELECT,INSERT,UPDATE,DELETE,LOCK TABLES on asterisk.* TO cron@'%' IDENTIFIED BY '1234';
GRANT SELECT,INSERT,UPDATE,DELETE,LOCK TABLES on asterisk.* TO cron@localhost IDENTIFIED BY '1234';
GRANT RELOAD ON *.* TO cron@'%';
GRANT RELOAD ON *.* TO cron@localhost;

### change root password(to delete it leave it BY '')
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';

### check a user groups permissions(replace 'ADMIN' accordingly)
mysql -u cron -p1234 asterisk -e "select * from vicidial_user_groups where user_group='ADMIN'\G"

####### if leads wont load or you get "no one in your session"
nano /etc/my.cnf
Look for sql_mode and change it to sqlmode=""
mysql -u cron -p1234 asterisk -e “select * from vicidial_user_groups where user_group=’ADMIN’\G”

Other useful commands

### watch asterisk messages thru linux cli ######
tail -f /var/log/asterisk/messages


####### apache tools ############
check web connections: netstat -tuna | grep ":80" | wc -l


##### Useful Vicidial Commands for Linux ##########
/usr/share/astguiclient/ADMIN_keepalive_ALL.pl --cu3way
/usr/share/astguiclient/AST_manager_listen.pl --debugX
/usr/share/AST_DB_action.pl --debugX

#### Check if Dahdi(Meetme/Vicidial Conferences) is running ####
dahdi_cfg -vv
If its not run this command: 
modprobe dahdi


### check keepalives
cat /etc/astguiclient.conf | grep VARactive_keepalives



##### viciphone time for autologin 
$webphone_call_seconds = '5 ; in options.php in agc dir



### upgrade vici ####
cd /usr/src/astguiclient
svn checkout svn://svn.eflo.net:3690/agc_2-X/trunk
cd trunk
perl install.pl

mysql -p -f --database=asterisk < /usr/src/astguiclient/trunk/extras/upgrade_2.14.sql


### certbot renewal command #####
certbot certonly --cert-name cyburityllc.com -d sunfun.cyburityllc.com -d mail.cyburityllc.com -d sunfunnow.cyburityllc.com -d cyburity.ml -d cyburity.ga -d cyburity.gq -d cyburity.cf -d informationtechnology.gq -d cyburityllc.com -d www.cyburityllc.com -d cyburhack.com -d cyburhacker.com -d cyburshield.com -d cyberdialer.net -d www.cyburdial.com -d www.cyberdialer.net -d cyburphone.com -d dialer.one -cyburdialer.com -d contactcentersrus.com -d fldream.cyburityllc.com -d www.contactcentersrus.com -d portal.contactcentersrus.com -d cyburdialer.com-d cyburdial.com



### to check whats eating all the ram
ps aux | awk '{print $2, $4, $11}' | sort -k2rn | head -n 20

#### cpu usage
ps -eo pcpu,pid,user,args | sort -k 1 -r | head -11

## check HDD space
df -h

### find the largest files and folders on your linux server(good to see whats taking up space) - This will find the top 20 files and folders, try it from /
du -ah | sort -hr | head -n 20

### check processors
grep processor /proc/cpuinfo | wc -l

### tcp dump for ports(change accordingly) #####
tcpdump -nttv -s 0 -i eth0 port 80

#### check connections to a port ##########
netstat -tuna | grep ":5038" | wc -l


###clear dns cache
/etc/init.d/nscd restart

###For a "live" view showing the logic involved in dialing:
screen -r ASTVDauto

ctrl-a - ctrl-d to get out of it.

###perl install based on asterisk version
perl install.pl --copy_sample_conf_files --asterisk_version=11.X

### start up asterisk
/usr/share/astguiclient/start_asterisk_boot.pl

/usr/share/astguiclient/ADMIN_keepalive_ALL.pl --cu3way



###VOLUME FOR AST13########
With Asterisk 13, the mechanism in Asterisk that allowed for volume changes and muting of meetme participants had been causing random crashes in Asterisk. We now disable this functionality by default, but if you want to enable it, all you have to do is use the agc/options.php setting of "$ast13_volume_override = '1';"

    

####USEFUL SVN TOOLS#######


Beware of the version in system settings. To be absolutely certain to version match:

SVN is used to manage the "install directory" (/usr/src/astguiclient/trunk)

The install directory has a group of sql files that are used to upgrade from the first version to NOW (based on the svn revision level presently in THAT directory).

When your last sql upgrade file has a last line indicating that the db schema value should be what is presently shown in your System Settings ... you have a match. All your code will match your entire DB if you run install.pl with that version loaded.

Anything else is more of a "sort of" match. That's the only truly reliable method. How you get there is a matter of experience and knowledge of svn. But upgrading/downgrading that svn repository until you get lucky and it matches is the easiest amateur way to get a lock-on match of your present db schema.

start here:

CODE: 
tail /usr/src/astguiclient/trunk/extras/upgrade_2.14.sql | grep db_schema_version
mysql -u cron -p1234 asterisk -e "select * from system_settings\G" | grep schema
cd /usr/src/astguiclient/trunk
svn info | grep Revision

Compare the db schema in system settings to the db schema in the upgrade.sql file.
Note the svn revision level.
Increase or decrease the svn revision level with "svn up -r ####" and ... try again until the db schema in the sql file and system settings match. Example:

svn up -r 2946

Then run perl install.pl. Example:
CODE: SELECT ALL
cd /usr/src/astguiclient/trunk
perl install.pl --copy_sample_conf_files


Note that --copy_sample_conf_files will overwrite the .conf files presently in the system. Any that you have edited will need to be re-edited. Such as externip=xxx.xx.xx.x in sip.conf. While updating these isn't always necessary, NOT updating them has been known to blow an entire workday for simple "missed" change that's very difficult to find otherwise. Skip copy_sample_conf_files at your own risk. 8-)

### for webrtc phone issue with chrome 87 update
zypper in ncurses-devel libxml2-devel sqlite-devel libsrtp-devel libuuid-devel openssl-devel
 


How to – Fix Dahdi errors(no sounds) in relation to Vicidial

dahdi error

How to – Fix Dahdi errors(no sounds) in relation to Vicidial

What is Dahdi’s function in Vicidial?

Dahdi is essentially what controls the meet-me conferences(Vicidial Conferences as shown below) for Vicidial. So when this is not running, you will get all types of errors, such as, time sync errors, “no one in your session” , no sound and other various issues. If you do not hear the “You’re the only one in this conference” sound when you login or any customer voice, then dahdi is probably not loaded correctly. The reason for this is because the meetme conferences link the audio channel from the carrier to the meetme conference. With no meetme confernce(dahdi) then the system will not work correctly.

VICIDIAL Conferences(Meet Me)

Typical Error: WARNING[5123][C-00000007]: app_meetme.c:1663 build_conf: Unable to open DAHDI pseudo device

[Feb 12 15:21:47] == Using SIP RTP CoS mark 5
[Feb 12 15:21:47] -- Called 1001
[Feb 12 15:21:47] -- SIP/1001-00000003 is ringing
[Feb 12 15:21:47] -- SIP/1001-00000003 is ringing
[Feb 12 15:21:51] > 0x7fa04800f470 -- Strict RTP learning after remote address set to: 192.168.0.1:29040
[Feb 12 15:21:51] -- SIP/1001-00000003 answered
[Feb 12 15:21:51] -- Executing [8600051@default:1] MeetMe("SIP/1001-00000003", "8600051,F") in new stack
[Feb 12 15:21:51] WARNING[5123][C-00000007]: app_meetme.c:1663 build_conf: Unable to open DAHDI pseudo device

What to do? Well, first let’s check if dahdi is running by using the command “dahdi_cfg -vvv” which should output as below after seeing the above error:

dahdi
Dahdi_cfg -vvv

So how do we fix it? Type “modprobe dahdi” and check again

dahdi
modprobe dahdi

Now this status shows we have Dahdi running correctly in Linux. So lets make sure this doesn’t happen anymore. Add this following line to your crontab:

* * * * * /usr/sbin/modprobe dahdi

This will attempt to run dahdi every minute in the case it does crash from now on, it will automatically recover. I hope this article helps.

-Nox

How to – Update your Vicidial version with subversion

SVN Update
The version number shows in the top right corner.

Updating Vicidial

This is a pretty simple process. Only a few commands needs to be run in order to update your vicidial/cyburdial version via the Linux Command Line Interface(CLI)

cd /usr/src/astguiclient
svn checkout svn://svn.eflo.net:3690/agc_2-X/trunk
cd trunk
perl install.pl

Then you may need to update your DB Schema using the following command which only be ran on your DB server in a cluster environment.

mysql -p -f --database=asterisk < /usr/src/astguiclient/trunk/extras/upgrade_2.14.sql

Incorrect DB Schema Error: Code expects different schema

If you receive this error, you can see how to fix that here

How to – Backup and Restore your Vicidial server

Cyburity - vicidial hosting

How to – Backup and Restore your Vicidial server

Why would you need to backup and restore your vicidial server? Suppose you need to migrate or duplicate Vicidial data (campaigns, leads, phones and so on) from one Vicibox server to another. In case two Vicidial boxes of the same versions the process will be simpler. In case the source server has older Vicibox version than the destination one you will have to perform additional steps to get the destination server working. Both cases are covered in the article below.

Backup / restore Vicidial data between the same version of Vicibox

Basically, to get the Vicidial backup you will need to run /usr/share/astguiclient/ADMIN_backup.pl script that has the following options:



/usr/share/astguiclient/ADMIN_backup.pl --help
allowed run time options:
  [--db-only] = only backup the database
  [--db-settings-only] = only backup the database without leads, logs, servers or phones
  [--db-without-logs] = do not backup the log tables in the database
  [--db-without-archives] = do not backup the archive tables in the database
  [--dbs-selected=X] = backup only selected databases, default uses conf file db only to backup databases X and Y, use X---Y, can use --ALL-- for all dbs on serveryou can use --ALLNS-- for all non-mysql dbs(will ignore 'test', 'mysql','information_schema')
This feature will NOT work with '--db_raw_files_copy' option
  [--conf-only] = only backup the asterisk conf files
  [--without-db] = do not backup the database
  [--without-conf] = do not backup the conf files
  [--without-web] = do not backup web files
  [--without-sounds] = do not backup asterisk sounds
  [--without-voicemail] = do not backup asterisk voicemail
  [--without-crontab] = do not backup crontab
  [--ftp-transfer] = Transfer backup to the 'REPORTS' FTP server
  [--ftp-server=XXXXXXXX] = OVERRIDE FTP server to send file to
  [--ftp-login=XXXXXXXX] = OVERRIDE FTP user
  [--ftp-pass=XXXXXXXX] = OVERRIDE FTP pass
  [--ftp-dir=XXXXXXXX] = OVERRIDE remote FTP server directory to post files to
  [--debugX] = super debug
  [--debug] = debug
  [--test] = test
  [--db_raw_files_copy] = if set the backup won't be a mysql dump. It will tar the /var/lib/mysql folder. WARNING, THIS OPTION WILL STOP THE MYSQL SERVER!
  [--archive_path=/PATH/FROM/ROOT] = absolute path to store the resulting backup

As you see it is capable to create partial backup, but in my example I run it like this to get a full backup of Vicidial:

# /usr/share/astguiclient/ADMIN_backup.pl --archive_path=/root
 
----- Archive path set to /root -----
 
 
----- Mysql dump -----
 
/bin/tar: Removing leading `/' from member names
/bin/tar: Removing leading `/' from member names
/bin/tar: Removing leading `/' from member names
/bin/tar: Removing leading `/' from member names
/bin/tar: Removing leading `/' from member names
/bin/tar: Removing leading `/' from member names
/bin/tar: Removing leading `/' from member names
script execution time in seconds: 48     minutes: 0.8

If the server has address 192.168.10.3 this will create 192.168.10.3_ALL_1.tar.gz archive that contains a set of archives with database dump and configuration files in their respective paths.

Now transfer it to the destination server (192.168.10.4) via SCP or any other suitable method. For example:

1# scp /root/192.168.10.3_ALL_1.tar.gz root@192.168.10.4:/

Now on the destination server navigate to / folder and extract the Vicidial backup archive:

1# tar -zxvf 192.168.10.3_ALL_1.tar.gz

Inside the main archive there will be separate archives for different parts of Vicidial system:

# ls -l /
[...]
192.168.10.3_BIN_1.tar
192.168.10.3_CONF_1.tar
192.168.10.3_LINUX_1.tar
192.168.10.3_SOUNDS_1.tar
192.168.10.3_VOICEMAIL_1.tar
192.168.10.3_WEB_1.tar
192.168.10.3asterisk1.gz
[...]

In tar archives config files are packed in their respective paths so in order restore Vicidial configuration files just unpack the .tar archives:

1# tar -xvf *.tar

Now extract and restore Vicidial database dump:

1
2
3
# gunzip 192.168.10.3asterisk1.gz
192.168.10.3asterisk1
# mysql -u root asterisk < 192.168.10.3asterisk1

At this point you have configuration files and database from the old server applied on the new one. We must change IP addresses in all configuration files and in database before we can use the new server.

To change IP address in all Vicidial configuration files and database run:

# /usr/share/astguiclient/ADMIN_update_server_ip.pl
Previous astGUIclient configuration file found at: /etc/astguiclient.conf
 
Would you like to use interactive mode (y/n): [y]
 
STARTING SERVER IP ADDRESS CHANGE FOR VICIDIAL...
 
Old server IP address or press enter for default: [192.168.10.4] 192.168.10.3
 
server IP address or press enter for default: [192.168.10.4]
 
  old server_ip:      192.168.10.3
  new server_ip:      192.168.10.4
 
Are these settings correct?(y/n): [y]
Writing change to astguiclient.conf file: /etc/astguiclient.conf
 
STARTING DATABASE TABLES UPDATES PHASE...
  Updating servers table...
     |0E0|UPDATE servers SET server_ip='192.168.10.4' where server_ip='192.168.10.3';|
	 [...]

This script is interactive and will guide you through the process.
Make sure there are no errors in the script’s output.
Now reboot your server and check functionality!

Migrate Vicidial data from Vicibox 8 to Vicibox 9

1. Upgrade database schemaVicibox 9 has new and altered tables and functions so you will have to add them to the restored database before you can use system

2. Run /usr/share/astguiclient/ADMIN_update_server_ip.pl again

3. Try to log in as agent. If you have the error There is a time synchronization problem with your system, please tell your system administrator – fix it as described here.

4. If you have the error Delays on agent login No one is on your session 8600051 check that in Admin -> Servers you have correct Asterisk Version set:

For Vicibox 8 it will be 11.21.2.-vici  but for Vicibox 9 it should be at least 13.29.2-vici up to 13.38.0-vici

Correct version of the Asterisk you can obtain by:

1# asterisk -rx “core show version”

Set the correct version in Vicidial’s settings make sure the error is gone.

backup

That’s all there is to it. If you have any questions feel free to comment here.

-Chris