← Back to team overview

ubuntu-accomplishments-contributors team mailing list archive

reloading accomplishments for another user?

 

When an accomplishments collection is added or removed, we need to send the reload signal to all instances of the daemon. I have code in the postrm/postinst steps that does this finally (below), but sudo -u {$user} just isn't enough due to the way the daemon looks for the PID file, I think. I considered modifying the daemon to accept a --user argument, but due to the way we look up the cache directory, I'm not sure that helps either. The brief question is: using sudo, how can I call /usr/bin/accomplishments-daemon --reload for another user. If you can solve that I have the rest of this issue solved.

Here's the postinst/postrm code that will go into the collections and the output follows:

#!/bin/sh -e

if [ -x /usr/bin/accomplishments-daemon ];
then
for user in `ps -ef | grep /usr/bin/accomplishments-daemon | grep /usr/bin/python | grep -v grep | awk '{ print $1 }'`; do
        echo "Reloading accomplishments for ${user}"
        sudo -u ${user} /usr/bin/accomplishments-daemon --reload
    done
fi


Unpacking replacement ubuntu-community-accomplishments ...
Reloading accomplishments for mfisch
mfisch: /home/mfisch/.cache/accomplishments
The daemon is not running.
Reloading accomplishments for fred
mfisch: /home/mfisch/.cache/accomplishments
The daemon is not running.
Setting up ubuntu-community-accomplishments (0.3~quantal2) ...
Reloading accomplishments for mfisch
mfisch: /home/mfisch/.cache/accomplishments
The daemon is not running.
Reloading accomplishments for fred
mfisch: /home/mfisch/.cache/accomplishments
The daemon is not running.


This is the bug: https://bugs.launchpad.net/ubuntu-accomplishments-daemon/+bug/1049846

--

Matthew (Matt) Fischer
LP: http://launchpad.net/~mfisch
IRC: mfisch


Follow ups