Skip to content

Instantly share code, notes, and snippets.

View aduzsardi's full-sized avatar
🛠️
d(0_0)b

Alexandru Duzsardi aduzsardi

🛠️
d(0_0)b
View GitHub Profile
@aduzsardi
aduzsardi / dhcp_119_dns.ps1
Created July 25, 2017 07:51
generate dhcp option 119 (DNS Search Suffix) powershell script
# ----------------------------------------------------------------------------------------------------------
# PURPOSE: Creates a byte array for use with DHCP Option 119
#
# VERSION DATE USER DETAILS
# 1 07/03/2016 Craig Tolley First version
# 1.1 08/03/2016 Craig Tolley Fixed issue where if the whole domain matched the pointer was incorrect
# 1.2 08/03/2017 Craig Tolley Fixed further issues where the whole domain was matched the pointers are incorrect
# Modified outputs and tidied some formatting
# Convert-StringToOpt119Hex option fixed to not return values for null/empty strings
#
@aduzsardi
aduzsardi / kubectl-decode_secret
Created April 26, 2023 15:05
kubectl plugin to base64 decode secrets data
#!/bin/bash
# Install: put this in an executable file named `kubectl-decode_secret` , which is in your PATH
# Usage: kubectl decode-secret <secret-name>
#
# Note: the script is using fzf (https://github.com/junegunn/fzf) , for example if you just type `kubectl decode-secret`
# it will list the screts and you can select whichever you want
kubectl get secret $(kubectl get secret | sed 1d | fzf | awk '{ print $1 }') --template='{{ range $key, $value := .data }}{{ printf "%s: %s\n" $key ($value | base64decode) }}{{ end }}'
@aduzsardi
aduzsardi / interfaces
Last active January 6, 2023 01:46
GRE VPN Tunnel - Linux (Ubuntu)
# Configurare GRE tunel (VPN) on Ubuntu Linux
# There are two ubuntu servers acting as routers on their own LAN networks 172.18.17.0/24 , 172.18.18.0/24 respectively
# Each of the servers also have public IP address
# configure /etc/network/interfaces on the servers adding *gre1* interface
#Ubuntu1 - 192.168.168.1/30 is the local IP address on the gre1 interface , this IP will comunicate with the remote gre1 tunnel interface for routing
# - <post-up> command: 172.18.18.0/24 which is the remote LAN is routed through the tunnel to 192.168.168.2
auto gre1
iface gre1 inet tunnel
address 192.168.168.1
@aduzsardi
aduzsardi / ansible_filter_plugin.py
Created August 8, 2022 05:06
Ansible filter plugin example
#!/usr/bin/env python3
from passlib.totp import TOTP
from ansible.module_utils._text import to_text
class FilterModule(object):
def filters(self):
return {
'totpcode': self.totpcode
}
@aduzsardi
aduzsardi / docker-volumes-clean.sh
Last active January 19, 2021 10:32
Remove docker volumes that have not been used for a time
#!/bin/bash -e
### Author: Alex Duzsardi
### Twitter: @aduzsardi
### GitHub: @aduzsardi
### Keybase: @aduzsardi
### Requirements: bash, date, docker, jq
# Remove docker volumes last used more than a month ago
#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.
@aduzsardi
aduzsardi / gist:ce194be2c7798850303ff780938a3604
Created August 21, 2020 07:21 — forked from hgross/gist:26042d052f58feeb6d1b329e8dd2dfcc
Change docker_gwbridge subnet address
## Do this on each swarm-node
# store containers attached to the bridge
$ gwbridge_users=$(docker network inspect --format '{{range $key, $val := .Containers}} {{$key}}{{end}}' docker_gwbridge | \
$ xargs -d' ' -I {} -n1 docker ps --format {{.Names}} -f id={})
# stop all containers
# if you have stacks that restart automatically, remove them via docker stack <stackName> rm
$ echo "$gwbridge_users" | xargs docker stop
$ docker network rm docker_gwbridge
$ docker network disconnect -f docker_gwbridge gateway_ingress-sbox
@aduzsardi
aduzsardi / swarm-output.json
Created August 15, 2020 18:55
docker swarm inspect infromation - json output
docker node inspect self --format '{{json .}}' | jq .
{
"ID": "misdcojgeuz8ps4v1w93apoiz",
"Version": {
"Index": 443
},
"CreatedAt": "2020-08-08T21:58:17.93412711Z",
"UpdatedAt": "2020-08-15T12:15:50.442472266Z",
"Spec": {
"Labels": {},
@aduzsardi
aduzsardi / httproxy.sh
Last active July 29, 2020 13:41
inlets bash helper function
# add this to your .bashrc
# call it with httproxy http://proxied-url.tld
httproxy() {
local bold='\e[1m' reset='\e[0m' bright='\e[37m'
local info='\e[96m' warn='\e[93m' error='\e[91m'
local helpmsg=$(cat <<HELP
${info}Usage:${reset}
${bright}${FUNCNAME[0]} <proxied-url>${reset}
@aduzsardi
aduzsardi / mask2cdr
Created April 23, 2020 14:23 — forked from RichardBronosky/mask2cdr
Convert netmask to CIDR
#!/bin/bash
# Based on https://stackoverflow.com/questions/20762575/explanation-of-convertor-of-cidr-to-netmask-in-linux-shell-netmask2cdir-and-cdir
mask2cdr ()
{
local mask=$1
# In RFC 4632 netmasks there's no "255." after a non-255 byte in the mask
local left_stripped_mask=${mask##*255.}
local len_mask=${#mask}