From c8ce27d10ebdfc91de5579c47c808a1d41b94223 Mon Sep 17 00:00:00 2001 From: Markus Strauss Date: Sun, 30 Oct 2011 17:41:19 -0400 Subject: added ability to configure the finish script and provide a simple default one --- manifests/service.pp | 17 +++++++++++++++-- templates/finish.erb | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 templates/finish.erb diff --git a/manifests/service.pp b/manifests/service.pp index 5d7d928..4f886cf 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -3,12 +3,16 @@ define runit::service ( $group = root, # the service's group name $enable = true, # shall the service be linked to /etc/service $ensure = present, # shall the service be present in /etc/sv - # either one of these three must be declared - it defines the content of the run script /etc/sv/$name/run + # start command - either one of these three must be declared - it defines the content of the run script /etc/sv/$name/run $command = undef, # the most simple way; just state command here - it may not daemonize itself, # but rather stay in the foreground; all output is logged automatically to $logdir/current # this uses a default template which provides logging $source = undef, # specify a source file on your puppet master $content = undef, # specify the content directly (mostly via 'template') + # finish command - defines the content of the finish script /etc/sv/$name/finish + $finish_command = '', + $finish_source = undef, + $finish_content = undef, # service directory - this is required if you use 'command' $rundir = undef, # logging stuff @@ -63,8 +67,17 @@ define runit::service ( ensure => $ensure, mode => 755, ; + "${svbase}/finish": + content => $finish_content ? { + undef => template('runit/finish.erb'), + default => $finish_content, + }, + source => $finish_source, + ensure => $ensure, + mode => 755, + ; } - + # eventually enabling the service if $ensure == present and $enable == true { $_ensure_enabled = present diff --git a/templates/finish.erb b/templates/finish.erb new file mode 100644 index 0000000..787a174 --- /dev/null +++ b/templates/finish.erb @@ -0,0 +1,3 @@ +#!/bin/bash +echo "Stopping <%= name %>" +<%= finish_command %> -- cgit v1.2.3