A couple of scripts for publishing the state of an openwrt router to mqtt.
Relies on mosquitto_pub and mosquitto_sub being present
Init.d scripts including one to start a pair of file monitors and one to publish whether or not the router is onlien
| module.exports = { | |
| /** | |
| * | |
| * Using raw socket.io functionality from a Sails.js controller | |
| * | |
| */ | |
| index: function (req,res) { |
| # Prepare system | |
| apt-get update | |
| apt-get upgrade | |
| apt-get install build-essential | |
| apt-get install cmake | |
| apt-get install git | |
| apt-get install pkg-config | |
| # Grab frest opencv library | |
| curl -sL https://github.com/Itseez/opencv/archive/master.zip > opencv.zip |
| var gpio = require("gpio") | |
| var gpio22, intervalTimer | |
| // Flashing lights if LED connected to GPIO22 | |
| gpio22 = gpio.export(22, { | |
| ready: blinkLED | |
| }) | |
| function blinkLED() { | |
| intervalTimer = setInterval(function() { |
| ############################################################################### | |
| ## Monit control file | |
| ############################################################################### | |
| ## | |
| ## Comments begin with a '#' and extend through the end of the line. Keywords | |
| ## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'. | |
| ## | |
| ## Below you will find examples of some frequently used statements. For | |
| ## information about the control file, a complete list of statements and | |
| ## options please have a look in the monit manual. |
| #!/bin/sh | |
| # Alot of these configs have been taken from the various places | |
| # on the web, most from here | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # Set the colours you can use | |
| black='\033[0;30m' | |
| white='\033[0;37m' | |
| red='\033[0;31m' |
| #include <stdio.h> | |
| #include <omp.h> | |
| static long num_steps = 99999999; | |
| double step,start = 0.0,stop = 0.0; | |
| #define NUM_THREADS 8 | |
| int main () | |
| { | |
| double pi; |
| /* | |
| You'll need the information below, get these after adding a device. I'm using the MAC address as the device's ID. | |
| org=[org-id] | |
| type=[device-type] | |
| id=[device-id] | |
| auth-method=token | |
| auth-token=[auth-token] | |
| */ |
| #!/bin/bash | |
| # Slightly modified version from https://raw.githubusercontent.com/Nyr/openvpn-install/master/openvpn-install.sh | |
| # Run with sudo ./openvpn-install.sh and not sudo sh ./openvpn-install.sh as read command has issues with external triggering of scripts | |
| # OpenVPN road warrior installer for Debian, Ubuntu and CentOS | |
| # This script will work on Debian, Ubuntu, CentOS and probably other distros | |
| # of the same families, although no support is offered for them. It isn't | |
| # bulletproof but it will probably work if you simply want to setup a VPN on | |
| # your Debian/Ubuntu/CentOS box. It has been designed to be as unobtrusive and | |
| # universal as possible. |
| #include <Wire.h> | |
| #include <LiquidCrystal_I2C.h> | |
| #include <ESP8266WiFi.h> | |
| #include <WiFiHelper.h> | |
| #include <CMDust.h> | |
| const char* ssid = ""; | |
| const char* pass = ""; | |
| int pinDust = 14; | |
| float concentrations = 0; |