Commit 1827fb0b authored by Seblu's avatar Seblu
Browse files

Add systemd service

parent 55bddfcc
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -2,20 +2,24 @@

pkgname=aurbot-git
pkgver=$(git log -1 --pretty=format:%h)
pkgrel=$(date +%s)
pkgrel=1
#pkgrel=$(date +%s)
pkgdesc='AUR Builder Bot'
arch=('any')
url='https://github.com/seblu/aurbot'
license=('GPL2')
makedepends=('python-distribute')
depends=('python')
depends=('python' 'systemd')
optdepends=('devtools')
install=aurbot.install

package() {
  cd "$startdir"
  python setup.py install --root "$pkgdir"
  # ensure rights are corrects
  chmod -R go+rX "$pkgdir/usr"
  install -Dm755 aurbot "$pkgdir/usr/bin/aurbot"
  install -Dm644 aurbot.service "$pkgdir/usr/lib/systemd/system/aurbot.service"
  install -Dm644 aurbot.sysusers "$pkgdir/usr/lib/sysusers.d/aurbot.conf"
  install -Dm644 packages.conf "$pkgdir/usr/share/doc/aurbot/samples/packages.conf"
  install -dm750 "$pkgdir/var/lib/aurbot"
}

# vim:set ts=2 sw=2 ft=sh et:
# vim:set ts=2 sw=2 et:
+5 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ from tempfile import TemporaryDirectory
from time import sleep
from urllib.request import urlopen, Request
from xdg.BaseDirectory import save_config_path, save_cache_path
from systemd.daemon import notify

AUR_URL = 'https://aur.archlinux.org'
USER_AGENT = "aurbot"
@@ -202,6 +203,9 @@ def main():
		packages.read(args.packages_path)
		# load cache
		cache = JsonDictFile(args.cache_path)
		# tell to systemd we are ready
		notify("READY=1\n")
		# while 42
		event_loop(packages, cache, args.sleep)
	except KeyboardInterrupt:
		exit(ERR_ABORT)

aurbot.install

0 → 100644
+11 −0
Original line number Diff line number Diff line
#!/bin/bash

## arg 1:  the new package version
post_install() {
  # ensure system users are present
  systemd-sysusers aurbot.conf
  # check file permissions
  chown aurbot:aurbot /var/lib/aurbot
}

# vim:set ts=2 sw=2 ft=sh et:

aurbot.service

0 → 100644
+14 −0
Original line number Diff line number Diff line
[Unit]
Description=AUR Builder Bot

[Service]
Type=notify
User=aurbot
ExecStart=/usr/bin/aurbot -d
Nice=10
IOSchedulingClass=best-effort
IOSchedulingPriority=7
CPUSchedulingPolicy=batch

[Install]
WantedBy=multi-user.target

aurbot.sysusers

0 → 100644
+1 −0
Original line number Diff line number Diff line
u aurbot - "AUR Bot" /var/lib/aurbot
Loading