Skip to content

Instantly share code, notes, and snippets.

View ProBackup-nl's full-sized avatar
🏠
Working from home

C. Jacobs ProBackup-nl

🏠
Working from home
View GitHub Profile
@ProBackup-nl
ProBackup-nl / sub2rbl
Last active February 14, 2024 19:34
sub2rbl for padavan firmware
#!/bin/sh
#
# sub2rbl for padavan firmware @ProBackup-nl
# ============
# Subscribes to IP or CIDR (netblock) RBLs; auto-integrates into iptables
# Purely for reduced memory consumption it creates two IP sets:
# 1. one for unicast IPs (sub2rbl)
# 2. the other one for CIDR (sub2rbl-net) blocks
# Realtime block lists contain both types
#
@ProBackup-nl
ProBackup-nl / backup.sh
Last active January 7, 2022 12:46
/opt and /etc/storage backup utility for Padavan firmware using rsync
#!/bin/sh
if [ $# = 0 ] || [ $1 = -h ]; then cat <<EOF
--------------------------------------------------------------------------
Pro Backup's handy rotating-filesystem-backup utility for Padavan firmware
--------------------------------------------------------------------------
It makes rotating backup-snapshots of /opt and /etc/storage when called
to a disk that must be prepared with label "Backup". (mkfs.ext4 -L Backup)
Installation: # curl -O https://gist.githubusercontent.com/ProBackup-nl/82fb02c67dc05ca0310d0f9f8e8be14c/raw/68bc28dbdcd7815feb6b5c2715ff121c44e03575/backup.sh && chmod 755 backup.sh && mkdir /opt/usr/sbin && mv backup.sh /opt/usr/sbin/backup
@ProBackup-nl
ProBackup-nl / pgist.sh
Last active September 6, 2018 16:36 — forked from s-leroux/pgist.sh
Gister to POST or PATCH a single file as public gist. PATCH does gist ID lookup: no need to remember gist ID's
#!/bin/sh
# --------------------------------------------------------
# Shell gister to POST or PATCH a single file as public gist.
# PATCH does gist ID lookup: no need to remember gist ID's
# --------------------------------------------------------
# usage: $ pgist file_to_post_or_patch.extension
#
# installation: $ curl -O https://gist.githubusercontent.com/ProBackup-nl/3971a45b21749cfff6c0069d3dad1dde/raw/pgist.sh && chmod 755 pgist.sh && mv pgist.sh /opt/usr/sbin/pgist
#
# tested with Busybox (ash shell) + Entware (opkg)
@ProBackup-nl
ProBackup-nl / S05syslogd
Created April 16, 2020 12:06
Move syslog to USB drive script, where stop returns firmware state. Tested with RT-N56U router + Padavan firmware.
#!/bin/sh
# save as /opt/etc/init.d/S05syslogd
# chmod +x,go-w /opt/etc/init.d/S05syslogd
# /opt/etc/init.d/S05syslogd start
MOUNT=/media/Main
FOLDER=/Syslog
# better not change anything below here
SOURCE=/tmp/syslog.log # original source of the syslog on /tmp
@ProBackup-nl
ProBackup-nl / ddrfind.sh
Last active June 5, 2023 17:43
ddrescue on a directory recursively (using find) skipping existing equally sized targets preservering metadata
#!/bin/bash
# ddrescue on a directory recursively (using find)
# skipping existing equally sized targets
# preservering metadata
# inspired by the-mikedavis ddrfind.fish
if [ -z $1 ] || [ ! -d $1 ] || [ -z $2 ] || [ ! -d $2 ]; then
echo "Usage: ddrfind.sh <input-dir> <output-dir-that-exists>"
echo "Example: ddrfind.sh /Volumes/A/folder-to-rescue /Volumes/B"
exit 1
@ProBackup-nl
ProBackup-nl / motd.sh
Last active April 2, 2024 08:54
Dynamic system status MOTD for Arch Linux
#!/bin/bash
# Preferred installation method
# nano /etc/profile.d/motd.sh;chmod +x /etc/profile.d/motd.sh
## <paste this>
#
# Alternative installation method
# nano /usr/bin/motd.sh;chmod +x /usr/bin/motd.sh
## <paste this>
# patch.sh or # patch -d/ --dry-run -p0 -i ~/patch.txt
# don't: # echo "session optional pam_exec.so stdout /usr/bin/motd.sh" >> /etc/pam.d/system-login
@ProBackup-nl
ProBackup-nl / PKGBUILD
Last active December 25, 2021 16:12
Influxdb2-bin package for Arch
# Maintainer: Ceriel Jacobs <2010 at probackup dot nl>
# Contributor: Bartłomiej Piotrowski <[email protected]>
# Contributor: Jozef Holly <[email protected]>
pkgname=influxdb2-bin
pkgver=2.0.7
pkgrel=1
pkgdesc='Scalable datastore for metrics, events, and real-time analytics; Binary release;'
arch=('x86_64' 'aarch64')
url="https://portal.influxdata.com/downloads/"
@ProBackup-nl
ProBackup-nl / .bashrc-locate_f
Last active February 6, 2024 13:41
Locate alias function for Arch
# nano ~/.bashrc # note: user=root without sudo
---
function locate_f()
{
sudo find / -regextype posix-extended -regex "/(afs|media|mnt|net|sfs|sys|tmp|proc|udev)" -prune -o -path "*$1*" -print 2>/dev/null
}
alias locate=locate_f
#!/bin/bash
# Script that runs a write endurance torture test, intended to measure SD card endurance.
# Like "Anvil's Storage Utilities" endurance test for command line Linux
# Check if running as root
if [[ "$(id -u)" -ne 0 ]]; then
echo "ERROR: Must be run as root" >&2
exit 2
fi
@ProBackup-nl
ProBackup-nl / dsm_reader.py
Last active February 6, 2024 13:45 — forked from ius/gist:e59adb64bbe8855cfc5c18297f6d692e
Dutch Smart Meter (DSM) P1 to InfluxDB 2.0 and pvoutput.org
#!/usr/bin/env python
# Store DSMR telegrams from P1 into influxdb 2.0 and pvoutput.org
# EN-IEC 62056-21, Part 21: direct local data exchange, 2002-05
# WARNING: influxdb will crash/become a memory hog after collecting a few months of data !!!
#- Requires python2+
#- Install deps
# # pacman -S python-requests python-pytz
#- Create script