1 |
misc |
2251 |
class ii { |
2 |
|
|
class base { |
3 |
misc |
2263 |
package { ["ii", "perl-Proc-Daemon"]: } |
4 |
misc |
2251 |
|
5 |
|
|
file { "/var/lib/ii/": |
6 |
|
|
ensure => directory, |
7 |
|
|
owner => nobody, |
8 |
|
|
} |
9 |
|
|
} |
10 |
|
|
|
11 |
|
|
define bot($server = 'irc.freenode.net', |
12 |
|
|
$channel) { |
13 |
|
|
|
14 |
|
|
$nick = $name |
15 |
|
|
|
16 |
|
|
include ii::base |
17 |
misc |
2262 |
# a custom wrappper is needed since ii do not fork in the |
18 |
|
|
# background, and bash is not able to properly do it |
19 |
|
|
local_script { "ii_$nick": |
20 |
misc |
2276 |
content => template("ii/ii_wrapper.pl"), |
21 |
misc |
2262 |
require => Class['ii::base'], |
22 |
|
|
} |
23 |
misc |
2251 |
|
24 |
|
|
service { 'ii': |
25 |
|
|
provider => base, |
26 |
misc |
2262 |
start => "/usr/local/bin/ii_$nick", |
27 |
|
|
require => Local_script["ii_$nick"], |
28 |
misc |
2251 |
} |
29 |
|
|
|
30 |
misc |
2262 |
exec { "join channel $nick": |
31 |
misc |
2251 |
command => "echo '/j $channel' > /var/lib/ii/$nick/$server/in", |
32 |
|
|
user => nobody, |
33 |
misc |
2264 |
unless => "test -d /var/lib/ii/$nick/$server/$channel", |
34 |
|
|
require => Service['ii'], |
35 |
misc |
2251 |
} |
36 |
|
|
} |
37 |
|
|
} |