Skip to content

Instantly share code, notes, and snippets.

View moqmar's full-sized avatar

Moritz Marquardt moqmar

View GitHub Profile
#!/bin/sh
# matrix-monitor.sh: a simple shell script to monitor service availability and report to a Matrix channel.
# Requirements:
# - matrix-commander (set up with --login to the room that should be used)
# - curl
# Usage: check my-service "$(curl my-service.example.org)" "<h1>Hello World</h1>" "My service unexpectedly doesn't say hello to the world."
TRIES=3
CHECK_ONLINE=1
PS1_usercolor=$([ $(id -u) -eq 0 ] && echo "31" || echo "34")
PS1=$(printf '\e[0;1m[\e[1;'$PS1_usercolor'm\\u\e[0;1m@\\h \e[1;33m\\w\e[0;1m]\\$\e[0m ')
# OpenWRT custom Dynamic DNS script for the hosting.de API.
# Set the password to your API key and the domain to the full FQDN of the DNS entry you want to change.
# TODO: try different zone names - currently only the root domain can be used.
HOSTINGDE_ENDPOINT=https://secure.hosting.de
HOSTINGDE_APIKEY="$password"
DOMAIN="$__VALUE"
RECORD_TYPE=A
if [ "$use_ipv6" = "1" ]; then RECORD_TYPE=AAAA; fi
TTL=60
@moqmar
moqmar / QuickAndDirtyLDAP.module
Created September 6, 2020 20:18
LDAP login module for ProcessWire admin - it's only "Quick and Dirty" as it's only built for our own use cases and hard-codes all the options currently, but it automatically updates users when they try to log in, checks for changed passwords, has group support, and deletes users who don't have access anymore if they log in
<?php
class QuickAndDirtyLDAP extends WireData implements Module, ConfigurableModule
{
// TODO: make those settings modifiable from the admin interface
private $LDAPServer = "ldaps://example.org:636";
private $LDAPBindUser = "cn=readonly,dc=example,dc=org";
private $LDAPBindPassword = "blubb";
private $LDAPSearchScope = "ou=users,dc=example,dc=org";
private $LDAPSearchFilter = "(|(uid=%u)(mail=%u))";
@moqmar
moqmar / ignition.json
Created March 9, 2020 17:02 — forked from thetechnick/ignition.json
Hetzner Cloud terraform coreos install
{
"ignition": {
"version": "2.0.0",
"config": {}
},
"storage": {
},
"systemd": {},
"networkd": {},
"passwd": {
@moqmar
moqmar / rollup.config.js
Created February 17, 2020 13:11
Rollup ready for Vue.js
import vue from "rollup-plugin-vue";
import postcss from "rollup-plugin-postcss";
import html2 from "rollup-plugin-html2";
import replace from "@rollup/plugin-replace";
import auto from "@rollup/plugin-auto-install";
import resolve from "@rollup/plugin-node-resolve";
import copy from "rollup-plugin-copy";
// yarn add --dev @rollup/plugin-auto-install @rollup/plugin-html @rollup/plugin-node-resolve @rollup/plugin-replace postcss rollup rollup-plugin-copy rollup-plugin-html2 rollup-plugin-postcss rollup-plugin-vue vue-template-compiler
@moqmar
moqmar / .bashrc
Last active February 23, 2024 06:57
My tiny & awesome .bashrc
###################################################################################################
# This is a very simple .bashrc file that I'm using on a daily basis. #
# It completely replaced my zsh setup, and should be relatively simple to understand and modify. #
# #
# Built by Moritz (mo-mar.de) - just do whatever you want with it, according to the Unlicense: #
# https://choosealicense.com/licenses/unlicense/ #
# #
# Simple installation: #
# wget https://go.momar.de/bashrc -O ~/.bashrc #
###################################################################################################
# Build the ubilinux kernel for the UP Boards. The script is built to be used with Docker.
# More information: https://wiki.up-community.org/Compile_ubilinux_kernel_from_source
# Usage: docker run -it --rm debian:9 sh -c 'wget ... && sh up-kernel-build.sh'
apt-get update
apt-get install -y git build-essential libncurses5-dev libssl-dev gcc g++ bc
git clone https://github.com/emutex/ubilinux-kernel.git -b upboard-4.9 linux-upboard
cd linux-upboard
make upboard_defconfig
@moqmar
moqmar / setup.sh
Last active February 5, 2019 20:46
#!/bin/sh
# Setup Packages
pacman -S yay
mkdir -p ~/.local/bin
wget https://gist.githubusercontent.com/moqmar/450ac6592028c742177bae71705e6e16/raw/autoyay -O ~/.local/bin/autoyay
chmod +x ~/.local/bin/autoyay
autoyay
# Setup Syncthing
@moqmar
moqmar / autoyay
Last active January 31, 2019 12:38
Bash script to apply a text file with a list of packages to add (package) and remove (!package) to an Arch-based system using yay. Written to keep two computers in sync, but can be used for a lot of purposes. The packages can be separated using spaces or newlines; line comments starting with # are supported, too.
#!/bin/sh
set -eu
IFS=$'\n\t'
# Bash script to apply a text file with a list of packages to add (package) and remove (!package) to an Arch-based
# system using yay. Written to keep two computers in sync, but can be used for a lot of purposes.
# The packages can be separated using spaces or newlines; line comments starting with # are supported, too.
# The packages file can be defined as a command line argument.
# Otherwise, it'll be taken from $XDG_PUBLICSHARE_DIR/packages.