Skip to content

Instantly share code, notes, and snippets.

@gdamjan
Last active August 18, 2019 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdamjan/ea4afa94afc71cdeb9d8b2c683f3177f to your computer and use it in GitHub Desktop.
Save gdamjan/ea4afa94afc71cdeb9d8b2c683f3177f to your computer and use it in GitHub Desktop.
Mozilla WebThings iot gateway - run as service on debian 10
  1. install from https://github.com/mozilla-iot/gateway
  2. install debian dependencies
  3. build
  4. copy static and build to /opt/mozilla-iot
  5. run npm install --production and then move node_modules to /opt/mozilla-iot
  6. make /opt/mozilla-iot/config/default.js
  7. make /etc/systemd/system/mozilla-iot.service (run as a dynamic user and keep state in /var/lib/mozilla-iot)
// config/default.js
'use strict';
const proc = require('process');
const os = require('os');
const path = require('path');
module.exports = {
// Expose CLI
cli: false,
profileDir: proc.env.STATE_DIRECTORY.split(':')[0],
ports: {
http: 8080,
},
// Whether the gateway is behind port forwarding and should use simplified
// port-free urls
behindForwarding: true,
database: {
removeBeforeOpen: false,
},
ipc: {
protocol: 'ipc',
},
settings: {
defaults: {
domain: {
localAccess: true,
mozillaTunnelService: false,
localControl: {
mdnsServiceType: 'http',
mdnsServiceName: 'Mozilla WebThings Gateway',
mdnsServiceDomain: os.hostname().split('.')[0],
mdnsTxt: {
desc: 'Web of Things Gateway',
protocol: 'http, https, Web Sockets',
power: '6 watts',
},
},
},
},
},
authentication: {
defaultUser: null,
},
ssltunnel: {
enabled: false
},
bcryptRounds: 2,
addonManager: {
api: 2,
listUrls: [
'https://api.mozilla-iot.org:8443/addons',
],
testAddons: false,
},
updateUrl: 'https://api.mozilla-iot.org:8443/releases',
wifi: {
ap: {
ipaddr: '192.168.2.1',
ssid_base: 'WebThings Gateway',
},
},
oauthPostToken: false,
oauthTestClients: false,
};
[Unit]
Description=Mozilla WebThings iot gateway
After=network.target
[Service]
DynamicUser=true
Type=simple
StateDirectory=mozilla-iot
Environment=HOME=/var/lib/mozilla-iot
WorkingDirectory=/opt/mozilla-iot
ExecStart=/usr/bin/node build/gateway.js
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment