Skip to content

Instantly share code, notes, and snippets.

@svet-b
svet-b / ext4_mac_docker.md
Created May 10, 2021 19:33
Mount and edit SD card image with ext4 partitions on Mac using Docker

Go to the directory with the image you want to work with. Run a Docker container with that directory mounted:

docker run -it --privileged -v /dev:/dev -v (pwd):/tmp --workdir /tmp ubuntu bash

(replace (pwd) with "$PWD" if using bash instead of fish)

See this thread for an explanation of why --privileged and -v /dev:/dev are required. The need for the latter can be avoided with this alrternative workaround.

In the container, assuming that $IMAGE_FILE is the name of your image file:

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 / 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
@svet-b
svet-b / bigdashboard_output.pdf
Last active April 28, 2024 09:30
PDF export of Grafana dashboard using puppeteer
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@svet-b
svet-b / grafana_pdf_via_snapshot.md
Last active December 27, 2022 09:01
PDF export of Grafana dashboard via snapshot

Get PDF export of Grafana dashboard

Note

As currently described, this approach does not work. The reason for that is that creating a snapshot via the API does not actually populate any data, as described in e.g. https://community.grafana.com/t/snapshot-using-http-api-does-nothing/. An alternative approach which does work described in https://gist.github.com/svet-b/1ad0656cd3ce0e1a633e16eb20f66425.

Prerequisites

Packages:

  • The jq JSON processing command line tool, which is available for most distributions (https://stedolan.github.io/jq/, sudo apt install jq)
  • NodeJS, and the puppeteer package (npm install puppeteer), which is used to run headless Chrome
@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 / _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 / 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
#!/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 / 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