Skip to content

Instantly share code, notes, and snippets.

@crpb
crpb / blauton.sh
Created October 22, 2021 19:34
First draft for adding registered bluetooth speakers or headsets to ~/.asoundrc for #osmc #kodi
#!/usr/bin/env bash
IFS=$'\n' BLAU_OUTPUT=( $(echo "exit" |bluetoothctl |grep Device |cat -A |cut -c59-) )
lines=${#BLAU_OUTPUT[@]}
for i in ${BLAU_OUTPUT[@]}; do addr+=(${i:0:17}); name+=(${i:18}); done
SKEL='pcm.PCMNAME {\n
type plug\n
slave.pcm {\n
@crpb
crpb / probackup_invoke.sh
Created November 7, 2021 02:50
Helper Script and functions for pg_probackup with which i run my cronjob's. The functions are also useful for ~backupuser/.bashrc|.zshrc.
#!/bin/bash
shopt -s expand_aliases
export BACKUPDIR=/mnt/to/nfs/dedup/storage/postgres/pg_probackup
INSTANCES () { pg_probackup-13 show -B $BACKUPDIR --format json |jq -r '. [].instance' ;}
SHOWBACKUP () {
if [ -z $@ ]; then
pg_probackup-13 show -B $BACKUPDIR
else
pg_probackup-13 show -B $BACKUPDIR --instance $1
@crpb
crpb / dotfiles.sh
Last active February 13, 2022 07:50
Move all your beloved dotfiles to a subdirectory and automagically track changes with git
mkdir -p ~/.dotfiles
cd ~/.dotfiles
git init
cd ~/
find ~/ -maxdepth 1 -regextype posix-extended -regex '.*[.](bash|zsh|profile|Xresources|xinitrc|vimrc|function|alias|sig|tmux|xbind|netrc|nethack|fasd|viminfo|selected_editor|tool-versions).*' -type f,l -exec mv -t ~/.dotfiles/ '{}' \;
find ~/.dotfiles -maxdepth 1 -type f,l -exec ln -s -t ~/ '{}' \;
crontab -l | cat<<EOF |crontab -
*/5 * * * * bash -c "cd ~/.dotfiles && git add . && git commit -m \$(echo \$(date +\%Y\%m\%d\%H\%M))" >> /dev/null
EOF
@crpb
crpb / occ
Last active February 27, 2022 22:07
One OCC to maintain them all! Nextcloud, Owncloud-Possible OCC-Wrapper for local installations and Docker-Guests.
#!/usr/bin/env bash
SUDO=''
if [[ $EUID -ne 0 ]]; then
SUDO='sudo'
fi
if [ -f /var/www/nextcloud/occ ]; then
COMMAND="/usr/bin/php /var/www/nextcloud/occ"
if [[ $(whoami) != 'www-data' ]]; then
@crpb
crpb / preseed.cfg
Last active March 30, 2022 21:59
My Base Debian Seed Template for simple virtual Machines. The Disk-layout is on purpose to be able to extend the Disk with no further investigation on the Guest-Level with `echo 1 > /sys/block/sda/device/rescan && growpart /dev/sda 1 && resize2fs /dev/sda1`
d-i debian-installer/locale string en_US
d-i localechooser/supported-locales multiselect en_US.UTF-8, de_DE.UTF-8
d-i keyboard-configuration/xkb-keymap select us
d-i netcfg/get_hostname string debian-raw
d-i netcfg/get_domain string unassigned-domain
d-i anna/choose_modules string network-console
d-i network-console/authorized_keys_url string http://URLTO/pub.key
d-i network-console/password password INSERTCOINH3R3
d-i network-console/password-again password INSERTCOINH3R3
d-i mirror/country string manual
@crpb
crpb / fluxbox-apps-helper.sh
Last active April 9, 2022 01:26
Fluxbox Apps xprop shell-function to create an ~/.fluxbox/apps entry
#Fluxbox-Helper
fbxprop(){
echo -n "[app] "
xprop WM_CLASS WM_NAME WM_WINDOW_ROLE | sed 's/WM_\(.*\)(\(.*\)) = "//g;s/", "/\n/;s/"$//'| sed '1 s/^/(name=/;2 s/^/(class=/;3 s/^/(title=/;4 s/^/(role=/;s/$/)/g' | grep -v WM_WINDOW_ROLE |tr '\n' ' '
echo
echo "[end]"
}
/*
* This combined file was created by the DataTables downloader builder:
* https://datatables.net/download
*
* To rebuild or modify this file with the latest versions of the included
* software please visit:
* https://datatables.net/download/#dt/dt-1.11.3/af-2.3.7
*
* Included libraries:
* DataTables 1.11.3, AutoFill 2.3.7
@crpb
crpb / gen_hosts_yml.sh
Created May 21, 2022 04:44
ansible hosts.yaml generated from ssh_config files
#!/usr/bin/env bash
# Generate hosts.yaml from ssh_config-Includes
# Filename-Pattern "NNN_customer.ssh"
SRC="$HOME/git/ssh_config/*.ssh"
printf "all:\n children:\n"
for CONF in ${SRC}; do
BASE=$(basename "${CONF}")
GROUP=${BASE:4:-4}
HOSTS=$(awk '/^Host / {print $2}' "${CONF}"|sort|uniq)
printf ' %s:\n hosts:\n' "${GROUP}"
## vim: filetype=sh
# FARBSPIELE #
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
function red { printf "${RED}$@${NC}\n" ; }
function green { printf "${GREEN}$@${NC}\n" ; }
@crpb
crpb / zfsinst.sh
Last active September 10, 2022 12:42
minimal debian installation with zfs / one or two disks.. haven't tried with two disks yet.. attention, this script will destroy your data without any question :-)
#!/bin/sh
modprobe zfs || exit
apt-get update
apt-get install ntpdate jq --yes
ntpdate-debian
#zpool export -f bpool
#zpool export -f rpool
#swapoff --all
#mount |awk '/\/mnt/ {print $3}'|xargs -n 1 umount 2>/dev/null