summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Heß2016-03-13 21:03:30 +0100
committerJanne Heß2016-03-13 21:03:30 +0100
commit9511dbd1f6fe91e8c77e6a43fc3abdf4d9d1cf6c (patch)
tree531964ef8b026434bbce31691b3f788122980e2e
downloadaur-9511dbd1f6fe91e8c77e6a43fc3abdf4d9d1cf6c.tar.gz
Initial commit of the anki sync server
-rw-r--r--.SRCINFO31
-rw-r--r--.gitignore5
-rw-r--r--PKGBUILD54
-rw-r--r--anki-sync-server.install16
-rw-r--r--anki-sync-server.service8
-rw-r--r--ankiserverctl.py.patch90
6 files changed, 204 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..c103e9c1ec78
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,31 @@
+# Generated by mksrcinfo v8
+# Sun Mar 13 20:02:37 UTC 2016
+pkgbase = anki-sync-server-git
+ pkgdesc = A personal Anki sync server (so you can sync against your own server rather than AnkiWeb)
+ pkgver = 2.0.5.g07eaac8
+ pkgrel = 1
+ url = https://github.com/dsnopek/anki-sync-server
+ install = anki-sync-server.install
+ arch = any
+ license = GPL
+ makedepends = patch
+ depends = python2
+ depends = python2-webob
+ depends = python2-pastedeploy
+ depends = python2-sqlalchemy
+ depends = python2-simplejson
+ depends = python2-paste-script
+ depends = anki
+ provides = anki-sync-server
+ conflicts = anki-sync-server
+ backup = etc/webapps/anki-sync-server/production.ini
+ backup = etc/webapps/anki-sync-server/logging.conf
+ source = git://github.com/dsnopek/anki-sync-server
+ source = ankiserverctl.py.patch
+ source = anki-sync-server.service
+ sha512sums = SKIP
+ sha512sums = f247d0b64a8d9df9b636e1e8f9fe8894982f3a26e0cf9297cebcb8bf51b7526e451e495e15c7f1cc1c250c265d44723f710c8a13d5cabeede4ebe222d3e3dff0
+ sha512sums = 7a11d2ac2d33d0888f5d1d777134348367116b8d2ba199a11aa55bab5b39d232ca91c4329635f2b1ffd4189b7e7ea0c49aa377d6396ae28dbf269e0706509b9e
+
+pkgname = anki-sync-server-git
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..ba6206b55ce3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+*.tar
+*.gz
+src/
+pkg/
+anki-sync-server/
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..d14f5a73a80a
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,54 @@
+# Maintainer: Janne Heß <jannehess@gmail.com>
+
+pkgname=anki-sync-server-git
+pkgver=2.0.5.g07eaac8
+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')
+provides=('anki-sync-server')
+conflicts=('anki-sync-server')
+depends=('python2' 'python2-webob' 'python2-pastedeploy' 'python2-sqlalchemy' 'python2-simplejson' 'python2-paste-script' 'anki')
+makedepends=('patch')
+backup=('etc/webapps/anki-sync-server/production.ini' 'etc/webapps/anki-sync-server/logging.conf')
+source=("git://github.com/dsnopek/${pkgname%-git}" 'ankiserverctl.py.patch' "${pkgname%-git}.service")
+sha512sums=('SKIP'
+ 'f247d0b64a8d9df9b636e1e8f9fe8894982f3a26e0cf9297cebcb8bf51b7526e451e495e15c7f1cc1c250c265d44723f710c8a13d5cabeede4ebe222d3e3dff0'
+ '7a11d2ac2d33d0888f5d1d777134348367116b8d2ba199a11aa55bab5b39d232ca91c4329635f2b1ffd4189b7e7ea0c49aa377d6396ae28dbf269e0706509b9e')
+arch=('any')
+install="${pkgname%-git}.install"
+
+pkgver() {
+ cd "${srcdir}/${pkgname%-git}"
+ git describe --tags --always | sed 's/-[[:digit:]]*-/./g'
+}
+
+prepare() {
+ cd "${srcdir}/${pkgname%-git}"
+
+ patch -p0 -i "${srcdir}/ankiserverctl.py.patch"
+}
+
+package() {
+ cd "${srcdir}/${pkgname%-git}"
+
+ 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..64512d88c84d
--- /dev/null
+++ b/anki-sync-server.install
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+post_install() {
+ getent passwd anki-sync-server &>/dev/null || useradd -mc '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 -r 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..54e5759e625b
--- /dev/null
+++ b/anki-sync-server.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Anki Sync Server
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/paster serve --quiet /etc/webapps/anki-sync-server/production.ini
+User=anki-sync-server
+Group=anki-sync-server
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])