Skip to content

How to override daemon templates

Martin Chalupa edited this page Jan 10, 2019 · 3 revisions

nebula.ospackage-daemon plugin provides opinions on how should look like scripts for starting a service. It provides those default templates run.tpl, log-run.tpl, initd.tpl, postInstall.tpl.

If you want to override those templates you can specify a custom folder for templates. Using this DSL:

daemonsTemplates.folder = 'templates'

The plugin will search for a folder called templates in your project directory. It will expect that you will provide all the mentioned templates in this directory. When writing your custom template the plugin will provide the following variables which you can use:

    String daemonName // defaults to packageName
    String command // Required
    String user // defaults to "root"
    String logCommand // defaults to "multilog t ./main"
    String logDir // defaults to "./main"
    String logUser // defaults to "nobody"
    List<Integer> runLevels = new LinkedList<>() // rpm default == [3,4,5], deb default = [2,3,4,5]
    Boolean autoStart // default true
    Integer startSequence // default 85
    Integer stopSequence // default 15
    String installCmd

You can consume a variable in a template like this:

#!/bin/sh
exec 2>&1
exec setuidgid ${user} ${command}
Clone this wiki locally