source: trunk/puppet/modules/puppet-cups/manifests/init.pp @ 546

Last change on this file since 546 was 514, checked in by sebas, 15 years ago

agregamos un programa de ocr en los clientes de scaneador

File size: 5.2 KB
RevLine 
[417]1# copyright koumbit.org
2# Licence: GPL
3
[471]4class cups {
[473]5}
[471]6
[478]7define cups::saned::client ($remotescanner)
8  {
9   package { "xsane": ensure => "installed" }
[514]10   package { "gocr-tk": ensure => "installed" }
[478]11
12   file { "/etc/sane.d/net.conf":
13      ensure => present,
14      require => Package["xsane"],
15      owner => "root", group => "root", mode => "644",
16   }
17    line { saned_remotescanner:
18      file => "/etc/sane.d/net.conf",
19      line => $remotescanner,
20      ensure => present,
21      require => Package["xsane"],
22    }
23  }
24
[473]25class cups::saned {
26
27   package { "sane-utils": ensure => "installed" }
28
[476]29    line { saned_activate_off:
30      file => "/etc/default/saned",
31      line => 'RUN=no',
32      ensure => absent,
33      require => Package["sane-utils"],
34      notify  => Service["saned"],
35    }
36    line { saned_activate_on:
37      file => "/etc/default/saned",
38      line => 'RUN=yes',
39      ensure => present,
40      require => Package["sane-utils"],
41      notify  => Service["saned"],
42    }
43
[473]44   file { "/etc/default/saned":
45      ensure => present,
46      require => Package["sane-utils"],
47      owner => "root", group => "root", mode => "644",
48   }
49
[478]50    line { saned_allow:
51      file => "/etc/sane.d/saned.conf",
52      line => $sanedallow,
53      ensure => present,
54      require => Package["sane-utils"],
55      notify  => Service["saned"],
56    }
57
58   file { "/etc/sane.d/saned.conf":
59      ensure => present,
60      require => Package["sane-utils"],
61      owner => "root", group => "root", mode => "644",
62   }
63
[472]64   service { "saned":
[473]65      enable => true,
66      ensure => running,
[476]67      provider => "debian",
[473]68      subscribe => [ Package["sane-utils"], File["/etc/default/saned"] ],
[472]69   }
[474]70
71   @user { "saned":
72        ensure  => "present",
73        groups  => "lp",
74        require => Package["sane-utils"],
75   }
76
77   realize(
78        User["saned"]
79   )
80
[471]81}
82
[463]83class cups::server {
[417]84
85   package { "cupsys": ensure => "installed" }
[469]86   package { [ "hplip", "hpijs-ppds" ]: ensure => installed; }
[417]87
[443]88   file { "/etc/cups/cupsd.conf":
[464]89      source => "puppet:///cups/cupsd.conf",
[419]90      ensure => present,
91      require => Package["cupsys"],
92      owner => "root", group => "root", mode => "644",
93   }
94
[469]95   file { "/etc/cups/printers.conf":
96      ensure => present,
97      require => Package["cupsys"],
98      owner => "root", group => "lp", mode => "600",
99   }
[475]100
101   service { "cups":
102      enable => true,
103      ensure => running,
[476]104      provider => "debian",
[475]105      subscribe => [ Package["cupsys"], File["/etc/cups/cupsd.conf"] ],
106   }
[417]107}
[419]108
[471]109define cups::printer ($printer, $p_deviceuri, $p_description, $p_location, $p_pathppd = "", $p_ppd = "", $p_filter = "", $p_accept = "", $p_enable = "", $p_scan = "" )
[463]110 {
111   include cups::server
112
[469]113  if $p_pathppd {
114    exec { "cups_create_printer_$name":
115      command => "lpadmin -p $printer -v $p_deviceuri -D '$p_description' -L '$p_location' -P $p_pathppd",
116      path => "/bin:/sbin:/usr/sbin:/usr/bin",
117      unless => "/bin/grep $printer /etc/cups/printers.conf",
[476]118      require => [Package["cupsys"], Package["hplip"], Package["hpijs-ppds"], Service["cups"]],
[469]119    }
120  } else {
121     file { "/etc/cups/ppd/$p_ppd":
122     ensure => present,
123     owner => "root", group => "root", mode => "644",
124     source  => "puppet:///files/cups/$name/$p_ppd",
125     require => [Package["cupsys"], Package["hplip"], Package["hpijs-ppds"]],
126    }
127    $p_pathppdd = "/etc/cups/ppd/"
128
129    exec { "cups_create_printer_$name":
130      command => "lpadmin -p $printer -v $p_deviceuri -D '$p_description' -L '$p_location' -P $p_pathppdd$p_ppd",
131      path => "/bin:/sbin:/usr/sbin:/usr/bin",
132      unless => "/bin/grep $printer /etc/cups/printers.conf",
133      require => [Package["cupsys"], Package["hplip"], Package["hpijs-ppds"]],
134    }
[463]135  }
136
[469]137  if $p_filter {
138     file { "/usr/lib/cups/filter/$p_filter":
139     ensure => present,
140     owner => "root", group => "root", mode => "755",
141     source  => "puppet:///files/cups/$name/$p_filter",
142     require => exec["cups_create_printer_$name"],
143    }
144  } else {
145    debug ("'$printer' doesn't need a special filter")
146  }
147
[468]148  if $p_accept {
149    exec { "cupsaccept_$name":
150      command => "cupsaccept $printer",
151      path => "/bin:/sbin:/usr/sbin:/usr/bin",
152      unless => "grep -A8 $printer /etc/cups/printers.conf | grep 'Accepting Yes'",
153      require => exec["cups_create_printer_$name"],
154    }
155  } else {
[477]156    exec { "cupsreject_$name":
157      command => "cupsreject $printer",
158      path => "/bin:/sbin:/usr/sbin:/usr/bin",
159      unless => "grep -A8 $printer /etc/cups/printers.conf | grep 'Accepting No'",
160      require => exec["cups_create_printer_$name"],
161    }
[468]162    debug ("'$printer' will not accept print jobs")
[464]163  }
164
[468]165  if $p_enable {
166    exec { "cupsenable_$name":
167      command => "cupsenable $printer",
168      path => "/bin:/sbin:/usr/sbin:/usr/bin",
169      unless => "grep -A5 $printer /etc/cups/printers.conf | grep 'State Idle'",
170      require => exec["cups_create_printer_$name"],
171    }
172  } else {
[477]173    exec { "cupsdisable_$name":
174      command => "cupsdisable $printer",
175      path => "/bin:/sbin:/usr/sbin:/usr/bin",
176      unless => "grep -A5 $printer /etc/cups/printers.conf | grep 'State Stopped'",
177      require => exec["cups_create_printer_$name"],
178    }
[468]179    debug ("'$printer' is disabled")
[464]180  }
181
[471]182  if $p_scan {
[473]183    include cups::saned
[471]184  } else {
185    debug ("'$printer' cannot scan on the network")
186  }
187
[463]188}
189
Note: See TracBrowser for help on using the repository browser.