Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash script to install a Thingspeak server on Ubuntu Server 14.04. Raspbian (2014-09-09-wheezy-raspbian).
#!/bin/bash
# Automatic install of Thingspeak server on Ubuntu 12.04 / Raspbmc / Debian (?)
# Updated to use ruby 2.1.4
# System updates & patches
sudo apt-get update # update the list of packages
sudo apt-get upgrade # update software packages
sudo apt-get dist-upgrade # upgrade the kernel
sudo sync
sudo reboot
# Get the required packages
sudo apt-get update
sudo apt-get -y install build-essential git mysql-server mysql-client libmysqlclient-dev libxml2-
dev libxslt-dev libssl-dev libsqlite3-dev
# Ruby and rails
wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.5.tar.gz
tar xvzf ruby-2.1.5.tar.gz
cd ruby-2.1.5
./configure
make
sudo make install
cd ..
echo "gem: --no-rdoc --no-ri" >> ${HOME}/.gemrc
sudo gem install rails
# Here we go for ThingSpeak
git clone https://github.com/iobridge/thingspeak.git
cp thingspeak/config/database.yml.example thingspeak/config/database.yml
cd thingspeak
bundle install
bundle exec rake db:create
### The first time, bundle exec rake db:create failed with the following error:
#Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnect"=>false,
#"database"=>"thingspeak_test", "pool"=>5, "username"=>"thing", "password"=>"speak",
#"socket"=>"/var/run/mysqld/mysqld.sock”}
# So I hacked with
#mysql --user=root mysql
#mysql> CREATE USER 'thing'@'localhost' IDENTIFIED BY 'speak’;
#mysql> GRANT ALL PRIVILEGES ON *.* TO 'thing'@'localhost' WITH GRANT OPTION;
#mysql> commit;
#mysql> exit;
# Then I ran that bundle command again
bundle exec rake db:create
# It then said that thingspeak_development DB already exists, so I verified through:
#mysql --user=root mysql
#mysql> show databases;
#+------------------------+
#| Database |
#+------------------------+
#| information_schema |
#| mysql |
#| performance_schema |
#| thingspeak_development |
#| thingspeak_test |
#+------------------------+
#mysql> exit;
# Then I continued with
bundle exec rake db:schema:load
# seems ok (no complains)
# Finally, I ran
rails server webrick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment