Hardware authentication for Linux using ordinary USB Flash Drives.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.0 KiB

  1. #!/usr/bin/env ruby
  2. require 'open-uri'
  3. BASE_URI = 'http://www.pamusb.org/doku/doc/'
  4. DOC_PATH = './pam_usb/doc/'
  5. DOCS = [ 'install', 'upgrading' ]
  6. REPLACE_LIST = [
  7. # Extract text area from xhtml document.
  8. { :pattern => /.*<textarea .+>(.*)<\/textarea>.*/m, :with => '\1' },
  9. # Remove wiki links [[link|name]]
  10. { :pattern => /\[\[.+\|(.+)\]\]/, :with => '\1' },
  11. # Remove trailing whitespaces
  12. { :pattern => /^ /, :with => '' },
  13. # Remove misc xhtml / wiki characters
  14. { :pattern => /\/\//, :with => '' },
  15. { :pattern => /\\\\ /, :with => '' },
  16. { :pattern => /\*\*/, :with => '' },
  17. { :pattern => /&lt;/, :with => '<' },
  18. { :pattern => /&gt;/, :with => '>' },
  19. { :pattern => /&quot;/, :with => '"' },
  20. ]
  21. def fetch_doc(name)
  22. uri = BASE_URI + name + '?do=edit'
  23. body = open(uri) { |f| f.read }
  24. REPLACE_LIST.each { |r| body.gsub!(r[:pattern], r[:with]) }
  25. body
  26. end
  27. DOCS.each do |doc|
  28. print "Fetching doc:#{doc}... "
  29. STDOUT.flush
  30. text = fetch_doc(doc)
  31. File.open(File.join(DOC_PATH, doc), 'w') { |f| f.write(text) }
  32. puts "Done."
  33. end