From 6a8edca4744788955b1f58ab8a5471fd9b1909f3 Mon Sep 17 00:00:00 2001 From: c0dev0id Date: Thu, 12 Dec 2024 18:56:36 +0100 Subject: [PATCH] Update 2024-12-12 18:56 OpenBSD/amd64-t14 --- .bin/clear-dl | 11 +++ .bin/gpgfile.sh | 130 +++++++++++++++++++++++++++++++++ .bin/selfhost-update.sh | 13 ++++ .config/spectrwm/spectrwm.conf | 10 +-- .config/zim/style.conf | 2 +- 5 files changed, 160 insertions(+), 6 deletions(-) create mode 100755 .bin/clear-dl create mode 100755 .bin/gpgfile.sh create mode 100755 .bin/selfhost-update.sh diff --git a/.bin/clear-dl b/.bin/clear-dl new file mode 100755 index 0000000..abb4286 --- /dev/null +++ b/.bin/clear-dl @@ -0,0 +1,11 @@ +#!/bin/sh + +find . -maxdepth 1 | grep -v ^.$ \ + | while read file +do + date="$(stat -f "%Sm" -t %Y-%m "$file" )" + [ OLD-$date ] && mkdir -p OLD-$date + [ "$file" != "./OLD-$date" ] \ + && mv "$file" OLD-$date/ +done +echo done. diff --git a/.bin/gpgfile.sh b/.bin/gpgfile.sh new file mode 100755 index 0000000..02b0e64 --- /dev/null +++ b/.bin/gpgfile.sh @@ -0,0 +1,130 @@ +#!/bin/sh + +# for shellrc: +# alias encrypt-kasse="gpgfile.sh -k 52BE43BA -k 7A97EAD5 -k 8AFDAD2D -e /path/to/kassenbuch.odt" +# alias decrypt-kasse="gpgfile.sh -d -e /path/to/kassenbuch.odt.gpg" +# alias encrypt-documents="gpgfile.sh -k 7A97EAD5 -e /path/to/documents" +# alias decrypt-documents"gpgfile.sh -d -e /path/to/documents.tar.gpg" + +### functions +usage() { + echo "usage: $(basename $0) " + echo "options:" + echo " -k key id (can be supplied multiple times)" + echo " -e encrypt files or directories (requires -k)" + echo " -d decrypt files or directories" + echo "note: directories will be wrapped in tar(1)" + exit 2 +} + +### main program + +# parse arguments +while getopts 'k:edh' arg +do + case ${arg} in + k) keylist="$keylist -r $OPTARG" ;; + e) encrypt=1 ;; + d) encrypt=0 ;; + h) usage ;; + ?) usage ;; + esac +done +# shift parsed arguments out of the way $1 starts now with fiels/dirs +shift $(($OPTIND - 1)) + +# print usage, if no file/dir argument is provided +[ -z "$1" ] && usage + +### handle encryption (set by -e) +if [ "$encrypt" -eq "1" ] +then + + # no key? + [ -z "$keylist" ] \ + && echo "ERROR: Encryption mode (-e) needs a key (-k), which was not provided." \ + && exit 1 + + # loop at provided files + for item in $@ + do + # Work in a subshell so dir changes won't be persistent. + # Due to this, we "return" instead of "continue". + # This is needed because we don't want to include the + # basedir hierarchy in tar files. + ( + + # change working directory + cd "$(dirname $item)" + item="$(basename $item)" + + # don't handle non existant files + readlink -f "$item" > /dev/null 2>&1 \ + || { echo "$item: skipped: file not found" \ + && return; } + + # don't re-encrypt gpg files + [ "${item##*.}" == "gpg" ] \ + && echo "$item: skipped: already gpg encrypted" \ + && return + + # handle directory: tar + gpg, then remove original dir + tar + [ -d "$item" ] \ + && echo "$item -> $item.tar" \ + && tar -cf "$item.tar" "$item" \ + && rm -rf "$item" \ + && item="$item.tar" + # no return: fallthrough to next handler + + # handle files: gpg, then remove original file + [ -f "$item" ] \ + && echo "$item -> $item.gpg" \ + && gpg -q -e $keylist -o "$item.gpg" "$item" \ + && rm -f "$item" + + ) # exit subshell + done +fi + +### handle decryption (set by -d) +if [ $encrypt -eq 0 ] +then + for item in $@ + do + # Work in a subshell so dir changes won't be persistent. + # Due to this, we "return" instead of "continue". + # This is needed because we don't want to include the + # basedir hierarchy in tar files. + ( + + # change working directory + cd "$(dirname $item)" + item="$(basename $item)" + + # don't handle non existant files + readlink -f "$item" > /dev/null 2>&1 \ + || { echo "skipping: $item (reason: file not found)" \ + && return; } + + # don't handle files that are not gpg encrypted + [ ${item##*.} != "gpg" ] \ + && echo "skipping: $item (reason: not a gpg file)" \ + && return + + # handle file: decrypt with gpg + delete encrypted version + [ ${item##*.} == "gpg" ] \ + && echo "$item -> ${item%.*}" \ + && gpg -q -d -o "${item%.*}" "$item" \ + && rm -f "$item" \ + && item="${item%.*}" + # no return: fallthrough to next handler + + # handle tar: if file ends in tar after decryption, untar it and delete the tar. + [ ${item##*.} == "tar" ] \ + && echo "$item -> ${item%.*}" \ + && tar xf "$item" \ + && rm -f "$item" + + ) # exit subshell + done +fi diff --git a/.bin/selfhost-update.sh b/.bin/selfhost-update.sh new file mode 100755 index 0000000..7ec62fa --- /dev/null +++ b/.bin/selfhost-update.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# Selfhost DynDns Update +# Usage: +# IPv4 Update: selfhost-update.sh +# IPv6 Update: selfhost-update.sh -6 +# Note, min 30 seconds between calls! (rate limit) + +ID=$(pass Internet/selfhost.de | grep DynDnsUser | cut -d" " -f2) +PW=$(pass Internet/selfhost.de | grep DynDnsPass | cut -d" " -f2) + +set -x +curl $1 "https://$ID:$PW@carol.selfhost.de/nic/update?textmodi=1" diff --git a/.config/spectrwm/spectrwm.conf b/.config/spectrwm/spectrwm.conf index a0583a7..2104599 100644 --- a/.config/spectrwm/spectrwm.conf +++ b/.config/spectrwm/spectrwm.conf @@ -193,13 +193,13 @@ program[xconsole] = xcons bind[xconsole] = MOD+Shift+minus program[screenshot_wind] = sshot -bind[screenshot_wind] = Print +bind[screenshot_wind] = MOD+Super_L -program[xcolor] = xcolorcopy -bind[xcolor] = MOD+Print +# program[xcolor] = xcolorcopy +# bind[xcolor] = MOD+Super_L -program[xmenu] = myxmenu -bind[xmenu] = Super_L +#program[xmenu] = myxmenu +#bind[xmenu] = MOD+Super_L program[lock] = /usr/bin/false diff --git a/.config/zim/style.conf b/.config/zim/style.conf index d90c3aa..109f17c 100644 --- a/.config/zim/style.conf +++ b/.config/zim/style.conf @@ -4,7 +4,7 @@ indent=30 tabs=None linespacing=3 wrapped-lines-linespacing=0 -font=FuraCode Nerd Font Mono weight=450 18 +font=FuraCode Nerd Font Mono weight=450 14 justify= background=#cccccc