3

I just installed couchdb on a debian5 system and added symlinks to the /etc/init.d/couchdb-script. Unfortunately, this script gets triggered on startup before the network interface received the address over DHCP that the couchdb-server tries to bind to - which leaves the instance defunct.

I kind of solved this, by executing dhclient in the start script, but there just HAS to be a better way...? Is there?

weeheavy
  • 4,039
  • 1
  • 27
  • 41
flitzwald
  • 188
  • 1
  • 8

2 Answers2

3

Yes, there is a better way: place your couchdb init script in /etc/network/if-up.d/ so it will run after your network is set up.

Pay attention to:

   Filenames should consist entirely of upper and lower case
   letters, digits, underscores, and hyphens. Subdirectories  
   of directory and files with other names will be silently ignored.
weeheavy
  • 4,039
  • 1
  • 27
  • 41
  • I have a problem with if-up scripts being run before DHCP. All my services are starting up while there's no DNS server in /etc/resolv.conf! http://unix.stackexchange.com/q/272459/84496 – Danny Tuppeny Mar 27 '16 at 19:50
0

On CentOS and probably RedHat it checks to see if there is a file /sbin/ifup-local and will execute that if it is available.

to create it:

sudo touch /sbin/ifup-local
sudo chmod +x /sbin/ifup-local

Then edit it to contain what you would like

#!/bin/sh
# your commands or calls to your script here

Hope that helps. I like Debian's .d directory better but this seems to be the closest equivalent on CentOS.

cwd
  • 2,693
  • 9
  • 32
  • 47