Skip to content

Instantly share code, notes, and snippets.

@b-mc
b-mc / openwrt_uci_scripting_cheat_sheet.md
Created February 2, 2024 16:10
OpenWRT UCI scripting cheat sheet

OpenWRT UCI scripting cheat sheet

Notes

I use UCI together with bash. In case of other shells the variable and loop syntax might have to be adjusted accordingly.

New config entry - indexes

  1. Reference the newly added item with [-1]:

    uci add firewall rule
    uci set firewall.@rule[-1].name=test
    
@b-mc
b-mc / ST8000NM000A.md
Last active January 30, 2024 19:18
ST8000NM000A

ST8000NM000A

A dump of low level information about the amazing Seagate Exos 7E 8TB 512e/4Kn Fastformat SATA drive (ST8000NM000A) - for all of you tech-savvy NAS builders.

https://github.com/b-mc/ST8000NM000A

@b-mc
b-mc / netplan_how_to_owe_lunch_your_fellow_technician.md
Last active July 17, 2023 08:13
How to owe a lunch your fellow technician

How to owe a lunch your fellow technician

  1. Install bare Ubuntu Server on a remote workstation intended for NAS/CAD etc. (a physical server with no iLO, iDRAC and similar)
  2. Switch the netplan renderer to NetworkManager without installing the network-manager package in the first place
  3. Apply the new netplan config right away: netplan apply
  4. Enjoy your offline workstation -.-'
@b-mc
b-mc / ansible-download-github-latest-asset.md
Created November 23, 2021 12:52
Ansible: download the latest release asset from GitHub

Ansible: download the latest release asset from GitHub

About

Node Exporter (Linux amd64) is the example here. Note: you might need to_json|from_json as a workaround for this issue.

Play

- name: get the latest release details
  uri:
    url: https://api.github.com/repos/prometheus/node_exporter/releases/latest
@b-mc
b-mc / ansible-mariadb-upgrade-rhel7.md
Last active August 2, 2021 08:09
Ansible Playbook: Upgrade MariaDB sequentially (RHEL/CentOS 7)

Ansible Playbook: Upgrade MariaDB sequentially

About

I have created this playbook to perform an in-place upgrade of an old MariaDB instance from 5.5.68 to 10.5, sequentially (this is the recommended upgrade path). The playbook works with RHEL7/CentOS7 only and assumes the default installation directories. It doesn't migrate the database settings. It saves the upgrade results locally on the host.

Prerequisites

  • community.mysql.mysql_variables installed on the controller
  • enabled SCL repos on the host
  • MariaDB root password defined in a secret vault file

Run

On each run, specify the old version and the new one, e.g.:

@b-mc
b-mc / dante-socks-server-minimal-config.md
Created June 16, 2021 09:17
Dante SOCKS Server Minimal Config

Dante SOCKS Server Minimal Config

Setup

Software

  • CentOS Linux release 8.3.2011
  • Dante 1.4.3

Install

# Install the build tools
dnf install make gcc
@b-mc
b-mc / ansible-playbook-nagios-downtime.md
Last active August 6, 2021 12:56
Ansible Playbook: Schedule Nagios Downtime

Ansible Playbook: Schedule Nagios Downtime

About

The main advantage here is you don't have to add the affected hosts to the Ansible inventory — useful when hosting e.g. an independently managed application. The start time is conveniently converted to an epoch since this is what the Nagios module expects.

Playbook

- name: schedule nagios downtime
  hosts: nagios
  gather_facts: no
  vars:
@b-mc
b-mc / docker-list-bind-mounts.md
Created February 25, 2021 18:03
Docker: List bind mounts

Docker: List bind mounts

Command

Lately I have found myself working a lot with containers with bind mounts and found no elegant way to display all of them in one go. The command below gives you a nice overview as a json array. You need to have jq installed.

docker inspect $(docker ps -a -q) | jq '[.[] | {Id: .Id[0:12], Name: .Config.Hostname, Image: .Config.Image, Binds: .HostConfig.Binds}]'

Example output