Browse Source

Changed Anemometer Installation And Add Some Checks

old-stable
Mitesh Shah 11 years ago
parent
commit
41c7679a93
  1. 92
      usr/local/sbin/easyengine
  2. 52
      usr/local/sbin/eeupdate

92
usr/local/sbin/easyengine

@ -497,52 +497,6 @@ PHP_PACKAGES()
touch /var/www/22222/htdocs/fpm/status/{php,debug}
fi
# Anemometer Setup
if [ ! -d /var/www/22222/htdocs/db/anemometer/ ]
then
mkdir -p /var/www/22222/htdocs/db/anemometer/ || OwnError "Unable To Create Anemometer Directory"
# Download Anemometer
git clone https://github.com/box/Anemometer.git /var/www/22222/htdocs/db/anemometer &>> $INSTALLLOG \
|| OwnError "Unable To Clone Anemometer"
# Setup Anemometer
# Collect MySQL Login Details
MYSQLROOT
# Setup Anemometer Database
mysql -u $MYSQLUSER -p$MYSQLPASS < /var/www/22222/htdocs/db/anemometer/install.sql \
|| OwnError "Unable To Import Anemometer Database"
# Setup Anemometer Database Grants
ANEMOMETERPASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1)
mysql -u $MYSQLUSER -p$MYSQLPASS -e "grant all on slow_query_log.* to 'anemometer'@'localhost' IDENTIFIED BY '$ANEMOMETERPASS';"
# Put Data In Anemometer Database
pt-query-digest --user=anemometer --password=$ANEMOMETERPASS \
--review D=slow_query_log,t=global_query_review \
--review-history D=slow_query_log,t=global_query_review_history \
--no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /var/log/mysql/slow.log &>> $INSTALLLOG
# Execute On MySQL Logrotation
sed -i "/endscript/,/}/d" /etc/logrotate.d/mysql-server
echo -e " pt-query-digest --user=anemometer --password=$ANEMOMETERPASS \\" >> /etc/logrotate.d/mysql-server
echo -e " --review D=slow_query_log,t=global_query_review \\" >> /etc/logrotate.d/mysql-server
echo -e " --review-history D=slow_query_log,t=global_query_review_history \\" >> /etc/logrotate.d/mysql-server
echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"\$HOSTNAME\\\"\" /var/log/mysql/slow.log >> /etc/logrotate.d/mysql-server
echo -e "\t\tendscript" >> /etc/logrotate.d/mysql-server
echo -e "}" >> /etc/logrotate.d/mysql-server
# Copy Anemometer Configuration File
cp /var/www/22222/htdocs/db/anemometer/conf/sample.config.inc.php /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \
|| OwnError "Unable To Copy Anemometer Configuration File"
# Update Anemoneter Configuration File
sed -i "s/root/anemometer/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php
sed -i "/password/ s/''/'$ANEMOMETERPASS'/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php
fi
# Call PHPUSERINFO Function For PHP User Details
PHPUSERINFO
@ -628,6 +582,52 @@ COMMONMYSQL()
# Decrease MySQL Wait Timeout
sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60" /etc/mysql/my.cnf
# Anemometer Setup
if [ ! -d /var/www/22222/htdocs/db/anemometer ]
then
mkdir -p /var/www/22222/htdocs/db/anemometer/ || OwnError "Unable To Create Anemometer Directory"
# Download Anemometer
git clone https://github.com/box/Anemometer.git /var/www/22222/htdocs/db/anemometer &>> $INSTALLLOG \
|| OwnError "Unable To Clone Anemometer"
# Setup Anemometer
# Collect MySQL Login Details
MYSQLROOT
# Setup Anemometer Database
mysql -u $MYSQLUSER -p$MYSQLPASS < /var/www/22222/htdocs/db/anemometer/install.sql \
|| OwnError "Unable To Import Anemometer Database"
# Setup Anemometer Database Grants
ANEMOMETERPASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1)
mysql -u $MYSQLUSER -p$MYSQLPASS -e "grant all on slow_query_log.* to 'anemometer'@'localhost' IDENTIFIED BY '$ANEMOMETERPASS';"
# Execute On MySQL Logrotation
sed -i "/endscript/,/}/d" /etc/logrotate.d/mysql-server
echo -e " pt-query-digest --user=anemometer --password=$ANEMOMETERPASS \\" >> /etc/logrotate.d/mysql-server
echo -e " --review D=slow_query_log,t=global_query_review \\" >> /etc/logrotate.d/mysql-server
echo -e " --review-history D=slow_query_log,t=global_query_review_history \\" >> /etc/logrotate.d/mysql-server
echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"\$HOSTNAME\\\"\" /var/log/mysql/slow.log >> /etc/logrotate.d/mysql-server
echo -e "\t\tendscript" >> /etc/logrotate.d/mysql-server
echo -e "}" >> /etc/logrotate.d/mysql-server
# Copy Anemometer Configuration File
cp /var/www/22222/htdocs/db/anemometer/conf/sample.config.inc.php /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \
|| OwnError "Unable To Copy Anemometer Configuration File"
# Update Anemoneter Configuration File
sed -i "s/root/anemometer/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php
sed -i "/password/ s/''/'$ANEMOMETERPASS'/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php
fi
# Call PHPUSERINFO Function For PHP User Details
PHPUSERINFO
# Change Ownership
chown -R $PHPUSER:$PHPUSER /var/www/22222/htdocs/db/anemometer/ || OwnError "Unable To Change Ownership For Anemometer"
}
POSTFIXINSTALLTWEAKS()

52
usr/local/sbin/eeupdate

@ -252,8 +252,20 @@ PHP_PACKAGES()
touch /var/www/22222/htdocs/fpm/status/{php,debug}
fi
# Call PHPUSERINFO Function For PHP User Details
PHPUSERINFO
# Change Ownership
chown -R $PHPUSER:$PHPUSER /var/www/22222 || OwnError "Unable To Change Ownership For /var/www/22222"
}
ANEMOMETER_INSTALL()
{
if [ -d /etc/mysql/ ]
then
# Anemometer Setup
if [ ! -d /var/www/22222/htdocs/db/anemometer/ ]
if [ ! -d /var/www/22222/htdocs/db/anemometer ]
then
mkdir -p /var/www/22222/htdocs/db/anemometer/ || OwnError "Unable To Create Anemometer Directory"
@ -273,12 +285,6 @@ PHP_PACKAGES()
ANEMOMETERPASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1)
mysql -u $MYSQLUSER -p$MYSQLPASS -e "grant all on slow_query_log.* to 'anemometer'@'localhost' IDENTIFIED BY '$ANEMOMETERPASS';"
# Put Data In Anemometer Database
pt-query-digest --user=anemometer --password=$ANEMOMETERPASS \
--review D=slow_query_log,t=global_query_review \
--review-history D=slow_query_log,t=global_query_review_history \
--no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /var/log/mysql/slow.log &>> $INSTALLLOG
# Execute On MySQL Logrotation
sed -i "/endscript/,/}/d" /etc/logrotate.d/mysql-server
echo -e " pt-query-digest --user=anemometer --password=$ANEMOMETERPASS \\" >> /etc/logrotate.d/mysql-server
@ -296,13 +302,12 @@ PHP_PACKAGES()
sed -i "s/root/anemometer/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php
sed -i "/password/ s/''/'$ANEMOMETERPASS'/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php
fi
# Call PHPUSERINFO Function For PHP User Details
PHPUSERINFO
# Change Ownership
chown -R $PHPUSER:$PHPUSER /var/www/22222 || OwnError "Unable To Change Ownership For /var/www/22222"
chown -R $PHPUSER:$PHPUSER /var/www/22222/htdocs/db/anemometer/ || OwnError "Unable To Change Ownership For Anemometer"
fi
}
INSTALLPMA()
@ -346,13 +351,9 @@ INSTALLPMA()
echo -e "\033[34mAlready Installed phpMyAdmin (/var/www/22222/htdocs/db/pma)...\e[0m"
fi
}
EE122()
{
# Install Packages
echo -e "\033[34mInstalling php5-xdebug percona-toolkit graphviz, Please Wait...\e[0m"
apt-get -y install php5-xdebug percona-toolkit graphviz
# EasyEngine Config File
sed -i "/# WordPress Defaults/i # Comma Separated Whitelist/Debugging IP Address\nip_address = \n" /etc/easyengine/ee.conf
@ -404,6 +405,14 @@ EE122()
openssl x509 -req -days 3652 -in /var/www/22222/cert/22222.csr -signkey /var/www/22222/cert/22222.key -out /var/www/22222/cert/22222.crt &>> $INSTALLLOG \
|| OwnError "Unable To Generate SSL Certificate"
# PHP Setup
dpkg -l | grep php5-fpm &>> $INSTALLLOG
if [ $? -eq 0 ]
then
# Install Packages
echo -e "\033[34mInstalling php5-xdebug percona-toolkit graphviz, Please Wait...\e[0m"
apt-get -y install php5-xdebug percona-toolkit graphviz
# Personal Settings For PHP
echo -e "\033[34mUpdating PHP Configuration Files, Please Wait...\e[0m"
@ -429,8 +438,19 @@ EE122()
echo -e "php_admin_value[xdebug.profiler_output_dir] = /tmp/ \nphp_admin_value[xdebug.profiler_output_name] = cachegrind.out.%p-%H-%R \nphp_admin_flag[xdebug.profiler_enable_trigger] = on \nphp_admin_flag[xdebug.profiler_enable] = off" | tee -ai /etc/php5/fpm/pool.d/debug.conf &>> $INSTALLLOG \
|| OwnError "Unable To Add Xdebug Settings"
else
# Install Packages
echo -e "\033[34mInstalling percona-toolkit graphviz, Please Wait...\e[0m"
apt-get -y install percona-toolkit graphviz
fi
# Install PHP Packages
PHP_PACKAGES
# Install Anemometer
ANEMOMETER_INSTALL
# Install phpMyAdmin
INSTALLPMA
}
@ -547,7 +567,7 @@ then
echo -e "\033[37msource /etc/bash_completion.d/ee\e[0m" | tee -ai $INSTALLLOG
echo
echo -e "\033[34mEasyEngine (ee) Updated Successfully\e[0m" | tee -ai $INSTALLLOG
echo -e "\033[34mPlease Ignore If You See Anything After This Line.\e[0m" | tee -ai $INSTALLLOG
echo -e "\033[34mPlease Ignore If You See Anything After This Line.\e[0m" | tee -ai $INSTALLLOGfwww
echo -e "\033[34mKilling The Parent Process\e[0m" &>> $INSTALLLOG
ps ax | grep $PPID | grep -v grep &>> $INSTALLLOG

Loading…
Cancel
Save