This commit is contained in:
Felipe Cecagno 2014-09-01 17:53:57 -03:00
parent dd97b8f80c
commit f68b0e4a16
13 changed files with 102 additions and 107 deletions

View File

@ -329,12 +329,12 @@ if [ $REPUBLISH ]; then
fi
if [ $CLEAN ]; then
sudo /etc/init.d/bbb-record stop
sudo /etc/init.d/bbb-record-core stop
for type in $TYPES; do
echo " clearning logs in /var/log/bigbluebutton/$type"
find /var/log/bigbluebutton/$type -name "*.log" -exec sudo rm '{}' \;
done
sudo /etc/init.d/bbb-record start
sudo /etc/init.d/bbb-record-core start
fi
if [ $DELETE ]; then

View File

@ -19,12 +19,9 @@
source "http://rubygems.org"
gem "rspec", "2.0.0", :require => "spec"
gem "cucumber", "0.9.2"
gem "redis", "2.1.1"
#gem "SystemTimer", "1.2.3"
gem "nokogiri", "1.4.4"
gem "resque", "1.15.0"
gem "redis"
gem "nokogiri"
gem "resque"
gem "mime-types"
gem "streamio-ffmpeg"
gem "rubyzip"

View File

@ -25,7 +25,7 @@ require 'fileutils'
require 'builder'
require 'mime/types'
require 'digest/md5'
require 'zip/zip'
require 'zip'
module BigBlueButton
@ -33,7 +33,7 @@ module BigBlueButton
def self.zip_directory (directory, zipped_file)
BigBlueButton.logger.info("Task: Zipping directory... #{zipped_file} #{directory}")
#files = [webcam, deskshare, dublincore, manifest]
Zip::ZipFile.open(zipped_file, Zip::ZipFile::CREATE) do |zipfile|
Zip::File.open(zipped_file, Zip::File::CREATE) do |zipfile|
Dir["#{directory}/**/**"].reject{|f|f==zipped_file}.each do |file|
zipfile.add(file.sub(directory+'/', ''), file)
end
@ -41,7 +41,7 @@ module BigBlueButton
end
def self.unzip(unzip_dir, zipfile)
Zip::ZipFile.open(zipfile) do |zip_file|
Zip::File.open(zipfile) do |zip_file|
zip_file.each do |f|
f_path=File.join(unzip_dir, f.name)
FileUtils.mkdir_p(File.dirname(f_path))

View File

@ -25,11 +25,6 @@ sudo rm -rf /usr/local/bigbluebutton/core/lib
sudo cp -r core/lib /usr/local/bigbluebutton/core/
sudo rm -rf /usr/local/bigbluebutton/core/scripts
sudo cp -r core/scripts /usr/local/bigbluebutton/core/
sudo rm -rf /etc/bigbluebutton/god
sudo cp -r core/god/god /etc/bigbluebutton/
sudo rm -f /etc/init.d/bbb-record-core
sudo cp core/god/initd.god /etc/init.d/bbb-record-core
sudo chmod 0755 /etc/init.d/bbb-record-core
sudo rm -rf /var/bigbluebutton/playback/*
function deploy_format() {
@ -40,17 +35,18 @@ function deploy_format() {
scripts_dir="$format/scripts"
if [ -d $playback_dir ]; then sudo cp -r $playback_dir /var/bigbluebutton/playback/; fi
if [ -d $scripts_dir ]; then sudo cp -r $scripts_dir/* /usr/local/bigbluebutton/core/scripts/; fi
sudo mkdir -p /var/log/bigbluebutton/$format
sudo mkdir -p /var/log/bigbluebutton/$format /var/bigbluebutton/published/$format /var/bigbluebutton/recording/publish/$format
done
}
RECORDING_SERVER=false
if $RECORDING_SERVER ; then
sudo cp mconf/scripts/mconf-god-conf.rb /etc/bigbluebutton/god/conf/
sudo cp mconf/scripts/mconf-decrypt.rb /usr/local/bigbluebutton/core/scripts/
deploy_format "presentation"
deploy_format "mconf_decrypter"
sudo mv /usr/local/bigbluebutton/core/scripts/mconf-recording-decrypter.initd /etc/init.d/mconf-recording-decrypter
sudo mv /usr/local/bigbluebutton/core/scripts/mconf-recording-decrypter.monit /etc/monit/conf.d/mconf-recording-decrypter
else
deploy_format "mconf"
deploy_format "mconf_encrypted"
fi
sudo mkdir -p /var/bigbluebutton/playback/
@ -63,7 +59,7 @@ sudo mkdir -p /var/bigbluebutton/recording/status/processed/
sudo mkdir -p /var/bigbluebutton/recording/status/sanity/
sudo mv /usr/local/bigbluebutton/core/scripts/*.nginx /etc/bigbluebutton/nginx/
sudo chown -R tomcat6:tomcat6 /var/bigbluebutton/ /var/log/bigbluebutton/
sudo chown -R tomcat7:tomcat7 /var/bigbluebutton/ /var/log/bigbluebutton/
sudo chown -R red5:red5 /var/bigbluebutton/deskshare/
sudo chown -R freeswitch:daemon /var/bigbluebutton/meetings/

View File

@ -1,55 +0,0 @@
#
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
#
# Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
#
# This program is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 3.0 of the License, or (at your option) any later
# version.
#
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
#
# NOTE:
# Copy into /etc/bigbluebutton/god/conf
# sudo cp matt-pub-god-conf.rb /etc/bigbluebutton/god/conf/matterhorn-publish-conf.rb
#
# Monitors the BigBlueButton Matterhorn publisher process
God.watch do |w|
# The name of the watcher
w.name = "mconf-decrypt"
# The default time for reporting the state of the monitored process
w.interval = 1.minute
# Start the process
w.start = "ruby mconf-decrypt.rb"
# Start your process in this directory
w.dir = "/usr/local/bigbluebutton/core/scripts/"
# Time to wait before monitoring, after starting the process
w.start_grace = 30.seconds
# Cleans the pid file before starting the process.
# god will daemonizes the process
w.behavior(:clean_pid_file)
# Start the process if it is not running
# And report its status every 30 seconds
# In other words god revives the process every time it dies
w.start_if do |start|
start.condition(:process_running) do |c|
c.interval = 30.seconds
c.running = false
end
end
end

View File

@ -1,2 +0,0 @@
get_recordings_url: http://143.54.10.52/bigbluebutton/api/getRecordings?checksum=39ebeadb772553a206d43857f6287b4536b1c32c
private_key: /home/mconf/dev/bigbluebutton/record-and-playback/key.pem

View File

@ -1,3 +1,4 @@
#!/usr/bin/ruby
# Set encoding to utf-8
# encoding: UTF-8
#
@ -26,11 +27,11 @@ require 'rexml/document'
require 'open-uri'
require 'digest/md5'
BigBlueButton.logger = Logger.new("/var/log/bigbluebutton/decrypt.log",'daily' )
BigBlueButton.logger = Logger.new("/var/log/bigbluebutton/mconf_decrypter.log",'daily' )
#BigBlueButton.logger = Logger.new(STDOUT)
bbb_props = YAML::load(File.open('../../core/scripts/bigbluebutton.yml'))
mconf_props = YAML::load(File.open('mconf.yml'))
mconf_props = YAML::load(File.open('mconf-decrypter.yml'))
# these properties must be global variables (starting with $)
$private_key = mconf_props['private_key']
@ -46,10 +47,11 @@ def fetchRecordings(url)
doc = Nokogiri::XML(Net::HTTP.get_response(URI.parse(url)).body)
returncode = doc.xpath("//returncode")
if returncode.empty? or returncode.text != "SUCCESS"
raise "getRecordings didn't return success:\n#{doc.to_xml(:indent => 2)}"
BigBlueButton.logger.error "getRecordings didn't return success:\n#{doc.to_xml(:indent => 2)}"
return false
end
rescue
BigBlueButton.logger.debug("Exception occurred: #{$!}")
BigBlueButton.logger.error("Exception occurred: #{$!}")
return false
end
@ -78,9 +80,15 @@ def fetchRecordings(url)
BigBlueButton.logger.debug("md5_value = #{md5_value}")
BigBlueButton.logger.info("Downloading the encrypted file to #{encrypted_file}")
writeOut = open(encrypted_file, "wb")
writeOut.write(open(file_url).read)
writeOut.close
begin
writeOut = open(encrypted_file, "wb")
writeOut.write(open(file_url).read)
writeOut.close
rescue Exception => e
BigBlueButton.logger.error "Failed to download the encrypted file: #{e.to_s}"
next
end
md5_calculated = Digest::MD5.file(encrypted_file)
@ -97,13 +105,15 @@ def fetchRecordings(url)
if key_file != decrypted_key_file
BigBlueButton.logger.debug("Locating private key")
if not File.exists?("#{$private_key}")
raise "Couldn't find the private key on #{$private_key}"
BigBlueButton.logger.error "Couldn't find the private key on #{$private_key}"
next
end
BigBlueButton.logger.debug("Decrypting recording key")
command = "openssl rsautl -decrypt -inkey #{$private_key} < #{key_file} > #{decrypted_key_file}"
status = BigBlueButton.execute(command)
status = BigBlueButton.execute(command, false)
if not status.success?
raise "Couldn't decrypt the random key with the server private key"
BigBlueButton.logger.error "Couldn't decrypt the random key with the server private key"
next
end
FileUtils.rm_r "#{key_file}"
else
@ -112,9 +122,10 @@ def fetchRecordings(url)
BigBlueButton.logger.debug("Decrypting the recording file")
command = "openssl enc -aes-256-cbc -d -pass file:#{decrypted_key_file} < #{encrypted_file} > #{decrypted_file}"
status = BigBlueButton.execute(command)
status = BigBlueButton.execute(command, false)
if not status.success?
raise "Couldn't decrypt the recording file using the random key"
BigBlueButton.logger.error "Couldn't decrypt the recording file using the random key"
next
end
BigBlueButton::MconfProcessor.unzip("#{$raw_dir}/#{meeting_id}", decrypted_file)

View File

@ -0,0 +1,2 @@
get_recordings_url: http://localhost/bigbluebutton/api/getRecordings?checksum=39ebeadb772553a206d43857f6287b4536b1c32c
private_key: /usr/local/bigbluebutton/core/scripts/private.pem

View File

@ -0,0 +1,44 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: mconf-recording-decrypter
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Starts the foo service
### END INIT INFO
NAME=mconf-recording-decrypter
PID_FILE=/var/run/mconf-recording-decrypter.pid
DIR=/usr/local/bigbluebutton/core/scripts
EXEC=mconf-decrypter.rb
RUN_AS=tomcat7
if [ ! -f $DIR/$EXEC ]; then
echo "$DIR/$EXEC not found."
exit
fi
case "$1" in
start)
echo "Starting $NAME"
cd $DIR
start-stop-daemon -d $DIR --start --background --pidfile $PID_FILE --chuid $RUN_AS:$RUN_AS --make-pidfile --exec $EXEC --quiet
;;
stop)
echo "Stopping $NAME"
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --exec $EXEC
;;
force-reload|restart)
$0 stop
$0 start
;;
*)
echo "Use: /etc/init.d/$NAME {start|stop|restart|force-reload}"
exit 1
;;
esac
exit 0

View File

@ -0,0 +1,3 @@
check process mconf-recording-decrypter with pidfile /var/run/mconf-recording-decrypter.pid
start program = "/etc/init.d/mconf-recording-decrypter start" with timeout 60 seconds
stop program = "/etc/init.d/mconf-recording-decrypter stop"

View File

@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
#
location /mconf/ {
location /mconf_encrypted {
root /var/bigbluebutton/published;
index index.html index.htm;
}

View File

@ -31,7 +31,7 @@ end
meeting_id = opts[:meeting_id]
#Mconf process log file
logger = Logger.new("/var/log/bigbluebutton/mconf/process-#{meeting_id}.log", 'daily' )
logger = Logger.new("/var/log/bigbluebutton/mconf_encrypted/process-#{meeting_id}.log", 'daily' )
BigBlueButton.logger = logger
# This script lives in scripts/archive/steps while bigbluebutton.yml lives in scripts/
@ -42,7 +42,7 @@ raw_presentation_src = props['raw_presentation_src']
meeting_raw_dir = "#{recording_dir}/raw/#{meeting_id}"
meeting_raw_presentation_dir = "#{raw_presentation_src}/#{meeting_id}"
meeting_process_dir = "#{recording_dir}/process/mconf/#{meeting_id}"
meeting_process_dir = "#{recording_dir}/process/mconf_encrypted/#{meeting_id}"
if not FileTest.directory?(meeting_process_dir)
FileUtils.mkdir_p "#{meeting_process_dir}"
@ -55,7 +55,7 @@ if not FileTest.directory?(meeting_process_dir)
# BigBlueButton.logger.info("Copying the recording presentation from #{meeting_raw_presentation_dir}/#{meeting_id} to #{meeting_process_dir}/presentation_raw")
# FileUtils.cp_r Dir.glob("#{meeting_raw_presentation_dir}/#{meeting_id}/*"), "#{meeting_process_dir}/presentation_raw"
process_done = File.new("#{recording_dir}/status/processed/#{meeting_id}-mconf.done", "w")
process_done = File.new("#{recording_dir}/status/processed/#{meeting_id}-mconf_encrypted.done", "w")
process_done.write("Processed #{meeting_id}")
process_done.close
end

View File

@ -25,7 +25,6 @@ require 'cgi'
require 'digest/md5'
bbb_props = YAML::load(File.open('../../core/scripts/bigbluebutton.yml'))
mconf_props = YAML::load(File.open('mconf.yml'))
recording_dir = bbb_props['recording_dir']
playback_host = bbb_props['playback_host']
@ -36,12 +35,12 @@ done_files = Dir.glob("#{recording_dir}/status/processed/*.done")
done_files.each do |df|
match = /(.*)-(.*).done/.match df.sub(/.+\//, "")
meeting_id = match[1]
if (match[2] == "mconf")
BigBlueButton.logger = Logger.new("/var/log/bigbluebutton/mconf/publish-#{meeting_id}.log", 'daily' )
if (match[2] == "mconf_encrypted")
BigBlueButton.logger = Logger.new("/var/log/bigbluebutton/mconf_encrypted/publish-#{meeting_id}.log", 'daily' )
meeting_process_dir = "#{recording_dir}/process/mconf/#{meeting_id}"
meeting_publish_dir = "#{recording_dir}/publish/mconf/#{meeting_id}"
meeting_published_dir = "#{recording_dir}/published/mconf/#{meeting_id}"
meeting_process_dir = "#{recording_dir}/process/mconf_encrypted/#{meeting_id}"
meeting_publish_dir = "#{recording_dir}/publish/mconf_encrypted/#{meeting_id}"
meeting_published_dir = "#{recording_dir}/published/mconf_encrypted/#{meeting_id}"
meeting_raw_dir = "#{recording_dir}/raw/#{meeting_id}"
meeting_raw_presentation_dir = "#{raw_presentation_src}/#{meeting_id}"
@ -123,9 +122,9 @@ done_files.each do |df|
b.end_time(BigBlueButton::Events.last_event_timestamp("#{meeting_process_dir}/events.xml"))
b.download {
b.format("encrypted")
b.link("http://#{playback_host}/mconf/#{meeting_id}/#{meeting_id}.dat")
b.link("http://#{playback_host}/mconf_encrypted/#{meeting_id}/#{meeting_id}.dat")
b.md5(md5sum)
b.key("http://#{playback_host}/mconf/#{meeting_id}/#{key_filename}")
b.key("http://#{playback_host}/mconf_encrypted/#{meeting_id}/#{key_filename}")
}
b.meta {
BigBlueButton::Events.get_meeting_metadata("#{meeting_process_dir}/events.xml").each { |k,v| b.method_missing(k,v) }
@ -136,14 +135,14 @@ done_files.each do |df|
metadata_xml.write(metaxml)
metadata_xml.close
BigBlueButton.logger.info("Publishing mconf")
BigBlueButton.logger.info("Publishing mconf_encrypted")
# Now publish this recording
if not FileTest.directory?("#{published_dir}/mconf")
FileUtils.mkdir_p "#{published_dir}/mconf"
if not FileTest.directory?("#{published_dir}/mconf_encrypted")
FileUtils.mkdir_p "#{published_dir}/mconf_encrypted"
end
BigBlueButton.logger.info("Publishing files")
FileUtils.cp_r(meeting_publish_dir, "#{published_dir}/mconf")
FileUtils.cp_r(meeting_publish_dir, "#{published_dir}/mconf_encrypted")
BigBlueButton.logger.info("Removing processed files: #{meeting_process_dir}")
FileUtils.rm_r meeting_process_dir, :force => true
@ -159,7 +158,7 @@ done_files.each do |df|
Dir.glob("/var/freeswitch/meetings/#{meeting_id}*.wav") ], :force => true
# Remove all the recording flags
FileUtils.rm_f [ "#{recording_dir}/status/processed/#{meeting_id}-mconf.done",
FileUtils.rm_f [ "#{recording_dir}/status/processed/#{meeting_id}-mconf_encrypted.done",
"#{recording_dir}/status/sanity/#{meeting_id}.done",
"#{recording_dir}/status/recorded/#{meeting_id}.done",
"#{recording_dir}/status/archived/#{meeting_id}.done" ]