Skip to content

Instantly share code, notes, and snippets.

[Service]
ExecStart=
ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --keep-baud --autologin root - 115200,38400,9600 $TERM
@rany2
rany2 / assoclist-all.sh
Last active November 10, 2025 19:22
OpenWRT assoclist for all WiFi interfaces
#!/bin/sh
. /usr/share/libubox/jshn.sh
list_ifaces() {
ubus list 'hostapd.*' 2>/dev/null | sed 's/^hostapd\.//' | sort -n
}
to_mbps() {
awk -v r="$1" 'BEGIN{if (r=="") {print "N/A"} else {printf "%.1f MBit/s", r/100000}}'
@rany2
rany2 / pretty-uptime.sh
Created March 9, 2024 14:22
Something similar to `uptime -p` but for busybox
#!/bin/sh
# pretty-print system uptime
# get uptime and idle
read -r u _ < /proc/uptime
u=${u%.*}
# function to calculate and print time period
print_period() {
period_seconds="$1"
@rany2
rany2 / iperf3-gw
Created January 14, 2024 16:58
IPERF3 script
#!/bin/sh
# Generate a random 32-bit number to use to pick a random
# IPERF3 port. Random device is overridable by setting the
# RAND_DEVICE environment variable.
RAND_DEVICE=${RAND_DEVICE:-/dev/random}
RAND_NUMBER=$(hexdump -n4 -e '4/4 "%u"' "${RAND_DEVICE}")
# IPERF3 paramaters, only dynamic parameter is IPERF3_PORT.
IPERF3_BIN=${IPERF3_BIN:-iperf3}
@rany2
rany2 / oracle_latency_test.py
Created January 10, 2024 15:06
Latency test against all Oracle Cloud regions
#!/usr/bin/env python3
import concurrent.futures
import socket
import timeit
import argparse
REGIONS = [ # https://docs.oracle.com/en-us/iaas/Content/General/Concepts/regions.htm
{"region": "Australia East", "area": "Sydney", "code": "ap-sydney-1"},
{"region": "Australia Southeast", "area": "Melbourne", "code": "ap-melbourne-1"},
@rany2
rany2 / iperf3.service
Last active April 15, 2023 18:31
Hardened iperf3 service
# /lib/systemd/system/iperf3.service
[Unit]
Description=iperf3 server
Documentation=man:iperf3(1)
After=network.target auditd.service
[Service]
Type=simple
Restart=always
RestartSec=15
@rany2
rany2 / [email protected]
Last active November 4, 2025 17:58
Hardened systemd service for PPP
[Unit]
Description=PPP connection for %I
Documentation=man:pppd(8)
StartLimitIntervalSec=0
Before=network.target
Wants=network.target
After=network-pre.target
[Service]
@rany2
rany2 / 01-maxwlanmtu
Last active January 9, 2024 14:25
OpenWRT workaround for inability to set MTU for WLAN interfaces
#!/bin/sh
# Ensure that WLAN interface MTU is set to the maximum
# permitted value to prevent issues when attached to a
# bridge with jumbo MTU.
#
# Do not attempt to use standard UCI configuration
# in /etc/config/network and set the MTU with a config
# of type interface. It does not work consistently
# and in the best case works for the first WLAN
@rany2
rany2 / get_x86_bootloader.sh
Created April 10, 2023 14:02
Get bootloader type and (if available) the bootloader version. Only works on x86/x86-64 Linux.
#!/bin/bash
set -euf -o pipefail
# Copyright (C) rany <[email protected]>. All rights reserved.
#
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
@rany2
rany2 / eskom.py
Last active January 4, 2023 07:44
Eskom API
#!/usr/bin/env python3
import urllib.parse
from enum import Enum
from typing import List
import requests
BASE_URL = "https://loadshedding.eskom.co.za/LoadShedding/"
USER_AGENT = "ZA_LOADSHEDDING/1.0 (github.com/rany2)"