From 57fbef7743da281d636bc7794cc9f25430a69a73 Mon Sep 17 00:00:00 2001 From: rafael Date: Tue, 9 May 2023 13:01:38 +0200 Subject: [PATCH] adding error controls for kernel optimizations to online scripts --- .../deploy-scripts/pandora_deploy_community.sh | 11 ++++++++++- .../pandora_deploy_community_el8.sh | 16 +++++++++++++++- .../pandora_deploy_community_ubuntu_2204.sh | 11 ++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh index 1a77182e24..46caf676e8 100644 --- a/extras/deploy-scripts/pandora_deploy_community.sh +++ b/extras/deploy-scripts/pandora_deploy_community.sh @@ -630,7 +630,16 @@ net.core.optmem_max = 81920 EO_KO -[ -d /dev/lxd/ ] || execute_cmd "sysctl --system" "Applying Kernel optimization" + echo -en "${cyan}Applying Kernel optimization... ${reset}" + sysctl --system &>> $LOGFILE + if [ $? -ne 0 ]; then + echo -e "${red}Fail${reset}" + echo -e "${yellow}Your kernel could not be optimized, you may be running this script in a virtualized environment with no support for accessing the kernel.${reset}" + echo -e "${yellow}This system can be used for testing but is not recommended for a production environment.${reset}" + echo "$old_sysctl_file" > old_sysctl_file + else + echo -e "${green}OK${reset}" + fi fi # Fix pandora_server.{log,error} permissions to allow Console check them diff --git a/extras/deploy-scripts/pandora_deploy_community_el8.sh b/extras/deploy-scripts/pandora_deploy_community_el8.sh index c2ac1662df..cd90cdbb84 100644 --- a/extras/deploy-scripts/pandora_deploy_community_el8.sh +++ b/extras/deploy-scripts/pandora_deploy_community_el8.sh @@ -46,6 +46,7 @@ fi red="\e[0;91m" green="\e[0;92m" cyan="\e[0;36m" +yellow="\e[33m" reset="\e[0m" # Functions @@ -667,6 +668,9 @@ EOF_ENV # Kernel optimization if [ "$SKIP_KERNEL_OPTIMIZATIONS" -eq '0' ] ; then + +old_sysctl_file=$(cat /etc/sysctl.conf) + cat >> /etc/sysctl.conf <> $LOGFILE + if [ $? -ne 0 ]; then + echo -e "${red}Fail${reset}" + echo -e "${yellow}Your kernel could not be optimized, you may be running this script in a virtualized environment with no support for accessing the kernel.${reset}" + echo -e "${yellow}This system can be used for testing but is not recommended for a production environment.${reset}" + echo "$old_sysctl_file" > old_sysctl_file + else + echo -e "${green}OK${reset}" + fi + fi # Fix pandora_server.{log,error} permissions to allow Console check them diff --git a/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh b/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh index d342d51da0..3d31ae10af 100644 --- a/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh +++ b/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh @@ -693,7 +693,16 @@ net.core.optmem_max = 81920 EO_KO -[ -d /dev/lxd/ ] || execute_cmd "sysctl --system" "Applying Kernel optimization" + echo -en "${cyan}Applying Kernel optimization... ${reset}" + sysctl --system &>> $LOGFILE + if [ $? -ne 0 ]; then + echo -e "${red}Fail${reset}" + echo -e "${yellow}Your kernel could not be optimized, you may be running this script in a virtualized environment with no support for accessing the kernel.${reset}" + echo -e "${yellow}This system can be used for testing but is not recommended for a production environment.${reset}" + echo "$old_sysctl_file" > old_sysctl_file + else + echo -e "${green}OK${reset}" + fi fi # Fix pandora_server.{log,error} permissions to allow Console check them