# (C) 2013-2026 by Christian Hesse <mail@eworm.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

[Unit]
Description=Serve pacman database files and package archives
Documentation=https://pacredir.eworm.de/
Requires=systemd-resolved.service
After=systemd-tmpfiles-setup.service network.target systemd-resolved.service

[Service]
EnvironmentFile=/etc/pacserve.conf
ExecStart=/usr/bin/pacserve /run/pacserve/ --ipv6 --port ${PORT} --no-listing --index empty
# magic numbers at the end represent TXT data: id=archarm arch=armv7h
ExecStartPost=+/usr/bin/busctl --quiet call org.freedesktop.resolve1 /org/freedesktop/resolve1 org.freedesktop.resolve1.Manager RegisterService sssqqqaa{say} pacserve 'pacserve on %l' _pacserve._tcp ${PORT} 0 0 1 2 id 7 97 114 99 104 97 114 109 arch 6 97 114 109 118 55 104
ExecStopPost=+/usr/bin/busctl --quiet call org.freedesktop.resolve1 /org/freedesktop/resolve1 org.freedesktop.resolve1.Manager UnregisterService o /org/freedesktop/resolve1/dnssd/pacserve
BindReadOnlyPaths=/var/cache/pacman/pkg:/run/pacserve/pkg /var/lib/pacman/sync:/run/pacserve/db
DynamicUser=on
ProtectSystem=full
ProtectHome=on
PrivateDevices=on
NoNewPrivileges=on
Restart=on-failure
RestartSec=2s

[Install]
WantedBy=multi-user.target
