From 68bbea6cdcbfe3a5f3e25a55f4fec52049efa5ab Mon Sep 17 00:00:00 2001 From: Rafael Ameijeiras Date: Thu, 10 Feb 2022 18:03:49 +0100 Subject: [PATCH 1/3] adding beta package option to online installer --- .../pandora_deploy_community.sh | 39 +++++++++++++--- .../pandora_deploy_community_el8.sh | 44 ++++++++++++++++--- 2 files changed, 71 insertions(+), 12 deletions(-) diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh index 2e617eeeb1..0251b53baf 100644 --- a/extras/deploy-scripts/pandora_deploy_community.sh +++ b/extras/deploy-scripts/pandora_deploy_community.sh @@ -11,7 +11,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf -S_VERSION='2022012401' +S_VERSION='2022020801' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" # define default variables @@ -26,6 +26,7 @@ LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" [ "$SKIP_DATABASE_INSTALL" ] || SKIP_DATABASE_INSTALL=0 [ "$SKIP_KERNEL_OPTIMIZATIONS" ] || SKIP_KERNEL_OPTIMIZATIONS=0 [ "$POOL_SIZE" ] || POOL_SIZE=$(grep -i total /proc/meminfo | head -1 | awk '{printf "%.2f \n", $(NF-1)*0.4/1024}' | sed "s/\\..*$/M/g") +[ "$PANDORA_BETA" ] || PANDORA_BETA=0 # Ansi color code variables red="\e[0;91m" @@ -110,6 +111,10 @@ fi execute_cmd "grep -i centos /etc/redhat-release" "Checking Centos" 'Error This is not a Centos Base system' +#Detect OS +os_name=$(grep ^PRETTY_NAME= /etc/os-release | cut -d '=' -f2 | tr -d '"') +execute_cmd "echo $os_name" "OS detected: ${os_name}" + echo -en "${cyan}Check Centos Version...${reset}" [ $(sed -nr 's/VERSION_ID+=\s*"([0-9])"$/\1/p' /etc/os-release) -eq '7' ] check_cmd_status 'Error OS version, Centos 7 is expected' @@ -125,6 +130,9 @@ check_root_permissions # Pre installed pandora [ "$SKIP_PRECHECK" == 1 ] || check_pre_pandora +#advicing BETA PROGRAM +[ "$PANDORA_BETA" -ne '0' ] && echo -e "${red}BETA version enable using nightly PandoraFMS packages${reset}" + # Connectivity check_repo_connection @@ -317,6 +325,16 @@ setenforce 0 sed -i -e "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config systemctl disable firewalld --now &>> $LOGFILE +# Adding standar cnf for initial setup. +cat > /etc/my.cnf << EO_CONFIG_TMP +[mysqld] +datadir=/var/lib/mysql +socket=/var/lib/mysql/mysql.sock +symbolic-links=0 +log-error=/var/log/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid +EO_CONFIG_TMP + #Configuring Database if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then execute_cmd "systemctl start mysqld" "Starting database engine" @@ -382,10 +400,21 @@ EO_CONFIG_F execute_cmd "systemctl restart mysqld" "Configuring database engine" +#Define packages +if [ "$PANDORA_BETA" -eq '0' ] ; then + [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_server-7.0NG.noarch.rpm" + [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.noarch.rpm" + [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm" +elif [ "$PANDORA_BETA" -ne '0' ] ; then + [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.artica.es/pandora_enterprise_nightlies/pandorafms_server-latest_noarch.rpm" + [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="https://pandorafms.com/community/community-console-rpm-beta/" + [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm" +fi + # Downloading Pandora Packages -execute_cmd "wget http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_server-7.0NG.noarch.rpm" "Downloading Pandora FMS Server community" -execute_cmd "wget http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.noarch.rpm" "Downloading Pandora FMS Console community" -execute_cmd "wget http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm" "Downloading Pandora FMS Agent community" +execute_cmd "curl -LSs --output pandorafms_server-7.0NG.noarch.rpm ${PANDORA_SERVER_PACKAGE}" "Downloading Pandora FMS Server community" +execute_cmd "curl -LSs --output pandorafms_console-7.0NG.noarch.rpm ${PANDORA_CONSOLE_PACKAGE}" "Downloading Pandora FMS Console community" +execute_cmd "curl -LSs --output pandorafms_agent_unix-7.0NG.noarch.rpm ${PANDORA_AGENT_PACKAGE}" "Downloading Pandora FMS Agent community" # Install Pandora execute_cmd "yum install -y $HOME/pandora_deploy_tmp/pandorafms*.rpm" "installing PandoraFMS packages" @@ -633,4 +662,4 @@ execute_cmd "rm -rf $HOME/pandora_deploy_tmp" "Removing temporary files" GREEN='\033[01;32m' NONE='\033[0m' printf " -> Go to Public ${green}http://"$ipplublic"/pandora_console${reset} to manage this server" -ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v -e "172.1[0-9].0.1" | awk '{print $2}' | awk -v g=$GREEN -v n=$NONE -F '/' '{printf "\n -> Go to Local "g"http://"$1"/pandora_console"n" to manage this server \n -> Use this credentials to login in the console "g"[ User: admin / Password: pandora ]"n" \n"}' \ No newline at end of file +ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v -e "172.1[0-9].0.1" | awk '{print $2}' | awk -v g=$GREEN -v n=$NONE -F '/' '{printf "\n -> Go to Local "g"http://"$1"/pandora_console"n" to manage this server \n -> Use these credentials to log in Pandora Console "g"[ User: admin / Password: pandora ]"n" \n"}' \ No newline at end of file diff --git a/extras/deploy-scripts/pandora_deploy_community_el8.sh b/extras/deploy-scripts/pandora_deploy_community_el8.sh index 5b0bc37b1e..aca6311820 100644 --- a/extras/deploy-scripts/pandora_deploy_community_el8.sh +++ b/extras/deploy-scripts/pandora_deploy_community_el8.sh @@ -14,7 +14,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf -S_VERSION='2022012401' +S_VERSION='2022020801' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" # define default variables @@ -29,6 +29,7 @@ LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" [ "$SKIP_DATABASE_INSTALL" ] || SKIP_DATABASE_INSTALL=0 [ "$SKIP_KERNEL_OPTIMIZATIONS" ] || SKIP_KERNEL_OPTIMIZATIONS=0 [ "$POOL_SIZE" ] || POOL_SIZE=$(grep -i total /proc/meminfo | head -1 | awk '{printf "%.2f \n", $(NF-1)*0.4/1024}' | sed "s/\\..*$/M/g") +[ "$PANDORA_BETA" ] || PANDORA_BETA=0 # Ansi color code variables red="\e[0;91m" @@ -106,14 +107,18 @@ echo "Starting PandoraFMS Community deployment EL8 ver. $S_VERSION" # Centos Version if [ ! "$(grep -Ei 'centos|rocky|Almalinux|Red Hat Enterprise' /etc/redhat-release)" ]; then - printf "\n ${red}Error this is not a Centos/Rocky/Almalinux Base system, this installer is compatible with Centos/Rocky systems only${reset}\n" + printf "\n ${red}Error this is not a Centos/Rocky/Almalinux Base system, this installer is compatible with RHEL/Almalinux/Centos/Rockylinux systems only${reset}\n" exit 1 fi echo -en "${cyan}Check Centos Version...${reset}" [ $(sed -nr 's/VERSION_ID+=\s*"([0-9]).*"$/\1/p' /etc/os-release) -eq '8' ] -check_cmd_status 'Error OS version, Centos/Rocky 8+ is expected' +check_cmd_status 'Error OS version, RHEL/Almalinux/Centos/Rockylinux 8+ is expected' + +#Detect OS +os_name=$(grep ^PRETTY_NAME= /etc/os-release | cut -d '=' -f2 | tr -d '"') +execute_cmd "echo $os_name" "OS detected: ${os_name}" # initialice logfile execute_cmd "echo 'Starting community deployment' > $LOGFILE" "All installer activity is logged on $LOGFILE" @@ -126,6 +131,9 @@ check_root_permissions # Pre installed pandora [ "$SKIP_PRECHECK" == 1 ] || check_pre_pandora +#advicing BETA PROGRAM +[ "$PANDORA_BETA" -ne '0' ] && echo -e "${red}BETA version enable using nightly PandoraFMS packages${reset}" + # Connectivity check_repo_connection @@ -360,6 +368,16 @@ setenforce 0 &>> "$LOGFILE" sed -i -e "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config &>> "$LOGFILE" systemctl disable firewalld --now &>> "$LOGFILE" +# Adding standar cnf for initial setup. +cat > /etc/my.cnf << EO_CONFIG_TMP +[mysqld] +datadir=/var/lib/mysql +socket=/var/lib/mysql/mysql.sock +symbolic-links=0 +log-error=/var/log/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid +EO_CONFIG_TMP + #Configuring Database if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then execute_cmd "systemctl start mysqld" "Starting database engine" @@ -425,10 +443,22 @@ EO_CONFIG_F execute_cmd "systemctl restart mysqld" "Configuring database engine" + +#Define packages +if [ "$PANDORA_BETA" -eq '0' ] ; then + [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_server-7.0NG.noarch.rpm" + [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.noarch.rpm" + [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm" +elif [ "$PANDORA_BETA" -ne '0' ] ; then + [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.artica.es/pandora_enterprise_nightlies/pandorafms_server-latest_noarch.rpm" + [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="https://pandorafms.com/community/community-console-rpm-beta/" + [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm" +fi + # Downloading Pandora Packages -execute_cmd "wget http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_server-7.0NG.noarch.rpm" "Downloading Pandora FMS Server community" -execute_cmd "wget http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.noarch.rpm" "Downloading Pandora FMS Console community" -execute_cmd "wget http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm" "Downloading Pandora FMS Agent community" +execute_cmd "curl -LSs --output pandorafms_server-7.0NG.noarch.rpm ${PANDORA_SERVER_PACKAGE}" "Downloading Pandora FMS Server community" +execute_cmd "curl -LSs --output pandorafms_console-7.0NG.noarch.rpm ${PANDORA_CONSOLE_PACKAGE}" "Downloading Pandora FMS Console community" +execute_cmd "curl -LSs --output pandorafms_agent_unix-7.0NG.noarch.rpm ${PANDORA_AGENT_PACKAGE}" "Downloading Pandora FMS Agent community" # Install Pandora execute_cmd "dnf install -y $HOME/pandora_deploy_tmp/pandorafms*.rpm" "Installing Pandora FMS packages" @@ -680,4 +710,4 @@ execute_cmd "rm -rf $HOME/pandora_deploy_tmp" "Removing temporary files" GREEN='\033[01;32m' NONE='\033[0m' printf " -> Go to Public ${green}http://"$ipplublic"/pandora_console${reset} to manage this server" -ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v -e "172.1[0-9].0.1" | awk '{print $2}' | awk -v g=$GREEN -v n=$NONE -F '/' '{printf "\n -> Go to Local "g"http://"$1"/pandora_console"n" to manage this server \n -> Use this credentials to login in the console "g"[ User: admin / Password: pandora ]"n" \n"}' \ No newline at end of file +ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v -e "172.1[0-9].0.1" | awk '{print $2}' | awk -v g=$GREEN -v n=$NONE -F '/' '{printf "\n -> Go to Local "g"http://"$1"/pandora_console"n" to manage this server \n -> Use these credentials to log in Pandora Console "g"[ User: admin / Password: pandora ]"n" \n"}' \ No newline at end of file From fded851f4ff4d5f39b9d37fb3d595e81a199d1d2 Mon Sep 17 00:00:00 2001 From: rafael Date: Tue, 15 Feb 2022 12:50:25 +0100 Subject: [PATCH 2/3] adding rpm pandora_server beta url --- extras/deploy-scripts/pandora_deploy_community.sh | 2 +- extras/deploy-scripts/pandora_deploy_community_el8.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh index 0251b53baf..d3415bf019 100644 --- a/extras/deploy-scripts/pandora_deploy_community.sh +++ b/extras/deploy-scripts/pandora_deploy_community.sh @@ -406,7 +406,7 @@ if [ "$PANDORA_BETA" -eq '0' ] ; then [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.noarch.rpm" [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm" elif [ "$PANDORA_BETA" -ne '0' ] ; then - [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.artica.es/pandora_enterprise_nightlies/pandorafms_server-latest_noarch.rpm" + [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.artica.es/pandora_enterprise_nightlies/pandorafms_server-latest.x86_64.rpm" [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="https://pandorafms.com/community/community-console-rpm-beta/" [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm" fi diff --git a/extras/deploy-scripts/pandora_deploy_community_el8.sh b/extras/deploy-scripts/pandora_deploy_community_el8.sh index aca6311820..b69eaa7dc7 100644 --- a/extras/deploy-scripts/pandora_deploy_community_el8.sh +++ b/extras/deploy-scripts/pandora_deploy_community_el8.sh @@ -450,7 +450,7 @@ if [ "$PANDORA_BETA" -eq '0' ] ; then [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.noarch.rpm" [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm" elif [ "$PANDORA_BETA" -ne '0' ] ; then - [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.artica.es/pandora_enterprise_nightlies/pandorafms_server-latest_noarch.rpm" + [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.artica.es/pandora_enterprise_nightlies/pandorafms_server-latest.x86_64.rpm" [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="https://pandorafms.com/community/community-console-rpm-beta/" [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm" fi From f84c37cee2c37765430b32aa81d7602faa5b35e1 Mon Sep 17 00:00:00 2001 From: rafael Date: Wed, 16 Feb 2022 15:24:15 +0100 Subject: [PATCH 3/3] fixing timezonectl error on redhat --- extras/deploy-scripts/pandora_deploy_community_el8.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/extras/deploy-scripts/pandora_deploy_community_el8.sh b/extras/deploy-scripts/pandora_deploy_community_el8.sh index b69eaa7dc7..9fb91bac8a 100644 --- a/extras/deploy-scripts/pandora_deploy_community_el8.sh +++ b/extras/deploy-scripts/pandora_deploy_community_el8.sh @@ -147,6 +147,7 @@ execute_cmd "[ $(grep MemTotal /proc/meminfo | awk '{print $2}') -ge 1700000 ]" execute_cmd "[ $(df -BM / | tail -1 | awk '{print $4}' | tr -d M) -gt 10000 ]" 'Checking Disk (required: 10 GB free min)' # Setting timezone +rm -rf /etc/localtime &>> "$LOGFILE" execute_cmd "timedatectl set-timezone $TZ" "Setting Timezone $TZ" # Execute tools check