Skip to content

Instantly share code, notes, and snippets.

View jordiclariana's full-sized avatar

Jordi Clariana jordiclariana

View GitHub Profile
@jordiclariana
jordiclariana / inotify_list.sh
Created January 30, 2024 15:18
List watched files by a PID
#!/usr/bin/env bash
set -e
LIST="$(grep inotify /proc/"$1"/fdinfo/* | \
awk '{print $3,$4}' | \
sed -r 's/ino:([^ ]+) sdev:(.{2})(.*)/\1 \2 \3/' | \
while read -r inode devmajor devminor; do
dec_inode=$((16#$inode))
dec_devmajor=$((16#$devmajor))
@jordiclariana
jordiclariana / 01-multus-k3s.md
Created October 29, 2023 13:52 — forked from janeczku/01-multus-k3s.md
Multus CNI with k3s and RKE

Using Multus CNI in K3S

By default, K3S will run with flannel as the CNI and use custom directories to store CNI plugin binaries and config files(You can inspect the kubelet args K3S uses via journalctl -u k3s|grep cni-conf-dir). So you need to configure that properly When deploying Multus CNI.

For example given the official Multus manifests in https://github.com/intel/multus-cni/blob/36f2fd64e0965e639a0f1d17ab754f0130951aba/images/multus-daemonset.yml, the following changes are needed:

volumes:
 - name: cni
@jordiclariana
jordiclariana / add_to_bashrc.sh
Created April 7, 2022 08:34 — forked from vyaslav/add_to_bashrc.sh
aliases for kubectl with autocomplete
source <(kubectl completion bash)
__start_kubectl_cust()
{
local cur prev words cword
declare -A flaghash 2>/dev/null || :
if declare -F _init_completion >/dev/null 2>&1; then
_init_completion -s || return
else
__kubectl_init_completion -n "=" || return
fi
@jordiclariana
jordiclariana / secure-gcp-checklist.md
Created February 22, 2022 08:48 — forked from mikesparr/secure-gcp-checklist.md
Secure Google Cloud Platform Checklist

Secure GCP infrastructure checklists

Initial setup

  • Configure org policies
    • Restrict allowed IAM domains
    • Disable key download
    • Disable default network
    • Disable external IP
    • Require shielded VM
  • Prepare for VPC service controls (data protection)
@jordiclariana
jordiclariana / tf_plan_simple_color.sh
Created July 14, 2021 13:45
Run Terraform plan or get a plan output, show only resources names to be changed and color the relevant parts
#!/bin/bash
set -e
if [ $# -eq 0 ]; then
plan_file=$(mktemp)
terraform plan -no-color > "$plan_file"
else
if [ ! -e "$1" ]; then
echo "File '$1' does not exist. Aborting"
@jordiclariana
jordiclariana / changeDiskEncryptionPassphrase.sh
Created June 21, 2021 14:49
changeDiskEncryptionPassphrase
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "Run this script as root"
exit 1
fi
UUID=$(sed -r 's#^.*_crypt UUID=([^ ]+) none.*#\1#' /etc/crypttab | head -n1)
sudo cryptsetup luksChangeKey "/dev/disk/by-uuid/$UUID"
@jordiclariana
jordiclariana / aws_console_sso_title.js
Last active May 28, 2021 16:14
Greeasemonkey/Tampermonkey script to change the logged in title to show simplify and show the account
// ==UserScript==
// @name AWS Console menu SSO role and account setter
// @version 1.0
// @include /^https?://(.+\.)?console.aws.amazon.com/.*$/
// @run-at document-end
// @grant none
// @icon https://www.google.com/s2/favicons?domain=amazon.com
// ==/UserScript==
const regex = /AWSReservedSSO_([^_]+)_[^/]+\/([^ ]+).*@ (.*)/;
var title = document.getElementById("nav-usernameMenu").childNodes[0].childNodes[1].title;
Device "nanoKONTROL2"
// Discord volume
Command controller
id=5
channel=0
remap=0:100
shell="pactl set-sink-input-volume $(pactl list | grep -E '(^Sink Input)|(media.name = \"playStream\")|(application.name = \"WEBRTC\"$)' | awk '/playStream/ {print a} {a = $0}' | cut -c 13-) $value%"
// Firefox volume
Command controller
@jordiclariana
jordiclariana / ssh_host_public_key_fingerprint.py
Created October 23, 2019 14:47
Get host SSH public key and its fingerprint. Prototype for an Ansible module
import binascii
import paramiko
import warnings
warnings.filterwarnings(action='ignore', module='.*paramiko.*')
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
HOSTNAME = 'github.com'
@jordiclariana
jordiclariana / consul-template-trace.log
Created May 30, 2019 08:27
consul-template -> vault unix socket TRACE
2019/05/30 08:26:27.999779 [INFO] consul-template v0.20.0 (b709612c)
2019/05/30 08:26:27.999893 [INFO] (runner) creating new runner (dry: false, once: false)
2019/05/30 08:26:28.000243 [DEBUG] (runner) final config: {"Consul":{"Address":"","Auth":{"Enabled":false,"Username":"","Password":""},"Retry":{"Attempts":12,"Backoff":250000000,"MaxBackoff":60000000000,"Enabled":true},"SSL":{"CaCert":"","CaPath":"","Cert":"","Enabled":false,"Key":"","ServerName":"","Verify":true},"Token":"","Transport":{"DialKeepAlive":30000000000,"DialTimeout":30000000000,"DisableKeepAlives":false,"IdleConnTimeout":90000000000,"MaxIdleConns":100,"MaxIdleConnsPerHost":2,"TLSHandshakeTimeout":10000000000}},"Dedup":{"Enabled":false,"MaxStale":2000000000,"Prefix":"consul-template/dedup/","TTL":15000000000},"Exec":{"Command":"","Enabled":false,"Env":{"Blacklist":[],"Custom":[],"Pristine":false,"Whitelist":[]},"KillSignal":2,"KillTimeout":30000000000,"ReloadSignal":null,"Splay":0,"Timeout":0},"KillSignal":2,"LogLevel":"trace","MaxStale":2000