3

I'm not clear on how to start a service when the server boots, I read on some of the other questions asked about adding the script to /etc/init.d, but It's just one line that I need to execute in the commandline:

sudo /etc/init.d/avahi-daemon restart

But I have a few issues with this, firstly, I apparently need to use sudo, and it gives me the following:

ngl-server-01:~% sudo /etc/init.d/avahi-daemon start  
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service avahi-daemon start

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start avahi-daemon

But when I try just avahi-daemon start I get:

Too many arguments

Why is this? and how would you start this service?

Update

Similarly, how can I mount a disk on boot as well?

3 Answers 3

5

You can start the service manually by using

sudo start avahi-daemon

and not using

sudo avahi-daemon start

If you want it so the service starts at boot. You need to have a look at adding a symlink to /etc/rc2.d/ to point at /etc/init.d/avahi-daemon. It is probably easier to read up on the programs sysv-rc-conf or update-rc.d

For mounting a disk you need to edit /etc/fstab with the correct details. You need to know the device you are trying to mount (eg /dev/sdb1), the mount point (eg /mnt/data)and the filesystem.

The entry in fstab will look something like this:

/dev/sdb1    /mnt/data    ext3    defaults    0    2
2
  • Hmm, this seems to be exactly what I need to do, the issue is that I don't know what to set as the mount point for the disk, when It is mounted it says it's mounted at /media/ca4a8c50-2d0a-4c38-a6c5-c0494d0533a2, and that number changes everytime it gets mounted. Also I need to have it mounted before the Avahi service starts so it can broadcast that the disk is available. Mar 21, 2010 at 23:35
  • 1
    Disks will get mounted before services are started. With regards to where you mount the drive it is up to you. Don't worry about the long number for what you are trying to do. Add the entry to /etc/fstab and try it. Post back if you get stuck or get further problems. Mar 22, 2010 at 8:48
8

If avahi-daemon is in /etc/init.d and you want to have it started at each boot, just add it to the startup scripts with:

sudo update-rc.d avahi-daemon defaults

But i'm surprised that avahi-daemon is not still linked in the required runlevels as it was probably added by the system.

To have your disk mounted at boot, add a line in your fstab like suggested by Richard.

2

I had a problem getting avahi-daemon to start on system startup in Ubuntu Server 12.04 even after doing sudo update-rc.d avahi-daemon defaults and I've solved it by changing AVAHI_DAEMON_DETECT_LOCAL from 1 to 0 in /etc/default/avahi-daemon (as proposed here).

My understanding of the problem is that avahi-daemon started before my server was ready for networking. It tried to detect "unicast dns servers", obviously failed and exited afterwards. This is the default behavior. By changing AVAHI_DAEMON_DETECT_LOCAL to 0, I told avahi-daemon not to look for these servers when it starts.

I've also figured that I did really not need to run sudo update-rc.d avahi-daemon defaults, so user MatToufoutu was right to doubt.

1
  • +1 The answer (changing AVAHI_DAEMON_DETECT_LOCAL) solved my problem with Raspberry Pi Zero W. The raspberry was running Raspbian GNU/Linux 9.4 (stretch) with avahi-daemon 0.6.32-2 Jun 15, 2019 at 18:48

You must log in to answer this question.

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