aboutsummaryrefslogtreecommitdiffstats
path: root/modules/ii/manifests/init.pp
blob: 9f58b785fe249c5fc5288f4ff026ae0836dcf08e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class ii {
    class base {
        package {['ii',
                  'perl-Proc-Daemon']: }

        file { '/var/lib/ii/':
            ensure => directory,
            owner  => 'nobody',
        }
    }

    define bot( $server = 'irc.freenode.net',
                $channel) {

        $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
        mga_common::local_script { "ii_${nick}":
            content => template('ii/ii_wrapper.pl'),
            require => Class['ii::base'],
        }

        service { 'ii':
            provider => base,
            start    => "/usr/local/bin/ii_${nick}",
            require  => Mga_common::Local_script["ii_${nick}"],
        }

        exec { "join channel ${nick}":
            command => "echo '/j ${channel}' > /var/lib/ii/${nick}/${server}/in",
            user    => 'nobody',
            creates => "/var/lib/ii/${nick}/${server}/${channel}/in",
            require => Service['ii'],
        }
    }
}