Skip to content

Instantly share code, notes, and snippets.

@joltcan
joltcan / deploy-firewall_vpn_certificates.sh
Last active August 24, 2023 06:37
Add and update VPN certificate in fortigate firewalls from acme.sh
#!/bin/bash
CRTFILE=~/.acme.sh/domain.com_ecc/fullchain.cer
KEYFILE=~/.acme.sh/domain.com_ecc/domain.com.key
CRTNAME="Acme.sh domain.com $(date +%Y-%m-%d)"
ADMINPORT=8444
APITOKEN="<apitoken>"
for FIREWALL in vpnhost1 vpnhost2
do
POSTCERT=$(echo -n '{"type":"regular","certname":"'"${CRTNAME}"'","scope":"global","file_content":"'$(base64 -w0 ${CRTFILE})'","key_file_content":"'$(base64 -w0 ${KEYFILE})'"}' | \
@joltcan
joltcan / README.md
Last active March 21, 2024 12:20
Prusa Connect Webcam upload

From Nunos great instructions

Instructions

  1. Go to the Cameras section at https://connect.prusa3d.com
  2. Add a new camera.
  3. Click the QR code link
  4. Click "Start Camera"
  5. Open your browser's inspector window and look for the "/snapshot" request.
  6. Copy the "Fingerprint" and "Token" headers into the file below.
@joltcan
joltcan / gist:2f2d523f5f0456a6fd2d0339c5743cb2
Created November 30, 2021 11:56
terraform-vsphere-error
2021-11-30T12:54:26.603+0100 [DEBUG] Adding temp file log sink: /tmp/terraform-log028892851
2021-11-30T12:54:26.603+0100 [INFO] Terraform version: 1.0.11
2021-11-30T12:54:26.603+0100 [INFO] Go runtime version: go1.16.4
2021-11-30T12:54:26.603+0100 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply"}
2021-11-30T12:54:26.603+0100 [DEBUG] Attempting to open CLI config file: /home/jolt/.terraformrc
2021-11-30T12:54:26.603+0100 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2021-11-30T12:54:26.603+0100 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2021-11-30T12:54:26.603+0100 [DEBUG] ignoring non-existing provider search directory /home/jolt/.terraform.d/plugins
2021-11-30T12:54:26.603+0100 [DEBUG] ignoring non-existing provider search directory /home/jolt/.local/share/terraform/plugins
2021-11-30T12:54:26.603+0100 [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
@joltcan
joltcan / streamdeck.ino
Created April 23, 2021 14:33
Streamdeck - Seeeduino XIAO version
/*
* Project 'Stream Cheap' Mini Macro Keyboard. Modified to work with Seeeduino XIAO
* @author David Madison, modified by Fredrik Lundhag <f@mekk.com>
* @link partsnotincluded.com/electronics/diy-stream-deck-mini-macro-keyboard
* @license MIT - Copyright (c) 2018 David Madison
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#!/bin/bash
# add this to crontab for automatic updates:
# @daily root /path/to/get-cloudflare-ips.sh
FILENAMEv4="/etc/network/cloudflare-ips-v4.new"
EXISTINGv4="/etc/network/cloudflare-ips-v4"
FILENAMEv6="/etc/network/cloudflare-ips-v6.new"
EXISTINGv6="/etc/network/cloudflare-ips-v6"
#!/bin/bash
INTERFACE="wg0"
WGDIR=/etc/wireguard
WGCONF="$WGDIR/$INTERFACE.conf"
WGPORT="51820"
cd $WGDIR
if [ -f "$WGDIR/wg_private.key" ]
then
auto wg0
iface wg0 inet static
address <changeme>.1
netmask 255.255.255.0
pre-up ip link add $IFACE type wireguard
pre-up wg setconf $IFACE /etc/wireguard/$IFACE.conf
post-down ip link del $IFACE
@joltcan
joltcan / backup-db.sh
Created November 25, 2019 15:56
Rolling backup for mariadb. Rsync $BACKUPPATH to some other $HOST to have a rolling backup.
#!/bin/bash
BACKUPHOST=10.20.30.40
PASSWORD=fettmepara
USERNAME=sst_user
BACKUPPATH=/backup/db
OPTIONS="--backup --compress --compress-threads=4 --host $BACKUPHOST --user $USERNAME --password=$PASSWORD"
STARTDAY=1 # 0=Sun, 1=Mon etc
@joltcan
joltcan / gen-wireguard-client.sh
Last active February 17, 2020 09:04
Generate wireguard client configuration
#!/bin/bash
# License: MIT
# Author: Fredrik Lundhag <f@mekk.com>
# Date: 2020-02-17
#
# range for the VPN itself
IPRANGE=192.168.255.1/24
WGSERVER="<hostname or IP of the vpn server>"
@joltcan
joltcan / myweechat.md
Created November 8, 2018 09:49 — forked from pascalpoitras/config.md
My always up-to-date WeeChat configuration (weechat-dev)

WeeChat Screenshot

You need at least WeeChat 2.3 for everything to work

Enable mouse

/mouse enable