diff --git a/telegram-bot-workout/PKGBUILD b/telegram-bot-workout/PKGBUILD new file mode 100644 index 0000000..92f940e --- /dev/null +++ b/telegram-bot-workout/PKGBUILD @@ -0,0 +1,34 @@ +# Maintainer: Manuel Vögele +pkgname=telegram-workout-bot-git +pkgver=0 +pkgrel=1 + +arch=('any') +makedepends=( + 'git' + 'cargo' +) +source=( + 'git+ssh://gitea@git.ccn.li/manuel/telegram-bot-workout.git' + 'telegram-bot-workout.service' + 'sysusers.d' +) +sha256sums=('SKIP' + '1123516aaac89cbf24526848b4e0b49bdf352cb4be819db11b714758bde2c7c0' + '128feac33a68097960d3690827c816777482a2ec5b5947a0bcd7a25bdbb93b54') + +pkgver() { + cd "${srcdir}/telegram-bot-workout" + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" +} + +build() { + cd "${srcdir}/telegram-bot-workout" + cargo build --release +} + +package() { + install -Dm755 "${srcdir}/telegram-bot-workout/target/release/workout-bot" "${pkgdir}/usr/bin/workout-bot" + install -Dm644 "${srcdir}/telegram-bot-workout.service" "${pkgdir}/usr/lib/systemd/system/telegram-bot-workout.service" + install -Dm644 "${srcdir}/sysusers.d" "${pkgdir}/usr/lib/sysusers.d/telegram-bot-workout.conf" +} diff --git a/telegram-bot-workout/sysusers.d b/telegram-bot-workout/sysusers.d new file mode 100644 index 0000000..3638881 --- /dev/null +++ b/telegram-bot-workout/sysusers.d @@ -0,0 +1 @@ +u telegram-bots - "Unprivileged user for running telegram bots" diff --git a/telegram-bot-workout/telegram-bot-workout.service b/telegram-bot-workout/telegram-bot-workout.service new file mode 100644 index 0000000..7c91a59 --- /dev/null +++ b/telegram-bot-workout/telegram-bot-workout.service @@ -0,0 +1,42 @@ +[Unit] +After=network-online.target + +[Service] +User=telegram-bots +Environment=RUST_LOG=info +Environment=WORKOUT_BOT_CONFIG_FILE=/etc/telegram-bot-workout.json +ExecStart=/usr/bin/workout-bot + +Restart=on-failure +RestartSec=5s + +ReadOnlyPaths=/etc/telegram-bot-workout.json +ReadWritePaths=/var/lib/telegram-bots/ +NoNewPrivileges=yes +PrivateTmp=yes +PrivateDevices=yes +PrivateUsers=yes +PrivateMounts=yes +DevicePolicy=closed +ProtectSystem=strict +ProtectHome=yes +ProtectClock=yes +ProtectHostname=yes +ProtectControlGroups=yes +ProtectKernelModules=yes +ProtectKernelTunables=yes +RestrictAddressFamilies=AF_INET AF_INET6 AF_NETLINK +CapabilityBoundingSet= +SystemCallArchitectures=native +SystemCallFilter=@system-service +ProtectKernelLogs=yes +RestrictNamespaces=yes +RestrictRealtime=yes +RestrictSUIDSGID=yes +MemoryDenyWriteExecute=yes +LockPersonality=yes +RemoveIPC=yes + + +[Install] +WantedBy=multi-user.target