16

I'm used to create upstart services with a file in /etc/init/<service>.conf and it works perfectly fine, the only thing I'd like to is to have tab completion the same way that every service in /etc/init.d/ have right now.

When writing sudo service xx the name of the service should apear.

Is there a way to add upstart services to that autocompletion list?

  • Hi , have you tried before ? – rɑːdʒɑ Jul 1 '13 at 14:12
25

Every package that provides a standard daemon using upstart is required to provide a symlink in /etc/init.d by Debian policy. So autocompletion for sudo service name already works. Make sure that you have the bash-completion package installed if you're having problems.

If you are creating your own upstart jobs, then symlink /etc/init.d/your_job to /lib/init/upstart-job like the other upstart jobs are doing already. This will make your own jobs work the same way.

There are special upstart jobs in /etc/init that do not have a corresponding entry in /etc/init.d. These are an exception. From Debian Policy:

An exception to this rule is scripts or jobs provided by the init implementation itself; such jobs may be required for an implementation-specific equivalent of the /etc/rcS.d/ scripts and may not have a one-to-one correspondence with the init scripts.

These exceptions do not currently work with bash-completion. However, you can use start, stop, restart and reload directly without service, and autocompletion will work. For example, sudo start shut correctly autocompletes. But you shouldn't normally need to directly call upstart jobs that do not have a corresponding init.d entry.

Note: I tested this on Saucy. If support doesn't appear in an older release, perhaps it is not available there (but you'll get it soon when you upgrade to a sufficiently new release).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.