Skip to content

Instantly share code, notes, and snippets.

View mortn's full-sized avatar

Morten Abildgaard mortn

  • IKEA IT
  • Europe, mostly
View GitHub Profile
@mortn
mortn / gh.sh
Created October 24, 2024 17:55
Github get latest release download URL
get_latest_release(){
curl -s https://api.github.com/repos/$GH_USER/$GH_REPO/releases/latest | jq '.assets[]|.browser_download_url'
}
@mortn
mortn / nextcloud-pod.sh
Created March 22, 2024 22:11
Example of Podman pod running Nextcloud
# https://help.nextcloud.com/t/howto-nextcloud-as-a-rootless-container-using-podman-play-kube-with-centos8-stream/110377
PODNAME=nxcl
DDIR=/var/lib/nextcloud
mkdir -p ${DDIR}/{nginx,html}
set -x
if (podman pod exists ${PODNAME}); then
podman rm -f ${PODNAME}-app
podman rm -f ${PODNAME}-cron
podman rm -f ${PODNAME}-redis
podman rm -f ${PODNAME}-nginx
@mortn
mortn / helm.sources
Created March 17, 2024 20:58
Helm APT repo in deb822 format
Types: deb
Architectures: amd64
URIs: https://baltocdn.com/helm/stable/debian/
Suites: all
Components: main
Signed-By:
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBF6yP7IBEADWk4aijQ7Vhj7wn2oz+8asnfzsD0+257qjWy1m+cN4RP6T2NBG
S2M5+vzbsKNmGAja8jOpo46pHo/SCdc8Bwv+QHH+JbuBbDNEHwIBGV5p+ZRETiHq
@mortn
mortn / setup-terraform.sh
Last active March 3, 2024 21:02
Bash script to setup latest version of Terraform
#!/bin/bash
# Function to extract the latest version number from the Terraform website
get_latest_version() {
curl -s https://releases.hashicorp.com/terraform/index.json | jq -r '.versions[].version' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n1
}
# Function to download and install Terraform
install_terraform() {
version=$1
@mortn
mortn / eth0.network
Created January 4, 2024 21:51
working native systemd-networkd dhcpserver in eth.network
[Match]
Name=br0
[Network]
Address=10.0.0.7/24
#Gateway=10.0.0.1
DNS=10.0.1.5
Domains=domain example.com
#LinkLocalAddressing=ipv6
ConfigureWithoutCarrier=yes
@mortn
mortn / gist:ef45d5f9ac2d41bb72a1162b52d6a95e
Created October 6, 2023 21:07
Clean up old Snap revision
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' | while read snapname revision; do sudo snap remove "$snapname" --revision="$revision"; done
@mortn
mortn / [email protected]
Last active March 2, 2024 15:29
Systemd template unit for controlling Cloud-hypervisor guests
[Unit]
Description=Cloud-Hypervisor for %i
After=network.target
After=local-fs.target
After=remote-fs.target
After=systemd-logind.service
After=systemd-machined.service
Wants=network.target
[Service]
<domain type='kvm'>
<name>cloudhypervisor</name>
<uuid>4dea22b3-1d52-d8f3-2516-782e98ab3fa0</uuid>
<os>
<type>hvm</type>
<kernel>hypervisor-fw</kernel>
</os>
<memory unit='G'>2</memory>
<devices>
<disk type='file'>
@mortn
mortn / etc-wireguard-wg0.conf
Created March 18, 2023 11:54
Wireguard client configuration example
[Interface]
PrivateKey = [local private key]
Address = [local IP matching what may be assigned on remote peer]/32
#DNS = [IP of remote DNS service if needed]
#PostUp = ip r add 172.12.0.0/22 dev wg0
#PostDown = ip r del 172.12.0.0/22
[Peer]
PublicKey = [remote peer public key]
AllowedIPs = [remote CIDR block]
@mortn
mortn / dd-iso2usb.sh
Last active May 2, 2022 07:10
dd write iso to usb with progress also on high mem system
sudo dd if=debian-live-11.3.0-amd64-gnome.iso of=/dev/sda bs=4M oflag=direct status=progress && sync