Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
In progress...
# Changes default shell to bash
chsh -s /bin/bash
su
# Update distribution
apt-get update
apt-get upgrade -y
apt-get dist-upgrade -y
# Update from wheezy to jessie
sed -i 's/wheezy/jessie/g' /etc/apt/sources.list
apt-get update
apt-get upgrade -y # Say no when asked
apt-get dist-upgrade -y
# Install packages
apt-get install nano mosquitto curl apt-utils keyboard-configuration git bison libnss-mdns -y
# Optionnal
apt-get install sudo
# Configure locales, timezone and data
dpkg-reconfigure locales
dpkg-reconfigure tzdata
dpkg-reconfigure keyboard-configuration
invoke-rc.d keyboard-setup start
# Install node-red
curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -
apt-get install -y build-essential python-dev nodejs
npm install -g --unsafe-perm node-red
sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/nodered.service -O /lib/systemd/system/nodered.service
sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-start -O /usr/bin/node-red-start
sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-stop -O /usr/bin/node-red-stop
sudo chmod +x /usr/bin/node-red-st*
sudo systemctl daemon-reload
sudo systemctl enable nodered.service
# Install Go for user pi
exit
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source /home/pi/.gvm/scripts/gvm
gvm install go1.4.2
gvm use go1.4.2 --default
#gvm install go1.5
#gvm use go1.5 --default
# Setup Go
mkdir go
export GOPATH=$HOME/go
mkdir -p $GOPATH/src/github.com/influxdb
cd $GOPATH/src/github.com/influxdb
git clone https://github.com/influxdb/influxdb.git
# Make influx
go get -u -f -t ./...
go build ./...
# Copy influx to bin directory
sudo cp /home/pi/go/bin/influx /usr/bin/
sudo cp /home/pi/go/bin/influxd /usr/bin/
# Launch at startup
sudo cp /home/pi/NoteRF-Soft/InfluxDB/influxStartupScript.sh /etc/init.d/influxdb
sudo chmod 755 /etc/init.d/influxdb
sudo update-rc.d influxdb defaults
# Creates database
CREATE USER ** WITH PASSWORD '**' WITH ALL PRIVILEGES
CREATE DATABASE db_note
USE db_note
CREATE RETENTION POLICY ret_25h ON db_note DURATION 25h REPLICATION 1 DEFAULT
CREATE RETENTION POLICY ret_7d_10m ON db_note DURATION 7d REPLICATION 1
CREATE RETENTION POLICY ret_31d_1h ON db_note DURATION 31d REPLICATION 1
CREATE RETENTION POLICY ret_inf ON db_note DURATION inf REPLICATION 1
CREATE CONTINUOUS QUERY dnSamp_10m ON db_note BEGIN SELECT mean(value) AS value INTO db_note."ret_7d_10m".sensorsData FROM sensorsData GROUP BY time(10m), * END
CREATE CONTINUOUS QUERY dnSamp_1h ON db_note BEGIN SELECT mean(value) AS value INTO db_note."ret_31d_1h".sensorsData FROM db_note."ret_7d_10m".sensorsData GROUP BY time(1h), * END
CREATE CONTINUOUS QUERY dnSamp_6h ON db_note BEGIN SELECT mean(value) AS value INTO db_note."ret_inf".sensorsData FROM db_note."ret_31d_1h".sensorsData GROUP BY time(6h), * END
CREATE CONTINUOUS QUERY dnSamp_10m_elec ON db_note BEGIN SELECT min(value) AS value INTO db_note."ret_7d_10m".electricity FROM electricity GROUP BY time(10m), * END
CREATE CONTINUOUS QUERY dnSamp_1h_elec ON db_note BEGIN SELECT min(value) AS value INTO db_note."ret_31d_1h".electricity FROM db_note."ret_7d_10m".electricity GROUP BY time(1h), * END
CREATE CONTINUOUS QUERY dnSamp_6h_elec ON db_note BEGIN SELECT min(value) AS value INTO db_note."ret_inf".electricity FROM db_note."ret_31d_1h".electricity GROUP BY time(6h), * END
SELECT mean("value") FROM "sensorsData" WHERE "data" = 'Temperature' AND "room" = 'Bedroom' AND time > now() - 6h GROUP BY time(5m)
SELECT mean("value") FROM "sensorsData" WHERE "data" = 'Temperature' AND "room" = 'BedroomNoe' AND time > now() - 6h GROUP BY time(5m)
SELECT mean("value") FROM "sensorsData" WHERE "data" = 'Temperature' AND "room" = 'LivingRoom' AND time > now() - 6h GROUP BY time(5m)
SELECT mean("value") FROM "sensorsData" WHERE "data" = 'Temperature' AND "room" = 'Outside' AND time > now() - 6h GROUP BY time(5m)
SELECT mean("value") FROM "sensorsData" WHERE "data" = 'Temperature' AND "room" = 'Office' AND time > now() - 6h GROUP BY time(5m)&epoch=ms
# Add sketchs
git clone https://github.com/Oliv4945/NoteRF-Soft.git
# Install Grafana
source /home/pi/.gvm/scripts/gvm
export GOPATH=$HOME/go
gvm use go1.4 --default
mkdir /home/pi/go/src/github.com/grafana
cd /home/pi/go/src/github.com/grafana
git clone https://github.com/grafana/grafana.git
cd grafana
go run build.go setup
godep restore
go build .
npm install
sudo npm install -g grunt-cli
grunt
sudo cp /home/pi/go/src/github.com/grafana/grafana/grafana /usr/sbin/
sudo cp /home/pi/NoteRF-Soft/grafana/grafana-server /etc/init.d/
sudo chmod 755 /etc/init.d/grafana-server
sudo update-rc.d grafana-server default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment