Skip to content

Instantly share code, notes, and snippets.

@rickychilcott
Created October 6, 2011 16:48
Show Gist options
  • Save rickychilcott/1267912 to your computer and use it in GitHub Desktop.
Save rickychilcott/1267912 to your computer and use it in GitHub Desktop.
Fixing hostnames for MunkiServer
Computer.all.each{|c|
if c.hostname == ""
c.hostname = c.name
end
if !c.valid?
c.hostname.downcase!
c.hostname.strip!
c.hostname.sub! /[_\s]/, '-'
if c.save
puts c.name + " hostname fix completed"
else
puts c.name + " still needs to be fixed"
end
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment