Setting the default mail address in cPanel

Suppose you want all mail that arrives at nonexistent mailboxes in your domain to be delivered to a specific mailbox.

For this:

1) On the cPanel main page, in the “Email” section, select “Default Address

2) In the window that opens, select the domain (if there are several), select “Forward to Email Address” and specify which address to forward.

Instead of sending it, you can also choose to delete emails, forward to a system mail account, or send to a script.

Done.

SMS sending script via Goip4 gateway

Here is an example of a script written in PHP, for sending SMS messages through the Goip4 gateway.
The script receives data from the SQL database with a query and alternately sends SMS to each number, and also writes an entry about sending it to a special sms table.
Continue reading “SMS sending script via Goip4 gateway”

White and black list iRedAdmin

Here are examples of viewing and working with iRedAdmin white and black lists.

Switch to the root user:

sudo -i

Let’s go to the directory with the script and execute it without options to see a brief help:

cd /opt/iredapd/tools/
python wblist_admin.py

To add the sender to the white list or black list, execute the following commands:

python wblist_admin.py --add --whitelist 192.168.25.2 info@example.com @test.com @.abc.com
python wblist_admin.py --add --blacklist 192.168.25.2 info@example.com @test.com @.abc.com

Example of deletion:

python wblist_admin.py --delete --whitelist 192.168.25.2

Adding a sender to the white or black list for a particular domain or user:

python wblist_admin.py --account mydomain.com --add --whitelist 192.168.25.2
python wblist_admin.py --account user@mydomain.com --add --blacklist 192.168.25.2

For outgoing messages:

python wblist_admin.py --outbound --account mydomain.com --add --whitelist 192.168.25.2

Commands for viewing lists:

python wblist_admin.py --list --whitelist
python wblist_admin.py --list --blacklist
python wblist_admin.py --account mydomain.com --list --whitelist
python wblist_admin.py --account user@mydomain.com --list --blacklist

In the iRedAdmin-Pro version, lists can be managed via the web interface.

See also:
Troubleshooting “Recipient address rejected: Intentional policy rejection, please try again later”

How to connect Google Drive to Linux using Grive

Grive – the console client allows you to synchronize data with Google Drive.

Install the necessary components:

sudo apt-get install git cmake build-essential libgcrypt11-dev libyajl-dev \
libboost-all-dev libcurl4-openssl-dev libexpat1-dev libcppunit-dev binutils-dev

Tried to install the command apt-get install grive, but in this case I have an old version installed, which is no longer workable.
So create a directory and clone the latest Grive source files from the official source:

mkdir grive
cd grive/
sudo git clone https://github.com/Grive/grive.git
cd grive/

Let’s build Grive from the source files:

sudo dpkg-buildpackage -j4

If desired, you can build manually:

mkdir build
cd build
sudo cmake ..
sudo make -j4
sudo make install

The installation of Grive is complete, now we will create and move to any directory where Google Drive will be synchronized:

mkdir ~/GoogleDrive
cd ~/GoogleDrive

Request an authorization token from Google:

grive -a

After the startup, a link will be generated that will need to go to the browser, login to the account, allow access, copy the response code and enter it in the terminal, then synchronization will begin.

In the future, for synchronization, go to the directory and run Grive:

cd ~/GoogleDrive
grive

You can save the synchronization report to a file:

grive -l ~/log.txt

To view the current version of Grive, use the command:

sudo grive -v

Installing and Configuring Bacula

Bacula – a set of client-server programs for managing backups.
It consists of the components of Director Daemon (DD), Storage Daemon (SD), File Daemon (FD) and Bacula Console (BC).

To install in Ubuntu/Debian, perform:

sudo apt-get install bacula

During the installation process, the MySQL user’s root password will be requested and a database created, and Postfix installed.

Create directories and set permissions:

sudo mkdir -p /bacula/backup /bacula/restore
sudo chown -R bacula:bacula /bacula
sudo chmod -R 700 /bacula

Open the configuration file DD, for example, in the text editor nano:

sudo nano /etc/bacula/bacula-dir.conf

Let’s find “Standard Restore template” and there where “Where” we change the path:

Job {
Name = "RestoreFiles"
Type = Restore
Client=Blank-fd
FileSet="Full Set"
Storage = File
Pool = Default
Messages = Standard
Where = /bacula/restore
}

Further we find “List of files to be backed up” and a little bit lower where “File =” we specify that it is necessary to copy in a backup copy.

Unnecessary directories can be deleted by adding for example:

Exclude {
File = /bacula
File = /proc
File = /tmp
}

Open the configuration file SD:

sudo nano /etc/bacula/bacula-sd.conf

Let’s find “Devices supported by this Storage daemon” and specify in “Archive Device =” where to store backup copies, for example:

Archive Device = /bacula/backup

We test the correctness of the configuration:

sudo bacula-dir -tc /etc/bacula/bacula-dir.conf
sudo bacula-sd -tc /etc/bacula/bacula-sd.conf

If the command did not say anything, then everything is fine and there are no errors.

Restart bacula services to apply configuration changes:

sudo service bacula-sd restart
sudo service bacula-director restart

Let’s check if all three services are running:

netstat -nlpt | grep [b]acula

Open the console bacula:

sudo bconsole

Check status:

status

We type the command:

label

and specify the name of the backup, then specify 2 that this file.

Run our configured backup process (select 1 and yes):

run

View successful completion messages:

messages

Leave the console bacula:

quit

A backup file should appear in the /bacula/backup directory.

See also:
How to install Bacula-web

How to install Bacula-web

Bacula-Web – a web-based tool for creating reports and monitoring Bacula.

Install the necessary components:

sudo apt-get install apache2 libapache2-mod-php5 php5-mysql php5-gd
sudo a2enmod php5
sudo a2enmod rewrite

Open the PHP configuration file in the editor and specify the time zone:

sudo nano /etc/php5/apache2/php.ini
date.timezone = Europe/Kiev

And also for the directory with Bacula-Web we specify the option:

sudo nano /etc/apache2/sites-enabled/000-default.conf
<Directory /var/www/html/bacula-web>
AllowOverride All
</Directory>

Restart apache2 to apply the changes:

sudo service apache2 restart

Let’s go to the web server directory, download the archive with the latest version of Bacula-web and unpack it:

cd /var/www/html
curl -O http://www.bacula-web.org/files/bacula-web.org/downloads/bacula-web-latest.tgz
mkdir -v /var/www/html/bacula-web
tar -xzf bacula-web-latest.tgz -C /var/www/html/bacula-web

Make a copy of the sample configuration file and open it for example in the text editor nano:

cd /var/www/html/bacula-web/application/config
cp -v config.php.sample config.php
sudo nano /var/www/html/bacula-web/application/config/config.php

Uncomment and configure MySQL parameters:

$config[0]['label'] = 'Backup Server';
$config[0]['host'] = 'localhost';
$config[0]['login'] = 'bacula';
$config[0]['password'] = 'test';
$config[0]['db_name'] = 'bacula';
$config[0]['db_type'] = 'mysql';
$config[0]['db_port'] = '3306';

Since some commands were executed through sudo, we will specify the correct owner of the files:

sudo chown -R www-data:www-data /var/www/html/bacula-web

This completes the installation, you can open the Bacula-Web from the http://SERVER/bacula-web link, and also it is advisable to look at the http://SERVER/bacula-web/test.php test page that will tell you whether all the necessary components are installed and configured.

See also:
Installing and Configuring Bacula

Installing Redmine in Ubuntu

Redmine – server web application for managing projects and tasks.

On the test I will install Redmine in Ubuntu Server 16.04, MySQL will be used as the database, and so first we will install the necessary components:

sudo apt-get update
sudo apt-get install apache2 libapache2-mod-passenger
sudo apt-get install mysql-server mysql-client

Now perform the installation of Redmine:

sudo apt-get install redmine redmine-mysql

Check whether bundler gem is installed:

sudo gem update
sudo gem install bundler

Open the configuration file in the text editor passenger.conf:

sudo nano /etc/apache2/mods-available/passenger.conf

And after the line:

<IfModule mod_passenger.c>

Let’s add:

PassengerDefaultUser www-data

Create a symbolic link to Redmine in the web server directory:

sudo ln -s /usr/share/redmine/public /var/www/html/redmine

Open the web server configuration file in a text editor:

sudo nano /etc/apache2/sites-available/000-default.conf

And somewhere inside the VirtualHost block, we add:

<Directory /var/www/html/redmine>
    RailsBaseURI /redmine
    PassengerResolveSymlinksInDocumentRoot on
</Directory>

Create a Gemfile.lock file and assign it to the owner of the web-server user www-data:

sudo touch /usr/share/redmine/Gemfile.lock
sudo chown www-data:www-data /usr/share/redmine/Gemfile.lock

Restart the web server to apply all the changes:

sudo service apache2 restart

Now Redmine is installed and it can be opened by link http://HOST/redmine
Where it is necessary to press Enter, enter the standard login admin and password admin.

Done.

Managing Asterisk modules

Let’s connect to the Asterisk console:

sudo asterisk -rvv

Let’s see what modules are already in use:

module show

Files of modules with the extension * .so are in the directory /usr/lib/asterisk/modules/

To load and unload a module, commands are used (the module name is specified without a file extension, for example, not chan_sip.so, but chan_sip):

module load NAME
module unload NAME

In order for the necessary modules to be loaded automatically when starting Asterisk, they must be specified in the file /etc/asterisk/modules.conf, for example, open it in the text editor nano:

sudo nano /etc/asterisk/modules.conf

You can enable the autoloading of all existing modules in the folder /usr/lib/asterisk/modules/:

[modules]
autoload=yes

And then we can exclude unnecessary ones using the following commands:

noload => module.so

Either prohibit downloading all and specify only those that are needed, for example:

;SIP VoIP driver
load => chan_sip.so
load => res_rtp_asterisk.so
load => app_dial.so
load => bridge_simple.so
load => res_features.so
load => res_musiconhold.so
load => res_adsi.so
load => pbx_config.so
; List of required codecs
load => codec_a_mu.so
load => codec_adpcm.so
load => codec_alaw.so
load => codec_ulaw.so
load => codec_gsm.so
load => codec_ilbc.so
load => codec_lpc10.so
; If you use Dahdi cards for analog lines
load => chan_dahdi.so
; Call parking
load => res_parking.so 
; Below are the modules I needed when setting up call recording
; требуется если используется res_monitor.so
load => func_periodic_hook.so
; Required if res_monitor.so is used, the function STRFTIME
load => func_strings.so
; Required if res_monitor.so is used to determine the number, function CALLERID
load => func_callerid.so
; Required if res_monitor.so is used for MixMonitor
load => app_dial.so
; For recording calls
load => res_monitor.so
; To support WAV format
load => format_wav.so
; For MP3 format support
load => format_mp3.so
; To record statistics of calls to MySQL database
load => cdr_mysql.so
; To enable SNMP functionality, for example, to collect statistics by various monitoring systems
load => res_snmp.so
; To make calls from the context of the placed files to the directory /var/spool/asterisk/outgoing/
load => pbx_spool.so

To apply the changes in the /etc/asterisk/modules.conf file, execute the command from the Asterisk console:

module reload

If necessary, you can reboot Asterisk as follows:

sudo service asterisk restart

How to remove iRedMail

Here is an example of removing iRedMail.
On the test, delete the installed iRedMail 0.9.7 with Ubuntu Server 16.04 using the uninstall script – clear_iredmail.

Let’s go to the tools directory of the iRedMail installer, save the script in it, in my case it’s:

cd /root/iRedMail-0.9.7/tools/
wget https://ixnfo.com/wp-content/uploads/2017/08/clear_iredmail.zip
unzip clear_iredmail.zip

Let’s make it executable:

chmod +x clear_iredmail.sh

And run:

bash clear_iredmail.sh

The script will remove mysql, ssl, amavisd, clamav, spamassassin, dovecot, postfix, iredapd, users, etc., you need to be careful if there is something else on the server besides iRedMail.
In the script code, you can see the step-by-step process of removing iRedMail.