Skip to content

Instantly share code, notes, and snippets.

Avatar

Elias Probst eliasp

View GitHub Profile
View jinja-copy.py
# the expected result would be:
# {'configuration': {'index': 1, 'targets': {'index': 1}}}
# {'configuration': {'index': 2, 'targets': {'index': 2}}}
# the actual result is (see targets.index in 1st line):
# {'configuration': {'index': 1, 'targets': {'index': 2}}}
# {'configuration': {'index': 2, 'targets': {'index': 2}}}
from jinja2 import Environment
from jinja2.ext import do
env = Environment(extensions=[do])
template = env.from_string('''
@eliasp
eliasp / README.md
Last active Jul 26, 2020
Run OnlyOffice Document Server using Podman and Caddy on Ubuntu 20.04
View README.md

This is just a basic setup.

  • automatic TLS via Caddy's built-in ACME support
  • no backup of any data
  • no advanced container security

Install Podman

source /etc/os-release
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key | apt-key add -
@eliasp
eliasp / a.sls
Last active Mar 16, 2020
SaltStack - SLS requisite ordering fails
View a.sls
include:
- second
View Caddyfile
:80 {
redir https://{host}{uri}
}
domain.test:443 {
tls foo@mailprovider.tld
root /some/directory
}
www.domain.test:443 {
View nm-iwd.diff
diff --git a/nixos/modules/services/networking/networkmanager.nix b/nixos/modules/services/networking/networkmanager.nix
index 2d76e0676b2..065cd108ad6 100644
--- a/nixos/modules/services/networking/networkmanager.nix
+++ b/nixos/modules/services/networking/networkmanager.nix
@@ -34,6 +34,8 @@ let
[device]
wifi.scan-rand-mac-address=${if cfg.wifi.scanRandMacAddress then "yes" else "no"}
+ ${optionalString (cfg.wifi.backend != null)
+ ''wifi.backend=${cfg.wifi.backend}''}
@eliasp
eliasp / jinja2_test.py
Created Oct 12, 2018 — forked from tristanfisher/jinja2_test.py
Test Jinja2 templates in a REPL
View jinja2_test.py
from jinja2 import Template
text = """
hi
"""
template = Template(text)
template.render() # passing variables here to the text template if needed
View restic@.service
[Unit]
Description=Backup %I using 'restic'
ConditionFileNotEmpty=/etc/restic/%i/restic.env
ConditionPathExists=/etc/restic/%i/backup.exclude
[Service]
# /run, /tmp are intentionally not --exclude'd as those are tmpfs anyways and therefore already excluded by --one-file-system
ExecStart=/usr/local/bin/restic backup --cache-dir=/var/cache/restic/%i --one-file-system --exclude-file=/etc/restic/%i/backup.exclude --exclude=/var/cache/* --exclude=/var/tmp/* --exclude=/home/*/.cache/* /
Type=simple
EnvironmentFile=/etc/restic/%i/restic.env
@eliasp
eliasp / IDEAS.md
Created Jan 14, 2017
Servo GSoC Ideas
View IDEAS.md

DBus interface

Adding a DBus interface would allow a lot of different things on Linux DEs.

Usecases

MPRIS

MPRIS is a standardized interface to control media playback.

Having MPRIS capabilities in a browser would allow for global media playback control, which is already possible with nearly every Linux mediaplayer. Making this possible for media playback in browsers follows the trend of more and more applications/platforms becoming web-based.

  • Pause/continue playback of a video without having to open the browser window and locate the corresponding tab
View systemd-networkd.journal
Oct 05 08:41:56 dev-api-00000000 systemd[1]: Starting Network Service...
Oct 05 08:41:56 dev-api-00000000 systemd-networkd[834]: timestamp of '/etc/systemd/network' changed
Oct 05 08:41:56 dev-api-00000000 systemd-networkd[834]: timestamp of '/lib/systemd/network' changed
Oct 05 08:42:21 dev-api-00000000 systemd[1]: systemd-networkd.service: main process exited, code=exited, status=1/FAILURE
Oct 05 08:42:21 dev-api-00000000 systemd[1]: Failed to start Network Service.
Oct 05 08:42:21 dev-api-00000000 systemd[1]: Unit systemd-networkd.service entered failed state.
Oct 05 08:42:21 dev-api-00000000 systemd[1]: systemd-networkd.service has no holdoff time, scheduling restart.
Oct 05 08:42:21 dev-api-00000000 systemd[1]: Stopping Network Service...
Oct 05 08:42:21 dev-api-00000000 systemd[1]: Starting Network Service...
Oct 05 08:42:21 dev-api-00000000 systemd-networkd[835]: timestamp of '/etc/systemd/network' changed
View salt-dunder-dict-in-jinja
{% if not 'systemd.sd_booted' in salt %} <======================
# for non-booted systems (e.g. a container during bootstrapping), `timedatectl` can't work
# and `systemd-firstboot` needs to be used instead
{% if not salt['file.is_link']('/etc/localtime') %}
systemd-firstboot-timedate:
cmd.run:
[...]
---
[CRITICAL] Rendering SLS 'base:linux.systemd.timedate' failed: Jinja error:
Traceback (most recent call last):