Skip to content

Instantly share code, notes, and snippets.

View mnl's full-sized avatar

Micke Nimell mnl

View GitHub Profile
@mnl
mnl / docker build on push.md
Last active February 17, 2024 15:16
docker build hook

Build images on tag push

Prepare build machine / remote repo

  • Create remote repo (suffix .git is convention for bare repos) git init --bare myrepo.git

  • Add docker build hook cp post-receive.bash myrepo/hooks/post-receive

@mnl
mnl / 70-wifi-conditional-toggle.sh
Last active November 14, 2023 22:07
NetworkManager dispatcher script for wifi toggling
#!/bin/sh
# NetworkManager dispatcher script for /etc/NetworkManager/dispatcher.d/
# Turn off wifi only while ethernet has connection. Adapted from manpage.
# mnl@vandal.nu 2023
ethernet_connected() {
# Check if any ethernet connections are up
nmcli --terse --fields type,state device | while read -r
do
[ "${REPLY}" = ethernet:connected ] && return
FROM registry.access.redhat.com/ubi9/python-39
COPY ./src /opt/app-root
RUN source ../bin/activate && \
pip3 install -r ../requirements.txt
EXPOSE 8000
USER 1000

$argon2id$v=19$m=64,t=512,p=2$O+ZS3ATKcY+llIQmxxiMRA$KIc7L2CRiJ6G+tQ9K4shCA

@mnl
mnl / node_exporter-router.sh
Created February 19, 2023 12:14
Install/update Node Exporter on OpenWRT
#!/bin/sh
# Install, start and enable Prometheus Node Exporter
# on a OpenWRT system. Does not check for space!
# Overwrites any existing versions. Changing release before running should
# be enough to update node_exporter version.
set -e
# node_exporter release version
release="1.5.0"
@mnl
mnl / lockscreen.bash
Created November 26, 2022 12:18
swaylock with blurred screenshot
#!/bin/bash
# shellcheck disable=SC2086,SC2064
# vim: set ts=2 sw=2 tw=0 noet :
# Take screenshots, apply gaussian blur, lock screen
# grim -> blur -> swaylock
readonly GRIM=/usr/bin/grim
readonly BLUR="$HOME/bin/blur"
set -Eueo pipefail
@mnl
mnl / mount-waiter.sh
Created November 13, 2022 21:33
Wait for activating systemd mount units
#!/bin/bash
wait_for_mounts() {
local timestamp=$(date -d 1min +%s)
timeleft() {
[[ $(date +%s) -lt $timestamp ]] && return 0
return 1 # Timeout, $timestamp passed
}
activating_mounts() {
# Get list of units
@mnl
mnl / femtocom.sh
Created August 6, 2022 10:30
femtocom - super simple serial port handler
#!/bin/bash
# Adapted from https://unix.stackexchange.com/a/311680/81195
# I added tput, fuser and cleanup
if [[ $# -lt 1 ]]; then
echo "Usage:"
echo " femtocom <serial-port> [ <speed> [ <stty-options> ... ] ]"
echo " Example: $0 /dev/ttyS0 9600"
echo " Press Ctrl+Q to quit"
fi
@mnl
mnl / yaml.vim
Created June 5, 2022 22:46 — forked from iangreenleaf/yaml.vim
Dumb-smart indentation for Yaml
" Vim indent file
" Language: Yaml
" Author: Ian Young
" Get it bundled for pathogen: https://github.com/avakhov/vim-yaml
if exists("b:did_indent")
finish
endif
"runtime! indent/ruby.vim
"unlet! b:did_indent
@mnl
mnl / nginx.conf
Created September 1, 2021 19:03 — forked from phpdude/nginx.conf
Nginx image filter + caching of results.
location /resize {
alias /tmp/nginx/resize;
set $width 150;
set $height 100;
set $dimens "";
if ($uri ~* "^/resize_(\d+)x(\d+)/(.*)" ) {
set $width $1;
set $height $2;
set $image_path $3;