Skip to content

Instantly share code, notes, and snippets.

View pojntfx's full-sized avatar
💭
🍂

Felicitas Pojtinger pojntfx

💭
🍂
View GitHub Profile
@pojntfx
pojntfx / main.sh
Last active April 24, 2024 23:39
Uninstall an old kernel version from a DNF-based system bypassing `kernel` package deletion protection
#!/bin/bash
uname -r # Get installed kernels - make sure that there is at least one more kernel than the one you're removing!
sudo rpm -e kernel-6.7.0_rc6_pvm_host_fedora_baremetal-1.x86_64
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo reboot
@pojntfx
pojntfx / main.c
Last active April 12, 2024 22:55
Overlay/"hole punch" a section of an `mmap`ed region with another `mmap`ed region
#include <bits/time.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <time.h>
#include <unistd.h>
int main() {
const size_t page_size = 4096 * 64;
@pojntfx
pojntfx / main.sh
Last active April 9, 2024 00:38
Use `slirp4netns` to add a tap device with working networking to an unprivileged/rootless namespace
# Also see: https://passt.top/passt/about/ for an alternative setup
# In first terminal (namespace 1)
unshare --user --map-root-user --net --mount
echo $$ > /tmp/pid
# In second terminal
# For port-forwarding: http://web.archive.org/web/20240112152726/https://rootlesscontaine.rs/how-it-works/netns/incoming/ for port-forwarding
# For communicating between different slirp4netns instances: https://github.com/rootless-containers/slirp4netns/blob/master/slirp4netns.1.md#inter-namespace-communication
slirp4netns --configure --mtu=65520 --disable-host-loopback --macaddress 26:87:71:8f:6f:57 --outbound-addr 100.111.168.3 --outbound-addr6 fd7a:115c:a1e0::1def:a803 --enable-ipv6 $(cat /tmp/pid) tap0
@pojntfx
pojntfx / main.sh
Created March 28, 2024 00:25
Shut down all NBD clients on a Linux host
#!/bin/bash
sudo su -c 'for file in /dev/nbd*; do nbd-client -d $file & done; wait'
@pojntfx
pojntfx / main.sh
Created March 22, 2024 04:54
Mark broken postmarketOS dependencies for rebuilds
#!/bin/bash
pmbootstrap pkgrel_bump --auto
@pojntfx
pojntfx / main.sh
Created February 18, 2024 22:55
Get Strato's public DKIM key
#!/bin/bash
# Note that you _have_ to copy the quotation marks around the return value of this into the value field of the DNS settings
# You can set the return value like this (note the quotation marks): strato-dkim-0002._domainkey.pojtinger.com. 1 IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt3a1nbhQdD0MtbPT1r8DGZefoQlj3fSgtWdINsXsRl55OmOAf2QNR8B0SwC59dWqA+isuH/bQnU0f0OmO5A7p+cyfT9EekbWslP575NAnAYpsUJlBv/0O8qA6T/cLoDz6LsUYv000gFRqSSUe1BZnJ/sjg0f96UCkomT1aQRpSUS" "DwNYCqpQKQ/fWg9IS2fL+d2kR1rckqwoKdgbEtjr4i+ICn2SUodI1KkGusIivuBueMYfDh8RGYKvFv40UZlBSfuX71GkzEPvQPnQTfXLqM9F8q1kWq/mdWYy5R0KrWptAnuAmCZqujkgWmcqzLoTMln04oOxGFp/zkf8iA75lwIDAQAB"
dig strato-dkim-0002._domainkey.strato.com TXT +short @shades09.rzone.de
@pojntfx
pojntfx / main.sh
Created February 7, 2024 22:53
Run a command each time a touchscreen is touched Linux
#!/bin/bash
DEVICE="/dev/input/event4" # Replace with your actual device
COMMAND="echo 'Touch detected'" # Replace with the command you want to run
sudo evtest "$DEVICE" | while read line; do
if echo "$line" | grep -q "EV_KEY"; then # Adjust based on actual output for a touch event
eval "$COMMAND"
fi
done
@pojntfx
pojntfx / main.sh
Created December 9, 2023 15:24
Forward audio using Pipewire-Pulse/Pulseaudio over TCP
#!/bin/bash
# Note: This doesn't work yet.
socat tcp:128.140.106.133:1338,forever,interval=2,fork tcp:127.0.0.1:7000
pactl load-module module-native-protocol-tcp port=7000 listen=127.0.0.1
socat tcp-listen:7001,reuseaddr,fork tcp-listen:1338,reuseaddr
pactl load-module module-tunnel-sink server=tcp:127.0.0.1:7001
@pojntfx
pojntfx / main.sh
Last active December 9, 2023 15:21
Use Waypipe to forward a Wayland application running on a remote system over TCP to localhost
#!/bin/bash
# Without gender changer (server dials client on port 1337)
# On client
waypipe --socket /tmp/waypipe-remote.sock client
socat TCP-LISTEN:1337,reuseaddr,fork UNIX-CONNECT:/tmp/waypipe-remote.sock
# On server
socat UNIX-LISTEN:/tmp/waypipe-local.sock,reuseaddr,fork TCP:127.0.0.1:1337
@pojntfx
pojntfx / main.sh
Created October 24, 2023 15:34
Find the 20 largest files on a Linux system
#!/bin/bash
find / -type f -exec du -h {} + 2>/dev/null | sort -rh | head -n 20