#!/bin/bash echo "this script requires git" yum install -y git echo "This script will download all Cacti dependecies and download the chosen cacti version from the cacti github" echo "Dont forget to support cacti @ cacti.net!" echo "set selinux to disabled" setenforce 0 sed -i ‘s/enforcing/disabled/g‘ /etc/selinux/config /etc/selinux/config #Download chosen release echo "here are some of the current cacti release versions \n release/1.2.3 release/1.2.2 release/1.2.1 release/1.2.0 " echo "which release would you like to download ? Hit enter for latest" read version if [ "$version" == "" ] then git clone https://github.com/Cacti/cacti.git else yum install -y wget unzip wget https://github.com/Cacti/cacti/archive/release/$version.zip unzip $version mv cacti-release-$version cacti fi echo "will you be using the spine poller enter 1 for yes 2 for no" read answer if [ $answer == "1" ] then ##Download packages needed for spine yum install -y gcc MysqL-devel net-snmp-devel autoconf automake libtool dos2unix help2man echo "downloading and compling spine" git clone https://github.com/Cacti/spine.git cd spine ./bootstrap ./configure make make install chown root:root /usr/local/spine/bin/spine chmod u+s /usr/local/spine/bin/spine cd .. else echo "spine dependecies will not be installed" fi echo "On Centos systems we need to enable EPEL repos" yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y yum install yum-utils -y yum-config-manager --enable remi-PHP72 echo "Downloading PHP modules needed for Cacti install" yum install -y rrdtool mariadb-server net-snmp-utils net-snmp snmpd PHP PHP-MysqL PHP-snmp PHP-xml PHP-mbstring PHP-json PHP-gd PHP-gmp PHP-zip PHP-ldap PHP-mc PHP-posix ###Start services systemctl enable httpd systemctl enable mariadb systemctl start mariadb systemctl start httpd ####Open Port 80 and 443 on firewalld echo "Open http and https ports on firewalld" firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-port=443/tcp --permanent firewall-cmd --reload ##Timezone settings needed for cacti echo "Enter your PHP time zone i.e America/Toronto Default is US/Central " read timezone if [ $timezone == "" ] then echo "date.timezone =" US/Central >> /etc/PHP.ini else echo "date.timezone =" $timezone >> /etc/PHP.ini fi echo "Where would you like to install cacti default location is /var/www/html hit enter for default location" read location if [$location = ""] then location="/var/www/html" mv cacti /var/www/html else mv cacti $location fi #Create cacti user and change permission of directory echo "Which user would you like to run Cacti under (Default is www-data) hit enter for default" read user if [$user = ""] then user="apache" echo "cacti will be run under apache" chown -R apache:apache $location/cacti else useradd $user chown -R $user:$user $location/cacti fi #assign permissions for cacti installation chown -R apache:apache $location/cacti/resource/snmp_queries/ chown -R apache:apache $location/cacti/resource/script_server/ chown -R apache:apache $location/cacti/resource/script_queries/ chown -R apache:apache $location/cacti/scripts/ chown -R apache:apache $location/cacti/cache/boost/ chown -R apache:apache $location/cacti/cache/mibcache/ chown -R apache:apache $location/cacti/cache/realtime/ chown -R apache:apache $location/cacti/cache/spikekill/ touch $location/cacti/log/cacti.log chmod 777 $location/cacti/log/cacti.log chown -R apache:apache $location/cacti/log/ cp $location/cacti/include/config.PHP.dist $location/cacti/include/config.PHP ##Create database echo "would you like to customize the database name and user ? hit enter for defaults" read customize if [[ $customize = "" ]] then MysqL -uroot <<MysqL_SCRIPT CREATE DATABASE cacti DEFAULT CHaraCTER SET utf8 COLLATE utf8_unicode_ci ; GRANT ALL PRIVILEGES ON cacti.* TO ‘cacti‘@‘localhost‘ IDENTIFIED BY ‘cacti‘; ; GRANT SELECT ON MysqL.time_zone_name TO [email protected]; USE MysqL; ALTER DATABASE cacti CHaraCTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; FLUSH PRIVILEGES; MysqL_SCRIPT #pre populate cacti db MysqL -u root cacti < $location/cacti/cacti.sql MysqL_tzinfo_to_sql /usr/share/zoneinfo | MysqL -u root MysqL sed -i -e ‘[email protected]^$database_type.*@$database_type = "MysqL";@g‘ /var/www/html/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_default.*@$database_default = "cacti";@g‘ /var/www/html/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_hostname.*@$database_hostname = "127.0.0.1";@g‘ /var/www/html/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_username.*@$database_username = "cacti";@g‘ /var/www/html/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_password.*@$database_password = "cacti";@g‘ /var/www/html/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_port.*@$database_port = "3306";@g‘ /var/www/html/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_ssl.*@$database_ssl = "false";@g‘ /var/www/html/cacti/include/config.PHP sed -i -e ‘[email protected]^//[email protected][email protected]‘ /var/www/html/cacti/include/config.PHP echo "default database setup with following details" echo "database name cacti\n database username cacti\n database password cacti" else echo "enter db name" read customdbname echo "enter db user" read customdbuser echo "enter db password" read customdbpassword MysqL -u root <<MysqL_SCRIPT CREATE DATABASE $customdbname; GRANT ALL PRIVILEGES ON $customdbname.* TO ‘$customdbuser‘@‘localhost‘ IDENTIFIED BY ‘$customdbpassword‘; GRANT SELECT ON MysqL.time_zone_name TO [email protected]; ALTER DATABASE $customdbname CHaraCTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; FLUSH PRIVILEGES; MysqL_SCRIPT echo "Pre-populating cacti DB" MysqL -u root $customdbname < $location/cacti/cacti.sql MysqL_tzinfo_to_sql /usr/share/zoneinfo | MysqL -u root MysqL sed -i -e ‘[email protected]^$database_type.*@$database_type = "MysqL";@g‘ $location/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_default.*@$database_default = ‘$customdbname‘\;@g‘ $location/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_hostname.*@$database_hostname = "127.0.0.1";@g‘ $location/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_username.*@$database_username = ‘$customdbuser‘;@g‘ $location/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_password.*@$database_password = ‘$customdbpassword‘;@g‘ $location/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_port.*@$database_port = "3306";@g‘ "$location"/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_ssl.*@$database_ssl = "false";@g‘ "$location"/cacti/include/config.PHP sed -i -e ‘[email protected]^//[email protected][email protected]‘ $location/cacti/include/config.PHP fi ###Adding recomended PHP settings sed -e ‘s/max_execution_time = 30/max_execution_time = 60/‘ -i /etc/PHP.ini sed -e ‘s/memory_limit = 128M/memory_limit = 400M/‘ -i /etc/PHP.ini echo "Applying recommended DB settings" echo " innodb_file_format = Barracuda character_set_client = utf8mb4 max_allowed_packet = 16777777 join_buffer_size = 32M innodb_file_per_table = ON innodb_large_prefix = 1 innodb_buffer_pool_size = 250M innodb_additional_mem_pool_size = 90M innodb_flush_log_at_trx_commit = 2 " >> /etc/my.cnf.d/server.cnf echo "this script can download the following plugins monitor,thold would you like to install them ? type yes to download hit enter to skip" read plugins if [ $plugins == "yes" ] then git clone https://github.com/Cacti/plugin_thold.git git clone https://github.com/Cacti/plugin_monitor.git mv plugin_thold thold mv plugin_monitor monitor chown -R $user:$user thold chown -R $user:$user monitor mv thold $location/cacti/plugins mv monitor $location/cacti/plugins else echo "plugins will not be installed" fi touch /etc/cron.d/$user echo "*/5 * * * * $user PHP $location/cacti/poller.PHP > /dev/null 2>&1" > /etc/cron.d/$user echo "refreshing services" systemctl restart httpd systemctl restart mariadb echo "Installation completed !"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。