MySQL Database Connection Issue


Error
Warning: mysql_connect(): Access denied for user: ‘user1_name1@localhost’ (Using password: YES) /home/public_html/catalog/includes/functions/database.php on line 19
Unable to connect to database server

Configuration File
Edit Configuration File
define(‘DB_NAME’, ‘radius’);
define(‘DB_USER’, ‘radius_02’);
define(‘DB_PASSWORD’, ‘5Jmfde%53L’);
define(‘DB_HOST’, ‘localhost’);

Update CPanel Username
define(‘DB_NAME’, ‘radius’);

Replace Current DB_USER & DB_PASSWORD
define(‘DB_USER’, ‘radius_03’);
define(‘DB_PASSWORD’, ‘nvGHdCC0dCMz’);

Advertisements

TroubleShooting Issue’s


TroubleShooting Issue’s
Troubleshooting is a form of problem solving, often applied to repair failed products or processes. It is a logical, systematic search for the source of a problem in order to solve it, and make the product or process operational again. Troubleshooting is needed to identify the symptoms. Determining the most likely cause is a process of elimination – eliminating potential causes of a problem. Finally, troubleshooting requires confirmation that the solution restores the product or process to its working state.

In general, troubleshooting is the identification of diagnosis of “trouble” in the management flow of a corporation or a system caused by a failure of some kind. The problem is initially described as symptoms of malfunction, and troubleshooting is the process of determining and remedying the causes of these symptoms.

How-to-Fix-and-Troubleshoot-10-Most-Common-Computer-Problems

A system can be described in terms of its expected, desired or intended behavior (usually, for artificial systems, its purpose). Events or inputs to the system are expected to generate specific results or outputs. (For example selecting the “print” option from various computer applications is intended to result in a hardcopy emerging from some specific device). Any unexpected or undesirable behavior is a symptom. Troubleshooting is the process of isolating the specific cause or causes of the symptom. Frequently the symptom is a failure of the product or process to produce any results. (Nothing was printed, for example). Corrective action can then be taken to prevent further failures of a similar kind.

The methods of forensic engineering are especially useful in tracing problems in products or processes, and a wide range of analytical techniques are available to determine the cause or causes of specific failures. Corrective action can then be taken to prevent further failure of a similar kind. Preventative action is possible using failure mode and effects (FMEA) and fault tree analysis (FTA) before full scale production, and these methods can also be used for failure analysis.

 

MikroTik RouterOS Configuration


MikroTik Configuration
The configuration backup can be used for backing up MikroTik RouterOS configuration to a binary file, which can be stored on the router or downloaded from it using FTP for future use. The configuration restore can be used for restoring the router’s configuration, exactly as it was at the backup creation moment, from a backup file. The restoration procedure assumes the cofiguration is restored on the same router, where the backup file was originally created, so it will create partially broken configuration if the hardware has been changed.

The configuration export can be used for dumping out complete or partial MikroTik RouterOS configuration to the console screen or to a text (script) file, which can be downloaded from the router using FTP protocol. The configuration dumped is actually a batch of commands that add (without removing the existing configuration) the selected configuration to a router. The configuration import facility executes a batch of console commands from a script file.

System reset command is used to erase all configuration on the router. Before doing that, it might be useful to backup the router’s configuration.

System Backup;
System Restore From a Backup;
Configuration Export;
Configuration Import;
System Configuration Reset.

MikroTik RouterOS & WinBox Installation


MikroTik RouterOS & WinBox Installation
Mikrotik
MikroTik RouterOS is a router operating system and software which turns a regular Intel PC or MikroTik RouterBOARD™ hardware into a dedicated router.  MikroTik is an operating system based on the Linux kernel, known as the MikroTik RouterOS. Installed on the companys proprietary hardware (RouterBOARD series), or on standard x86-based computers, it turns a computer into a network router and implements various additional features, such as firewalling, virtual private network (VPN) service and client, bandwidth shaping and quality of service, wireless access point functions and other commonly used features when interconnecting networks. The system is also able to serve as a captive-portal-based hotspot system.

WinBox
When connecting to the MikroTik router via http (TCP port 80 by default), the router’s Welcome Page is displayed in the web browser. By clicking on the Winbox Console link you can start the winbox.exe download. Choose Open to start the Winbox loader program you can also save this program to your local disk, and run it from there. The winbox.exe program opens the Winbox login window. Login to the router by specifying the IP address and the port number if you have changed it from the default value of 80.

 

MikroTik Information


MikroTik
The main product of MikroTik is an operating system based on the Linux kernel, known as the MikroTik RouterOS. Installed on the company’s proprietary hardware (RouterBOARD series), or on standard x86-based computers, it turns a computer into a network router and implements various additional features, such as firewalling, virtual private network (VPN) service and client, bandwidth shaping and quality of service, wireless access point functions and other commonly used features when interconnecting networks. The system is also able to serve as a captive-portal-based hotspot system.

The operating system is licensed in increasing service levels, each releasing more of the available RouterOS features. A MS Windows application called Winbox provides a graphical user interface for the RouterOS configuration and monitoring, but RouterOS also allows access via FTP, telnet, and secure shell (SSH). An application programming interface is available for direct access from applications for management and monitoring.

1075_hi_res

Web Control Panel Automated Script for CentOS


#!/bin/bash

clear

CentOS Web Panel (CWP) Installer
if [ ! -e “/etc/redhat-release” ]; then
echo “You need to have CentOS, RedHat or CloudLinux system!”
exit 0
fi

CHKDATE=date +%Y
if [ “$CHKDATE” -le “2014” ];then
echo “You have incorrect date set on your server!”
echo date
exit 0
fi

type mysql && MYSQLCHK=”on” || MYSQLCHK=”off”

MySQL checker
if [ “$MYSQLCHK” = “on” ]; then
#check pwd if works
while [ “$check” != “Database” ]
do
echo “Enter MySQL root Password: ”
read -p “MySQL root password []:” password
check=mysql -u root -p$password -e "show databases;" -B|head -n1
if [ “$check” = “Database” ]; then
echo “Password OK!!”
else
echo “MySQL root passwordis invalid!!!”
echo “You can remove MySQL server using command: yum remove mysql”
echo “after mysql is removed run installer again.”
echo “”
echo “if exists you can check your mysql password in file: /root/.my.cnf”
echo “”
if [ -e “/root/.my.cnf” ]; then
echo “”
cat /root/.my.cnf
echo “”
fi
fi
done

else
password=$(</dev/urandom tr -dc A-Za-z0-9 | head -c12)
fi

service httpd stop
service mysql stop
yum -y install wget chkconfig

Check if version el5
centosversion=rpm -qa \*-release | grep -Ei "oracle|redhat|centos|cloudlinux" | cut -d"-" -f3

if [ $centosversion -eq “5” ]; then
echo “#el5 version detected”
echo “We recommend you to use CentOS 6 servers for full functionality!”
echo “Press ENTER to continue with CentOS 5 installation”
read CENTOS5CONFIRM
fi

if [ $centosversion -eq “6” ]; then
echo
echo “#el6 version detected”
echo
fi

Check /tmp
if [[ cat /etc/fstab | grep -E 'tmp.*noexec' != “” ]]; then mount -o remount,exec /tmp >/dev/null 2>&1 ; fi

Umask Fix
sed -ie “s/umask\=002/umask=022/g” /etc/bashrc >/dev/null 2>&1

Install RPMforge repo
cd /tmp
rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt
wget -q http://dl1.centos-webpanel.com/files/repos/rpmforge-release-0.5.3-1.el$centosversion.rf.$(uname -m).rpm
rpm -i rpmforge-release-0.5.3-1.el.rpm
rm -f rpmforge-release-0.5.3-1.el

Install Dependecies
yum -y install bzip2-devel gcc libxml2-devel openssl-devel pcre-devel sqlite-devel curl-devel libc-client-devel libmcrypt-devel libxslt-devel libpng-devel automake autoconf gcc-c++ freetype-devel libjpeg-devel
yum -y install make rsync mysql-server at mysql-devel bzip2-devel zip git pure-ftpd unzip cronie perl-libwww-perl
yum -y remove apr
yum -y install rsync cpulimit nano links bzip2-devel
yum -y install postfix dovecot dovecot-mysql
yum -y install bind bind-utils bind-libs

#pubip=curl -s http://centos-webpanel.com/webpanel/main.php?app=showip
pubip=curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/&lt;.*$//'
fqdn=/bin/hostname
echo “PREPARING THE SERVER”
if [ -e “/etc/selinux/config” ]; then
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config
setenforce 0
fi

if [ -e “/etc/init.d/sendmail” ]
then
chkconfig –levels 235 sendmail off
/etc/init.d/sendmail stop
fi

service iptables save
service iptables stop

#yum -y install make zip unzip git ld-linux.so.2 libbz2.so.1 libdb-4.7.so libgd.so.2 vsftpd
#Installation of Web Files
#FTPD configuration

if [ ! -e “/etc/pure-ftpd/pure-ftpd.conf” ]
then
echo “Installation FAILED at pure-ftpd”
yum -y install pure-ftpd
touch /etc/pure-ftpd/pure-ftpd.passwd
pure-pw mkdb /etc/pure-ftpd/pureftpd.pdb -f /etc/pure-ftpd/pure-ftpd.passwd -m
fi

FTPD Configuration
if [ ! -e “/etc/pure-ftpd/pure-ftpd.conf” ]
then
echo “Installation FAILED at pure-ftpd”
exit 0
fi

#echo “chroot_local_user=YES” >> /etc/vsftpd/vsftpd.conf
#sed -i “s|anonymous_enable=YES|anonymous_enable=NO|” /etc/vsftpd/vsftpd.conf
#sed -i “s|userlist_enable=YES|userlist_enable=NO|” /etc/vsftpd/vsftpd.conf

sed -i ‘s|.pureftpd.pdb.|PureDB /etc/pure-ftpd/pureftpd.pdb|g’ /etc/pure-ftpd/pure-ftpd.conf

Apache Installer
mkdir -p /usr/local/src
cd /usr/local/src
wget -q http://dl1.centos-webpanel.com/files/c_scripts/apache-2.2.27-cwp.sh
wget -q http://dl1.centos-webpanel.com/files/c_scripts/php-5.4-cwp.sh
wget -q http://dl1.centos-webpanel.com/files/c_scripts/apache-2.2.27.sh
wget -q http://dl1.centos-webpanel.com/files/c_scripts/php-5.4.sh

sh /usr/local/src/apache-2.2.27.sh
if [ ! -e “/usr/local/apache/bin/httpd” ]
then
echo
echo “Compiler requires 512 MB RAM + SWAP”
echo “Installation FAILED at httpd”
echo “Installation FAILED at httpd” > /tmp/cwp.log
curl http://dl1.centos-webpanel.com/files/s_scripts/sinfo.sh|sh 2>&1 >> /tmp/cwp.log
curl -F”operation=upload” -F”file=@/tmp/cwp.log” http://dl1.centos-webpanel.com/post/post.php
exit 0
fi
rm -f /usr/local/src/apache-2.2.27.sh

sh /usr/local/src/php-5.4.sh
if [ ! -e “/usr/local/bin/php” ]
then
echo
echo “Compiler requires 512 MB RAM + SWAP”
echo “Installation FAILED at php”
echo “Installation FAILED at php” > /tmp/cwp.log
curl http://dl1.centos-webpanel.com/files/s_scripts/sinfo.sh|sh 2>&1 >> /tmp/cwp.log
curl -F”operation=upload” -F”file=@/tmp/cwp.log” http://dl1.centos-webpanel.com/post/post.php
exit 0
fi
rm -f /usr/local/src/php-5.4.sh

if [ -e “/usr/local/bin/php-config” ]
then
CHKEXTENSIONTDIR=/usr/local/bin/php-config --extension-dir;grep ^extension_dir /usr/local/php/php.ini || echo “extension_dir=’$CHKEXTENSIONTDIR'” >> /usr/local/php/php.ini
fi

sh /usr/local/src/apache-2.2.27-cwp.sh
if [ ! -e “/usr/local/cwpsrv/bin/cwpsrvd” ]
then
echo
echo “Compiler requires 512 MB RAM + SWAP”
echo “Installation FAILED at cwpsrvd”
echo “Installation FAILED at cwpsrvd” > /tmp/cwp.log
curl http://dl1.centos-webpanel.com/files/s_scripts/sinfo.sh|sh 2>&1 >> /tmp/cwp.log
curl -F”operation=upload” -F”file=@/tmp/cwp.log” http://dl1.centos-webpanel.com/post/post.php
exit 0
fi
rm -f /usr/local/src/apache-2.2.27-cwp.sh

sh /usr/local/src/php-5.4-cwp.sh
if [ ! -e “/usr/local/cwp/php54/bin/php” ]
then
echo
echo “Compiler requires 512 MB RAM + SWAP”
echo “Installation FAILED at cwp php”
echo “Installation FAILED at cwp php” > /tmp/cwp.log
curl http://dl1.centos-webpanel.com/files/s_scripts/sinfo.sh|sh 2>&1 >> /tmp/cwp.log
curl -F”operation=upload” -F”file=@/tmp/cwp.log” http://dl1.centos-webpanel.com/post/post.php
exit 0
fi
rm -f /usr/local/src/php-5.4-cwp.sh

cat > /usr/local/cwpsrv/conf.d/server.conf <<EOF
#Timeout 300
TraceEnable Off
ServerSignature Off
ServerTokens ProductOnly
FileETag None
StartServers 1
<IfModule prefork.c>
MinSpareServers 1
MaxSpareServers 2
</IfModule>
<IfModule itk.c>
MinSpareServers 1
MaxSpareServers 2
</IfModule>
ServerLimit 35
MaxClients 25
MaxRequestsPerChild 10000
#KeepAlive Off
#KeepAliveTimeout 5
#MaxKeepAliveRequests 100
EOF

IonCube Installer
PHPVER=/usr/local/bin/php -v| awk '{ print $2 }'|head -n 1|cut -c 1-3
echo “zend_extension = /usr/local/ioncube/ioncube_loader_lin_$PHPVER.so” >> /usr/local/php/php.ini

Configure Mysql
cd /usr/local/src
chkconfig –levels 235 mysqld on
sed -i “s|old_passwords=1|#old_passwords=1|” /etc/my.cnf
service mysqld start
mysqladmin -u root password $password
mysql -u root -p$password -e “DROP DATABASE test”;
mysql -u root -p$password -e “DELETE FROM mysql.user WHERE User=’root’ AND Host!=’localhost'”;
mysql -u root -p$password -e “DELETE FROM mysql.user WHERE User=””;
mysql -u root -p$password -e “FLUSH PRIVILEGES”;

cat > /root/.my.cnf <<EOF
[client]
password=$password
user=root
EOF
chmod 600 /root/.my.cnf

Configure Apache
touch /usr/local/apache/conf.d/vhosts.conf
sed -i “s|#Include conf/extra/httpd-userdir.conf|Include conf/extra/httpd-userdir.conf|” /usr/local/apache/conf/httpd.conf

Apache Server Status
cat > /usr/local/apache/conf.d/server-status.conf <<EOF
<Location /server-status>
SetHandler server-status
Order deny,allow
Allow from localhost
</Location>
EOF

#Set PHP Config
#sed -i “s|;date.timezone =|date.timezone = $tz|” /etc/php.ini
#sed -i “s|extension=module.so|extension=mcrypt.so|” /etc/php.d/mcrypt.ini

echo “127.0.0.1 “$fqdn >> /etc/hosts
chkconfig –levels 235 httpd on
service httpd restart

Mail Server Config
sed -i “s|inet_interfaces = localhost|inet_interfaces = all|” /etc/postfix/main.cf
sed -i “s|mydestination = $myhostname, localhost.$mydomain, localhost|mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, $domain|” /etc/postfix/main.cf
sed -i “s|#home_mailbox = Maildir/|home_mailbox = Maildir/|” /etc/postfix/main.cf

Install csf Firewall
cd /tmp
rm -fv csf.tgz
wget -q http://www.configserver.com/free/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh
sed -i “s|465,587,993,995|465,587,993,995,2030,2031|” /etc/csf/csf.conf
sed -i “s|80,110,113,443|80,110,113,443,2030,2031|” /etc/csf/csf.conf
sed -i ‘s|TESTING = “1”|TESTING = “0”|’ /etc/csf/csf.conf
echo “# Run external commands before csf configures iptables” >> /usr/local/csf/bin/csfpre.sh
echo “# Run external commands after csf configures iptables” >> /usr/local/csf/bin/csfpost.sh
csf -x

cat >> /etc/csf/csf.pignore <<EOF

CWP CUSTOM
exe:/usr/sbin/clamd
exe:/usr/sbin/opendkim
exe:/usr/libexec/mysqld
exe:/usr/libexec/dovecot/anvil
exe:/usr/libexec/dovecot/auth
exe:/usr/libexec/dovecot/imap-login
exe:/usr/libexec/dovecot/dict
exe:/usr/libexec/dovecot/pop3-login
exe:/usr/libexec/postfix/tlsmgr
exe:/usr/libexec/postfix/qmgr
exe:/usr/libexec/postfix/pickup
exe:/usr/libexec/postfix/smtpd
exe:/usr/libexec/postfix/smtp
exe:/usr/libexec/postfix/bounce
exe:/usr/libexec/postfix/scache
exe:/usr/libexec/postfix/anvil
exe:/usr/libexec/postfix/cleanup
exe:/usr/libexec/postfix/proxymap
exe:/usr/libexec/postfix/trivial-rewrite
exe:/usr/libexec/postfix/local
exe:/usr/libexec/postfix/pipe
exe:/usr/libexec/postfix/spawn
exe:/usr/sbin/varnishd
exe:/usr/sbin/nginx
exe:/usr/bin/perl
user:amavis
cmd:/usr/sbin/amavisd
EOF

CWP BruteForce Protection
sed -i “s|CUSTOM1_LOG.*|CUSTOM1_LOG = \”/var/log/cwp_client_login.log\”|g” /etc/csf/csf.conf
cat > /usr/local/csf/bin/regex.custom.pm <<EOF
#!/usr/bin/perl
sub custom_line {
my \$line = shift;
my \$lgfile = shift;
#Do not edit before this point
if ((\$globlogs{CUSTOM1_LOG}{\$lgfile}) and (\$line =~ /^\S+\s+\S+\s+(\S+)\s+Failed Login from:\s+(\S+) on: (\S+)/)) {
return (“Failed CWP-Login login for User: \$1 from IP: \$2 URL: \$3″,\$2,”cwplogin”,”5″,”2030,2031″,”1″);
}
#Do not edit beyond this point
return 0;
}
1;
EOF

Dovecot Bug Fix
touch /var/log/dovecot-debug.log
touch /var/log/dovecot-info.log
touch /var/log/dovecot.log
chmod 600 /var/log/dovecot-debug.log
chmod 600 /var/log/dovecot-info.log
chmod 600 /var/log/dovecot.log

WebPanel Install
cd /usr/local/cwpsrv/htdocs
wget -q dl1.centos-webpanel.com/files/cwp/cwp_test_093.zip
unzip -o cwp_test_093.zip
rm -f cwp_test.zip
cd /usr/local/cwpsrv/htdocs/resources/admin/include
wget -q http://dl1.centos-webpanel.com/files/cwp/sql/db_conn.txt
mv db_conn.txt db_conn.php
cd /usr/local/cwpsrv/htdocs/resources/admin/modules
wget -q http://dl1.centos-webpanel.com/files/cwp/modules/example.txt
mv example.txt example.php

PhpMyAdmin Installer
cd /usr/local/apache/htdocs/
wget -q http://dl1.centos-webpanel.com/files/mysql/phpMyAdmin.zip
unzip -o phpMyAdmin.zip
rm -f phpMyAdmin.zip

WebFTP Installer
cd /usr/local/apache/htdocs/
wget -q dl1.centos-webpanel.com/files/cwp/addons/webftp_simple.zip
unzip -o webftp_simple.zip
rm -f webftp_simple.zip

Default Website Setup
cp /usr/local/cwpsrv/htdocs/resources/admin/tpl/new_account_tpl/* /usr/local/apache/htdocs/.

WebPanel Settings
mv /usr/local/apache/htdocs/phpMyAdmin/config.sample.inc.php /usr/local/apache/htdocs/phpMyAdmin/config.inc.php
ran_password=$(</dev/urandom tr -dc A-Za-z0-9 | head -c12)
sed -i “s|[’blowfish_secret’] = ”|[’blowfish_secret’] = ‘${ran_password}’|” /usr/local/apache/htdocs/phpMyAdmin/config.inc.php
ran_password2=$(</dev/urandom tr -dc A-Za-z0-9 | head -c12)
sed -i “s|\$crypt_pwd = ”|\$crypt_pwd = ‘${ran_password2}’|” /usr/local/cwpsrv/htdocs/resources/admin/include/db_conn.php
sed -i “s|\$db_pass = ”|\$db_pass = ‘$password’|” /usr/local/cwpsrv/htdocs/resources/admin/include/db_conn.php
chmod 600 /usr/local/cwpsrv/htdocs/resources/admin/include/db_conn.php
chmod 777 /var/lib/php/session/

PHP Short tags fix
sed -i “s|short_open_tag = Off|short_open_tag = On|” /usr/local/cwp/php54/php.ini
sed -i “s|short_open_tag = Off|short_open_tag = On|” /usr/local/php/php.ini

Setup Cron
cat > /etc/cron.daily/cwp <<EOF
/usr/local/cwp/php54/bin/php -d max_execution_time=1000000 -q /usr/local/cwpsrv/htdocs/resources/admin/include/cron.php
/usr/local/cwp/php54/bin/php -d max_execution_time=1000000 -q /usr/local/cwpsrv/htdocs/resources/admin/include/cron_backup.php
EOF
chmod +x /etc/cron.daily/cwp

MySQL Database Import
curl ‘http://dl1.centos-webpanel.com/files/cwp/sql/root_cwp.sql&#8217;|mysql -uroot -p$password
mysql -u root -p$password << EOF
use root_cwp;
UPDATE settings SET shared_ip=”$pubip”;
EOF

Disable named for antiDDoS security
chkconfig named on

DNS Setup
if [ $centosversion -eq “5” ]; then
ln -s /etc/named.rfc1912.zones /etc/named.conf
fi
echo “nameserver 8.8.8.8” >> /etc/resolv.conf
echo “nameserver 8.8.4.4” >> /etc/resolv.conf
sed -i “s|127.0.0.1|any|” /etc/named.conf
sed -i “s|localhost|any|” /etc/named.conf
sed -i ‘s/recursion yes/recursion no/g’ /etc/named.conf

Clean yum
yum clean all

Replace & Read From Root Folder
#if [ ! -e “/usr/local/cwpsrv/htdocs/mysql.txt” ]
#then
#echo “\”$password\”” > /etc/webpanel/mysql.txt
#fi

Check MySQL Root Password
mysql_root_password=$password
if [ -z “${mysql_root_password}” ]; then
read -p “MySQL root password []:” mysql_root_password
fi

clear

check=mysql -u root -p$mysql_root_password -e "show databases;" -B|head -n1
if [ “$check” = “Database” ]; then
echo “Password OK”
else
echo “MySQL root password is invalid”
echo “Check password and run this script again.”
exit 0

fi

Needed to Add Password in Root Folder
mysql -u root -p$mysql_root_password -e “UPDATE mysql.user SET Password = PASSWORD(‘$mysql_root_password’) WHERE user = ‘root’;”
mysql -u root -p$mysql_root_password -e “FLUSH PRIVILEGES;”

Password Generator
postfix_pwd=$(</dev/urandom tr -dc A-Za-z0-9 | head -c12)
cnf_hostname=/bin/hostname

Create Database & User
mysql -u root -p$mysql_root_password -e “CREATE DATABASE postfix;”
mysql -u root -p$mysql_root_password -e “CREATE USER postfix@localhost IDENTIFIED BY ‘$postfix_pwd’;”
mysql -u root -p$mysql_root_password -e “GRANT ALL PRIVILEGES ON postfix . * TO postfix@localhost;”

MySQL Database Import
curl ‘http://centos-webpanel.com/webpanel/main.php?dl=postfix.sql&#8217;|mysql -uroot -p$mysql_root_password -h localhost postfix
yum -y remove sendmail exim
yum -y install postfix dovecot dovecot-mysql dovecot-pigeonhole cyrus-sasl-devel cyrus-sasl-sql subversion
yum -y install perl-MailTools perl-MIME-EncWords perl-MIME-Charset perl-Email-Valid perl-Test-Pod perl-TimeDate
yum -y install perl-Mail-Sender perl-Log-Log4perl imapsync offlineimap
yum -y install perl-Razor-Agent perl-Convert-BinHex crypto-utils
yum -y install amavisd-new clamav clamd –disablerepo=rpmforge-webpanel

GET Mail Configs
cd /
wget -q http://dl1.centos-webpanel.com/files/mail/mail_server.zip
unzip -o /mail_server.zip
rm -f /mail_server.zip

User add
mkdir /var/vmail
chmod 770 /var/vmail
useradd -r -u 101 -g mail -d /var/vmail -s /sbin/nologin -c “Virtual mailbox” vmail
chown vmail:mail /var/vmail

touch /etc/postfix/virtual_regexp

Virtual Vacation
useradd -r -d /var/spool/vacation -s /sbin/nologin -c “Virtual vacation” vacation
mkdir /var/spool/vacation
chmod 770 /var/spool/vacation
cd /var/spool/vacation/
#ln -s /etc/postfix/vacation.pl /var/spool/vacation/vacation.pl
ln -s /etc/postfix/vacation.php /var/spool/vacation/vacation.php
chmod +x /etc/postfix/vacation.php

echo “autoreply.$cnf_hostname vacation:” > /etc/postfix/transport
postmap /etc/postfix/transport
chown -R vacation:vacation /var/spool/vacation
echo “127.0.0.1 autoreply.$cnf_hostname” >> /etc/hosts

Sieve
mkdir -p /var/sieve/
cat > /var/sieve/globalfilter.sieve <<EOF
require “fileinto”;
if exists “X-Spam-Flag” {
if header :contains “X-Spam-Flag” “NO” {
} else {
fileinto “Spam”;
stop;
}
}
if header :contains “subject” [“SPAM“] {
fileinto “Spam”;
stop;
}
EOF
chown -R vmail:mail /var/sieve

Razor-admin -register -user=some_user -pass=somepas
freshclam
service clamd restart

SSL Self signed certificate
cd /root
DOMAIN=”$cnf_hostname”
if [ -z “$DOMAIN” ]; then
echo “Usage: $(basename $0) <domain>”
exit 11
fi

fail_if_error() {
[ $1 != 0 ] && {
unset PASSPHRASE
exit 10
}
}

Generate a passphrase
export PASSPHRASE=$(head -c 500 /dev/urandom | tr -dc a-z0-9A-Z | head -c 128; echo)

Certificate details; replace items in angle brackets with your own info
subj=”
C=HR
ST=Zagreb
O=CentOS Web Panel
localityName=HR
commonName=$DOMAIN
organizationalUnitName=CentOS Web Panel
emailAddress=info@studio4host.com

Generate the server private key
openssl genrsa -des3 -out $DOMAIN.key -passout env:PASSPHRASE 2048
fail_if_error $?

Generate the CSR
openssl req \
-new \
-batch \
-subj “$(echo -n “$subj” | tr “\n” “/”)” \
-key $DOMAIN.key \
-out $DOMAIN.csr \
-passin env:PASSPHRASE
fail_if_error $?
cp $DOMAIN.key $DOMAIN.key.org
fail_if_error $?

Strip the password so we don’t have to type it every time we restart Apache
openssl rsa -in $DOMAIN.key.org -out $DOMAIN.key -passin env:PASSPHRASE
fail_if_error $?

Generate the cert (Good for 10 Years)
openssl x509 -req -days 3650 -in $DOMAIN.csr -signkey $DOMAIN.key -out $DOMAIN.crt
fail_if_error $?

mv /root/$cnf_hostname.key /etc/pki/tls/private/.
mv /root/$cnf_hostname.crt /etc/pki/tls/certs/.
echo ” ” > /etc/pki/tls/certs/$cnf_hostname.bundle

/etc/postfix/main.cf
sed -i “s|MY_HOSTNAME|$cnf_hostname|” /etc/postfix/main.cf
sed -i “s|MY_DOMAIN|$cnf_hostname|” /etc/postfix/main.cf
sed -i “s|MY_DOMAIN|$cnf_hostname|” /etc/postfix/main.cf

MySQL PWD Fix for Postfix
sed -i “s|MYSQL_PASSWORD|$postfix_pwd|” /etc/postfix/mysql-relay_domains_maps.cf
sed -i “s|MYSQL_PASSWORD|$postfix_pwd|” /etc/postfix/mysql-virtual_alias_maps.cf
sed -i “s|MYSQL_PASSWORD|$postfix_pwd|” /etc/postfix/mysql-virtual_domains_maps.cf
sed -i “s|MYSQL_PASSWORD|$postfix_pwd|” /etc/postfix/mysql-virtual_mailbox_limit_maps.cf
sed -i “s|MYSQL_PASSWORD|$postfix_pwd|” /etc/postfix/mysql-virtual_mailbox_maps.cf

Postfix Web panel SQL Setup
if [ ! -e “/usr/local/cwpsrv/htdocs/resources/admin/include/postfix.php” ]
then
cd /usr/local/cwpsrv/htdocs/resources/admin/include
wget -q http://centos-webpanel.com/webpanel/main.php?dl=postfix.txt
mv main.php?dl=postfix.txt postfix.php
fi
sed -i “s|\$db_pass_postfix = ”|\$db_pass_postfix = ‘$postfix_pwd’|” /usr/local/cwpsrv/htdocs/resources/admin/include/postfix.php
chmod 600 /usr/local/cwpsrv/htdocs/resources/admin/include/postfix.php

Vacation fix
sed -i “s|MYSQL_PASSWORD|$postfix_pwd|” /etc/postfix/vacation.conf
sed -i “s|AUTO_REPLAY|autoreply.$cnf_hostname|” /etc/postfix/vacation.conf

DOVECOT fix
sed -i “s|MYSQL_PASSWORD|$postfix_pwd|” /etc/dovecot/dovecot-dict-quota.conf
sed -i “s|MYSQL_PASSWORD|$postfix_pwd|” /etc/dovecot/dovecot-mysql.conf
sed -i “s|MY_DOMAIN|$cnf_hostname|” /etc/dovecot/dovecot.conf
sed -i “s|MY_DOMAIN|$cnf_hostname|” /etc/dovecot/dovecot.conf

Roundcube Installer
if [ -z “${mysql_roundcube_password}” ]; then
tmp=$(</dev/urandom tr -dc A-Za-z0-9 | head -c12)
mysql_roundcube_password=${mysql_roundcube_password:-${tmp}}
echo “MySQL roundcube: ${mysql_roundcube_password}” >> .passwords
fi

if [ -z “${mysql_root_password}” ]; then
read -p “MySQL root password []:” mysql_root_password
fi

wget -P /usr/local/apache/htdocs http://dl1.centos-webpanel.com/files/mail/roundcubemail-0.8.5.tar.gz
tar -C /usr/local/apache/htdocs -zxvf /usr/local/apache/htdocs/roundcubemail-.tar.gz
rm -f /usr/local/apache/htdocs/roundcubemail-
.tar.gz
mv /usr/local/apache/htdocs/roundcubemail-* /usr/local/apache/htdocs/roundcube
chown nobody:nobody -R /usr/local/apache/htdocs/roundcube
chmod 777 -R /usr/local/apache/htdocs/roundcube/temp/
chmod 777 -R /usr/local/apache/htdocs/roundcube/logs/

/usr/local/apache/conf.d/20-roundcube.conf ROUNDCUBE CONFIG FOR APACHE
sed -e “s|mypassword|${mysql_roundcube_password}|” <<‘EOF’ | mysql -u root -p”${mysql_root_password}”
USE mysql;
CREATE USER ’roundcube’@’localhost’ IDENTIFIED BY ‘mypassword’;
GRANT USAGE ON * . * TO ’roundcube’@’localhost’ IDENTIFIED BY ‘mypassword’;
CREATE DATABASE IF NOT EXISTS roundcube;
GRANT ALL PRIVILEGES ON roundcube . * TO ’roundcube’@’localhost’;
FLUSH PRIVILEGES;
EOF

mysql -u root -p”${mysql_root_password}” ’roundcube’ < /usr/local/apache/htdocs/roundcube/SQL/mysql.initial.sql

cp /usr/local/apache/htdocs/roundcube/config/main.inc.php.dist /usr/local/apache/htdocs/roundcube/config/main.inc.php

sed -i “s|^(\$rcmail_config[’default_host’] =).$|\1 \’localhost\’;|” /usr/local/apache/htdocs/roundcube/config/main.inc.php
sed -i “s|^(\$rcmail_config[’smtp_server’] =).
$|\1 \’localhost\’;|” /usr/local/apache/htdocs/roundcube/config/main.inc.php
sed -i “s|^(\$rcmail_config[’smtp_user’] =).$|\1 \’%u\’;|” /usr/local/apache/htdocs/roundcube/config/main.inc.php
sed -i “s|^(\$rcmail_config[’smtp_pass’] =).
$|\1 \’%p\’;|” /usr/local/apache/htdocs/roundcube/config/main.inc.php
#sed -i “s|^(\$rcmail_config[’support_url’] =).$|\1 \’mailto:${E}\’;|” /usr/local/apache/htdocs/roundcube/config/main.inc.php
sed -i “s|^(\$rcmail_config[’quota_zero_as_unlimited’] =).
$|\1 true;|” /usr/local/apache/htdocs/roundcube/config/main.inc.php
sed -i “s|^(\$rcmail_config[’preview_pane’] =).$|\1 true;|” /usr/local/apache/htdocs/roundcube/config/main.inc.php
sed -i “s|^(\$rcmail_config[’read_when_deleted’] =).
$|\1 false;|” /usr/local/apache/htdocs/roundcube/config/main.inc.php
sed -i “s|^(\$rcmail_config[’check_all_folders’] =).$|\1 true;|” /usr/local/apache/htdocs/roundcube/config/main.inc.php
sed -i “s|^(\$rcmail_config[’display_next’] =).
$|\1 true;|” /usr/local/apache/htdocs/roundcube/config/main.inc.php
sed -i “s|^(\$rcmail_config[’top_posting’] =).$|\1 true;|” /usr/local/apache/htdocs/roundcube/config/main.inc.php
sed -i “s|^(\$rcmail_config[’sig_above’] =).
$|\1 true;|” /usr/local/apache/htdocs/roundcube/config/main.inc.php
sed -i “s|^(\$rcmail_config[’login_lc’] =).*$|\1 2;|” /usr/local/apache/htdocs/roundcube/config/main.inc.php

cp /usr/local/apache/htdocs/roundcube/config/db.inc.php.dist /usr/local/apache/htdocs/roundcube/config/db.inc.php

sed -i “s|^(\$rcmail_config[’db_dsnw’] =).*$|\1 \’mysqli://roundcube:${mysql_roundcube_password}@localhost/roundcube\’;|” /usr/local/apache/htdocs/roundcube/config/db.inc.php
rm -rf /usr/local/apache/htdocs/roundcube/installer
chown -R nobody:nobody /usr/local/apache/htdocs/roundcube
#mv /usr/local/apache/htdocs/roundcube /usr/local/cwpsrv/htdocs/admin/lib/.

Setup Login Screen
[[ $(grep “bash_cwp” /root/.bash_profile) == “” ]] && echo “sh /root/.bash_cwp” >>  /root/.bash_profile
cat > /root/.bash_cwp <<EOF
echo “”
echo “if you can not access CWP try this command: service iptables stop”
echo “”
w
echo “”
df -h
echo “”
EOF

FIX /etc/init.d links
yum -y remove httpd
cd /etc/init.d/
rm -f /etc/init.d/httpd
wget -q http://dl1.centos-webpanel.com/files/s_scripts/httpd
chmod +x /etc/init.d/httpd

cd /etc/init.d/
rm -f /etc/init.d/cwpsrv
wget -q http://dl1.centos-webpanel.com/files/s_scripts/cwpsrv
chmod +x /etc/init.d/cwpsrv

if [ ! -e “/scripts” ]
then
cd /;ln -s /usr/local/cwpsrv/htdocs/resources/scripts /scripts
fi

Chkconfig
iptables -F
chkconfig iptables off
chkconfig httpd on
chkconfig cwpsrv on
chkconfig mysqld on
chkconfig pure-ftpd on
chkconfig postfix on
chkconfig dovecot on

Service restart
service httpd restart
service cwpsrvd restart

Check /tmp
if [[ cat /etc/fstab | grep -E 'tmp.*noexec' != “” ]]; then mount -o remount /tmp >/dev/null 2>&1 ; fi
chown vmail.mail /var/log/dovecot*
chown -R nobody:nobody /usr/local/apache/htdocs/*
/usr/bin/chattr +i /usr/local/cwpsrv/htdocs/admin

clear
echo “go to CentOS WebPanel Admin GUI at http://SERVER_IP:2030/&#8221;
echo “”
echo “http://${pubip}:2030”
echo “SSL: https://${pubip}:2031”
echo “Username: root”
echo “Password: ssh server root password”
echo “MySQL root Password: $password”
echo “SSL Cert name (hostname): ${cnf_hostname}”
echo “SSL Cert file location /etc/pki/tls/ private|certs”
echo “visit for help: http://www.centos-webpanel.com&#8221;
echo “Write down login details and press ENTER for server reboot!”
read -p “Press ENTER for server reboot!”

shutdown -r now

Mikogo Automated Script for Ubuntu


#!/bin/bash

Updating System
sudo apt-get update

Downloading Mikogo
wget http://download.mikogo4.com/mikogo.tar.gz
Decompress the archive
tar xzf mikogo.tar.gz

Moving Files
sudo mv mikogo4.5 /usr/lib/

Create a symlink
sudo ln -s /usr/lib/mikogo4.5/mikogo /usr/bin/mikogo

Create a new File
echo “[Desktop Entry]
Type=Application
Name=Mikogo
Comment=Mikogo Desktop Sharing Tool
Icon=/usr/lib/mikogo4.5/mikogo.png
Exec=mikogo
Terminal=false
Categories=Network;Application;” >> /usr/share/applications/mikogo.desktop

Output Details
chaitanya-GA-78LMT-S2 ~ # cd /usr/lib/mikogo4.5/
chaitanya-GA-78LMT-S2 mikogo4.5 # ls
config.ini  connections.ini  mikogo  sessionplayer
chaitanya-GA-78LMT-S2 mikogo4.5 # ./mikogo
Application asked to unregister timer 0xb0678f0 which is not registered in this thread. Fix application.