Skip to content

Instantly share code, notes, and snippets.

@jamtur01
Created December 27, 2014 05:47
Show Gist options
  • Save jamtur01/4b4916df93cc6ffd3be7 to your computer and use it in GitHub Desktop.
Save jamtur01/4b4916df93cc6ffd3be7 to your computer and use it in GitHub Desktop.
Tilde.works active user list script
require 'rubygems'
require 'digest/md5'
require 'pathname'
default_md5 = Digest::MD5.hexdigest(File.read('/etc/skel/public_html/index.html'))
homedirs = Pathname.glob('/home/*/').map(&:basename)
html = "our hard working users (#{homedirs.length})<br> <sub>generated at #{Time.now.strftime("%Y-%m-%d %H:%M:%S")}</sub><br>\n<ul>\n"
homedirs.each { |d|
index = Dir.glob("/home/#{d}/public_html/index.html")
md5 = Digest::MD5.hexdigest(File.read(index.first))
if md5 == default_md5
html << "<li><a href=\"http://tilde.works/~#{d}\">#{d}</a> - default :3</li>"
else
html << "<li><a href=\"http://tilde.works/~#{d}\">#{d}</a> </li>"
end
html << "\n"
}
html << "</ul>"
puts html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment