Skip to content

Instantly share code, notes, and snippets.

View dannysauer's full-sized avatar

Danny Sauer dannysauer

View GitHub Profile
@dannysauer
dannysauer / keybase.md
Created February 16, 2021 22:03
keybase.md

Keybase proof

I hereby claim:

  • I am dannysauer on github.
  • I am dannysauer (https://keybase.io/dannysauer) on keybase.
  • I have a public key ASB_nYLw_XvDJ7TQ9OQQDjxS5QMqfCd_UL8z_jbXKWpFwAo

To claim this, I am signing this object:

@dannysauer
dannysauer / notes.md
Created December 28, 2020 23:53
windows Linux setup
# /etc/systemd/system/importscannerdisk.service
[Unit]
Description=Import images from scanner SSD card
Requires=media-sauer-DOCSCAN.mount
After=media-sauer-DOCSCAN.mount
[Service]
ExecStart=/bin/true
[Install]
@dannysauer
dannysauer / readme.md
Created July 30, 2020 02:27
Script to sync fork's head branch with upstream

When I fork a repo, I checkout out my fork as origin and add a remote for the upstream repo as upstream. I hate having a fork where the default (usually called master) branch is way out of date, though. So this gets run from a scheduler to walk through checked out repos under a couple of directories in $HOME/dev, figure out the default branch, and sync that with the same-name branch in my fork.

The main interesting thing it does is to use a worktree. So it doesn't need to check out the whole repo again, but also doesn't disturb my main working repository. It also uses a unique temporary directory and a branch with the same name to do the sync, as I couldn't get it to work properly without creating a branch. I could swear I had made that work before (completely avoiding a branch name), but I can't for the life of me remember how. :D The tempname should be unique enough.

@dannysauer
dannysauer / corefiles.pl
Last active April 18, 2020 18:02
perl script to drop into /etc/cron.hourly (or whatever) to clean up core files
#!/usr/bin/perl
# drop into /etc/cron.hourly (or whatever) to clean up core files
use warnings;
use strict;
use File::Find;
use File::LibMagic;
use Number::Bytes::Human;
sub wanted;
@dannysauer
dannysauer / perms.py
Last active February 5, 2020 00:05
Fix perms after installing package `foo` on SUSE / OpenSUSE via YaST
#!/usr/bin/env python
#
# Reset perms on a file after installing an RPM
#
import os
import json
import logging
from pwd import getpwnam
from grp import getgrnam
# from stat import *
@dannysauer
dannysauer / install process
Created December 28, 2019 20:13
Zoneminder on Ubuntu 19.10
# configure PHP Timezone
sed -ne "s|\\(date.timezone =\\).*|\\1 $(< /etc/timezone )|p" /etc/php/7.3/apache2/php.ini
@dannysauer
dannysauer / "Static" IP notes.md
Last active December 4, 2019 22:02
Firewall stuff

Rather than set up static IPs in VMs, I'd prefer to use DHCP and just have static assignments. This is basically how I do that:

List the interfaces:

for H in $( sudo virsh list --name | grep proxy ); do echo $H; sudo virsh --quiet domiflist --domain $H; done

For each interface's MAC, add a static lease:

sudo virsh net-update proxynet add-last ip-dhcp-host '<host mac="52:54:00:02:e1:aa" ip="192.168.42.10" />' --live --config
@dannysauer
dannysauer / clone.sh
Last active April 3, 2020 05:39
kvm cloning script
#!/bin/bash
# usage: clone.sh [source_domain] target_domain [target_domain_2 ...]
# note - if you want to make more than one clone, you must specify the source.
set -o errexit
SRC=sle15sp1
if (( ${#@} > 1 ))
then
SRC="$1"
shift
@dannysauer
dannysauer / summary.md
Last active October 29, 2019 13:49
testing with proxy
  1. Set up a virtual network that uses nat
  2. Build machines using that network
  3. Figure out what bridge device this network is using (my example is "hundrednet")
    1. virsh net-info hundrednet | grep -i bridge
  4. Configure that network to only communicate internally and to the proxy
    1. sudo iptables -L FORWARD --line-numbers --verbose
    2. find the line for this network like 7 66 7322 ACCEPT all -- virbr2 any 192.168.100.0/24 anywhere
    3. replace that line (line 7 in the example) with one that only accepts traffic to the proxy: sudo iptables -R FORWARD 7 -i virbr2 -s 192.168.100.0/24 -p tcp --dport 3128 -j ACCEPT Note that this uses the same input interface (-i), the same source range (-s), and adds TCP protocol and destination port 3128