Skip to content

Instantly share code, notes, and snippets.

View alainwolf's full-sized avatar

Alain Wolf alainwolf

View GitHub Profile
@alainwolf
alainwolf / ssh_config
Last active December 19, 2023 22:35
Make SSH use my IPv4 jump host only if the target host is unreachable by IPv6
# /etc/ssh/ssh_config
#
# All my hosts are reachable by IPv6 only. IPv6 addresses don't get spammed with SSH login probes.
# But what if I need to connect from a network which has no IPv6 enabled?
# Setup an SSH jump host which is reachable over IPv4 and use that only if the target host is unreachable by IPv6
#
Match host *.example.net,!ipv4.example.net !exec "ip route get $(host %h | grep 'IPv6 address' | awk '{print $NF}') &> /dev/null"
ProxyJump ipv4.example.net
@alainwolf
alainwolf / unbound-root-hints-update
Last active August 4, 2023 19:06
unbound-root-hints-update
#!/bin/bash
#
# Refresh list of Internet root servers from Internic
# See https://www.iana.org/domains/root/files
#
# Vars
REMOTE_URL="https://www.internic.net/domain/named.cache"
LOCAL_FILE="/var/lib/unbound/root.hints"
FILE_USER="unbound"
@alainwolf
alainwolf / mariabackup
Last active March 1, 2022 15:44
MariaDB Backup Scrip to be run on Synology NAS
#!/usr/bin/env bash
# ******************************************************************************
# MariaDB Backup Scrip to be run on Synology NAS
# (MariaDB 10.3.29-1038 package published by Synology Inc.)
#
# * Full online physical backups with mariabackup:
# - no databse downtime (as with physical copy or HyperBackup)
# - database caches are not affected (as with SQL-dumps)
# * Ensure only one single instance is running at same time
# * Ensure at least one successful full backup is present at all times
@alainwolf
alainwolf / domain_serial
Last active February 12, 2022 14:14
Compare Domain Serials of hidden primary server with public servers
#!/usr/bin/env bash
#
# Compare Domain Serials of hidden primary server with public servers
#
# Our hidden primary server
_PRIMARY_SERVER="dns0.example.net."
# The domain to query
_domain="$1"
@alainwolf
alainwolf / nextcloud-update-check
Last active May 13, 2022 15:27
Nextcloud Core Update Checker and Apps Updater
#!/bin/env ash
# shellcheck shell=dash
#
# Check Nextcloud core for available updates.
# * Update all Nextcloud apps to their latest available versions.
# * Notify if core update is available or any apps have been updated.
# * Stay silent otherwise (for cron-jobs or scheduled tasks).
# * Runs on standard Linux (Ubuntu, etc.), as well as Synology NAS DSM (if you get your settings right).
# * Works with different instances with dedicated Linux user profiles.
#
@alainwolf
alainwolf / occ
Created January 18, 2022 21:26
Nextcloud Command-Line Interface
#!/bin/env sh
# shellcheck shell=dash
#
# Nextcloud Command-Line Interface
#
# See https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html
#
# --------------------------------------------------
# Configuration Settings
#!/bin/env ash
# shellcheck shell=dash
#
# Nextcloud core and apps update checks
#
# Doesn't output anything, if everything is up to date.
# Usefull when executed by cron-jobs, to only receive a mail, if updates are
# available.
# See https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html
#
#!/bin/env ash
# shellcheck shell=dash
#
# Nextcloud command-line upgrades for Synology DiskStation system environments.
# See https://docs.nextcloud.com/server/stable/admin_manual/maintenance/update.html#using-the-command-line-based-updater
#
# Its recommended to disable Nextcloud cron jobs beforehand manuallly
# synoschedtask --get owner=root type=daily state=enabled
# --------------------------------------------------
#!/bin/bash
#
# Create new domains (or sub-domains) in PowerDNS authoritative servers
# using pdnsutil
#
# Features:
# * DNSSEC (incl. delegation in parent zone, if on same server);
# * NSEC3;
# * CAA;
# * SPF, DKIM and DMARC;
@alainwolf
alainwolf / Synology_backup.sh
Last active January 11, 2023 16:05
Synology DiskStation configuration backup
#!/bin/ash
#
# Synology DiskStation configuration backup
# Must be run as root
# Tested on
# DSM 6.1.6-15266 Update 1 - MARVELL Armada XP MV78230 (DS214+)
#
# Author: Alain Wolf <alain@alainwolf.ch> - https://gist.github.com/alainwolf/
# Date/Version: 2018-04-22/1.5
#