All pastes #758477 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-11-02 09:13 UTC
rendered paste body
#!/usr/bin/ruby
# updatenotice.rb
##
##      This is a Ruby script meant to run in a cron on a Gentoo system.
##
##      The goal of this script is to email available portage updates to the system administrator
##

from = "scripts@hackdmz.net"
to = "magari@hackdmz.net"

emailheader = <<END_OF_MESSAGE
From: Scripts <#{$from}>
To: Magari <#{$to}>
Subject: Update Notice

END_OF_MESSAGE

emailfooter = <<END_OF_MESSAGE

--- SCRIPTS @ HACKDMZ ---

END_OF_MESSAGE

##
##
##      DONT EDIT PAST THIS LINE
##
##

require 'net/smtp'

sync = %x[emerge --sync]

if ($? == 0)
        updates = %x[emerge -uDpv world]

        if ($? == 0)
                message = "#{emailheader} #{updates} #{emailfooter}\n"
                Net::SMTP.start('localhost') do |smtp|
                        smtp.send_message message, from, to
                end
        end
end