diff options
author | Janne Heß | 2016-06-29 13:43:29 +0200 |
---|---|---|
committer | Janne Heß | 2016-06-29 13:44:47 +0200 |
commit | 274bc0a61e075f52475fa56ee1865dc62f358760 (patch) | |
tree | d9817d6c394a5c4ec666d26e204ef577d2f94cd9 | |
download | aur-anki-sync-server.tar.gz |
Initial commit of the anki sync server stable release
-rw-r--r-- | .SRCINFO | 30 | ||||
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | PKGBUILD | 49 | ||||
-rw-r--r-- | anki-sync-server.install | 16 | ||||
-rw-r--r-- | anki-sync-server.service | 20 | ||||
-rw-r--r-- | ankiserverctl.py.patch | 90 |
6 files changed, 210 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..a4115189ec37 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,30 @@ +# Generated by mksrcinfo v8 +# Wed Jun 29 11:44:33 UTC 2016 +pkgbase = anki-sync-server + pkgdesc = A personal Anki sync server (so you can sync against your own server rather than AnkiWeb) + pkgver = 2.0.6 + pkgrel = 1 + url = https://github.com/dsnopek/anki-sync-server + install = anki-sync-server.install + arch = any + license = GPL + makedepends = patch + makedepends = python2-setuptools + depends = python2 + depends = python2-webob + depends = python2-sqlalchemy + depends = python2-simplejson + depends = python2-paste-script + depends = anki + conflicts = anki-sync-server-git + backup = etc/webapps/anki-sync-server/production.ini + backup = etc/webapps/anki-sync-server/logging.conf + source = https://github.com/dsnopek/anki-sync-server/archive/2.0.6.tar.gz + source = ankiserverctl.py.patch + source = anki-sync-server.service + sha512sums = SKIP + sha512sums = f247d0b64a8d9df9b636e1e8f9fe8894982f3a26e0cf9297cebcb8bf51b7526e451e495e15c7f1cc1c250c265d44723f710c8a13d5cabeede4ebe222d3e3dff0 + sha512sums = 1d0666f17c181b4946fd37cc5d323a53d674b0b7e330eac515f4bea74e726162bd357b51e00bf162de7f2229aabec6859363f8c4aa7ce5e8e1974d72661b2860 + +pkgname = anki-sync-server + diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..d78df195e893 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.tar +*.gz +*.xz +src/ +pkg/ diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..95627d3a1aea --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,49 @@ +# Maintainer: Janne Heß <jannehess@gmail.com> + +pkgname=anki-sync-server +pkgver=2.0.6 +pkgrel=1 +pkgdesc='A personal Anki sync server (so you can sync against your own server rather than AnkiWeb)' +url='https://github.com/dsnopek/anki-sync-server' +license=('GPL') +conflicts=('anki-sync-server-git') +depends=('python2' 'python2-webob' 'python2-sqlalchemy' 'python2-simplejson' 'python2-paste-script' 'anki') # TODO Replace anki with libanki +makedepends=('patch' 'python2-setuptools') +backup=('etc/webapps/anki-sync-server/production.ini' 'etc/webapps/anki-sync-server/logging.conf') +source=("https://github.com/dsnopek/${pkgname}/archive/${pkgver}.tar.gz" + 'ankiserverctl.py.patch' + "${pkgname}.service") +sha512sums=('SKIP' + 'f247d0b64a8d9df9b636e1e8f9fe8894982f3a26e0cf9297cebcb8bf51b7526e451e495e15c7f1cc1c250c265d44723f710c8a13d5cabeede4ebe222d3e3dff0' + '1d0666f17c181b4946fd37cc5d323a53d674b0b7e330eac515f4bea74e726162bd357b51e00bf162de7f2229aabec6859363f8c4aa7ce5e8e1974d72661b2860') +arch=('any') +install="${pkgname}.install" + +prepare() { + cd "${srcdir}/${pkgname}-${pkgver}" + patch -p0 -i "${srcdir}/ankiserverctl.py.patch" +} + +package() { + cd "${srcdir}/${pkgname}-${pkgver}" + + python2 setup.py install --root="${pkgdir}/" --optimize=1 + + install -dm755 "${pkgdir}/etc/webapps/anki-sync-server" + install -dm755 "${pkgdir}/var/lib/anki-sync-server" + install -Dm644 "${srcdir}/anki-sync-server.service" "${pkgdir}/usr/lib/systemd/system/anki-sync-server.service" + # Sanatize paths + mv "${pkgdir}/usr/bin/ankiserverctl.py" "${pkgdir}/usr/bin/ankiserverctl" + mv "${pkgdir}/usr/examples/example.ini" "${pkgdir}/etc/webapps/anki-sync-server/production.ini" + mv "${pkgdir}/usr/examples/logging.conf" "${pkgdir}/etc/webapps/anki-sync-server/" + # Remove useless files and directories + rm -r "${pkgdir}/usr/examples" "${pkgdir}/usr/anki-bundled" + # Fix paths + sed -i \ + -e 's:logging.conf$:/etc/webapps/anki-sync-server/logging.conf:g' \ + -e 's:./collections:/var/lib/anki-sync-server/collections:g' \ + -e 's:./session.db:/var/lib/anki-sync-server/session.db:g' \ + -e 's:./auth.db:/var/lib/anki-sync-server/auth.db:g' \ + "${pkgdir}/etc/webapps/anki-sync-server/production.ini" +} + diff --git a/anki-sync-server.install b/anki-sync-server.install new file mode 100644 index 000000000000..872ea30d7b3e --- /dev/null +++ b/anki-sync-server.install @@ -0,0 +1,16 @@ +#!/bin/bash + +post_install() { + getent passwd anki-sync-server &>/dev/null || useradd -Mrc 'Anki Sync Server user' -d /var/lib/anki-sync-server -s /usr/bin/nologin anki-sync-server + chown -R anki-sync-server: /var/lib/anki-sync-server + chown anki-sync-server /usr/bin/ankiserverctl +} + +post_remove() { + getent passwd anki-sync-server &>/dev/null && userdel anki-sync-server || true + getent group anki-sync-server &>/dev/null && groupdel anki-sync-server || true +} + +post_upgrade() { + post_install +} diff --git a/anki-sync-server.service b/anki-sync-server.service new file mode 100644 index 000000000000..6927a4f4de2f --- /dev/null +++ b/anki-sync-server.service @@ -0,0 +1,20 @@ +[Unit] +Description=Anki Sync Server + +[Service] +Type=simple +ExecStart=/usr/bin/paster serve --quiet /etc/webapps/anki-sync-server/production.ini +Restart=on-failure + +User=anki-sync-server +Group=anki-sync-server +CapabilityBoundingSet= +PrivateTmp=true +PrivateDevices=true +ProtectSystem=full +ProtectHome=true +NoNewPrivileges=true + +[Install] +WantedBy=multi-user.target + diff --git a/ankiserverctl.py.patch b/ankiserverctl.py.patch new file mode 100644 index 000000000000..a6e92251ebef --- /dev/null +++ b/ankiserverctl.py.patch @@ -0,0 +1,90 @@ +--- ankiserverctl.py.orig 2016-03-13 20:18:43.119078359 +0100 ++++ ankiserverctl.py 2016-03-13 20:20:44.351755216 +0100 +@@ -1,68 +1,25 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python2 + + import os + import sys +-import signal +-import subprocess + import binascii + import getpass + import hashlib + import sqlite3 + +-SERVERCONFIG = "production.ini" +-AUTHDBPATH = "auth.db" +-PIDPATH = "/tmp/ankiserver.pid" +-COLLECTIONPATH = "collections/" ++SERVERCONFIG = "/etc/anki-sync-server/production.ini" ++AUTHDBPATH = "/var/lib/anki-sync-server/auth.db" ++COLLECTIONPATH = "/var/lib/anki-sync-server/collections/" + + def usage(): + print "usage: "+sys.argv[0]+" <command> [<args>]" + print + print "Commands:" +- print " start [configfile] - start the server" +- print " debug [configfile] - start the server in debug mode" +- print " stop - stop the server" + print " adduser <username> - add a new user" + print " deluser <username> - delete a user" + print " lsuser - list users" + print " passwd <username> - change password of a user" + +-def startsrv(configpath, debug): +- if not configpath: +- configpath = SERVERCONFIG +- +- # We change to the directory containing the config file +- # so that all the paths will be relative to it. +- configdir = os.path.dirname(configpath) +- if configdir != '': +- os.chdir(configdir) +- configpath = os.path.basename(configpath) +- +- if debug: +- # Start it in the foreground and wait for it to complete. +- subprocess.call( ["paster", "serve", configpath], shell=False) +- return +- +- devnull = open(os.devnull, "w") +- pid = subprocess.Popen( ["paster", "serve", configpath], +- stdout=devnull, +- stderr=devnull).pid +- +- with open(PIDPATH, "w") as pidfile: +- pidfile.write(str(pid)) +- +-def stopsrv(): +- if os.path.isfile(PIDPATH): +- try: +- with open(PIDPATH) as pidfile: +- pid = int(pidfile.read()) +- +- os.kill(pid, signal.SIGKILL) +- os.remove(PIDPATH) +- except Exception, error: +- print >>sys.stderr, sys.argv[0]+": Failed to stop server: "+error.message +- else: +- print >>sys.stderr, sys.argv[0]+": The server is not running" +- + def adduser(username): + if username: + print "Enter password for "+username+": " +@@ -145,13 +102,7 @@ + if argc < 3: + sys.argv.append(None) + +- if sys.argv[1] == "start": +- startsrv(sys.argv[2], False) +- elif sys.argv[1] == "debug": +- startsrv(sys.argv[2], True) +- elif sys.argv[1] == "stop": +- stopsrv() +- elif sys.argv[1] == "adduser": ++ if sys.argv[1] == "adduser": + adduser(sys.argv[2]) + elif sys.argv[1] == "deluser": + deluser(sys.argv[2]) |