Skip to content

Instantly share code, notes, and snippets.

Robin Smidsrød robinsmidsrod

Block or report user

Report or block robinsmidsrod

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:a7da9f326d3e4e94a2a54f030abb8272
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 Nov 20, 2019
How to build iPXE VirtualBox ROM that fits into 56KB
View make_vbox.sh
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 Oct 10, 2019
USB-over-IP for sharing webcam over local network
View gist:d2bdb98110e56f1a0f55adcbd593c371
# 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
View gist:55963a62214da9a24bc9a646e4fba0a2
src/config/local/efi/console.h:/* Everything but DEBUG and LOG output to EFI console */
src/config/local/efi/console.h:#undef CONSOLE_EFI
src/config/local/efi/console.h://#define CONSOLE_EFI ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_DEBUG & ~CONSOLE_USAGE_LOG )
src/config/local/efi/console.h:#define CONSOLE_EFI ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG )
src/config/local/efi/console.h:/* Everything but TUI output to syslog console */
src/config/local/efi/console.h:#undef CONSOLE_SYSLOG
src/config/local/efi/console.h:#define CONSOLE_SYSLOG ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_TUI )
src/config/local/efi/console.h:#undef LOG_LEVEL
src/config/local/efi/console.h:#define LOG_LEVEL LOG_ALL /* Full syslog logging */
src/config/local/efi/general.h:#undef BANNER_TIMEOUT
@robinsmidsrod
robinsmidsrod / ubuntu_1804.ipxe
Last active Oct 5, 2019
iPXE script entries for booting Ubuntu 18.04 in different ways
View ubuntu_1804.ipxe
# boot-url points to an nfs URL
# sanboot-url points to an http URL
# ubuntu-version contains 18.04.3
# ubuntu-release contains bionic
:ubuntu
echo Booting Ubuntu from iSCSI for ${initiator-iqn}
set root-path ${base-iscsi}:${hostname}.boot.ubuntu
sanboot ${root-path} || goto failed
goto start
@robinsmidsrod
robinsmidsrod / gist:18a559af2680f85a72134a6d3093f62f
Last active Aug 22, 2019
BitDefender Rescue CD iPXE boot script (non-working because missing /bin/mount.nfs in initramfs)
View gist:18a559af2680f85a72134a6d3093f62f
:bitdefender
echo Booting BitDefender Rescue ${bitdefender-version} x86 for ${initiator-iqn}
set base-url bitdefender-rescue-${bitdefender-version}/
kernel ${base-url}boot/kernel.i386-pc root=/dev/nfs nfsroot=${nfs-server}:${nfs-root}${base-url} ip=dhcp real_root=/dev/nfs loop=/rescue/livecd.squashfs looptype=squashfs livecd.nfsif=${netX/mac} initrd udev cdroot
initrd ${base-url}boot/initfs.i386-pc
boot || goto failed
goto start
@robinsmidsrod
robinsmidsrod / git-branch-sizes
Last active Aug 8, 2019
Output all non-merged refs in a git repo, ordered by number of changed lines in the diff output
View git-branch-sizes
#!/bin/bash
#
# Output all non-merged refs in a git repo, ordered by number of changed lines in the diff output
#
git for-each-ref --shell --format="ref=%(refname)" --no-merged | \
while read entry
do
eval "$entry"
size=$(git diff -U0 "master...$ref" | grep -vP '^(diff|index|@@|\-\-\-|\+\+\+)' | wc -l)
View list_container_by_parent.sql
CREATE FUNCTION public.list_container_by_parent(in_parent_id uuid, in_locale text, in_sort_key text, in_custom_init_key text) RETURNS SETOF public.node
LANGUAGE sql STABLE COST 30 ROWS 20
AS $$
-- Returns the child containers of the specified parent container in the
-- sort order specified by the sort key and locale.
-- If sort key is not specified, the sort key of the parent container,
-- or default for parent container type, is used.
-- If custom_init key is specified, containers that have this key set are
-- excluded from output. The value of the custom_init key doesn't matter.
WITH
View datatype_or_null.sql
CREATE FUNCTION public.datatype_or_null(data anyelement, datatype text)
RETURNS anyelement
LANGUAGE plpgsql IMMUTABLE
AS $$
BEGIN
RETURN CAST(data AS datatype);
EXCEPTION
WHEN OTHERS THEN
RETURN CAST(NULL AS datatype);
END;
@robinsmidsrod
robinsmidsrod / file_listing.txt
Last active Aug 4, 2018
Saltstack formulas for deplying networkboot/dhcpd docker hub image for guest network using VLAN 6
View file_listing.txt
/srv/salt/dhcpd/green/dhcpd.conf
/srv/salt/dhcpd/green/netboot.conf
/srv/salt/dhcpd/green/option-space.conf
/srv/salt/dhcpd/green.sls
/srv/salt/dhcpd/green/static.conf
/srv/salt/dhcpd/green.upstart
/srv/salt/dhcpd/guest/dhcpd.conf
/srv/salt/dhcpd/guest.sls
/srv/salt/dhcpd/guest.upstart
/srv/salt/dhcpd/init.sls
You can’t perform that action at this time.