4

I have a daemon script in /etc/init.d that performs some background packet logging using the tcpdump command. The script starts up fine using an interactive shell using sudo /etc/init.d/packetlog start

When I execute the same command through my fabric script (below) the command returns successfully but the process is not running.

def startpacketlog(): sudo(r'/etc/init.d/packetlog start') 

Further to this, the service does not start automatically on boot as I had expected.

Some tips for troubleshooting this would be appreciated

The script is here and is modified from this original

Update This seems to be a general problem with starting any service on this host using fabric. When starting the apache2 service I get the same problem. I can stop the service using fabric successfully though.

Update 2 After re-reading the documentation and some experimentation the following change fixed the problem. (This disables the remote pseudo-terminal, whatever that is)

def startpacketlog(): sudo(r'/etc/init.d/packetlog start',pty=False) 
2
  • might help if you post the fabric line you are using Commented May 17, 2011 at 16:07
  • good point - I've added it now Commented May 17, 2011 at 17:20

1 Answer 1

3

When you invoke an init script directly, your current environment can "leak" into the init script.

Test your init script using the appropriate system tools:

# Redhat/CentOS, and Ubuntu with upstart sudo service packetlog start # traditional method on Debian/Ubuntu sudo invoke-rc.d packetlog start 

These will make sure the script is starting in a clean environment, identical to the one it would be in when started by init.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.