Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use unqualified command paths #52

Merged
merged 1 commit into from
Jun 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/puppet/provider/default_printer/cups.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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