gau1991
10 years ago
47 changed files with 976 additions and 68 deletions
@ -0,0 +1,22 @@ |
|||||
|
# Check Server hostname is FQDN or not |
||||
|
|
||||
|
function ee_lib_check_fqdn() |
||||
|
{ |
||||
|
case $1 in |
||||
|
*.*) |
||||
|
if [ "$EE_FQDN" != "" ];then |
||||
|
echo $EE_FQDN > /etc/hostname |
||||
|
if [ "$EE_DEBIAN_VERSION" == "squeeze" ];then |
||||
|
/etc/init.d/hostname.sh start &>> $EE_COMMAND_LOG |
||||
|
else |
||||
|
service hostname restart &>> $EE_COMMAND_LOG |
||||
|
fi |
||||
|
hostname -f &>> $EE_COMMAND_LOG |
||||
|
fi |
||||
|
;; |
||||
|
*) |
||||
|
read -p "Enter hostname [FQDN]: " EE_FQDN |
||||
|
ee_lib_check_fqdn $EE_FQDN |
||||
|
;; |
||||
|
esac |
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
# Install Dovecot package |
||||
|
|
||||
|
function ee_mod_install_dovecot() |
||||
|
{ |
||||
|
# Add Dovecot repo for Debian 6 |
||||
|
ee_mod_repo_dovecot |
||||
|
ee_lib_apt_get_update |
||||
|
|
||||
|
# Install Dovecot |
||||
|
ee_lib_echo "Installing Dovecot, please wait..." |
||||
|
debconf-set-selections <<< "dovecot-core dovecot-core/create-ssl-cert boolean yes" |
||||
|
debconf-set-selections <<< "dovecot-core dovecot-core/ssl-cert-name string $(hostname -f)" |
||||
|
|
||||
|
# Debian 6 doesn't provide Dovecot 2.x |
||||
|
if [ "$EE_DEBIAN_VERSION" == "squeeze" ]; then |
||||
|
$EE_APT_GET -t squeeze-backports install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ |
||||
|
|| ee_lib_error "Unable to install Dovecot, exit status = " $? |
||||
|
else |
||||
|
$EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ |
||||
|
|| ee_lib_error "Unable to install Dovecot, exit status = " $? |
||||
|
fi |
||||
|
|
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
# Install Amavis package |
||||
|
|
||||
|
function ee_mod_install_mailscan() |
||||
|
{ |
||||
|
# Install Amavis |
||||
|
ee_lib_echo "Installing Amavis, SpamAssassin and ClamAV, please wait..." |
||||
|
$EE_APT_GET install amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch cpio lzop cabextract p7zip rpm unrar-free \ |
||||
|
|| ee_lib_error "Unable to install Amavis, SpamAssassin and ClamAV, exit status = " $? |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
# Setup nginx repository |
||||
|
|
||||
|
function ee_mod_repo_dovecot() |
||||
|
{ |
||||
|
if [ "$EE_DEBIAN_VERSION" == "squeeze" ];then |
||||
|
|
||||
|
# Add Dovecot repository |
||||
|
ee_lib_echo "Adding Dovecot repository, please wait..." |
||||
|
echo "deb http://http.debian.net/debian-backports squeeze-backports main" > /etc/apt/sources.list.d/dovecot-$(lsb_release -sc).list \ |
||||
|
|| ee_lib_error "Unable to add Dovecot repository, exit status = " $? |
||||
|
|
||||
|
fi |
||||
|
} |
@ -0,0 +1,69 @@ |
|||||
|
# Setup Dovecot |
||||
|
|
||||
|
function ee_mod_setup_dovecot() |
||||
|
{ |
||||
|
|
||||
|
EE_EMAIL=$($EE_CONFIG_GET wordpress.email) |
||||
|
if [[ $EE_EMAIL = "" ]]; then |
||||
|
EE_EMAIL=$(git config user.email) |
||||
|
fi |
||||
|
|
||||
|
EE_HOSTNAME=$(hostname -f) |
||||
|
|
||||
|
ee_lib_echo "Setting up Dovecot, please wait..." |
||||
|
# Adding mail user with GID 5000 and UID 5000 |
||||
|
adduser --uid 5000 --home /var/vmail --disabled-password --gecos '' vmail &>> $EE_COMMAND_LOG \ |
||||
|
|| ee_lib_error "Unable to setup vmail user/group = " $? |
||||
|
|
||||
|
# Configuring dovecot.conf |
||||
|
sed -i "s/*.protocol/*.protocol\\nprotocols = imap pop3 lmtp sieve/" /etc/dovecot/dovecot.conf \ |
||||
|
|| ee_lib_error "Unable to configure Dovecot protocol, exit status = " $? |
||||
|
|
||||
|
# Configuring 10-mail.conf |
||||
|
sed -i "s/mail_location = mbox:~\/mail:INBOX=\/var\/mail\/%u/mail_location = maildir:\/var\/vmail\/%d\/%n/" /etc/dovecot/conf.d/10-mail.conf \ |
||||
|
|| ee_lib_error "Unable to configure Dovecot mail_location, exit status = " $? |
||||
|
|
||||
|
# Configuring 10-auth.conf |
||||
|
sed -i "s/#disable_plaintext_auth = yes/disable_plaintext_auth = no/" /etc/dovecot/conf.d/10-auth.conf && \ |
||||
|
sed -i "s/auth_mechanisms = plain/auth_mechanisms = plain login/" /etc/dovecot/conf.d/10-auth.conf && \ |
||||
|
sed -i "s/\!include auth-system.conf.ext/#\!include auth-system.conf.ext/" /etc/dovecot/conf.d/10-auth.conf && \ |
||||
|
sed -i "s/#\!include auth-sql.conf.ext/\!include auth-sql.conf.ext/" /etc/dovecot/conf.d/10-auth.conf \ |
||||
|
|| ee_lib_error "Unable to setup 10-auth.conf file, exit status = " $? |
||||
|
|
||||
|
# Configuring dovecot-sql.conf.ext |
||||
|
cp -v /usr/share/easyengine/mail/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext &>> $EE_COMMAND_LOG \ |
||||
|
|| ee_lib_error "Unable to copy dovecot-sql.conf.ext, exit status = " $? |
||||
|
|
||||
|
cp -v /usr/share/easyengine/mail/auth-sql.conf.ext /etc/dovecot/conf.d/auth-sql.conf.ext &>> $EE_COMMAND_LOG \ |
||||
|
|| ee_lib_error "Unable to setup auth-sql.conf.ext, exit status = " $? |
||||
|
|
||||
|
|
||||
|
# Configuring 10-master.conf |
||||
|
cp -v /etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf.bak &>> $EE_COMMAND_LOG |
||||
|
cp -v /usr/share/easyengine/mail/10-master.conf /etc/dovecot/conf.d/10-master.conf &>> $EE_COMMAND_LOG \ |
||||
|
|| ee_lib_error "Unable to setup 10-master.conf, exit status = " $? |
||||
|
|
||||
|
# Change Dovecot log location |
||||
|
sed -i "s/#log_path = syslog/log_path = \/var\/log\/dovecot.log/" /etc/dovecot/conf.d/10-logging.conf \ |
||||
|
|| ee_lib_error "Unable to setup Dovecot log_path, exit status = " $? |
||||
|
|
||||
|
# Configure self signed SSL for Dovecot |
||||
|
ee_lib_echo "Generating self signed certificate for Dovecot, please wait..." |
||||
|
openssl req -new -x509 -days 3650 -nodes -subj /commonName=${EE_HOSTNAME}/emailAddress=${EE_EMAIL} -out /etc/ssl/certs/dovecot.pem -keyout /etc/ssl/private/dovecot.pem &>> $EE_COMMAND_LOG |
||||
|
chmod 0600 /etc/ssl/private/dovecot.pem |
||||
|
|
||||
|
# Setting up certificate in file |
||||
|
sed -i "s'/etc/dovecot/dovecot.pem'/etc/ssl/certs/dovecot.pem'" /etc/dovecot/conf.d/10-ssl.conf \ |
||||
|
&& sed -i "s'/etc/dovecot/private/dovecot.pem'/etc/ssl/private/dovecot.pem'" /etc/dovecot/conf.d/10-ssl.conf \ |
||||
|
|| ee_lib_error "Unable to setup Dovecot SSL certificate path, exit status = " $? |
||||
|
|
||||
|
# Setting Dovecot init.d script |
||||
|
if [ ! -f /etc/init.d/dovecot ];then |
||||
|
cp -v /usr/share/easyengine/mail/dovecot /etc/init.d/dovecot &>> $EE_COMMAND_LOG |
||||
|
fi |
||||
|
# Add autocreate plugin |
||||
|
sed -i "s'#mail_plugins = \$mail_plugins'mail_plugins = \$mail_plugins autocreate'" /etc/dovecot/conf.d/20-imap.conf \ |
||||
|
|| ee_lib_error "Unable to setup Dovecot autocreate plugin, exit status = " $? |
||||
|
cat /usr/share/easyengine/mail/autocreate >> /etc/dovecot/conf.d/20-imap.conf |
||||
|
|
||||
|
} |
@ -0,0 +1,40 @@ |
|||||
|
# Install mail scanner packages |
||||
|
|
||||
|
function ee_mod_setup_mailscan() |
||||
|
{ |
||||
|
# Confiure Amavis |
||||
|
|
||||
|
ee_lib_echo "Setting up Amavis, please wait..." |
||||
|
sed -i "s'#@'@'" /etc/amavis/conf.d/15-content_filter_mode && \ |
||||
|
sed -i "s'# ' '" /etc/amavis/conf.d/15-content_filter_mode \ |
||||
|
|| ee_lib_error "Unable to setup Amavis, exit status = " $? |
||||
|
|
||||
|
# Add mail filtering rules |
||||
|
sed -i "s/use strict;/use strict;\n\$sa_spam_subject_tag = undef;\n\$spam_quarantine_to = undef;\n\$sa_tag_level_deflt = undef;\n\n# Prevent spams from automatically rejected by mail-server\n\$final_spam_destiny = D_PASS;\n# We need to provide list of domains for which filtering need to be done\n@lookup_sql_dsn = (\n ['DBI:mysql:database=vimbadmin;host=127.0.0.1;port=3306',\n 'vimbadmin',\n 'password']);\n\n\$sql_select_policy = 'SELECT domain FROM domain WHERE CONCAT("@",domain) IN (%k)';/" /etc/amavis/conf.d/50-user \ |
||||
|
|| ee_lib_error "Unable to setup Amavis, exit status = " $? |
||||
|
|
||||
|
sed -i "s'\@local_domains_acl = ( \".\$mydomain\" );'\@local_domains_acl = ( \".\" );'" /etc/amavis/conf.d/05-domain_id \ |
||||
|
|| ee_lib_error "Unable to setup Amavis, exit status = " $? |
||||
|
|
||||
|
# Configure Postfix to use Amavis |
||||
|
# For postfix main.cf |
||||
|
postconf -e "content_filter = smtp-amavis:[127.0.0.1]:10024" |
||||
|
|
||||
|
# For postfix master.cf |
||||
|
sed -i "s/1 pickup/1 pickup\n -o content_filter=\n -o receive_override_options=no_header_body_checks/" /etc/postfix/master.cf \ |
||||
|
|| ee_lib_error "Unable to setup Amavis, exit status = " $? |
||||
|
cat /usr/share/easyengine/mail/amavis-master.cf >> /etc/postfix/master.cf |
||||
|
|
||||
|
# Configure ClamAv and Amavis to each other files |
||||
|
adduser clamav amavis &>> $EE_COMMAND_LOG |
||||
|
adduser amavis clamav &>> $EE_COMMAND_LOG |
||||
|
chmod -R 775 /var/lib/amavis/tmp &>> $EE_COMMAND_LOG |
||||
|
|
||||
|
# Update ClamAV database (freshclam) |
||||
|
ee_lib_echo "Updating ClamAV database, please wait..." |
||||
|
freshclam &>> $EE_COMMAND_LOG |
||||
|
|
||||
|
service clamav-daemon restart &>> $EE_COMMAND_LOG \ |
||||
|
|| ee_lib_echo "Unable to start ClamAV deamon" |
||||
|
|
||||
|
} |
@ -0,0 +1,65 @@ |
|||||
|
# Setup Postfix |
||||
|
|
||||
|
function ee_mod_setup_postfix() |
||||
|
{ |
||||
|
|
||||
|
EE_EMAIL=$($EE_CONFIG_GET wordpress.email) |
||||
|
if [[ $EE_EMAIL = "" ]]; then |
||||
|
EE_EMAIL=$(git config user.email) |
||||
|
fi |
||||
|
|
||||
|
EE_HOSTNAME=$(hostname -f) |
||||
|
|
||||
|
#We previously not used this package. So, if some one don't have Postfix-MySQL installed, |
||||
|
#Postfix will not work |
||||
|
ee_lib_echo "Installing Postfix-MySQL, please wait..." |
||||
|
$EE_APT_GET install postfix-mysql \ |
||||
|
|| ee_lib_error "Unable to install Postfix-MySQL, exit status = " $? |
||||
|
|
||||
|
ee_lib_echo "Setting up Postfix, please wait..." |
||||
|
#Configure Master.cf |
||||
|
sed -i 's/#submission/submission/' /etc/postfix/master.cf && |
||||
|
sed -i 's/#smtps/smtps/' /etc/postfix/master.cf \ |
||||
|
|| ee_lib_error "Unable to setup details in master.cf file, exit status = " $? |
||||
|
|
||||
|
# Handle SMTP authentication using Dovecot" |
||||
|
# On Debian6 following command not work ( Postfix < 2.8 ) |
||||
|
# postconf "smtpd_sasl_type = dovecot" |
||||
|
# The -e option is no longer needed with Postfix version 2.8 and later. |
||||
|
|
||||
|
postconf -e "smtpd_sasl_type = dovecot" |
||||
|
postconf -e "smtpd_sasl_path = private/auth" |
||||
|
postconf -e "smtpd_sasl_auth_enable = yes" |
||||
|
|
||||
|
postconf -e "smtpd_relay_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination" |
||||
|
|
||||
|
# other destination domains should be handled using virtual domains |
||||
|
postconf -e "mydestination = localhost" |
||||
|
|
||||
|
# using Dovecot's LMTP for mail delivery and giving it path to store mail |
||||
|
postconf -e "virtual_transport = lmtp:unix:private/dovecot-lmtp" |
||||
|
|
||||
|
# virtual mailbox setups |
||||
|
postconf -e "virtual_uid_maps = static:5000" |
||||
|
postconf -e "virtual_gid_maps = static:5000" |
||||
|
postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_domains_maps.cf" |
||||
|
postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps.cf" |
||||
|
#postconf "message_size_limit = 20971520" |
||||
|
|
||||
|
|
||||
|
# Setting up Postfix MySQL configuration |
||||
|
mkdir -p /etc/postfix/mysql |
||||
|
cp -av /usr/share/easyengine/mail/virtual_alias_maps.cf /etc/postfix/mysql/virtual_alias_maps.cf &>> $EE_COMMAND_LOG && \ |
||||
|
cp -av /usr/share/easyengine/mail/virtual_domains_maps.cf /etc/postfix/mysql/virtual_domains_maps.cf &>> $EE_COMMAND_LOG && \ |
||||
|
cp -av /usr/share/easyengine/mail/virtual_mailbox_maps.cf /etc/postfix/mysql/virtual_mailbox_maps.cf &>> $EE_COMMAND_LOG \ |
||||
|
|| ee_lib_error "Unable to copy Postfix MySQL configuration files, exit status = " $? |
||||
|
|
||||
|
# Configure self signed SSL for Postfix |
||||
|
ee_lib_echo "Generating self signed certificate for Postfix, please wait..." |
||||
|
openssl req -new -x509 -days 3650 -nodes -subj /commonName=${EE_HOSTNAME}/emailAddress=${EE_EMAIL} -out /etc/ssl/certs/postfix.pem -keyout /etc/ssl/private/postfix.pem &>> $EE_COMMAND_LOG |
||||
|
chmod 0600 /etc/ssl/private/postfix.pem |
||||
|
|
||||
|
postconf -e smtpd_tls_cert_file=/etc/ssl/certs/postfix.pem |
||||
|
postconf -e smtpd_tls_key_file=/etc/ssl/private/postfix.pem |
||||
|
|
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
# Setup Sieve rules |
||||
|
|
||||
|
function ee_mod_setup_sieve() |
||||
|
{ |
||||
|
EE_EMAIL=$($EE_CONFIG_GET wordpress.email) |
||||
|
if [[ $EE_EMAIL = "" ]]; then |
||||
|
EE_EMAIL=$(git config user.email) |
||||
|
fi |
||||
|
|
||||
|
ee_lib_echo "Setting up Sieve rules, please wait..." |
||||
|
|
||||
|
# Enable sieve plugin support for dovecot-lmtp |
||||
|
sed -i "s' #mail_plugins = \$mail_plugins' postmaster_address =$EE_EMAIL \n mail_plugins = \$mail_plugins sieve'" /etc/dovecot/conf.d/20-lmtp.conf \ |
||||
|
|| ee_lib_error "Unable to add sieve plugin support for dovecot-lmtp, exit status = " $? |
||||
|
|
||||
|
# Sieve dovecot-pluign configuration |
||||
|
sed -i "s'sieve = ~/.dovecot.sieve'sieve = ~/.dovecot.sieve\n sieve_global_path = /var/lib/dovecot/sieve/default.sieve'" /etc/dovecot/conf.d/90-sieve.conf && \ |
||||
|
sed -i "s'#sieve_global_dir ='sieve_global_dir = /var/lib/dovecot/sieve/'" /etc/dovecot/conf.d/90-sieve.conf \ |
||||
|
|| ee_lib_error "Unable to setup Sieve dovecot-pluign, exit status = " $? |
||||
|
|
||||
|
# Create global Sieve rules file |
||||
|
mkdir -p /var/lib/dovecot/sieve/ |
||||
|
cp /usr/share/easyengine/mail/default.sieve /var/lib/dovecot/sieve/default.sieve |
||||
|
chown -R vmail:vmail /var/lib/dovecot |
||||
|
|
||||
|
# Compile Sieve rules |
||||
|
sievec /var/lib/dovecot/sieve/default.sieve \ |
||||
|
|| ee_lib_error "Unable to compile Sieve rules, exit status = " $? |
||||
|
|
||||
|
# Configure Roundcube |
||||
|
sed -i "s:\$config\['plugins'\] = array(:\$config\['plugins'\] = array(\n 'sieverules',:" /var/www/roundcubemail/htdocs/config/config.inc.php \ |
||||
|
|| ee_lib_error "Unable to configure Sieve Roundcube plugin, exit status = " $? |
||||
|
echo "\$config['sieverules_port'] = 4190;" >> /var/www/roundcubemail/htdocs/config/config.inc.php |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
# Remove Dovecot package |
||||
|
|
||||
|
function ee_mod_remove_dovecot() |
||||
|
{ |
||||
|
ee_lib_echo "$EE_SECOND Dovecot package, please wait..." |
||||
|
$EE_APT_GET $EE_SECOND dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ |
||||
|
|| ee_lib_error "Unable to $EE_SECOND Dovecot, exit status = " $? |
||||
|
|
||||
|
deluser --remove-home vmail &>> $EE_COMMAND_LOG || ee_lib_error "Unable to Remove user vmail, exit status = " $? |
||||
|
rm -f /etc/init.d/dovecot |
||||
|
rm -rf /var/vmail |
||||
|
|
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
# Remove MailScan package |
||||
|
|
||||
|
function ee_mod_remove_mailscan() |
||||
|
{ |
||||
|
ee_lib_echo "$EE_SECOND Amavis, SpamAssassin and ClamAV package, please wait..." |
||||
|
$EE_APT_GET $EE_SECOND amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch lzop cabextract p7zip rpm unrar-free \ |
||||
|
|| ee_lib_error "Unable to $EE_SECOND Amavis, SpamAssassin and ClamAV,, exit status = " $? |
||||
|
|
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
# Install Roundcube |
||||
|
|
||||
|
function ee_ven_install_roundcube() |
||||
|
{ |
||||
|
# Install Roundcube dependencies |
||||
|
ee_lib_echo "Installing Roundcube, please wait..." |
||||
|
$EE_APT_GET install php-pear \ |
||||
|
|| ee_lib_error "Unable to install php-pear, exit status = " $? |
||||
|
pear install Mail_Mime Net_SMTP Mail_mimeDecode Net_IDNA2-beta Auth_SASL Net_Sieve Crypt_GPG &>> $EE_COMMAND_LOG \ |
||||
|
|| ee_lib_error "Unable to install pear packages, exit status = " $? |
||||
|
|
||||
|
# Setup Roundcube directory |
||||
|
mkdir -p /var/www/roundcubemail/{htdocs,logs} |
||||
|
ee_lib_symbolic_link /var/log/nginx/roundcubemail.access.log /var/www/roundcubemail/logs/access.log |
||||
|
ee_lib_symbolic_link /var/log/nginx/roundcubemail.error.log /var/www/roundcubemail/logs/error.log |
||||
|
|
||||
|
# Install Roundcube |
||||
|
wget -cqO /var/www/roundcube.tar.gz https://github.com/roundcube/roundcubemail/releases/download/${EE_ROUNDCUBE_VERSION}/roundcubemail-${EE_ROUNDCUBE_VERSION}.tar.gz \ |
||||
|
|| ee_lib_error "Unable to download Roundcube, exit status = " $? |
||||
|
|
||||
|
tar -zxf /var/www/roundcube.tar.gz -C /var/www/roundcubemail/htdocs/ --strip-components=1 \ |
||||
|
|| ee_lib_error "Unable to extract Roundcube, exit status = " $? |
||||
|
|
||||
|
# Fix permissions |
||||
|
chown -R $EE_PHP_USER:$EE_PHP_USER /var/www/roundcubemail \ |
||||
|
|| ee_lib_error "Unable to change ownership for ViMbAdmin, exit status = " $? |
||||
|
|
||||
|
# Remove unwanted files |
||||
|
rm -rf /var/www/roundcube.tar.gz /var/www/roundcubemail-1.0.1 |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
# Install ViMbAdmin |
||||
|
|
||||
|
function ee_ven_install_vimbadmin() |
||||
|
{ |
||||
|
|
||||
|
# Install needed PHP5 libraries for ViMbAdmin |
||||
|
# ee stack install php installed php5-mcrypt, php5-memcache, php5-mysqlnd |
||||
|
$EE_APT_GET install php5-cgi php5-json php-gettext \ |
||||
|
|| ee_lib_error "Unable to install php-pear, exit status = " $? |
||||
|
|
||||
|
# Install ViMbAdmin |
||||
|
ee_lib_echo "Installing ViMbAdmin, please wait..." |
||||
|
ee_lib_echo "It will take nearly 10-20 minutes, please wait..." |
||||
|
wget -cqO /var/www/22222/htdocs/vimbadmin.tar.gz https://github.com/opensolutions/ViMbAdmin/archive/${EE_VIMBADMIN_VERSION}.tar.gz \ |
||||
|
|| ee_lib_error "Unable to download ViMbAdmin, exit status = " $? |
||||
|
|
||||
|
mkdir -p /var/www/22222/htdocs/vimbadmin |
||||
|
tar --strip-components=1 -zxf /var/www/22222/htdocs/vimbadmin.tar.gz -C /var/www/22222/htdocs/vimbadmin |
||||
|
|
||||
|
# Install Composer |
||||
|
cd /var/www/22222/htdocs/vimbadmin |
||||
|
curl -sS https://getcomposer.org/installer | php &>> $EE_COMMAND_LOG \ |
||||
|
|| ee_lib_error "Unable to install Composer, exit status = " $? |
||||
|
php composer.phar install --prefer-dist --no-dev &>> $EE_COMMAND_LOG \ |
||||
|
|| ee_lib_error "Unable to install ViMbAdmin, exit status = " $? |
||||
|
|
||||
|
# Fix permissions |
||||
|
chown -R $EE_PHP_USER:$EE_PHP_USER /var/www/22222/htdocs/vimbadmin \ |
||||
|
|| ee_lib_error "Unable to change ownership for ViMbAdmin, exit status = " $? |
||||
|
|
||||
|
# Remove unwanted files |
||||
|
rm -rf /var/www/22222/htdocs/vimbadmin.tar.gz /var/www/22222/htdocs/vimbadmin/composer.phar |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
# Remove Roundcube |
||||
|
|
||||
|
function ee_ven_remove_roundcube() |
||||
|
{ |
||||
|
ee_lib_echo "Removing Roundcube dependencies, please wait..." |
||||
|
# Remove packages installed using Pear |
||||
|
pear uninstall Mail_Mime Net_SMTP Mail_mimeDecode Net_IDNA2-beta Auth_SASL Net_Sieve Crypt_GPG &>> $EE_COMMAND_LOG |
||||
|
|
||||
|
# Remove Roundcube |
||||
|
ee_lib_echo "Removing Roundcube, please wait..." |
||||
|
|
||||
|
mysql -e "drop database \`roundcubemail\`" &>> $EE_COMMAND_LOG |
||||
|
mysql -e "drop user roundcube@'$EE_MYSQL_GRANT_HOST'" &>> $EE_COMMAND_LOG |
||||
|
|
||||
|
rm -rf /var/www/roundcubemail /etc/nginx/sites-available/webmail /etc/nginx/sites-enabled/webmail \ |
||||
|
|| ee_lib_error "Unable to remove Roundcube, exit status = " $? |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
# Remove ViMbAdmin |
||||
|
|
||||
|
function ee_ven_remove_vimbadmin() |
||||
|
{ |
||||
|
ee_lib_echo "Removing ViMbAdmin, please wait..." |
||||
|
|
||||
|
mysql -e "drop database \`vimbadmin\`" &>> $EE_COMMAND_LOG |
||||
|
mysql -e "drop user vimbadmin@'$EE_MYSQL_GRANT_HOST'" &>> $EE_COMMAND_LOG |
||||
|
|
||||
|
ee_lib_echo "Removing ViMbAdmin PHP dependencies, please wait..." |
||||
|
$EE_APT_GET $EE_SECOND php5-cgi php-gettext \ |
||||
|
||ee_lib_error "Unable to $EE_SECOND ViMbAdmin PHP dependencies, exit status = " $? |
||||
|
|
||||
|
rm -rf /var/www/22222/htdocs/vimbadmin \ |
||||
|
|| ee_lib_error "Unable to remove ViMbAdmin, exit status = " $? |
||||
|
} |
@ -0,0 +1,35 @@ |
|||||
|
# Setup Roundcube |
||||
|
|
||||
|
function ee_ven_setup_roundcube() |
||||
|
{ |
||||
|
ee_lib_echo "Setting up Roundcube, please wait..." |
||||
|
|
||||
|
# Random characters |
||||
|
local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) |
||||
|
|
||||
|
# Setting up database for Roundcube |
||||
|
mysql -e "create database \`roundcubemail\`" \ |
||||
|
|| ee_lib_error "Unable to create Roundcube database, exit status = " $? |
||||
|
|
||||
|
# Create MySQL user |
||||
|
mysql -e "grant all privileges on roundcubemail.* to roundcube@'$EE_MYSQL_GRANT_HOST' IDENTIFIED BY '$ee_random'" \ |
||||
|
|| ee_lib_error "Unable to grant privileges for Roundcube database user, exit status = " $? |
||||
|
mysql -e "flush privileges" |
||||
|
|
||||
|
# Import Roundcube initial database |
||||
|
mysql roundcubemail < /var/www/roundcubemail/htdocs/SQL/mysql.initial.sql \ |
||||
|
|| ee_lib_error "Unable to import database for Roundcube, exit status = " $? |
||||
|
|
||||
|
# Setup configuration for Roundcube |
||||
|
cp -av /var/www/roundcubemail/htdocs/config/config.inc.php.sample /var/www/roundcubemail/htdocs/config/config.inc.php &>> $EE_COMMAND_LOG |
||||
|
sed -i "s'mysql://roundcube:pass@localhost/roundcubemail'mysql://roundcube:${ee_random}@${EE_MYSQL_HOST}/roundcubemail'" /var/www/roundcubemail/htdocs/config/config.inc.php \ |
||||
|
|| ee_lib_error "Unable to setup Roundcube database details in config.inc.php file, exit status = " $? |
||||
|
|
||||
|
# Setup Nginx configuration to access Webmail |
||||
|
cp -v /usr/share/easyengine/mail/webmail /etc/nginx/sites-available/ &>> $EE_COMMAND_LOG \ |
||||
|
|| ee_lib_error "Unable to copy Nginx configuration for Roundcube, exit status = " $? |
||||
|
|
||||
|
ln -sf /etc/nginx/sites-available/webmail /etc/nginx/sites-enabled/ \ |
||||
|
|| ee_lib_error "Unable to create softlink for Webmail, exit status = " $? |
||||
|
|
||||
|
} |
@ -0,0 +1,78 @@ |
|||||
|
# Setup ViMbAdmin |
||||
|
|
||||
|
function ee_ven_setup_vimbadmin() |
||||
|
{ |
||||
|
if [ $EE_MYSQL_HOST = "localhost" ];then |
||||
|
ee_vimbadmin_host="127.0.0.1" |
||||
|
else |
||||
|
ee_vimbadmin_host=$EE_MYSQL_HOST |
||||
|
fi |
||||
|
|
||||
|
ee_lib_echo "Setting up ViMbAdmin, please wait..." |
||||
|
|
||||
|
# Random characters |
||||
|
local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) |
||||
|
|
||||
|
# Setting up database for ViMbAdmin |
||||
|
mysql -e "create database \`vimbadmin\`" \ |
||||
|
|| ee_lib_error "Unable to create ViMbAdmin database, exit status = " $? |
||||
|
|
||||
|
# Create MySQL User |
||||
|
mysql -e "grant all privileges on vimbadmin.* to vimbadmin@'$EE_MYSQL_GRANT_HOST' IDENTIFIED BY '$ee_random'" \ |
||||
|
|| ee_lib_error "Unable to grant privileges for ViMbAdmin database user, exit status = " $? |
||||
|
mysql -e "flush privileges" |
||||
|
|
||||
|
# Setup configuration for ViMbAdmin |
||||
|
cp -av /var/www/22222/htdocs/vimbadmin/application/configs/application.ini.dist /var/www/22222/htdocs/vimbadmin/application/configs/application.ini &>> $EE_COMMAND_LOG |
||||
|
|
||||
|
sed -i "s/defaults.mailbox.uid = 2000/defaults.mailbox.uid = 5000/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && |
||||
|
sed -i "s/defaults.mailbox.gid = 2000/defaults.mailbox.gid = 5000/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && |
||||
|
sed -i "s'maildir:/srv/vmail/%d/%u/mail:LAYOUT=fs'maildir:/var/vmail/%d/%u'" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && |
||||
|
sed -i "s'/srv/vmail/%d/%u'/var/vmail/'" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && |
||||
|
sed -i "s/pdo_mysql/mysqli/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && |
||||
|
sed -i "s/'xxx'/'$ee_random'/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && |
||||
|
sed -i "s/resources.doctrine2.connection.options.host = 'localhost'/resources.doctrine2.connection.options.host = '$ee_vimbadmin_host'/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && |
||||
|
sed -i "s/defaults.mailbox.password_scheme = \"md5.salted\"/defaults.mailbox.password_scheme = \"md5\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini \ |
||||
|
|| ee_lib_error "Unable to setup ViMbAdmin configuration file, exit status = " $? |
||||
|
|
||||
|
# Changing hosts and password of ViMbAdmin database in postfix configuration |
||||
|
sed -i "s/password = password/password = $ee_random/" /etc/postfix/mysql/virtual_alias_maps.cf && |
||||
|
sed -i "s/hosts = 127.0.0.1/hosts = $ee_vimbadmin_host/" /etc/postfix/mysql/virtual_alias_maps.cf \ |
||||
|
|| ee_lib_error "Unable to setup ViMbAdmin database details in virtual_alias_maps.cf file, exit status = " $? |
||||
|
|
||||
|
sed -i "s/password = password/password = $ee_random/" /etc/postfix/mysql/virtual_domains_maps.cf && |
||||
|
sed -i "s/hosts = 127.0.0.1/hosts = $ee_vimbadmin_host/" /etc/postfix/mysql/virtual_domains_maps.cf \ |
||||
|
|| ee_lib_error "Unable to setup ViMbAdmin database details in virtual_domains_maps.cf file, exit status = " $? |
||||
|
|
||||
|
sed -i "s/password = password/password = $ee_random/" /etc/postfix/mysql/virtual_mailbox_maps.cf && |
||||
|
sed -i "s/hosts = 127.0.0.1/hosts = $ee_vimbadmin_host/" /etc/postfix/mysql/virtual_mailbox_maps.cf \ |
||||
|
|| ee_lib_error "Unable to setup ViMbAdmin database details in virtual_mailbox_maps.cf file, exit status = " $? |
||||
|
|
||||
|
sed -i "s/password=password/password=$ee_random/" /etc/dovecot/dovecot-sql.conf.ext && |
||||
|
sed -i "s/hosts=localhost/hosts=$ee_vimbadmin_host/" /etc/dovecot/dovecot-sql.conf.ext \ |
||||
|
|| ee_lib_error "Unable to setup ViMbAdmin database details in dovecot-sql.conf.ext file, exit status = " $? |
||||
|
|
||||
|
# Changing hosts and password of ViMbAdmin database in Amavis configuration |
||||
|
sed -i "s/127.0.0.1/$ee_vimbadmin_host/" /etc/amavis/conf.d/50-user && |
||||
|
sed -i "s/password/$ee_random/" /etc/amavis/conf.d/50-user \ |
||||
|
|| ee_lib_error "Unable to setup ViMbAdmin database details in 50-user file, exit status = " $? |
||||
|
|
||||
|
# Copying HTACCESS |
||||
|
cp -av /var/www/22222/htdocs/vimbadmin/public/.htaccess.dist /var/www/22222/htdocs/vimbadmin/public/.htaccess &>> $EE_COMMAND_LOG |
||||
|
|
||||
|
# Setting default database |
||||
|
/var/www/22222/htdocs/vimbadmin/bin/doctrine2-cli.php orm:schema-tool:create &>> $EE_COMMAND_LOG \ |
||||
|
|| ee_lib_error "Unable to setup ViMbAdmin default database , exit status = " $? |
||||
|
|
||||
|
ee_security_salt=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n1) |
||||
|
sed -i "s/securitysalt = \"\"/securitysalt = \"$ee_security_salt\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini \ |
||||
|
|| ee_lib_error "Unable to setup ViMbAdmin security salt , exit status = " $? |
||||
|
|
||||
|
ee_rememberme_salt=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n1) |
||||
|
sed -i "s/resources.auth.oss.rememberme.salt = \"\"/resources.auth.oss.rememberme.salt = \"$ee_rememberme_salt\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini \ |
||||
|
|| ee_lib_error "Unable to setup ViMbAdmin remember me salt , exit status = " $? |
||||
|
|
||||
|
ee_password_salt=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n1) |
||||
|
sed -i "s/defaults.mailbox.password_salt = \"\"/defaults.mailbox.password_salt = \"$ee_password_salt\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini \ |
||||
|
|| ee_lib_error "Unable to setup ViMbAdmin mailbox password salt , exit status = " $? |
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
service lmtp { |
||||
|
unix_listener /var/spool/postfix/private/dovecot-lmtp { |
||||
|
mode = 0600 |
||||
|
user = postfix |
||||
|
group = postfix |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
service auth { |
||||
|
unix_listener /var/spool/postfix/private/auth { |
||||
|
mode = 0666 |
||||
|
user = postfix |
||||
|
group = postfix |
||||
|
} |
||||
|
|
||||
|
unix_listener auth-userdb { |
||||
|
mode = 0600 |
||||
|
user = vmail |
||||
|
} |
||||
|
|
||||
|
user = dovecot |
||||
|
} |
||||
|
|
||||
|
service auth-worker { |
||||
|
user = vmail |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
smtp-amavis unix - - n - 2 smtp |
||||
|
-o smtp_data_done_timeout=1200 |
||||
|
-o smtp_send_xforward_command=yes |
||||
|
-o disable_dns_lookups=yes |
||||
|
-o max_use=20 |
||||
|
|
||||
|
127.0.0.1:10025 inet n - n - - smtpd |
||||
|
-o content_filter= |
||||
|
-o smtpd_delay_reject=no |
||||
|
-o smtpd_client_restrictions=permit_mynetworks,reject |
||||
|
-o smtpd_helo_restrictions= |
||||
|
-o smtpd_sender_restrictions= |
||||
|
-o smtpd_recipient_restrictions=permit_mynetworks,reject |
||||
|
-o smtpd_data_restrictions=reject_unauth_pipelining |
||||
|
-o smtpd_end_of_data_restrictions= |
||||
|
-o smtpd_restriction_classes= |
||||
|
-o mynetworks=127.0.0.0/8 |
||||
|
-o smtpd_error_sleep_time=0 |
||||
|
-o smtpd_soft_error_limit=1001 |
||||
|
-o smtpd_hard_error_limit=1000 |
||||
|
-o smtpd_client_connection_count_limit=0 |
||||
|
-o smtpd_client_connection_rate_limit=0 |
||||
|
-o receive_override_options=no_header_body_checks,no_unknown_recipient_checks |
||||
|
-o local_header_rewrite_clients= |
@ -0,0 +1,13 @@ |
|||||
|
passdb { |
||||
|
driver = sql |
||||
|
args = /etc/dovecot/dovecot-sql.conf.ext |
||||
|
} |
||||
|
|
||||
|
userdb { |
||||
|
driver = prefetch |
||||
|
} |
||||
|
|
||||
|
userdb { |
||||
|
driver = sql |
||||
|
args = /etc/dovecot/dovecot-sql.conf.ext |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
plugin { |
||||
|
autocreate = Trash |
||||
|
autocreate2 = Junk |
||||
|
autocreate3 = Drafts |
||||
|
autocreate4 = Sent |
||||
|
autosubscribe = Trash |
||||
|
autosubscribe2 = Junk |
||||
|
autosubscribe3 = Drafts |
||||
|
autosubscribe4 = Sent |
||||
|
} |
@ -0,0 +1,4 @@ |
|||||
|
require "fileinto"; |
||||
|
if header :contains "X-Spam-Flag" "YES" { |
||||
|
fileinto "Junk"; |
||||
|
} |
@ -0,0 +1,73 @@ |
|||||
|
# EasyEngine Dovecot init script |
||||
|
### BEGIN INIT INFO |
||||
|
# Provides: dovecot |
||||
|
# Required-Start: $local_fs $remote_fs $network $syslog $time |
||||
|
# Required-Stop: $local_fs $remote_fs $network $syslog |
||||
|
# Should-Start: postgresql mysql slapd winbind |
||||
|
# Should-Stop: postgresql mysql slapd winbind |
||||
|
# Default-Start: 2 3 4 5 |
||||
|
# Default-Stop: 0 1 6 |
||||
|
# Short-Description: Dovecot init script |
||||
|
# Description: Init script for dovecot services |
||||
|
### END INIT INFO |
||||
|
|
||||
|
# Example /etc/init.d/dovecot script. Change DAEMON if necessary. |
||||
|
# License is public domain. |
||||
|
|
||||
|
DAEMON=/usr/sbin/dovecot |
||||
|
|
||||
|
# Uncomment to allow Dovecot daemons to produce core dumps. |
||||
|
#ulimit -c unlimited |
||||
|
|
||||
|
test -x $DAEMON || exit 1 |
||||
|
set -e |
||||
|
|
||||
|
base_dir=`$DAEMON config -h base_dir` |
||||
|
pidfile=$base_dir/master.pid |
||||
|
|
||||
|
if test -f $pidfile; then |
||||
|
running=yes |
||||
|
else |
||||
|
running=no |
||||
|
fi |
||||
|
|
||||
|
case "$1" in |
||||
|
start) |
||||
|
echo -n "Starting Dovecot" |
||||
|
$DAEMON |
||||
|
echo "." |
||||
|
;; |
||||
|
stop) |
||||
|
if test $running = yes; then |
||||
|
echo "Stopping Dovecot" |
||||
|
kill `cat $pidfile` |
||||
|
echo "." |
||||
|
else |
||||
|
echo "Dovecot is already stopped." |
||||
|
fi |
||||
|
;; |
||||
|
reload) |
||||
|
if test $running = yes; then |
||||
|
echo -n "Reloading Dovecot configuration" |
||||
|
kill -HUP `cat $pidfile` |
||||
|
echo "." |
||||
|
else |
||||
|
echo "Dovecot isn't running." |
||||
|
fi |
||||
|
;; |
||||
|
restart|force-reload) |
||||
|
echo -n "Restarting Dovecot" |
||||
|
if test $running = yes; then |
||||
|
kill `cat $pidfile` |
||||
|
sleep 1 |
||||
|
fi |
||||
|
$DAEMON |
||||
|
echo "." |
||||
|
;; |
||||
|
*) |
||||
|
echo "Usage: /etc/init.d/dovecot {start|stop|reload|restart|force-reload}" >&2 |
||||
|
exit 1 |
||||
|
;; |
||||
|
esac |
||||
|
|
||||
|
exit 0 |
@ -0,0 +1,15 @@ |
|||||
|
driver = mysql |
||||
|
|
||||
|
connect = host=localhost user=vimbadmin password=password dbname=vimbadmin |
||||
|
default_pass_scheme = MD5 |
||||
|
|
||||
|
password_query = SELECT username as user, password as password, \ |
||||
|
homedir AS home, maildir AS mail, \ |
||||
|
concat('*:bytes=', quota) as quota_rule, uid, gid \ |
||||
|
FROM mailbox \ |
||||
|
WHERE username = '%Lu' AND active = '1' \ |
||||
|
AND ( access_restriction = 'ALL' OR LOCATE( access_restriction, '%Us' ) > 0 ) |
||||
|
|
||||
|
user_query = SELECT homedir AS home, maildir AS mail, \ |
||||
|
concat('*:bytes=', quota) as quota_rule, uid, gid \ |
||||
|
FROM mailbox WHERE username = '%u' |
@ -0,0 +1,5 @@ |
|||||
|
user = vimbadmin |
||||
|
password = password |
||||
|
hosts = 127.0.0.1 |
||||
|
dbname = vimbadmin |
||||
|
query = SELECT goto FROM alias WHERE address = '%s' AND active = '1' |
@ -0,0 +1,5 @@ |
|||||
|
user = vimbadmin |
||||
|
password = password |
||||
|
hosts = 127.0.0.1 |
||||
|
dbname = vimbadmin |
||||
|
query = SELECT domain FROM domain WHERE domain = '%s' AND backupmx = '0' AND active = '1' |
@ -0,0 +1,7 @@ |
|||||
|
user = vimbadmin |
||||
|
password = password |
||||
|
hosts = 127.0.0.1 |
||||
|
dbname = vimbadmin |
||||
|
table = mailbox |
||||
|
select_field = maildir |
||||
|
where_field = username |
@ -0,0 +1,23 @@ |
|||||
|
# Nginx Configuration to access webmail |
||||
|
# Don't modify this file, EasyEngine replaces it with new version |
||||
|
|
||||
|
server { |
||||
|
server_name webmail.*; |
||||
|
|
||||
|
access_log /var/log/nginx/webmail.access.log; |
||||
|
error_log /var/log/nginx/webmail.error.log; |
||||
|
|
||||
|
root /var/www/roundcubemail/htdocs/; |
||||
|
index index.php; |
||||
|
|
||||
|
location / { |
||||
|
try_files $uri $uri/ /index.php?$args; |
||||
|
} |
||||
|
|
||||
|
location ~ \.php$ { |
||||
|
try_files $uri =404; |
||||
|
include fastcgi_params; |
||||
|
fastcgi_pass 127.0.0.1:9000; |
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue