-
-
Save gauravarora/fca313f992d134c7b7ce to your computer and use it in GitHub Desktop.
Shell script to download, and configure, InfluxDB, nginx, and Grafana
This file contains hidden or 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 | |
| AWS_EC2_HOSTNAME_URL=http://169.254.169.254/latest/meta-data/public-hostname | |
| INFLUXDB_DATABASE=test67 | |
| INFLUXDB_PKG=influxdb_latest_amd64.deb | |
| INFLUXDB_URL=http://s3.amazonaws.com/influxdb/$INFLUXDB_PKG | |
| GRAFANA_VER=grafana-1.5.4 | |
| GRAFANA_PKG=$GRAFANA_VER.tar.gz | |
| GRAFANA_URL=http://grafanarel.s3.amazonaws.com/$GRAFANA_PKG | |
| GRAFANA_CONFIG_GIST=https://gist.github.com/otoolep/c58991dec54711026b77/raw/c5af837b93032d5b929fef0ea0b262648ddd4b7f/gistfile1.js | |
| echo "Downloading and installing Influxdb." | |
| wget $INFLUXDB_URL | |
| sudo dpkg -i $INFLUXDB_PKG | |
| sudo /etc/init.d/influxdb start | |
| echo "Downloading and installing Grafana." | |
| wget $GRAFANA_URL | |
| tar xvfz $GRAFANA_PKG | |
| echo "Downloading and installing nginx." | |
| sudo apt-get -y install nginx-full | |
| sudo sed -i "s|/usr/share/nginx/html|/home/ubuntu/$GRAFANA_VER|g" /etc/nginx/sites-available/default | |
| sudo service nginx restart | |
| public_hostname=`curl -s $AWS_EC2_HOSTNAME_URL` | |
| echo "Public hostname of this EC2 instance is: $public_hostname" | |
| echo "Configuring Grafana." | |
| wget https://gist.github.com/otoolep/c58991dec54711026b77/raw/606c0f5adccba4153c5daa016711f2e5350f6939/gistfile1.js -O $GRAFANA_VER/config.js | |
| sed -i "s|PUBLIC_HOSTNAME|$public_hostname|g" $GRAFANA_VER/config.js | |
| echo "Creating Influxdb database $INFLUXDB_DATABASE." | |
| curl -s "http://localhost:8086/db?u=root&p=root" -d "{\"name\": \"$INFLUXDB_DATABASE\"}" | |
| echo "Downloading sine wave generation program." | |
| curl -s https://gist.github.com/otoolep/3d5741e680bf76021f77/raw/1d81a1ad4771659b008b9c346b4dd20ef1b72536/sine.py >sine.py | |
| echo "Configuration complete." | |
| echo "Influxdb URL: http://$public_hostname:8083" | |
| echo "Grafana URL: http://$public_hostname" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment