Skip to content

shanesiebken/gradle-init-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RPM init script plugin

The plugin builds on the nubula.rpm plugin from Netflix. Unlike the more general service script code created by nebula.ospackage-daemon, the scripts generated by this plugin do not use daemontools. This plugin also provides a options for creating a service account user.

Usage

General

Add both this plugin and nebula.rpm to your project.
plugins {
  id "nebula.rpm" version "4.3.0"
  id "amdonov.ospackage-init" version "0.4.0"
}
Use daemon to configure your service
daemon {
    daemonName = "myservice"
    command = "/usr/bin/myservice server"
    user = 'myuser'
    group = 'myuser'
    createUser = true
}

In addition to creating the init script, the preceeding options would create the following RPM scripts.

preinstall
/usr/sbin/groupadd -r myuser 2>/dev/null || :
/usr/sbin/useradd -g myuser \
 -s /sbin/nologin -r myuser 2>/dev/null || :
postinstall
/sbin/chkconfig myservice on
preuninstall
if [ "$1" = "0" ]; then
    /etc/rc.d/init.d/myservice stop >/dev/null 2>&1
    /sbin/chkconfig --del myservice
fi

Options

The plugin supports the options shown below.

Daemon options
    String daemonName // defaults to packageName
    String command // Required
    String user // defaults to "root"
    String group // defaults to "root"
    List<Integer> runLevels = new LinkedList<>() // rpm default == [3,4,5]
    Integer startSequence // default 85
    Integer stopSequence // default 15
    Boolean createUser // default false
    String userShell // defaults /sbin/nologin
    String userHome  // default unset

Customizing Service Execution

The generated service script initializes and uses variables shown below. It will also source the the file /etc/sysconfig/${daemonName}. Use that file to override defaults, set extra environment varibles, etc.

Script variables
name=${daemonName}
pidfile="/var/run/${daemonName}.pid"
command="${command}"
user="${user}"
group="${group}"
chroot="/"
chdir="/"
nice=""

About

Extension to nebula ospackage plugin to create init scripts for RPM projects

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Groovy 77.4%
  • Shell 22.6%