Skip to content

Instantly share code, notes, and snippets.

View pschichtel's full-sized avatar

Phillip Schichtel pschichtel

View GitHub Profile
@pschichtel
pschichtel / README.md
Created November 29, 2024 01:09
Restic Backups on Windows

Installation

  1. Place the script resticbackup.cmd into C:\Windows
  2. Customize the script (S3 credentials, S3 endpoint, folders, ...)
  3. Create the file C:\Windows\resticbackup.password containing the restic repository password
  4. Install the restic binary at C:\Windows\restic.exe
  5. Create a task in Windows' task scheduler application that executes the C:\Windows\resticbackup.cmd script as an action on the desired schedule (e.g. nightly).
@pschichtel
pschichtel / minio-k0s-reproducer.sh
Created August 14, 2024 17:41
This is a script that creates a single-node k0s cluster, deploys the minio operator and a single tenant with a single pool with a single disk. It then displays a couple of commands that show how to interact with the setup. Depending on your internet connection the setup might take a couple of minutes to become ready. Most, but not all data will …
#!/usr/bin/env bash
# Required binaries:
# * k0s
# * kubectl
# * helm
# * cut
# * grep
# * ip
# * hostname
@pschichtel
pschichtel / direct-grant-auth.sh
Last active May 30, 2024 18:30
A simple example for a script that can be used with FreeRADIUS to authenticate a user against an oauth server that supports the 'Resource Owner Password Credentials Grant' (grant=password). It requires bash, jq and cut.
#!/usr/bin/env bash
set -euo pipefail
username="${USER_NAME?No User-Name found!}"
password="${USER_PASSWORD?No Password found!}"
token_endpoint="${OIDC_TOKEN_ENDPOINT?No Oidc-Token-Endpoint!}"
client_id="${OIDC_CLIENT_ID?No Oidc-Client-Id!}"
client_secret="$(< "${OIDC_CLIENT_SECRET_FILE?No Oidc-Client-Secret-File!}")"
@pschichtel
pschichtel / migrate-sc.sh
Created May 13, 2024 00:49
A small script to migrate PVCs and their data to a new storage class. It requires bash, kubectl, yq, jq and [pv-migrate](https://github.com/utkuozdemir/pv-migrate).
#!/usr/bin/env bash
set -euo pipefail
namespace="${1?no namespace}"
source_pvc="${2?no source pvc}"
target_sc="${3?no target SC}"
tmp_pvc_name="${source_pvc}-tmp"
@pschichtel
pschichtel / fetch-adlists-rpz.sh
Created May 10, 2024 01:23
A simple bash script that can be used to fetch various DNS ad filter lists in either rpz or /etc/hosts format.
#!/usr/bin/env bash
set -euo pipefail
fetch_hosts_as_rpz() {
local action="${1?no action!}"
local destination="${2?no destination!}"
shift 2
if [ $# = 0 ]
#!/usr/bin/env bash
set -euo pipefail
target_dir="${1?no target dir!}"
if [ -e "$target_dir" ]
then
echo "$target_dir already exists!" >&2
exit 1
fi
@pschichtel
pschichtel / unpack-legacy-p12.sh
Last active November 17, 2022 19:05
pfSense generates legacy p12 files which are not compatible with latest OpenSSL 3. This script unpacks the p12 file into separate PEM files, which work nicely with GNOME's network management stuff. See: https://github.com/openssl/openssl/commit/15c9aa3aef77c642ef2b6c84bba2b57b35ed083e
#!/usr/bin/env bash
input="${1?no input}"
key_output="${2?no key output}"
crt_output="${3?no crt output}"
ca_output="${4?no ca output}"
openssl pkcs12 -legacy -in "$input" -out "${key_output}" -nocerts -nodes
openssl pkcs12 -legacy -in "$input" -out "${crt_output}" -clcerts -nokeys
openssl pkcs12 -legacy -in "$input" -out "${ca_output}" -cacerts -nokeys
@pschichtel
pschichtel / CustomLocalValidatorFactoryBean.kt
Created August 17, 2021 14:53
SuspendAwareKotlinParameterNameDiscoverer
import org.hibernate.validator.internal.engine.DefaultClockProvider
import org.springframework.core.LocalVariableTableParameterNameDiscoverer
import org.springframework.core.PrioritizedParameterNameDiscoverer
import org.springframework.core.StandardReflectionParameterNameDiscoverer
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean
import java.lang.reflect.Constructor
import java.lang.reflect.Method
import javax.validation.ClockProvider
import javax.validation.Configuration
import javax.validation.ParameterNameProvider
@pschichtel
pschichtel / saml_helpers.sh
Created March 7, 2021 19:59
Keycloak SAML helpers
keycloak_to_pem() {
input="$(mktemp)"
echo "-----BEGIN $1-----" > "$input"
echo "$2" >> "$input"
echo "-----END $1-----" >> "$input"
output="$(mktemp)"
case "$1" in
"CERTIFICATE")
openssl x509 -inform PEM -in "$input" -out "$output"
;;
@pschichtel
pschichtel / .gitlab-ci.yml
Created February 7, 2021 02:10
Gitlab CI setup to build the discourse docker image on a docker-based gitlab-runner
services:
- name: postgres:12-alpine
alias: bootstrap-postgres
- name: redis:6
alias: bootstrap-redis
variables:
POSTGRES_DB: bootstrap
POSTGRES_USER: bootstrap
POSTGRES_PASSWORD: ''