upstart config to start sync daemon as non-root user
- by Rudiger Wolf
I am planning to use inosync to sync data from master server to several client servers. I have created a user called rsyncuser in both master and slaves with access permissions and passwordless ssh access from master to slave servers.
Inosync is working when I use it from the command line as rsyncuser.
Next I want this to start automatically when server is turned on. I figured upstart is the way to get this working.
I am unable to find the right upstart command to get this working.
Here is my upstart conf file. The problem seems to be around running "inosync -d -c /etc/inosync/inosync_rsyncuser.py" as a given user.
As you can see I have tried a number of various options!
description "start inosync to sync data to other CDN Servers as rsyncuser"
console output
#start on startup
#stop on shutdown
start on (net-device-up and local-filesystems)
stop on runlevel [016]
#start on runlevel [2345]
#stop on runlevel [!2345]
#kill timeout 30
env RUN_AS_USER=rsyncuser
expect fork
script
echo "Inosync updtart job seems to have started" /tmp/upstart.log
# exec sudo -u rsyncuser -c "ls -la" /tmp/upstart.log 2&1
# LOGFILE=/var/log/logfile.`date +%Y-%m-%d`.log
# exec su - $RUN_AS_USER -c "inosync -d -c /etc/inosync/inosync_rsyncuser.py" $LOGFILE 2&1
# exec su -c "ls -la" /tmp/upstart.log 2&1
# emit inosync_running
end script