Difference between revisions of "Webcam"

From Baltimore Node Wiki
(Created page with 'http://baltimorenode.org/images/webcam.jpg')
 
Line 1: Line 1:
 
http://baltimorenode.org/images/webcam.jpg
 
http://baltimorenode.org/images/webcam.jpg
 +
 +
backup_images.sh :
 +
<pre><code>
 +
#!/bin/sh
 +
 +
OLDFILE=`md5sum /home/bnode/webcam-backup/$(ls /home/bnode/webcam-backup | tail -n1) | cut -d ' ' -f1`
 +
 +
NEWFILE=`md5sum /home/bnode/baltimorenode.org/public/images/webcam.jpg | cut -d ' ' -f1`
 +
 +
if [ "$OLDFILE" == "$NEWFILE" ]; then
 +
  echo "Still the same"
 +
else
 +
  echo "NEW!"
 +
  cp /home/bnode/baltimorenode.org/public/images/webcam.jpg /home/bnode/webcam-backup/webcam-$(date +%Y%m%d%H%M%S).jpg
 +
fi
 +
 +
</code></pre>
 +
 +
makeimagepage.rb:
 +
 +
<pre><code>
 +
#!/usr/bin/env ruby
 +
 +
`touch /home/bnode/baltimorenode.org/public/webcam.html`
 +
out = []
 +
File.open("/home/bnode/baltimorenode.org/public/webcam.html", 'w') do |f|
 +
  f.write("<html><head></head><body>")
 +
  f.write("<img src='images/webcam.jpg'><br><br>")
 +
  f.write("<ul><li>")
 +
  Dir.entries("/home/bnode/webcam-backup").sort.each do |e|
 +
    next if ['.', '..'].include? e
 +
    out << "<a href='images/#{e}'>#{e}</a>"
 +
    `ln -fs /home/bnode/webcam-backup/#{e} /home/bnode/baltimorenode.org/public/images/#{e}`
 +
  end
 +
  f.write out.join('</li><li>')
 +
  f.write("</li></ul></body></html>")
 +
end
 +
puts "Linked to: \n* #{out.join("\n")}"
 +
</code></pre>

Revision as of 02:01, 26 August 2009

webcam.jpg

backup_images.sh :

<code>
#!/bin/sh

OLDFILE=`md5sum /home/bnode/webcam-backup/$(ls /home/bnode/webcam-backup | tail -n1) | cut -d ' ' -f1`

NEWFILE=`md5sum /home/bnode/baltimorenode.org/public/images/webcam.jpg | cut -d ' ' -f1`

if [ "$OLDFILE" == "$NEWFILE" ]; then
  echo "Still the same"
else
  echo "NEW!"
  cp /home/bnode/baltimorenode.org/public/images/webcam.jpg /home/bnode/webcam-backup/webcam-$(date +%Y%m%d%H%M%S).jpg
fi

</code>

makeimagepage.rb:

<code>
#!/usr/bin/env ruby

`touch /home/bnode/baltimorenode.org/public/webcam.html`
out = []
File.open("/home/bnode/baltimorenode.org/public/webcam.html", 'w') do |f|
  f.write("<html><head></head><body>")
  f.write("<img src='images/webcam.jpg'><br><br>")
  f.write("<ul><li>")
  Dir.entries("/home/bnode/webcam-backup").sort.each do |e|
    next if ['.', '..'].include? e
    out << "<a href='images/#{e}'>#{e}</a>"
    `ln -fs /home/bnode/webcam-backup/#{e} /home/bnode/baltimorenode.org/public/images/#{e}`
  end
  f.write out.join('</li><li>')
  f.write("</li></ul></body></html>")
end
puts "Linked to: \n* #{out.join("\n")}"
</code>