From 171dcf96c2fc4dad0ab755661115cf0b96a78d60 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 31 Aug 2017 12:43:28 +0000 Subject: [PATCH 1/4] added function to check all dependencies --- Linux Script/configure-linux.sh | 35 ++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/Linux Script/configure-linux.sh b/Linux Script/configure-linux.sh index 588a999..543fcf4 100644 --- a/Linux Script/configure-linux.sh +++ b/Linux Script/configure-linux.sh @@ -106,16 +106,16 @@ checkLinuxLogglyCompatibility() #check if the OS is supported by the script. If no, then exit checkIfSupportedOS + + #check if required dependencies to run the script are not installed. If yes, ask user to install them manually and run the script again. + checkIfRequiredDependenciesAreNotInstalled - #check if package-manager is installed - checkIfPackageManagerIsInstalled + #check if package-manager is present on the machine + checkIfPackageManagerIsPresent #set the basic variables needed by this script setLinuxVariables - #check if curl is not installed. If yes, ask user to install it manually and run the script again. - checkIfCurlIsNotInstalled - #check if the Loggly servers are accessible. If no, ask user to check network connectivity & exit checkIfLogglyServersAccessible @@ -217,8 +217,8 @@ checkIfUserHasRootPrivileges() fi } -#check if package-manager is installed -checkIfPackageManagerIsInstalled() +#check if package-manager is present on the machine +checkIfPackageManagerIsPresent() { if [ -x "$(command -v apt-get)" ]; then PKG_MGR="apt-get" @@ -229,6 +229,18 @@ checkIfPackageManagerIsInstalled() fi } +#check if required dependencies to run the script are not installed, If yes then ask user to install them manually and run the script again +checkIfRequiredDependenciesAreNotInstalled() +{ + if ! [ -x "$(command -v curl)" ]; then + logMsgToConfigSysLog "ERROR" "ERROR: 'Curl' executable could not be found on your machine, since it is a dependent package to run this script, please install it manually and then run the script again."; + exit 1 + elif ! [ -x "$(command -v ping)" ]; then + logMsgToConfigSysLog "ERROR" "ERROR: 'Ping' executable could not be found on your machine, since it is a dependent package to run this script, please install it manually and then run the script again."; + exit 1 + fi +} + #check if supported operating system checkIfSupportedOS() { @@ -310,15 +322,6 @@ setLinuxVariables() LOGGLY_ACCOUNT_URL=https://$LOGGLY_ACCOUNT.loggly.com } -#check if curl is not installed -checkIfCurlIsNotInstalled() -{ - if ! [ -x "$(command -v curl)" ]; then - logMsgToConfigSysLog "ERROR" "ERROR: 'Curl' is not installed on your machine, please install it manually and then run the script again."; - exit 1 - fi -} - #checks if all the various endpoints used for configuring loggly are accessible checkIfLogglyServersAccessible() { From 80d1d051afc47b548721db30b4e50483ad4bbfd3 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Fri, 1 Sep 2017 09:12:40 +0000 Subject: [PATCH 2/4] Refactor --- Linux Script/configure-linux.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Linux Script/configure-linux.sh b/Linux Script/configure-linux.sh index 543fcf4..d6d5b8a 100644 --- a/Linux Script/configure-linux.sh +++ b/Linux Script/configure-linux.sh @@ -935,7 +935,7 @@ checkIfTLS() if [ "$SUPPRESS_PROMPT" == "false" ]; then while true; do - read -p "Hey you are going to setup system logs in insecure mode. Do you want to overwrite this with secure mode? (yes/no)" yn + read -p "Hey, you are going to setup the system logs in insecure mode. Do you want to overwrite this with secure mode? (yes/no)" yn case $yn in [Yy]* ) logMsgToConfigSysLog "INFO" "INFO: Going to overwrite the conf file: $LOGGLY_RSYSLOG_CONFFILE with secure configuration"; @@ -948,7 +948,7 @@ checkIfTLS() esac done else - logMsgToConfigSysLog "WARN" "WARN: Your system logs are being send insecurely. We prefer to send system logs securely so switching to secure configuration." + logMsgToConfigSysLog "WARN" "WARN: Your system logs are being sent insecurely. We prefer to send the system logs securely so switching to the secure configuration." LOGGLY_TLS_SENDING="true" LOGGLY_SYSLOG_PORT=6514 From 6239784139983d5a2dab8e2f9d232b7da44d8678 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 7 Sep 2017 06:15:57 +0000 Subject: [PATCH 3/4] remove unnecessary prompt --- Linux Script/configure-linux.sh | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/Linux Script/configure-linux.sh b/Linux Script/configure-linux.sh index d6d5b8a..6923b0f 100644 --- a/Linux Script/configure-linux.sh +++ b/Linux Script/configure-linux.sh @@ -636,7 +636,8 @@ if [ "$FORCE_SECURE" == "false" ]; then if [ "$DEPENDENCIES_INSTALLED" == "false" ]; then if [ "$SUPPRESS_PROMPT" == "false" ]; then logMsgToConfigSysLog "WARN" "WARN: The rsyslog-gnutls package could not download automatically either because of your package manager could not be found or due to some other reason." - while true; do + while true; + do read -p "Do you wish to continue with insecure mode? (yes/no)" yn case $yn in [Yy]* ) @@ -662,7 +663,6 @@ fi #write the contents to 22-loggly.conf file writeContents() { -checkIfTLS confString installTLSDependencies switchToInsecureModeIfTLSNotFound @@ -927,35 +927,6 @@ getPassword() echo } -#Change TLS settings -checkIfTLS() -{ - if [[ $LOGGLY_SYSLOG_PORT == 514 ]]; then - - if [ "$SUPPRESS_PROMPT" == "false" ]; then - while true; - do - read -p "Hey, you are going to setup the system logs in insecure mode. Do you want to overwrite this with secure mode? (yes/no)" yn - case $yn in - [Yy]* ) - logMsgToConfigSysLog "INFO" "INFO: Going to overwrite the conf file: $LOGGLY_RSYSLOG_CONFFILE with secure configuration"; - LOGGLY_TLS_SENDING="true" - LOGGLY_SYSLOG_PORT=6514 - break;; - [Nn]* ) - break;; - * ) echo "Please answer yes or no.";; - esac - done - else - logMsgToConfigSysLog "WARN" "WARN: Your system logs are being sent insecurely. We prefer to send the system logs securely so switching to the secure configuration." - LOGGLY_TLS_SENDING="true" - LOGGLY_SYSLOG_PORT=6514 - - fi - fi -} - #display usage syntax usage() { From 0ec45e08f349c0eebc1c7a48528d17ed2650df45 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 7 Sep 2017 09:23:52 +0000 Subject: [PATCH 4/4] correct the min rsyslog version error message --- Linux Script/configure-linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Linux Script/configure-linux.sh b/Linux Script/configure-linux.sh index 6923b0f..a4a41fd 100644 --- a/Linux Script/configure-linux.sh +++ b/Linux Script/configure-linux.sh @@ -464,7 +464,7 @@ checkIfMinVersionOfRsyslog() RSYSLOG_VERSION=${RSYSLOG_VERSION%,*} RSYSLOG_VERSION=$RSYSLOG_VERSION | tr -d " " if [ $(compareVersions $RSYSLOG_VERSION $MIN_RSYSLOG_VERSION 3) -lt 0 ]; then - logMsgToConfigSysLog "ERROR" "ERROR: Min rsyslog version required is 5.8.0." + logMsgToConfigSysLog "ERROR" "ERROR: Minimum rsyslog version required to run this script is 5.8.0. Please upgrade your rsyslog version or follow the manual instructions." exit 1 fi }