Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question

1 Answer 1

sudo by default stomps on most of the environment. Try this (adding -E):

exec sudo -E -u rsyncuser -c "ls -la" >> /tmp/upstart.log 2>&1

-E tells sudo to preserve the environment.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.