Skip to content

Instantly share code, notes, and snippets.

View zerwes's full-sized avatar
🤯
I may be slow to respond.

Klaus Zerwes zerwes

🤯
I may be slow to respond.
View GitHub Profile
#! /usr/bin/env ruby
require 'sophos/sg/rest'
require "resolv"
client = Sophos::SG::REST::Client.new(
'https://$RESTAPIUSER:$TOKEN@$URL:$PORT/api/',
fingerprint: '$CERTHASH')
typelist = ['host', 'group', 'network', 'range']
#! /bin/bash
#
# starts a new gnome terminal with a random profile selected
#
eval "PROFILES=( $(for p in $(dconf list /org/gnome/terminal/legacy/profiles:/ | sed '/^:/!d'); do dconf read /org/gnome/terminal/legacy/profiles:/${p}visible-name; done | grep -vi transparent) )"
gnome-terminal --window-with-profile "${PROFILES[$((RANDOM%${#PROFILES[@]}))]}" &
@zerwes
zerwes / ipsec.pl
Created January 4, 2018 12:48 — forked from rlsit/ipsec.pl
sophos SG restart stalled ipsec tunnels
#! /usr/bin/perl -w
use strict;
use warnings;
use Astaro::ConfdPlRPC;
use Data::Dumper;
use Try::Tiny;
my $restartall = 0;
@zerwes
zerwes / gist:b725b977b828c75736adf613dae695e8
Created March 14, 2018 13:16 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@zerwes
zerwes / gnome-terminal-profiles.adoc
Created October 16, 2019 08:32
Export / Import Gnome Terminal Profiles

Export Gnome Terminal Profile

List profiles

dconf dump /org/gnome/terminal/legacy/profiles:/

Determine the terminal profile string for the profile you will need. This is the terminal profile that I will export:

@zerwes
zerwes / opnsensefilterlogsplit.sh
Created June 8, 2021 03:23
opnsense filterlog split up in human readable format
#! /bin/sh
clog -f /var/log/filter.log | sed 's/ \+/,/g' | awk 'BEGIN { FS = "," } ; {print "iface:"$5" action:"$7" dir:"$8" proto:"$17" src:"$19" dst:"$20" sport:"$21" dport:"$22}'
@zerwes
zerwes / nmcli find psk
Created October 1, 2021 07:51
linux networkmanager: find passwords of stored wifi connections
## list connections
nmcli c
## get the password of a specific connection
## where XXX is the NAME or UUID from the list above
nmcli --show-secrets c show XXX | grep psk
@zerwes
zerwes / nmcli-vlan.md
Created November 18, 2021 08:39
nmcli vlan

add vlan interface

nmcli con add type vlan ifname VLAN1 dev enp0 id 1 where:

  • enp0 is the interface name
  • 1 the vlan ID

remove vlan interface

nmcli con del vlan-VLAN1
# alternative
ip link del
@zerwes
zerwes / haproxy.cfg
Created January 19, 2022 15:27 — forked from jriguera/haproxy.cfg
Haproxy for Multimaster MySQL cluster
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the '-r' option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
@zerwes
zerwes / sambadcrename.md
Last active February 19, 2022 18:06
rename the single DC in a samba domain

rename the single DC in a samba domain

samba backup and restore with new DC name

# service samba-ad-dc stop
# mkdir sambabackup-20220213-offline
# samba-tool domain backup offline --targetdir=/root/sambabackup-20220213-offline
# mv /var/lib/samba /var/lib/samba.bakup
# samba-tool domain backup restore --newservername=DC01 --backup-file=/root/sambabackup-20220213-offline/samba-backup-2022-02-13T19-38-42.702607.tar.bz2 --targetdir=/var/lib/samba
# vim /etc/samba/smb.conf # set new "netbios name"