Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to start a service that depends on networking being started, whenever the computer is rebooted. I have a few questions:

  1. Is this easily possible from an /etc/init.d script? I have tried creating a script here (conforming to the standards), but I'm really doubtful that it's even running on boot, let alone working. When I test it manually, it works.

  2. I've seen the new Upstart service, but as far as how that actually works, I'm completely in the dark.

How can I make a script that runs on boot which runs after networking has been started? If I could run it after connected to wireless network, even better :)

share|improve this question
up vote 6 down vote accepted

You can use files in /etc/init as models. For example, this is /etc/init/mountall-net.conf:

# mountall-net - Mount network filesystems
#
# Send mountall the USR1 signal to inform it to try network filesystems
# again.

description     "Mount network filesystems"

start on net-device-up

task

script
    PID=$(status mountall 2>/dev/null | sed -e '/,/{s/.*,[^0-9]*//;q};d')
    [ -n "$PID" ] && kill -USR1 $PID || true
end script

and this is '/etc/init/ufw.conf`:

# ufw - Uncomplicated Firewall
#
# The Uncomplicated Firewall is a front-end for iptables, to make managing a
# Netfilter firewall easier.

description     "Uncomplicated firewall"

start on net-device-added INTERFACE=lo
stop on runlevel [!023456]

console output

pre-start exec /lib/ufw/ufw-init start quiet
post-stop exec /lib/ufw/ufw-init stop

The latter file has a symlink in /etc/init.d:

$ ls -l /etc/init.d/ufw
lrwxrwxrwx 1 root root 21 2009-11-05 00:14 /etc/init.d/ufw -> /lib/init/upstart-job
share|improve this answer
    
Should I start on net-device-up or on net-device-added? I'm using this script to start a DLNA server serving over wlan0. Thanks for the tip, I'll have to find a good guide on all of the options available for Upstart, seems like it's years ahead of system v. – Naftuli Tzvi Kay Feb 21 '11 at 23:28
1  
@TKKocheran: Since you probably need communication to be available, net-device-up would probably be the way to go. Here's the reference. Look particularly at the wiki. – Dennis Williamson Feb 22 '11 at 0:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .