Skip to content

Instantly share code, notes, and snippets.

@enoch85
Created February 14, 2020 07:36
Show Gist options
  • Save enoch85/f3dbaf5c85fb4acbf353e3d11be43804 to your computer and use it in GitHub Desktop.
Save enoch85/f3dbaf5c85fb4acbf353e3d11be43804 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Root is needed
if [ "$EUID" -ne 0 ]
then
echo "This script must be run with root or sudo privileges! Please try again. :)"
exit
fi
# Check if Ubuntu
if lsb_release -i | grep -ic "Ubuntu" &> /dev/null
then
OS=1
fi
if [ "$OS" != 1 ]
then
echo "This doesn't seem to be an Ubuntu installation, exiting"
exit 1
fi
# Check exact version number
DISTRO_FULL=$(lsb_release -sd | cut -d ' ' -f 2)
if [ -z "$DISTRO_FULL" ]
then
echo "Couldn't get Ubuntu version, exiting..."
exit
fi
# Is Solarwinds already installed?
if [ -d /usr/local/rmmagent ]
then
echo "It seems like /usr/local/rmmagent already exists, is it already installed?"
exit 1
fi
##################################
# Add repo depending on version
if [ -f /etc/apt/sources.list ]
then
if ! grep -q repos.systemmonitor.eu /etc/apt/sources.list
then
if [ "${DISTRO_FULL%.*}" = "18.04" ] # Ubuntu 18.04
then
echo "deb http://repos.systemmonitor.eu.com/rmmagent/xUbuntu_17.04/ ./" >> /etc/apt/sources.list
elif [ "${DISTRO_FULL%.*}" = "16.04" ] # Ubuntu 16.04
then
echo "deb http://repos.systemmonitor.eu.com/rmmagent/xUbuntu_16.04/ ./" >> /etc/apt/sources.list
elif [ "${DISTRO_FULL%.*}" = "14.04" ] # Ubuntu 14.04
then
echo "deb http://repos.systemmonitor.eu.com/rmmagent/xUbuntu_14.04/ ./" >> /etc/apt/sources.list
elif [ "${DISTRO_FULL%.*}" = "12.04" ] # Ubuntu 12.04
then
echo "deb http://repos.systemmonitor.eu.com/rmmagent/xUbuntu_12.04/ ./" >> /etc/apt/sources.list
fi
fi
else
exit && echo "/etc/apt/sources.list doesn't exist"
fi
# Install Solarwindws
if grep -q repos.systemmonitor.eu /etc/apt/sources.list
then
apt-get update --allow-insecure-repositories || apt-get update --allow-unauthenticated
apt-get install rmmagent -y --allow-unauthenticated
fi
# Run the config
cd /usr/local/rmmagent || exit
./rmmagentd -i && wait
update-rc.d rmmagent defaults
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment