Skip to content

Instantly share code, notes, and snippets.

@svet-b
svet-b / compile_plugin.sh
Created June 13, 2018 14:07
Compile Grafana plugin (e.g. status panel) on MacOS
#!/bin/bash
# Update npm to latest
npm i npm@latest -g
# Make sure Sass is installed (requires Ruby)
gem install sass
$SRCDIR="/opt/codebase/Grafana_Status_panel"
@svet-b
svet-b / make_ammp_moxa_image.md
Last active July 16, 2018 06:25
Making an AMMP edge image for Moxa

This works on the v3 firmware of the Moxa UC-8100(-LX)

Log into Moxa Edit /etc/network/interfaces to enable DHCP on LAN1

iface eth0 inet dhcp
#iface eth0 inet static
#        address 192.168.3.127
#        network 192.168.3.0
# netmask 255.255.255.0
@svet-b
svet-b / edge_without_snapd.sh
Created July 30, 2018 21:56
Set up AMMP-edge without snapd
# Ensure that package dependencies are met (specifically python3, libsnmp-dev, and python3-netifaces)
# Create user under which software will be run.
# Enter user directory. In this example this is /opt/datalog
# Pull the codebade
git clone https://github.com/ammpio/ammp-edge.git
# Install python package
cd ammp-edge
@svet-b
svet-b / grafana_set_up.sh
Last active September 1, 2018 23:21
Setting up Grafana environment
#!/bin/bash
export CODEDIR="/opt/codebase"
export DEVGROUP="devs"
export GH_ORIG="github.com/grafana"
export GH_FORK="github.com/ammpio"
export REPONAME="grafana"
export GOROOT=/usr/local/go
export GOPATH=$CODEDIR
sudo apt install npm
sudo npm install -g npm@latest
sudo npm install bower -g

git clone https://github.com/sabhiram/raspberry-wifi-conf.git
cd raspberry-wifi-conf
npm update
bower install
sudo npm run-script provision
@svet-b
svet-b / _make_ammp_raspbian_img.md
Last active July 22, 2020 13:58
Making a Raspbian-based AMMP edge image to run on Raspberry Pi

Create Raspbian SD card with image from https://www.raspberrypi.org/downloads/raspbian/

Create file named ssh in boot partition, so that ssh is enabled on boot.

Log into Raspberry Pi (user pi, password raspberry).

Set strong password on pi user. (passwd) (optional) Copy SSH key

ssh-copy-id -i id_ed25519_ammpedge pi@[raspberry_IP]
@svet-b
svet-b / wireguard_userspace.sh
Last active July 30, 2020 09:04
Install WireGuard userspace on Linux
sudo apt update && sudo apt upgrade
sudo apt install golang
sudo apt-get install libmnl-dev libelf-dev build-essential pkg-config
git clone https://git.zx2c4.com/wireguard-go
cd wireguard-go/
git checkout 0.0.20181001 # Get the desired release tag from `git tag`
make
sudo make install
#!/bin/bash
# Version of pishrink (https://github.com/Drewsif/PiShrink) to work on Moxa UC-8100 series image
function cleanup() {
if losetup $loopback &>/dev/null; then
losetup -d "$loopback"
fi
}
@svet-b
svet-b / grafana_search_replace.md
Last active September 9, 2022 08:32
Search-and-replace on Grafana dashboards by manipulating database

It's possible to do search-and-replace on Grafana dashboard definitions by directly manipulating the SQLite database. The key steps after logging into the server are as follows:

cd /var/lib/grafana
# Make backup copy; preserve old backup copies
sudo cp --backup=numbered grafana.db grafana.db.bak

# Stop Grafana
sudo systemctl stop grafana-server
@svet-b
svet-b / snapd_on_moxa.md
Last active October 7, 2022 05:36
Running snapd and snaps on a Moxa UC-8100 board

The Moxa UC-8100 line of "industrial IoT gateways", such as the Moxa UC-8112-LX, can be a good solution for on-site data acquisition. To get the most out of them we want to enable them to run snaps, like https://snapcraft.io/ammp-edge. Unfortunately, as of writing, the latest v2.0 firmware provided with these devices does not support this, for two main reasons:

  1. The pre-installed OS is Debian 8, while snapd requires at least Debian 9.
  2. The stock kernel does not include SquashFS support, and does not have the required CONFIG_DEVPTS_MULTIPLE_INSTANCES option set.

The steps for rectifying these shortcomings are roughly as follows:

Compiling and installing a custom kernel

The following commands assume you're doing this on the Moxa device itself, though for more expedient results you'll want to cross-compile on something more powerful. Also note that in order to build the kernel you'll need a couple of GB of free space, which is more