|
| 1 | +# A simpler version of the service template with wider compatibility for older OS's |
| 2 | + |
| 3 | +[Unit] |
| 4 | +Description=listmonk email service |
| 5 | +ConditionPathExists=/etc/listmonk/config.toml |
| 6 | +Wants=network.target |
| 7 | +# The PostgreSQL database may not be on the same host but if it |
| 8 | +# is listmonk should wait for it to start up. |
| 9 | +After=postgresql.service |
| 10 | + |
| 11 | +[Service] |
| 12 | +Type=simple |
| 13 | +PermissionsStartOnly=true |
| 14 | +WorkingDirectory=/usr/bin |
| 15 | +ExecStartPre=/usr/bin/mkdir -p "/etc/listmonk/uploads" |
| 16 | +ExecStartPre=/usr/bin/listmonk --config /etc/listmonk/config.toml --upgrade --yes |
| 17 | +ExecStart=/usr/bin/listmonk --config /etc/listmonk/config.toml |
| 18 | +TimeoutStopSec=10 |
| 19 | +Restart=on-failure |
| 20 | +RestartSec=5 |
| 21 | + |
| 22 | +# To enable a static dir, add the following |
| 23 | +# --static-dir /etc/listmonk/static |
| 24 | +# to the end of the ExecStart line above after creating the dir and fetching the files with: |
| 25 | +# mkdir -p /etc/listmonk/static ; wget -O - https://github.com/knadh/listmonk/archive/master.tar.gz | tar xz -C /etc/listmonk/static --strip=2 "listmonk-master/static" |
| 26 | + |
| 27 | +# Set user to run listmonk service as (instead of root), and folders it can write to. |
| 28 | +# Can use "DynamicUser=" instead, if your systemd version is >= 232. |
| 29 | +# https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#DynamicUser= |
| 30 | +#User= |
| 31 | +#StateDirectory=/etc/listmonk |
| 32 | +#LogsDirectory=/etc/listmonk |
| 33 | +#CacheDirectory=/etc/listmonk/cache |
| 34 | +#Environment=HOME=/usr/bin |
| 35 | + |
| 36 | +# Use systemd’s ability to disable security-sensitive features |
| 37 | +# that listmonk does not explicitly need. |
| 38 | +# NoNewPrivileges should be enabled by DynamicUser=yes but systemd-analyze |
| 39 | +# still recommended to explicitly enable it. |
| 40 | +NoNewPrivileges=True |
| 41 | +# listmonk doesn’t need any capabilities as defined by the linux kernel |
| 42 | +# see: https://man7.org/linux/man-pages/man7/capabilities.7.html |
| 43 | +CapabilityBoundingSet= |
| 44 | +# listmonk only executes native code with no need for any other ABIs. |
| 45 | +SystemCallArchitectures=native |
| 46 | + |
| 47 | +# Make /home/, /root/, and /run/user/ inaccessible. |
| 48 | +# ProtectSystem=strict and ProtectHome=read-only are implied by DynamicUser=True |
| 49 | +# If you set ExecStartPre=/usr/bin/mkdir -p "listmonk/uploads" to a directory in /home/ or /root/ it will cause uploads to fail |
| 50 | +# See https://github.com/knadh/listmonk/issues/843#issuecomment-1836023524 |
| 51 | +ProtectHome=True |
| 52 | + |
| 53 | +# Make sure files created by listmonk are only readable by itself and |
| 54 | +# others in the listmonk system group. |
| 55 | +UMask=0027 |
| 56 | +# listmonk only needs to support the IPv4 and IPv6 address families. |
| 57 | +RestrictAddressFamilies=AF_INET AF_INET6 |
| 58 | + |
| 59 | +[Install] |
| 60 | +WantedBy=multi-user.target |
0 commit comments