Properly Configuring Upstart to Run gw6c IPv6 Client After Networking is Available


1 views

When migrating from Ubuntu Karmic to Lucid, one common pitfall is ensuring network-dependent services start at the right time. The gw6c IPv6 client is particularly sensitive to this timing issue, as it requires a functional network interface before it can establish connections.

The traditional init.d script approach was straightforward:

#! /bin/sh
/usr/local/gw6c/bin/gw6c -f /usr/local/gw6c/bin/gw6c.conf

However, when translating this to Upstart, we need to consider service dependencies more carefully.

The initial Upstart configuration had several issues:

respawn
console none

start on startup

stop on shutdown

script
exec /usr/local/gw6c/bin/gw6c -f /usr/local/gw6c/bin/gw6c.conf
emit free6_ipv6_started
end script

Key problems with this implementation:

  • Starting on 'startup' is too early in the boot process
  • No network interface dependency
  • Error code 8 suggests network unavailability

The solution lies in using the correct Upstart events. Here's the corrected version:

description "gw6c IPv6 client"
author "Your Name"

respawn
console none

start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown

script
    # Small delay to ensure network stability
    sleep 2
    exec /usr/local/gw6c/bin/gw6c -f /usr/local/gw6c/bin/gw6c.conf
    emit free6_ipv6_started
end script

The modified configuration makes several important changes:

  • Waits for both filesystems and specific network interface
  • Adds a small delay to ensure network stability
  • Maintains respawn behavior for reliability

If issues persist, consider these troubleshooting steps:

# Check Upstart logs
sudo cat /var/log/upstart/gw6c.log

# Verify network status
ip addr show eth0

# Test manual start
sudo start gw6c

For systems using NetworkManager, you might consider:

start on (local-filesystems and started network-manager)

This provides more flexibility if your network configuration changes frequently.


When migrating from traditional init.d scripts to Upstart in Ubuntu Lucid Lynx, one common pitfall is handling service dependencies - particularly network availability. The gw6c client failing to start at boot with status code 8 typically indicates it's attempting to establish IPv6 connectivity before the network interface is ready.

The key is using Upstart's event system to delay gw6c startup until networking is fully initialized. Here's the corrected configuration for /etc/init/gw6c.conf:

description "Gogo6 IPv6 Client"
author "Your Name"

start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown

respawn
console none

script
    # Add slight delay after network comes up
    sleep 2
    exec /usr/local/gw6c/bin/gw6c -f /usr/local/gw6c/bin/gw6c.conf
    emit free6_ipv6_started
end script
  • start on net-device-up: Ensures the network interface is operational
  • IFACE=eth0: Specifies the exact interface to wait for
  • sleep 2: Adds buffer time after network initialization
  • local-filesystems: Guarantees filesystem availability

If issues persist, add logging to your Upstart script:

script
    logger -t gw6c "Starting gw6c service"
    ifconfig eth0 > /var/log/gw6c-start.log
    /usr/local/gw6c/bin/gw6c -f /usr/local/gw6c/bin/gw6c.conf 2>&1 | logger -t gw6c
end script

For newer Ubuntu versions using systemd, create /etc/systemd/system/gw6c.service:

[Unit]
Description=Gogo6 IPv6 Client
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/gw6c/bin/gw6c -f /usr/local/gw6c/bin/gw6c.conf
Restart=on-failure

[Install]
WantedBy=multi-user.target
  1. sudo initctl list | grep gw6c - Check service status
  2. tail -f /var/log/syslog - Monitor startup messages
  3. ip -6 addr show - Verify IPv6 connectivity