Skip to content

Instantly share code, notes, and snippets.

@Robertof
Robertof / README.md
Last active February 6, 2023 00:33
node-exporter prevents systemd automount/autofs expiry (TimeoutIdleSec, x-systemd.idle-timeout)

Do you have an automount configured using systemd (or another autofs-based daemon) with an expiry/timeout and it's not automatically unmounting? i.e., is x-systemd.idle-timeout or TimeoutIdleSec not working?

Do you use Prometheus' node_exporter?

The problem

If you answered yes to both questions, you're in luck. After being confused for a while with this problem and furiously Googling about it, I found this issue reported by @huww98 on the systemd repo: systemd/systemd#18445 "Support for autofs "strictexpire" option".

Thanks to their amazing debugging skills, they were able to trace the root cause of the issue to a statfs() syscall made by node_exporter on all mountpoints. If the scrape interval of your Prometheus instance is lower than the timeout, your mountpoint will never be unmounted. In their own words:

@Robertof
Robertof / README.md
Created January 29, 2023 19:18
Fix for "can't open /opt/var/run/smbd-ZyXELSambaReplacement.conf.pid: Error was File exists"

This happens because /opt/var/run is not a tmpfs, and the data is never removed on reboot.

As a workaround, the fs can be mounted as tmpfs on boot before the new Samba is loaded and replaced. Place the S00runtmpfs file attached to this gist in /opt/etc/init.d, run:

chmod a+x /opt/etc/init.d/S00runtmpfs

Reboot your NAS. Profit!

@Robertof
Robertof / README
Last active December 23, 2022 20:17
Patch to add support for vfs_full_audit.c to Entware-NG Samba modules to fix Zyxel's NSA-325v2 requiring it for 'admin' shares
This was compiled using the following guide: https://github.com/Entware/Entware-ng/wiki/Compile-packages-from-sources on Ubuntu 12.04 LTS.
Binary pre-compiled package is available here: https://robertof.ovh/mirror/add-vfs-full-audit-to-entware-ng-samba/samba36-server_3.6.25-9_armv5soft.ipk
Install by downloading it on your device, then `opkg install --force-checksum samba36-server_3.6.25-9_armv5soft.ipk`. Restart Samba or device afterwards, `admin` share should work.
For posterity, rough list of commands:
- sudo sed -i 's/us-east-1.ec2.archive.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
- sudo sed -i 's/security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
- sudo apt-get update
@Robertof
Robertof / busybox applets
Created September 5, 2022 00:41
Hikvision DS-KH9510-WTE1 dump
# busybox
BusyBox v1.22.1 (2014-11-27 12:30:44 CST) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2012.
Licensed under GPLv2. See source distribution for detailed
copyright notices.
Usage: busybox [function [arguments]...]
or: busybox --list
or: function [arguments]...
@Robertof
Robertof / agvtf-refresh-ip.sh
Created April 24, 2016 23:58
Hassle-free automatic IP renewer for what is known as "Technicolor AG plus VDNT-S Router VDSL2" or "Telecom Italia VDSL/Fibra modem".
#!/usr/bin/env bash
# Technicolor AG plus VDNT-S Router VDSL2 - (ba)sh IP renewer
# This script logs into the router and refreshes the IP address by toggling on
# and off the "automatic connection" parameter.
# It *NEEDS* to be configured. Please keep reading.
# Disable globbing, die on undefined variables and errors
set -efu
# Configuration
@Robertof
Robertof / pppoe-relay.patch
Created January 4, 2016 16:09
A patch for pppoe-relay which completely removes the usage of the tag "Relay-Session-Id". The tag, used to keep track of the clients making use of the PPPoEd protocol, has been replaced with two variables inside the source code. This allows this instance of pppoe-relay to work with other instances of pppoe-relay which do not have the same patch …
--- relay.orig 2016-01-04 17:02:33.538674500 +0100
+++ relay.c 2016-01-04 03:18:44.972518900 +0100
@@ -83,6 +83,31 @@
/* Hack for daemonizing */
#define CLOSEFD 64
+/* Debug flag */
+//#define ROB_DEBUG
+
+/* No syslog when debugging! */
@Robertof
Robertof / tg-example-bot.pl
Last active February 17, 2023 01:31
Basic Telegram bot implementation using WWW::Telegram::BotAPI
#!/usr/bin/env perl
# Basic Telegram Bot implementation using WWW::Telegram::BotAPI
use strict;
use warnings;
use WWW::Telegram::BotAPI;
use utf8;
my $api = WWW::Telegram::BotAPI->new (
token => (shift or die "ERROR: a token is required!\n")
);
@Robertof
Robertof / router-report.pl
Created May 22, 2015 17:31
This script generates a report containing various statistics about the Technicolor AG plus VDNT-S Router VDSL2 (also known as the "Telecom Italia VDSL/Fibra modem"). This is achieved by logging in to the router, requesting the various statistics page and summarising everything in a JSON file. The file is saved inside the REPORT_DIR, with the for…
#!/usr/bin/env perl
use autodie;
use strict;
use warnings;
use Digest::MD5 "md5_hex";
use File::Path ();
use File::Spec;
use Fcntl qw(:DEFAULT :flock);
use HTTP::Cookies;
use JSON::MaybeXS;

Keybase proof

I hereby claim:

  • I am Robertof on github.
  • I am robertof (https://keybase.io/robertof) on keybase.
  • I have a public key whose fingerprint is 9786 7646 60D9 AA54 3072 306D B7F6 7885 CA4B D3E8

To claim this, I am signing this object:

@Robertof
Robertof / pasteling.sh
Last active August 29, 2015 13:57
pasteling.sh - a Bash script for Pasteling. Please check out the help with `pasteling -h`.
#!/usr/bin/env bash
PL_VERSION="1.1.1"
PL_KEY=""
PL_LANG=""
PL_FULLPAGE=""
PL_URL="http://pasteling.giovannicapuano.net/api"
command -v curl >/dev/null 2>&1 || \
{ echo >&2 "This script requires 'curl'. Aborting."; exit 2; }
command -v rev >/dev/null 2>&1 || \