Created
May 12, 2015 06:27
-
-
Save simplyadrian/aaa93773559f368b8593 to your computer and use it in GitHub Desktop.
a bash script to install the new relic client.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# | |
# Test for a reboot, if this is a reboot just skip this script. | |
# | |
if test "$RS_REBOOT" = "true" ; then | |
logger -t RightScale "New Relic PHP Agent install, skipped on a reboot."; | |
exit 0; | |
fi | |
# Check if agent is already installed | |
type newrelic-daemon >/dev/null 2>&1 && { | |
logger -t RightScale "New Relic agent already installed. Aborting."; | |
exit 0; | |
} | |
if [ "$RS_DISTRO" = "ubuntu" ]; then | |
wget -O - http://download.newrelic.com/548C16BF.gpg | apt-key add - | |
if [ ! -f /etc/apt/sources.list.d/newrelic.list ]; then | |
echo deb http://apt.newrelic.com/debian/ newrelic non-free > /etc/apt/sources.list.d/newrelic.list | |
apt-get update | |
fi | |
apt-get install -y newrelic-php5 | |
elif [ "$RS_DISTRO" = "centos" ]; then | |
os_version=`uname -m` | |
if [ "$os_version" = "x86_64" ]; then | |
rpm -Uvh http://yum.newrelic.com/pub/newrelic/el5/x86_64/newrelic-repo-5-3.noarch.rpm | |
else | |
rpm -Uvh http://yum.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm | |
fi | |
yum install -y newrelic-php5 | |
fi | |
# Install without user input | |
NR_INSTALL_SILENT=1 NR_INSTALL_KEY=$NR_LICENSE_KEY /usr/bin/newrelic-install install | |
# Insert and uncomment the application name if given | |
if [ -n "$NR_APP_NAME" ]; then | |
sed -e "s/\;newrelic\.appname\ \=\ \"PHP\ Application\"/newrelic\.appname\ \=\ \"$NR_APP_NAME\"/g" -i /etc/php.d/newrelic.ini | |
fi | |
# Reboot apache to take effect | |
if [ "$RS_DISTRO" = "ubuntu" ]; then | |
service apache2 restart | |
elif [ "$RS_DISTRO" = "centos" ]; then | |
service httpd restart | |
fi | |
logger -t RightScale "Installed New Relic PHP Module." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was helpful, thank you.