Archive

Archive for the ‘CentOS’ Category

CentOS 7, VestaCP and the Irritating clamd

July 9, 2016 1 comment

Here is the step by step guide in getting clamav to work in CentOS 7 for a VestaCP setup

Install Updated ClamAV components
yum install clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd -y

Link scan.conf to the default VestaCP clamd config file
rm -f /etc/clamd.d/scan.conf
ln -s /etc/clamd.conf /etc/clamd.d/scan.conf

Create freshclam service (Running it as a service will automatically update your AV definitions)
vi /usr/lib/systemd/system/clam-freshclam.service

[Unit]
Description = freshclam scanner
After = network.target
[Service]
Type = forking
ExecStartPre=/usr/bin/mkdir -p /var/lib/clamav/
ExecStartPre=/usr/bin/chown -R clam.clam /var/lib/clamav
ExecStartPre=/usr/bin/chmod 755 /var/lib/clamav
ExecStart = /usr/bin/freshclam -d -c 4
Restart = on-failure
PrivateTmp = true
[Install]
WantedBy=multi-user.target

Register and start freshclam service
systemctl enable clam-freshclam.service
systemctl restart clam-freshclam.service
systemctl status clam-freshclam.service -l

Update clamd@ service to create the neccessary folders
vi /usr/lib/systemd/system/clamd@.service
[Unit]
Description = clamd scanner (%i) daemon
After = syslog.target nss-lookup.target network.target

[Service]
Type = simple
***ADD these 2 lines below, they must be before ExecStart
ExecStartPre = /usr/bin/mkdir -p /var/log/clamav/
ExecStartPre = /usr/bin/chown -R clam:clam /var/log/clamav/
ExecStart = …

Update startup to use the new clamd service
cd /usr/lib/systemd/system

systemctl disable clamd.service

systemctl enable clamd@scan.service
systemctl restart clamd@scan.service
systemctl status clamd@scan.service
image

Test scan, make sure it is successful
clamdscan -c /etc/clamd.d/scan.conf –fdpass

image

Advertisements
Categories: CentOS, Vesta

Easy way to IMAP sync 2 mailboxes

February 2, 2016 Leave a comment

Linux has a great tool to sync 2 different mailboxes, this is especially useful when you need to migrate from one mailbox to another

  1. First install imapsync
  2. Then run the following command

imapsync –host1 –user1 –password1 –host2 [destination server] –user2 [destination email] –password2 [destination password]

Categories: CentOS, Open Source, Ubuntu

Enable Roundcube filters in Vesta 0.98 on CentOS 6.6

November 23, 2015 2 comments

#Install Dovecot Manage Sieve
yum install dovecot-pigeonhole

#edit 20-managesieve.conf
vi /etc/dovecot/conf.d/20-managesieve.conf

#Uncomment protocols
protocols = $protocols sieve

#Edit 10-master.conf
#add in section listed in blue

vi /etc/dovecot/conf.d/10-master.conf

service auth {
  unix_listener auth-client {
    group = mail
    mode = 0660
    user = dovecot
  }
  unix_listener auth-master {
    group = mail
    mode = 0660
    user = dovecot
  }

  user = dovecot
}

#Append this to the end of 10-master.conf
service managesieve-login {
  inet_listener sieve {
  port = 4190
  }
}
service managesieve {
}
protocol sieve {
    managesieve_max_line_length = 65536
    managesieve_implementation_string = dovecot
    log_path = /var/log/dovecot-sieve-errors.log
    info_log_path = /var/log/dovecot-sieve.log
}
plugin {
    sieve = ~/.dovecot.sieve
    sieve_global_path = /etc/dovecot/sieve/default.sieve
    sieve_dir = ~/sieve
    sieve_global_dir = /etc/dovecot/sieve/global/
}
lda_mailbox_autocreate = yes
lda_mailbox_autosubscribe = yes
protocol lda {
    mail_plugins = $mail_plugins autocreate sieve quota
    postmaster_address = postmaster@testdomain.com
    hostname = srv.testdomain.com
    auth_socket_path = /var/run/dovecot/auth-master
    log_path = /var/log/dovecot-lda-errors.log
    info_log_path = /var/log/dovecot-lda.log
}
protocol lmtp {
    mail_plugins = $mail_plugins autocreate sieve quota
    log_path = /var/log/dovecot-lmtp-errors.log
    info_log_path = /var/log/dovecot-lmtp.log
}

#touch and set the permissions on the log files, else you will get permission errors
touch /var/log/dovecot-lda-errors.log
chmod 660 /var/log/dovecot-lda-errors.log
chown dovecot.mail /var/log/dovecot-lda-errors.log

touch /var/log/dovecot-lda.log
chmod 660 /var/log/dovecot-lda.log
chown dovecot.mail /var/log/dovecot-lda.log

touch /var/log/dovecot-lmtp-errors.log
chmod 660 /var/log/dovecot-lmtp-errors.log
chown dovecot.mail /var/log/dovecot-lmtp-errors.log

touch /var/log/dovecot-lmtp.log
chmod 660 /var/log/dovecot-lmtp.log
chown dovecot.mail /var/log/dovecot-lmtp.log

#Create default sieve rule

mkdir /etc/dovecot/sieve
vi /etc/dovecot/sieve/default.sieve
require ["fileinto"];
# rule:[SPAM]
if header :contains "X-Spam-Flag" "YES" {
        fileinto "Spam";
}

touch /etc/dovecot/sieve/default.sieve
chmod +w /etc/dovecot/sieve/default.sieve
chown dovecot.mail /etc/dovecot/sieve/default.sieve

#Restart dovecot, if service starts, means configuration is successful
service dovecot restart

#Configure roundcube

vi /etc/roundcubemail/main.inc.php
$rcmail_config[‘plugins’] = array(‘managesieve’);

vi /usr/share/roundcubemail/plugins/managesieve/config.inc.php.dist

// default contents of filters script (eg. default spam filter)
$config[‘managesieve_default’] = ‘/etc/dovecot/sieve/default.sieve’;

#Configure Exim, modify part in purple
vi /etc/exim/exim.conf
localuser:
  driver = accept
  #transport = local_delivery
  transport = dovecot
  condition = ${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}{true}{false}}

 

######################################################################
#                      TRANSPORTS CONFIGURATION                      #
######################################################################
begin transports

dovecot:
    driver = pipe
    command = /usr/libexec/dovecot/dovecot-lda -e -d $local_part@$domain -f $sender_address -a $original_local_part@$original_domain
    return_path_add
    log_output = true
    delivery_date_add
    envelope_to_add
    user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}
    group = mail
    return_output

#Restart exim, if service starts, means configuration is successful
service exim restart

Categories: CentOS, Vesta

Setting up ASP.NET on CentOS 6.x

August 23, 2015 1 comment

With vNext, we are now finally able to run asp.net on Linux!

 

This is done via the MONO framework, which has been around for ages. However as it is with bleeding edge technologies, the setup can be rather cumbersome.

 

Here is the script that you can use to install the latest version of everything and set it up nicely on a minimal setup CentOS box (which is what most servers typically use).

Full source can be found at http://pastebin.com/aTxQne2n

 

##################################################################
# For minimal setup of CentOS 6.5/6.6
##################################################################

##################################################################
# Basic Server essentials
##################################################################
yum -y update
yum -y install yum-utils epel-release
yum clean all && yum makecache
yum -y groupinstall ‘Development tools’

##################################################################
# Install Mono (Latest Version)
##################################################################
yum -y install git autoconf libtool automake build-essential gettext
git clone git://github.com/mono/mono.git
cd mono
./autogen.sh –prefix=/usr/local
make get-monolite-latest
make EXTERNAL_MCS="${PWD}/mcs/class/lib/monolite/gmcs.exe"
make
make install

##################################################################
# Install LibUV (Latest Version)
##################################################################
yum -y install gcc automake libtool
git clone https://github.com/libuv/libuv.git
cd libuv
sh autogen.sh
./configure
make
make install
ldconfig

##################################################################
# Install Node (Latest Version)
##################################################################
yum remove -y nodejs npm
curl -sL https://rpm.nodesource.com/setup | bash –
yum install -y nodejs

##################################################################
# Install Yeoman and Generator Support (Latest Version)
##################################################################
yum -y install npm

#update npm to latest
npm install -g npm@latest
npm install -g yo

#install Generator support
npm install -g generator-aspnet

##################################################################
# Install DNVM (Latest Version)
##################################################################
yum -y install unzip
curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh
source ~/.dnx/dnvm/dnvm.sh

##################################################################
# Update Mozilla Root Server Certificates
##################################################################
mozroots –import –sync

## for dnu restore to work more reliably, increase concurrent threads
echo -e ‘\r\n## Enable greater Mono concurrency (helps dnu restore)\r\nexport MONO_THREADS_PER_CPU=2000’ >> ~/.bashrc

## dnx needs this to load libuv on CentOS (why not on Ubuntu?)
echo -e ‘\r\n## dnx needs this to load libuv on CentOS (why not on Ubuntu?)\r\nexport LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH’ >> ~/.bashrc

## done – print final instructions
echo -e ‘\r\nDone installing ASP.NET 5 prerequisites and DNVM.\r\nOpen new shell environment\r\nor\r\n$ source .bashrc to keep using this one.\r\n’

Categories: ASP.NET, CentOS