Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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