Skip to content

Instantly share code, notes, and snippets.

View wopfel's full-sized avatar

Bernd Arnold wopfel

  • Bavaria, Germany
View GitHub Profile
@wopfel
wopfel / gist:6150628
Last active December 20, 2015 14:59
My steps for creating an encrypted ArchLinux installation based on LVM inside a virtual machine. Meine Schritte zum Erstellen einer verschlüsselten, auf LVM basierenden ArchLinux-Installation innerhalb einer virtuellen Maschine.
Boot: archlinux-2012.10.06-dual.iso
Boot: archlinux-2012.11.01-dual.iso
Boot: archlinux-2013.01.04-dual.iso
Netzwerkkarte auf Bridge stellen, dann mit Putty einwählen
passwd ; /etc/rc.d/sshd start
loadkeys de-latin1 (loadkezs deßlatin1)
cfdisk /dev/sda
@wopfel
wopfel / Info.md
Last active December 28, 2015 11:59
A tiny backup script using CloneZilla Live 2.1.2.-43. The output directory is named dynamically (YYYY-MM-DD_HHMMSS-img-...) and created under /home/partimag by ocs-sr. The first three partitions are backed up (sda1, sda2, and sda3).

Steps

  • Boot from Clonezilla Live CD
  • Select "Clonezilla live" (default entry in boot menu)
  • Choose keyboard language
  • Select "Enter shell"
  • Choose "cmd" mode
  • If the script resides on /dev/sdb1, then "mount /dev/sdb1 /home/partimag" now (the mount inside the script will fail, but that doesn't matter)
  • Run script ("sudo ...")
@wopfel
wopfel / gist:8071781
Created December 21, 2013 16:42
Wait until a process ends (Linux, /proc filesystem, PID subdirectory, 14989 is the process ID in this example)
while [[ -d /proc/14989/ ]] ; do sleep 1 ; done
@wopfel
wopfel / copy-loop.cmd
Created June 1, 2014 11:46
Copy a file inside a diretory to a new file with a random name to fill (almost) all space
:beginn
cd /d F:\DCIM\100EOS7D
copy IMG_5239.CR2 %RANDOM%.DAT
goto beginn
@wopfel
wopfel / sync-wedding-pictures.cmd
Created June 1, 2014 11:50
Synchronize (make a backup of) a folder in a loop; used during photographing a wedding ceremony; a backup is automatically created after importing the photos into the Lightroom catalog
ping -n 3600 localhost
:beginn
robocopy M:\Lightroom-Bilder\2013\2013-06-15 E:\kopie_hochzeit\ /e
ping -n 30 localhost
goto beginn
@wopfel
wopfel / backup-mysql-db
Created July 13, 2014 11:23
Backup script for MariaDB (or MySQL). Placed in /etc/cron.hourly/. Creates a backup of all databases every hour and keeps the current plus nine previous versions.
#!/bin/bash
BASENAME="/var/backups/MySQL-Backup.gz"
x=9
rm "$BASENAME.$x"
while [ $x -gt 1 ]
do
y=$(( $x - 1 ))
@wopfel
wopfel / gist:3ef099fef3687d010255
Last active August 29, 2015 14:10
Raspberry Pi timelapse video (create pictures and create video). Sample values can/must be replaced.
# Create pictures ...
DESTDIR=/mnt/timelapse/series_$RANDOM && mkdir $DESTDIR && /opt/vc/bin/raspistill -o $DESTDIR/`date '+%Y-%m-%d'`_pic_%04d.jpg -t 7999000 -tl 15000
# Sample picture name including path is:
# /mnt/timelapse/series_15554/2014-12-02_pic_0001.jpg
# Create video ...
cd /mnt/timelapse/series_15554
ffmpeg -n -pattern_type glob -r 15 -i "2014-12-02_pic_*.jpg" -r 15 -vcodec libx264 -crf 25 -g 15 -vf crop=2592:1458,scale=1280:720 timelapse_2014-12-02.mp4
@wopfel
wopfel / fswebcam-loop.sh
Created August 23, 2016 17:30
Save a webcam picture every x seconds (suitable for a timelapse). Created on a Raspberry Pi 3 running Arch Linux.
#!/bin/bash
# Exit script if /mnt is not mounted somewhere
# Prevents filling the root filesystem (/)
if ! mountpoint /mnt ; then
>&2 echo "Error: No mountpoint."
exit 1
fi
# Endless loop
@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
@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