Skip to content

Instantly share code, notes, and snippets.

View wopfel's full-sized avatar

Bernd Arnold wopfel

  • Bavaria, Germany
View GitHub Profile
set HEUTE=%date:~6,4%-%date:~3,2%-%date:~0,2%
mkdir %HEUTE%
pause
@wopfel
wopfel / check_pihole_updates
Created August 13, 2020 17:45
A check script for Icinga // checks for pihole updates
#!/usr/bin/perl
use strict;
use warnings;
# Sample output:
# pihole2# pihole -up --check-only
# [i] Checking for updates...
# [i] Pi-hole Core: update available
# [i] Web Interface: update available
@wopfel
wopfel / js2json.pl
Created September 28, 2019 15:17
Read a .js file from STDIN and write JSON-compatible output (suitable for jq)
#!/bin/perl
# Description:
# Read a .js file from STDIN and write JSON-compatible output (suitable for jq)
# The input file in the format ...
# var data = { "run": [...
# cannot be read by jq directly. This script transforms a javascript file to json output.
use strict;
@wopfel
wopfel / create-lxc-container.sh
Last active September 28, 2019 17:19
Create lxc container on a Proxmox VE host
#!/bin/bash
NEXTID=518
LXCNAME=testct3
LXCIP=192.168.2.178
#TEMPLATE=archlinux-base_20190426-1_amd64.tar.gz
TEMPLATE=ubuntu-19.04-standard_19.04-1_amd64.tar.gz
OSTYPE=${TEMPLATE%%-*}
lvcreate -V8G -T vg_ssd_evo/vms3 -n vm-$NEXTID-disk-0
@wopfel
wopfel / test-image.php
Created November 27, 2018 19:45
Detect LED state from image created by Raspberry Pi (raspistill)
<?php
#
# PiCam is placed on Buderus control panel
# /opt/vc/bin/raspistill -ISO 200 -t 3000 -rot 270 -awb shade -o /tmp/test.jpg
#
# Sorry, this may be a poor description
#
$img = imagecreatefromjpeg( "/tmp/test.jpg" );
@wopfel
wopfel / prepare-sd-card.sh
Last active November 17, 2018 17:53
Prepare SD card for Raspberry Pi / ArchLinuxARM
#!/bin/bash
# Call: ./prepare-sd-card.sh /dev/sdX
# Danger! May wipe the wrong data...
exit 99
# This script also copies a public key to the SSH authorized_keys file for the root user (ansible, here)
set -e
@wopfel
wopfel / show-data-as-matrix.md
Last active August 14, 2018 14:45
Show a=b data from text lines as grid / matrix

Show data as grid / matrix

Assuming you have an input file like this one ...

horse	green
horse	blue
dog	green
dog	red
dog	yellow
@wopfel
wopfel / Icinga.md
Last active July 4, 2018 15:21
Software updates

Updating my Icinga 2 VM

pacman -Syu

cd ~/icinga2
git pull
cd build
cmake -DICINGA2_WITH_PGSQL=OFF -DUSE_SYSTEMD=ON -DCMAKE_INSTALL_PREFIX=/usr/local/icinga2 -DICINGA2_PLUGINDIR=/usr/local/icinga/libexec -DCMAKE_INSTALL_LOCALSTATEDIR=/usr/local/icinga2/var ..
make -j2
@wopfel
wopfel / delete-old-hourly-backups
Created June 16, 2018 13:17
Delete old backups
#!/usr/bin/perl
use strict;
use warnings;
use File::Path qw( remove_tree );
# Call it by ./delete-old-hourly-backups DIRNAME
# Keeps exactly 1 backup directory per day
# Assumes the following directory structure below DIRNAME/:
# back-2018-01-15T13_15_00
@wopfel
wopfel / basic-setup-archlinux-vm
Last active September 3, 2017 09:03
Basic setup for an Arch Linux VM
#!/bin/bash
# Basic setup for an Arch Linux VM
# Usage in a fresh VM (example):
# # script -c 'bash basic-setup-archlinux-vm' --timing=/tmp/capture-timing /tmp/capture
# # cp /tmp/capture /mnt/root/script-installation-recording
# # cp /tmp/capture-timing /mnt/root/script-installation-recording-timing
# Exit script on any error
set -e