Skip to content

Instantly share code, notes, and snippets.

@fionn
Last active February 18, 2020 13:56
Show Gist options
  • Save fionn/a9e036cfed4994c3c3de0e74dd775da4 to your computer and use it in GitHub Desktop.
Save fionn/a9e036cfed4994c3c3de0e74dd775da4 to your computer and use it in GitHub Desktop.
Systemd service unit templates for bots
# symlink to /etc/systemd/system/
[Unit]
Description=%I bot
After=network.target
[Service]
Type=simple
WorkingDirectory=/home/fionn/bots/%i/
EnvironmentFile=/home/fionn/bots/%i/.env
ExecStart=/home/fionn/bots/%i/venv/bin/python -u src/main.py
Restart=on-failure
RestartSec=900
DynamicUser=true
PrivateDevices=true
ProtectHostname=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
SystemCallArchitectures=native
LockPersonality=true
MemoryDenyWriteExecute=true
InaccessiblePaths=/dev /boot
RestrictRealtime=true
PrivateMounts=true
MountFlags=private
PrivateUsers=true
UMask=0777
RestrictAddressFamilies=AF_INET AF_INET6
RestrictNamespaces=yes
CapabilityBoundingSet=
AmbientCapabilities=
SystemCallFilter=@system-service
SystemCallFilter=~@privileged @resources
ProtectKernelLogs=true
# symlink to /etc/systemd/system/
[Unit]
Description=%I bot timer
[Timer]
OnCalendar=*:0/10
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment