|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Update system timezone |
| 4 | +rm -f /etc/localtime |
| 5 | +ln -s /usr/share/zoneinfo/US/Pacific /etc/localtime |
| 6 | + |
| 7 | +# Remove unused packages from original distribution |
| 8 | +sudo apt-get remove -y puppet chef |
| 9 | + |
| 10 | +# ---------------------------------------------------------------------- |
| 11 | +# Get up-to-date |
| 12 | +sudo apt-get update |
| 13 | +sudo apt-get upgrade -y |
| 14 | +sudo apt-get autoremove -y |
| 15 | + |
| 16 | +# guest utils for VirtualBox are missing in 16.04 |
| 17 | +sudo apt-get install -y --no-install-recommends virtualbox-guest-utils |
| 18 | + |
| 19 | +# Install required packages |
| 20 | +sudo apt-get install -y openssh-server |
| 21 | +sudo apt-get install -y python-pip |
| 22 | +sudo apt-get install -y supervisor |
| 23 | +sudo apt-get install -y curl |
| 24 | +sudo apt-get install -y unzip |
| 25 | +sudo apt-get install -y stunnel4 |
| 26 | +sudo apt-get install -y nginx |
| 27 | + |
| 28 | +sudo systemctl enable supervisor.service |
| 29 | + |
| 30 | +sudo pip install requests |
| 31 | + |
| 32 | +# ---------------------------------------------------------------------- |
| 33 | +# Install and start InfluxDB |
| 34 | + |
| 35 | +curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add - |
| 36 | +source /etc/lsb-release |
| 37 | +echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list |
| 38 | +sudo apt-get update && sudo apt-get install -y influxdb |
| 39 | + |
| 40 | +sudo systemctl daemon-reload |
| 41 | +sudo systemctl unmask influxdb |
| 42 | +sudo systemctl start influxdb |
| 43 | +sudo systemctl enable influxdb.service |
| 44 | + |
| 45 | +# configure the grafana database |
| 46 | +influx -import -path=/vagrant/grafanadb.influx |
| 47 | + |
| 48 | +# ---------------------------------------------------------------------- |
| 49 | +# Install and start grafana |
| 50 | + |
| 51 | +curl -sL https://packagecloud.io/gpg.key | sudo apt-key add - |
| 52 | +# grafana says use wheezy even for recent Ubuntu distributions |
| 53 | +echo "deb https://packagecloud.io/grafana/stable/debian/ wheezy main" | sudo tee /etc/apt/sources.list.d/grafana.list |
| 54 | +sudo apt-get update && sudo apt-get install -y adduser libfontconfig grafana |
| 55 | + |
| 56 | +sudo systemctl daemon-reload |
| 57 | +sudo systemctl start grafana-server |
| 58 | +#systemctl status grafana-server |
| 59 | +sudo systemctl enable grafana-server.service |
| 60 | + |
| 61 | +# ---------------------------------------------------------------------- |
| 62 | +# configure nginx |
| 63 | + |
| 64 | +sudo cp /vagrant/clouddata_server.site.conf /etc/nginx/sites-available/clouddata_server.conf |
| 65 | +sudo rm /etc/nginx/sites-enabled/default |
| 66 | +sudo ln -s /etc/nginx/sites-available/clouddata_server.conf /etc/nginx/sites-enabled/default |
| 67 | + |
| 68 | +sudo nginx -s reload |
| 69 | + |
| 70 | +# ---------------------------------------------------------------------- |
| 71 | +# configure clouddata_server |
| 72 | + |
| 73 | +# clouddata_server requirements |
| 74 | +sudo pip install influxdb |
| 75 | +sudo pip install bottle |
| 76 | + |
| 77 | +# note: clouddata_server.py comes from the SmartMeshSDK source |
| 78 | +# http://dust-jenkins:8080/job/SmartMeshSDK/lastSuccessfulBuild/artifact/SmartMeshSDKTool/gen/SmartMeshSDK-1.0.7.140.zip |
| 79 | + |
| 80 | +cp /vagrant/clouddata_server.py /home/ubuntu/clouddata_server.py |
| 81 | + |
| 82 | +sudo cp /vagrant/clouddata_server.program.conf /etc/supervisor/conf.d/clouddata_server.conf |
| 83 | +sudo systemctl restart supervisor |
| 84 | + |
| 85 | +# ---------------------------------------------------------------------- |
| 86 | +# other configurations -- manually set up |
| 87 | +# - update hostname to clouddata |
| 88 | +# - grafana: configure influxdb data source |
| 89 | +# - grafana: dashboard creation, set as default |
| 90 | +# - grafana: enable anonymous access |
| 91 | +# - iptables firewall |
0 commit comments