Add Debian postinst script to create /etc/dmedia/machine.json

Bug #856070 reported by Jason Gerard DeRose
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Dmedia
Invalid
High
Unassigned

Bug Description

dmedia creates a 'dmedia/machine' doc to track each machine in a group of peers sharing the same dmedia library.

Currently dmedia stores this in CouchDB only and uses a special dmedia/_local/machine doc so it knows which one this machine is. But it would be better to have this in /etc/dmedia/machine.json so if you happen to delete all your user CouchDB files, you'll get a stable machine id when you use dmedia next. Also nice because if multiple users share a computer, they get the same machine id.

We should probably have a /var/lib/dmedia/create-machine script that a Debian postinst script calls.

Here's how to create the machine doc:

>>> from dmedia import schema
>>> schema.create_machine()
{'type': 'dmedia/machine', '_id': 'KY7WRUNJCEAXQKQI7QB2UV2T', 'ver': 0, 'hostname': 'jgd-test', 'time': 1316661512.761287}

Note that the doc saved in /etc/dmedia/machine.json wont have a CouchDB doc['_rev'], so it can be saved into CouchDB without conflict as long as that doc['_id'] doesn't exist.

The idea is we pass this to dmedia.core. As a fallback, if /etc/dmedia/machine.json doesn't exist, we should look for ~/.config/dmedia/machine.json and create it if it doesn't exist. Also makes things a bit friendlier for running dmedia in-tree.

I believe all postinst scripts need to be shell scripts. Relevant Debian Policy:

http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html

The postinst scripts in apache2 seems like useful reference examples.

Changed in dmedia:
milestone: 11.09 → 11.10
Changed in dmedia:
milestone: 11.10 → 11.11
Changed in dmedia:
milestone: 11.11 → 11.12
Revision history for this message
Jason Gerard DeRose (jderose) wrote :

I'm closing this out as we use the machine_id to identify the Dmedia HTTP server via Avahi, so this should be per-user, per-machine.

Changed in dmedia:
status: Triaged → Invalid
milestone: 11.12 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.