Skip to content

Instantly share code, notes, and snippets.

View scratchoo's full-sized avatar
🎯
Focusing

scratchoo

🎯
Focusing
View GitHub Profile
@scratchoo
scratchoo / apt_wait.sh
Created January 9, 2024 13:41 — forked from tedivm/apt_wait.sh
A BASH function to wait for `apt` to finish and release all locks.
#!/usr/bin/env bash
apt_wait () {
while sudo fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
sleep 1
done
while sudo fuser /var/lib/apt/lists/lock >/dev/null 2>&1 ; do
sleep 1
done
if [ -f /var/log/unattended-upgrades/unattended-upgrades.log ]; then
@scratchoo
scratchoo / shell_execute.rb
Created May 21, 2024 21:49 — forked from troelskn/shell_execute.rb
Running a shell subprocess is surprisingly hard in ruby
require "open3"
def execute_shell(command, verbose: false)
Rails.logger.info "[SHELL] #{command}"
# see: https://nickcharlton.net/posts/ruby-subprocesses-with-stdout-stderr-streams.html
# see: http://stackoverflow.com/a/1162850/83386
output = []
Open3.popen3(command) do |stdin, stdout, stderr, thread|
# read each stream from a new thread
@scratchoo
scratchoo / NetworkingFirecracker.md
Created June 3, 2024 19:33 — forked from s8sg/NetworkingFirecracker.md
Networking with Firecracker

Create Bridge interface on the host and give internet access

sudo ip link add name br0 type bridge
sudo ip addr add 172.20.0.1/24 dev br0
sudo ip link set dev br0 up
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables --table nat --append POSTROUTING --out-interface enp3s0 -j MASQUERADE
sudo iptables --insert FORWARD --in-interface br0 -j ACCEPT

Create a tap device and link to the bridge