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)
rupello
  • 113
  • 9

1 Answers1

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.

JimB
  • 1,924
  • 12
  • 15