#!/bin/bash . /usr/src/m2/framework/settings.sh . /usr/src/m2/framework/bash_functions.sh VERSION="1.4.3" SCRIPT_NAME="M4 GERD Install" k_kolmisoft_logo # Loging to stdout/err and install.log too exec > >(tee -a /usr/src/m2/install.log) exec 2> >(tee -a /usr/src/m2/install.log >&2) k_supported_os_check; if [ "$?" != "0" ]; then k_exit 1; fi # /etc/machine-id fix for Hetzner systemd-firstboot --setup-machine-id if ! grep -F '127.0.0.1' /etc/hosts | grep -E '^localhost[[:space:]]?|[[:space:]]localhost$|[[:space:]]localhost[[:space:]]'; then report "localhost is not defined in /etc/hosts. This might cause issues later." 6 echo "Press any key to Continue or CRTL+C to Cancel Installation" read user_input fi kf="/usr/src/k_framework" src="/usr/src/m2" k_start echo `date` $kf/maintenance/system_preparation/set_server_timezone_to_utc.sh echo `date` $kf/maintenance/system_preparation/time_sync.sh echo `date` # after sync we will get better time # check for rvm presence to determine if server is empty or not if [ -f '/usr/local/rvm/bin/rvm' ]; then . /usr/src/m2/framework/bash_functions.sh report "System is not empty, aborting installation" 6 exit 0 fi if (( $# == 0 )); then while true; do read -r terminal_rows terminal_columns < <(stty size) if (( terminal_rows < 15 || terminal_columns < 120 )); then report "Please resize terminal window to at least 120x15" 0 else break fi done fi $src/maintenance/configuration_prepare.sh "$@" k_config_details no_mysql # environment check $src/maintenance/vm_detection.sh $src/maintenance/dns_check.sh # todo: we should terminate if dns does not work if [[ $ROCKY9 == 1 ]]; then $kf/maintenance/system_preparation/rocky9_actions.sh fi # environment preparation $kf/maintenance/system_preparation/selinux_disable.sh $kf/maintenance/system_preparation/yum_updatesd_disable.sh $kf/maintenance/system_preparation/deadline_scheduler_for_ssd_enable.sh k_cpu_frequency_check $kf/maintenance/security/ssl_heartbleed_fix.sh $kf/helpers/iptables/iptables_install.sh $src/maintenance/folders_permissions_prepare.sh $src/maintenance/aliases_install.sh $src/maintenance/packets_install.sh $kf/checks/connections_check.sh if [ "$?" != "0" ]; then report "Connection limited. Fix your firewall. Aborting." 1 exit 1 fi $kf/maintenance/system_preparation/tmpwatch_cron_disable.sh $kf/maintenance/system_preparation/svn_store_plaintext_passwords_disable.sh $kf/helpers/tuned_install.sh $kf/maintenance/network_tune.sh $kf/maintenance/journald_tune.sh # necessary for DB/GUI servers $kf/helpers/gui/rvm_install.sh $kf/helpers/gui/ruby_install.sh # for DB server if [[ $DB_PRESENT == "1" ]]; then if [[ $ROCKY9 == 1 ]]; then $kf/helpers/mysql/8/mysql_install.sh $kf/helpers/mysql/8/mysql_configure.sh else $kf/helpers/mysql/5.7/mysql_5.7_install.sh $kf/helpers/mysql/5.7/mysql8_repo_disable.sh fi $src/db/db_create.sh NEW svn update $src/db $src/db/db_update.sh LATEST $src/db/init_archived_calls.sh $src/db/disable_mysql_secure_file_priv.sh INSTALL $src/db/add_skip_name_resolve.sh INSTALL # activate M4 k_confline_set M4_Functionality 1 # calls/calls_old structure with partitions /usr/bin/mysql -h localhost -u m2 --password=m2 m2 < /usr/src/m2/db/calls_tables_with_partitions.sql # Create new partitions and install partitions cron # Create partitions from 45 days in the past start_date=$(date -I -d "$(date +'%Y-%m-%d') - 45 days") report "Generating initial partitions for calls table" 0 /usr/src/m2/mysql/partitions/partition_create.sh 55 "$start_date" calls EXECUTE report "Generating initial partitions for calls_old table" 0 /usr/src/m2/mysql/partitions/partition_create.sh 55 "$start_date" calls_old EXECUTE # Install cron which will create partitions in the future each night, keeping 10 partitions in the future buffer " /usr/src/m2/mysql/partitions/install_partitions_cron.sh fi # for GUI server " if [[ $GUI_PRESENT == "1" ]]; then # gui_nstall supports both Centos and Rocky $src/gui/gui_install.sh $kf/maintenance/system_preparation/client_tag_set.sh FAST $kf/helpers/gui/apache_install.sh $src/maintenance/xsendfile.sh $kf/helpers/gui/passenger_install.sh $kf/helpers/gui/ssl_install.sh $kf/helpers/memcached/memcached_install.sh $kf/helpers/phpmyadmin/phpmyadmin_install.sh fi $kf/helpers/redis/hiredis_install.sh # for RADIUS-CORE server if [[ $RADIUS_PRESENT == "1" ]]; then $src/freeradius/freeradius_install.sh fi # for GUI/CORE servers if [[ $GUI_PRESENT == "1" || $RADIUS_PRESENT == "1" ]]; then $src/scripts/scripts_install.sh #this script should be before $src/core/m2_core_radius_configure.sh INSTALL fi # for CORE server if [[ $RADIUS_PRESENT == "1" ]]; then $src/core/m2_core_radius_configure.sh INSTALL $src/maintenance/safe_services.sh fi # SIP Trunking modules $src/scripts/go/go_modules_install.sh # helper packages $src/helpers/fail2ban/fail2ban_install.sh $src/helpers/m2_connection_points_whitelist/install.sh $src/helpers/m2_gui_iptables/m2_gui_iptables_install.sh $src/helpers/m2_blocked_countries/m2_blocked_countries_install.sh $src/helpers/m2_block_scanners/install_m2_block_scanners.sh #m2 pcap tshark if [[ $PCAP_ENABLED == 1 ]]; then $src/helpers/m2_pcap_tshark/m2_pcap_tshark_install.sh fi # update tables using percona. Should be before ES to avoid 'Unknown column' error svn update $src/db/percona $src/db/percona/percona_calls_update_v2.sh calls force $src/db/percona/percona_calls_update_v2.sh calls_old force $src/db/percona/percona_calls_update_v2.sh rates force $src/db/percona/percona_calls_update_v3.sh calls NO_SCREEN FORCE SKIP_BACKUP SKIP_CORE_CHECK $src/db/percona/percona_calls_update_v3.sh calls_old NO_SCREEN FORCE SKIP_BACKUP SKIP_CORE_CHECK $src/db/percona/percona_calls_update_v4.sh calls NO_SCREEN FORCE SKIP_BACKUP SKIP_CORE_CHECK $src/db/percona/percona_calls_update_v4.sh calls_old NO_SCREEN FORCE SKIP_BACKUP SKIP_CORE_CHECK # install ES if [[ $ES_PRESENT == "1" || $ES_PRESENT == "-1" ]]; then svn update $src/elasticsearch/ $src/elasticsearch/elasticsearch_install.sh fi # create symlink to 'elasticsearch' command on all servers ln -fs /usr/src/m2/elasticsearch/m2_elasticsearch.sh /usr/bin/elasticsearch &> /dev/null # Update email2tariff scripts in GUI server if Automatic Tariff Import is activated if [[ $GUI_PRESENT == "1" ]]; then if [[ $(get_confline "show_tariff_import_menu") == 1 ]]; then $src/helpers/email2tariff/email2tariff_install.sh else rm -f /etc/cron.d/m2_tariff_import_actions fi fi #irqbalance service $src/maintenance/irqbalance_service.sh # logrotates $src/maintenance/logrotates_enable.sh $src/maintenance/permissions_post_install.sh $src/maintenance/iptables_service_update.sh $src/maintenance/fix_crons_and_services.sh $src/maintenance/reconfigure_ip.sh $src/maintenance/multiserver/gui_ssh_connections.sh $kf/helpers/zabbix/zabbix_mysql_setup.sh $kf/maintenance/security/log4j1.x_fix.sh $kf/maintenance/system_preparation/perl_ssl_fix.sh if [[ $GUI_PRESENT == "1" || $RADIUS_PRESENT == "1" ]]; then $kf/helpers/redis/redis_install.sh # activate Redis on GUI k_confline_set use_redis 1 k_confline_set Redis_IP 127.0.0.1 k_confline_set Redis_Port 6379 fi $kf/helpers/zabbix/zabbix_agent_install.sh # Free 10cc Core install $src/core/10cc/core_install_10cc.sh $src/maintenance/multiserver/radius_ssh_connections.sh # these should be the last ones to run to check everything $src/check.sh echo `date` k_exit $EXIT_CODE