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?
Best Answer
Every package that provides a standard daemon using upstart is required to provide a symlink in
/etc/init.d
by Debian policy. So autocompletion forsudo service name
already works. Make sure that you have thebash-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:These exceptions do not currently work with
bash-completion
. However, you can usestart
,stop
,restart
andreload
directly withoutservice
, 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 correspondinginit.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).