Skip to content

Commit

Permalink
Merge pull request #52 from pyther/master
Browse files Browse the repository at this point in the history
use unqualified command paths
  • Loading branch information
mosen committed Jun 18, 2015
2 parents 8eab33d + fc367c7 commit 1e2484c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 56 deletions.
6 changes: 3 additions & 3 deletions lib/puppet/provider/default_printer/cups.rb
Expand Up @@ -4,8 +4,8 @@
This has no effect on the Mac OS X default destination, which is set via the GUI only.
"

commands :lpoptions => '/usr/bin/lpoptions'
commands :lpstat => '/usr/bin/lpstat'
commands :lpoptions => 'lpoptions'
commands :lpstat => 'lpstat'

def self.instances
default = printer_default
Expand Down Expand Up @@ -37,4 +37,4 @@ def exists?
self.class.printer_default == @resource[:name]
end

end
end
68 changes: 18 additions & 50 deletions lib/puppet/provider/printer/cups.rb
Expand Up @@ -22,58 +22,26 @@
a printer.
"

commands :lpadmin => '/usr/sbin/lpadmin'
commands :lpoptions => '/usr/bin/lpoptions'
commands :lpstat => '/usr/bin/lpstat'

#
# candidate locations for the enable command
# Solaris 11 & Illumos/OpenIndiana have /usr/bin/{enable,disable}
#
[ "/usr/sbin/cupsenable",
"/usr/bin/cupsenable",
"/usr/sbin/enable",
"/usr/bin/enable"].each do |cups_command|
if File.exists?(cups_command)
commands :cupsenable => cups_command
break
end
end

[ "/usr/sbin/cupsdisable",
"/usr/bin/cupsdisable",
"/usr/sbin/disable",
"/usr/bin/disable"].each do |cups_command|
if File.exists?(cups_command)
commands :cupsdisable => cups_command
break
end
os = Facter.fact('os').value
os_family = os['family'].downcase

commands :lpadmin => 'lpadmin'
commands :lpoptions => 'lpoptions'
commands :lpstat => 'lpstat'

# Solaris 11 & Illumos/OpenIndiana have /usr/bin/{enable,disable,accept,reject}
if os_family == 'solaris'
commands :cupsenable => 'enable'
commands :cupsdisable => 'disable'
commands :cupsaccept => 'accept'
commands :cupsreject => 'reject'
else
commands :cupsenable => 'cupsenable'
commands :cupsdisable => 'cupsdisable'
commands :cupsaccept => 'cupsaccept'
commands :cupsreject => 'cupsreject'
end

#
# Candidate locations for the accept and reject commands
# Older Fedora and RHEL/CentOS 6.x and earlier have /usr/sbin/{accept,reject}
# Solaris 11 & Illumos/OpenIndiana have the same.
#
[ "/usr/sbin/cupsaccept",
"/usr/bin/cupsaccept",
"/usr/sbin/accept",
"/usr/bin/accept"].each do |cups_command|
if File.exists?(cups_command)
commands :cupsaccept => cups_command
break
end
end

[ "/usr/sbin/cupsreject",
"/usr/bin/cupsreject",
"/usr/sbin/reject",
"/usr/bin/reject"].each do |cups_command|
if File.exists?(cups_command)
commands :cupsreject => cups_command
break
end
end

mk_resource_methods

Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/provider/printer_defaults/cups_options.rb
Expand Up @@ -11,8 +11,8 @@
Classes are parsed as normal printer destinations at the moment, and are interpreted as such.
"

commands :lpoptions => "/usr/bin/lpoptions"
#commands :lpinfo => "/usr/sbin/lpinfo"
commands :lpoptions => "lpoptions"
#commands :lpinfo => "lpinfo"

mk_resource_methods

Expand Down Expand Up @@ -70,4 +70,4 @@ def destroy
def exists?
self.class.printer_options().key? @resource[:name]
end
end
end

0 comments on commit 1e2484c

Please sign in to comment.