Skip to content

Instantly share code, notes, and snippets.

View dunkelstern's full-sized avatar
🐢

Johannes Schriewer dunkelstern

🐢
View GitHub Profile
@dunkelstern
dunkelstern / nousa1t.yaml
Created November 9, 2023 19:24
NOUS A1T ESPHome template
esphome:
name: "nousa1t0"
friendly_name: NousA1T0
comment: "Wohnzimmer"
project:
name: "NOUS.Smart-Wifi-Socket_001"
version: "A1T"
#
# Original Tasmota Template:
@dunkelstern
dunkelstern / README.md
Created May 8, 2023 17:58
Systemd Unit for running python application in virtualenv

Assumptions

  • Username is user
  • User is in group user
  • User's home is /home/user
  • Python application is in /home/user/pythonapp
  • Python script is named start.py
  • Virtual environment is /home/user/.virtualenvs/pythonapp created with python -m venv /home/user/.virtualenvs/pythonapp

You can add multiple Environment lines if you need more env-variables

@dunkelstern
dunkelstern / portainer_status.py
Created February 3, 2023 17:58
Use portainer API to query for container health, with support for stacks, needs python3, no external deps
#!/usr/bin/python3
from typing import Union, List, Any, Dict, Optional
import argparse
import os
import json
import ssl
from urllib.request import urlopen, Request
JSON = Union[List[Any], Dict[str, Any]]
@dunkelstern
dunkelstern / style.xsl
Created September 21, 2016 12:58
nginx rtmp status style sheet
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
@dunkelstern
dunkelstern / nginx.conf
Created September 21, 2016 12:33
nginx RTMP config
user rtmp;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
@dunkelstern
dunkelstern / logcat.py
Created September 7, 2016 16:57
ScribeJS commandline logfile dumper and filtering tool (python 3)
#!/usr/bin/env python
import json
import argparse
import itertools
import time
from dateutil.parser import parse
import datetime
@dunkelstern
dunkelstern / vpn_setup.ps1
Created August 8, 2016 15:38
VPN Setup script for windows powershell
# Set these to the correct values
$server_address = "vpn.example.com"
$connection_name = "VPN Connection"
$certificate_path = "certificate.p12"
$ca_cert_path = "strongswanCert.pem"
$password = ConvertTo-SecureString -String "P12 passphrase" -AsPlainText -Force
# Import machine cert
Import-PfxCertificate -FilePath $certificate_path -CertStoreLocation Cert:\LocalMachine\My\ -Password $password
@dunkelstern
dunkelstern / create_vpn_user.sh
Created August 7, 2016 19:35
Create certificates for a new machine for an IKEv2 vpn
#!/bin/bash
if [ "$1" = "" ] ; then
echo "Usage: $0 <machine_name>"
exit 1
fi
machinename=$1
# configure these to the visible public values of the server
@dunkelstern
dunkelstern / rc.local
Created August 7, 2016 19:14
iptables rules for vpn config
# for ISAKMP (handling of security associations)
iptables -A INPUT -p udp --dport 500 --j ACCEPT
# for NAT-T (handling of IPsec between natted devices)
iptables -A INPUT -p udp --dport 4500 --j ACCEPT
# for ESP payload (the encrypted data packets)
iptables -A INPUT -p esp -j ACCEPT
# for the routing of packets on the server
iptables -t nat -A POSTROUTING -j SNAT --to-source %IP% -o eth0
# internet access
iptables -t nat -A POSTROUTING -s 10.0.42.0/24 -o eth0 -m policy --dir out --pol ipsec -j ACCEPT
@dunkelstern
dunkelstern / vpn.conf
Created August 7, 2016 19:10
sysctl config for ip packet forwarding
# ipv4
net.ipv4.ip_forward=1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.icmp_ignore_bogus_error_responses = 1