I'm running owncloud client in Ubuntu and after a suspend/resume there's a bug in owncloud which makes it not be able to connect to the server.
I wrote a little script which should restart owncloud, but it doesn't.
I've put it in
/lib/systemd/system-sleep and the script runs.
#! /bin/sh case $1 in pre) echo "$(date) off" >> /var/log/sulog.txt #debugging ;; post) echo "$(date) on" >> /var/log/sulog.txt #debugging killall owncloud /usr/bin/owncloud echo "$(date) started owncloud" >> /var/log/sulog.txt #debugging ;; esac
The script executes as the log file is updated. However it doesn't kill the active owncloud instance and it doesn't start a new one either when I resume after a suspend.
When I run the script in terminal as the current user it works as I want it to.
When I run it in root it kills the owncloud instance, but it then start a new one without the server settings etc. I've worked around that with
sudo -H -u <user> bash <....> to start it as another user, but then it doesn't work because it doesn't have the keychain unlocked.
How can I
/usr/bin/owncloud from within the script (which is run as root) as the current user with the current session so that the icon is also added to the statusbar?