From 592706382d6e717e991cacb8041da179eafa5e95 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Sun, 15 Jan 2012 13:41:11 +0000 Subject: add a custom wrapper for running ii, since it doesn't react like a regular daemon, and doing this with simple shell command is too tedious. --- modules/ii/manifests/init.pp | 14 ++++++++++---- modules/ii/templates/ii_wrapper.pl | 10 ++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 modules/ii/templates/ii_wrapper.pl (limited to 'modules') diff --git a/modules/ii/manifests/init.pp b/modules/ii/manifests/init.pp index e0e9b5c7..c024bc49 100644 --- a/modules/ii/manifests/init.pp +++ b/modules/ii/manifests/init.pp @@ -14,15 +14,21 @@ class ii { $nick = $name include ii::base + # a custom wrappper is needed since ii do not fork in the + # background, and bash is not able to properly do it + local_script { "ii_$nick": + content => "ii/ii_wrapper.pl", + require => Class['ii::base'], + } service { 'ii': provider => base, - start => "su nobody -c 'nohup ii -n $nick -i /var/lib/ii/$nick -s $server'", - notify => Exec["join channel"], - require => Class['ii::base'], + start => "/usr/local/bin/ii_$nick", + notify => Exec["join channel $nick"], + require => Local_script["ii_$nick"], } - exec { "join channel": + exec { "join channel $nick": command => "echo '/j $channel' > /var/lib/ii/$nick/$server/in", user => nobody, refreshonly => true, diff --git a/modules/ii/templates/ii_wrapper.pl b/modules/ii/templates/ii_wrapper.pl new file mode 100644 index 00000000..da3a380f --- /dev/null +++ b/modules/ii/templates/ii_wrapper.pl @@ -0,0 +1,10 @@ +#!/usr/bin/perl +use warnings; +use strict; +use Proc::Daemon; +my $nick = "<%= nick %>"; +my $server = "<%= server %>"; + +Proc::Daemon::Init(); +fork() || exec "ii -n $nick -i /var/lib/ii/$nick -s $server"; +wait(); -- cgit v1.2.1