Created
April 1, 2013 20:27
-
-
Save danmilleruk/5287483 to your computer and use it in GitHub Desktop.
Server Density installation script. Edit the two configurables and run to add new servers to your Server Density account.
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/sh | |
# Configurables | |
SD_URL="http://changeme.serverdensity.com" | |
AGENT_KEY="changeme" | |
# Core - DO NOT CHANGE | |
CONFIGFILE="/etc/sd-agent/config.cfg" | |
wget -q https://www.serverdensity.com/downloads/boxedice-public.key -O- | sudo apt-key add - | |
if [ "$?" -ne "0" ] ; then | |
echo "Failed to download server density key." | |
exit $rc | |
fi | |
echo "" >> /etc/apt/sources.list.d/sd-agent.list | |
echo "deb http://www.serverdensity.com/downloads/linux/deb all main" >> /etc/apt/sources.list.d/sd-agent.list | |
if [ "$?" -ne "0" ] ; then | |
echo "Failed to add repository" | |
exit $rc | |
fi | |
sudo apt-get -qq update | |
if [ "$?" -ne "0" ] ; then | |
echo "Failed to run 'apt-get update', you may need to run this manually" | |
exit $rc | |
fi | |
sudo apt-get -qq install sd-agent | |
if [ "$?" -ne "0" ] ; then | |
echo "Failed to install agent." | |
echo "Try installing manually: apt-get install sd-agent" | |
exit $rc | |
fi | |
# Configuration | |
sed -i "s,sd_url: http://example.serverdensity.com,sd_url: $SD_URL,g" $CONFIGFILE | |
sed -i "s,agent_key:,agent_key: $AGENT_KEY,g" $CONFIGFILE | |
if [ "$?" -ne "0" ] ; then | |
echo "Failed to replace [Main] config file variables" | |
echo "Edit '/etc/sd-agent/config.cfg' manually." | |
exit $rc | |
fi | |
sudo /etc/init.d/sd-agent start | |
if [ "$?" -ne "0" ] ; then | |
echo "Failed to start agent" | |
echo "Run '/etc/init.d/sd-agent start' manually" | |
exit $rc | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment