Skip to content

Instantly share code, notes, and snippets.

View robinsmidsrod's full-sized avatar

Robin Smidsrød robinsmidsrod

View GitHub Profile
@robinsmidsrod
robinsmidsrod / configuration.yaml
Created September 13, 2023 16:42
garate gate cover
cover:
- platform: template
covers:
garage_gate:
device_class: garage
friendly_name: "Garage Gate"
value_template: |
{% if is_state('binary_sensor.garage_gate', 'off') %}
closed
{% else %}
@robinsmidsrod
robinsmidsrod / gist:35894f5fbaef210869d2b40759654f24
Created February 2, 2023 17:02
Informasjon om Altibox IPTV oppsett med egen router
Jeg fant på https://forum.openwrt.org/t/help-getting-iptv-working-with-the-altibox-isp/38063/24?page=2 litt informasjon som jeg har skrevet om litt etter informasjon fra @trrunde (diskusjon.no).
The requirements for forwarding Altbox IPTV and Internet between fiber (with SFP or media converter) and a shared lan with both STBs and Internet clients are simple:
* tag VLAN 101 (IPTV) and 102 (Internet) on wan
* clone mac address of ISP gateway/router on the wan.101 interface
* run DHCP client on both wan.101 and wan.102
* SNAT/masquerade between lan and both wan interfaces
* igmpproxy between wan.101 (upstream) and lan (downstream)
@robinsmidsrod
robinsmidsrod / debug.out.strace
Last active March 15, 2022 14:45
Perl 5.34.1 test suite failure with Time::HiRes on Ubuntu 18.04 on Azure VM
execve("/home/portfolio/perlbrew/perls/perl-5.34.1/bin/perl", ["perl", "t/stat.t"], 0x7ffdd9beab48 /* 48 vars */) = 0
brk(NULL) = 0x563492d8d000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd57eb6b000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/portfolio/perlbrew/perls/perl-5.34.1/lib/5.34.1/x86_64-linux-thread-multi/CORE/tls/haswell/avx512_1/x86_64/libperl.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/portfolio/perlbrew/perls/perl-5.34.1/lib/5.34.1/x86_64-linux-thread-multi/CORE/tls/haswell/avx512_1/x86_64", 0x7ffe2d377500) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/portfolio/perlbrew/perls/perl-5.34.1/lib/5.34.1/x86_64-linux-thread-multi/CORE/tls/haswell/avx512_1/libperl.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/portfolio
@robinsmidsrod
robinsmidsrod / userns.sls
Created November 4, 2021 18:32
userns.sls subuid subgid podman-compatible saltstack formula
# Only supported on Ubuntu 18.04 and newer
{% if grains.osmajorrelease >= 18 %}
userns.uidmap:
file.touch:
- name: /etc/subuid
- unless: test -f /etc/subuid
userns.gidmap:
file.touch:
@robinsmidsrod
robinsmidsrod / read-omnikey.pl
Created September 29, 2021 16:45
OMNIKey chipcard reader Perl
#!/usr/bin/perl
use strict;
use warnings;
use Chipcard::PCSC;
use Data::Dumper qw(Dumper);
use HTTP::Tiny ();
my $http = HTTP::Tiny->new();
@robinsmidsrod
robinsmidsrod / my-network
Created August 1, 2021 18:20
Home Assistant OS Wi-Fi configuration file
# File /config/network/my-network in hassos-boot partition
[connection]
id=my-network
# Must be unique
uuid=YOUR_UUID_NUMBER
type=802-11-wireless
[802-11-wireless]
mode=infrastructure
ssid=YOUR_WIFI_NAME
@robinsmidsrod
robinsmidsrod / ubuntu-autoinstall.ipxe
Last active February 23, 2023 15:22
Ubuntu 20.04 autoinstall (casper/subiquity/curtin) to iPXE - work-in-progress (not fully working for iSCSI)
:ubuntu-autoinstall
echo Starting Ubuntu ${ubuntu-version} ${archl} autoinstaller for ${initiator-iqn}
sanhook ${base-iscsi}:${hostname}.boot.ubuntu || sleep 1
#sanhook ${base-iscsi}:${hostname}.boot.ubuntu && set ubuntu-cc-iscsi storage: { layout: { name: lvm }, config: [{type: disk, path: ${base-iscsi}:${hostname}.boot.ubuntu }] } || sleep 1
#sanhook ${base-iscsi}:${hostname}.boot.ubuntu && set ubuntu-iscsi ISCSI_INITIATOR=${initiator-iqn} ISCSI_TARGET_NAME=${base-iqn}:${hostname}.boot.ubuntu ISCSI_TARGET_IP=${iscsi-server} ISCSI_TARGET_PORT=3260 || sleep 1
# https://medium.com/@tlhakhan/ubuntu-server-20-04-autoinstall-2e5f772b655a
# https://ubuntu.com/server/docs/install/autoinstall
# https://github.com/canonical/cloud-init/blob/master/doc/examples/kernel-cmdline.txt
# https://matt.olan.me/raspberry-pi-iscsi-root-on-ubuntu-20-04/
# https://askubuntu.com/questions/1235723/automated-20-04-server-installation-using-pxe-and-live-server-image
sensor:
- platform: mqtt
state_topic: "sensor/server-room/temperature"
name: "Server room temperature"
unit_of_measurement: "°C"
value_template: "{{ value | round(1) }}"
@robinsmidsrod
robinsmidsrod / make_vbox.sh
Created November 20, 2019 14:55
How to build iPXE VirtualBox ROM that fits into 56KB
make_vbox() {
pushd "$HOME/src/forked/ipxe/src" >/dev/null &&
make CONFIG=vbox bin/intel--virtio-net--pcnet32.isarom && #EMBED=config/vbox/embedded.ipxe &&
echo "Max size of VirtualBox ROM is 56KB, 57344 bytes" &&
ls -l bin/intel--virtio-net--pcnet32.isarom &&
prefix=$(date +%Y%m%d-%H%M%S) &&
mkdir -p /ipxe/$prefix &&
cp -v bin/intel--virtio-net--pcnet32.isarom /ipxe/$prefix/ &&
echo -e "@echo off\r\nvboxmanage setextradata global VBoxInternal/Devices/pcbios/0/Config/LanBootRom C:\\Programs\\iPXE\\$prefix\\intel--virtio-net--pcnet32.isarom\r\nvboxmanage getextradata global enumerate\r\n" >/ipxe/setvboxrom.bat &&
popd >/dev/null
@robinsmidsrod
robinsmidsrod / gist:d2bdb98110e56f1a0f55adcbd593c371
Created October 10, 2019 10:09
USB-over-IP for sharing webcam over local network
# server - make a device available remotely
apt install linux-tools-common linux-tools-generic hwdata
modprobe usbip-core
modprobe usbip-host
usbipd -D # (runs in background)
usbip list -l
usbip bind -b <busid>
# client - attach to remote device
apt install linux-tools-common linux-tools-generic-hwe-18.04 hwdata