Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tested script with RPM-based and Debian-based Distributions #94

Merged
merged 7 commits into from Jun 1, 2017
Prev

Restored checkIfSupportedOS function and checking package manager ava…

…ilablity
  • Loading branch information
root
root committed Jun 1, 2017
commit d38956036281841675f6d0e2a3bb25c162725343
@@ -101,8 +101,11 @@ checkLinuxLogglyCompatibility()
#check if the user has root permission to run this script
checkIfUserHasRootPrivileges

#check if the OS is supported by the script. If no, then exit
checkIfSupportedOS

#check if package-manager is installed
checkIfPackageManagerIsInstalled
checkIfPackageManagerIsInstalled

#set the basic variables needed by this script
setLinuxVariables
@@ -178,6 +181,9 @@ removeLogglyConf()

#check if the user has root permission to run this script
checkIfUserHasRootPrivileges

#check if the OS is supported by the script. If no, then exit
checkIfSupportedOS

#set the basic variables needed by this script
setLinuxVariables
@@ -208,19 +214,66 @@ checkIfUserHasRootPrivileges()
#check if package-manager is installed
checkIfPackageManagerIsInstalled()
{
if [ -x "$(command -v apt-get)" ]; then
if [ -x "$(command -v apt-get)" ]; then

PKG_MGR="apt-get"

else
if [ -x "$(command -v yum)" ]; then

PKG_MGR="yum"
fi

fi
fi
}

#check if supported operating system
checkIfSupportedOS()
{
getOs

LINUX_DIST_IN_LOWER_CASE=$(echo $LINUX_DIST | tr "[:upper:]" "[:lower:]")

case "$LINUX_DIST_IN_LOWER_CASE" in
*"ubuntu"* )
echo "INFO: Operating system is Ubuntu."
;;
*"redhat"* )
echo "INFO: Operating system is Red Hat."
;;
*"centos"* )
echo "INFO: Operating system is CentOS."
;;
*"debian"* )
echo "INFO: Operating system is Debian."
;;
*"amazon"* )
echo "INFO: Operating system is Amazon AMI."
;;
*"darwin"* )
#if the OS is mac then exit
logMsgToConfigSysLog "ERROR" "ERROR: This script is for Linux systems, and Darwin or Mac OSX are not currently supported. You can find alternative options here: https://www.loggly.com/docs/send-mac-logs-to-loggly/"
exit 1
;;
* )
logMsgToConfigSysLog "WARN" "WARN: The linux distribution '$LINUX_DIST' has not been previously tested with Loggly."
if [ "$SUPPRESS_PROMPT" == "false" ]; then
while true; do
read -p "Would you like to continue anyway? (yes/no)" yn
case $yn in
[Yy]* )
break;;
[Nn]* )
exit 1
;;
* ) echo "Please answer yes or no.";;
esac
done
fi
;;
esac
}

getOs()
{
# Determine OS platform
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.