2012-09-05 05:42:13 +08:00
|
|
|
# Set encoding to utf-8
|
|
|
|
# encoding: UTF-8
|
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
2012-08-21 07:12:58 +08:00
|
|
|
require '../lib/recordandplayback'
|
|
|
|
require 'logger'
|
|
|
|
require 'trollop'
|
|
|
|
require 'yaml'
|
2012-08-14 04:22:53 +08:00
|
|
|
require "nokogiri"
|
2012-08-16 08:10:29 +08:00
|
|
|
require "redis"
|
|
|
|
require "fileutils"
|
2012-08-14 04:22:53 +08:00
|
|
|
|
2012-08-16 08:10:29 +08:00
|
|
|
def check_events_xml(raw_dir,meeting_id)
|
|
|
|
filepath = "#{raw_dir}/#{meeting_id}/events.xml"
|
2012-08-14 04:22:53 +08:00
|
|
|
raise Exception, "Events file doesn't exists." if not File.exists?(filepath)
|
2012-08-21 07:12:58 +08:00
|
|
|
bad_doc = Nokogiri::XML(File.open(filepath)) { |config| config.options = Nokogiri::XML::ParseOptions::STRICT }
|
2012-08-14 04:22:53 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def check_audio_files(raw_dir,meeting_id)
|
|
|
|
#check every file that is in events.xml, it's in audio dir
|
|
|
|
doc = Nokogiri::XML(File.open("#{raw_dir}/#{meeting_id}/events.xml"))
|
|
|
|
|
|
|
|
doc.xpath("//event[@eventname='StartRecordingEvent']/filename/text()").each { |fs_audio_file|
|
|
|
|
audioname = fs_audio_file.content.split("/").last
|
|
|
|
raw_audio_file = "#{raw_dir}/#{meeting_id}/audio/#{audioname}"
|
|
|
|
#checking that the audio file exists in raw directory
|
|
|
|
raise Exception, "Audio file doesn't exists in raw directory." if not File.exists?(raw_audio_file)
|
|
|
|
|
|
|
|
#checking length
|
|
|
|
raise Exception, "Audio file length is zero." if BigBlueButton::AudioEvents.determine_length_of_audio_from_file(raw_audio_file) <= 0
|
|
|
|
}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2012-08-16 08:10:29 +08:00
|
|
|
BigBlueButton.logger = Logger.new('/var/log/bigbluebutton/sanity.log', 'daily' )
|
|
|
|
|
|
|
|
opts = Trollop::options do
|
|
|
|
opt :meeting_id, "Meeting id to archive", :default => '58f4a6b3-cd07-444d-8564-59116cb53974', :type => String
|
2012-08-14 04:22:53 +08:00
|
|
|
end
|
|
|
|
|
2012-08-16 08:10:29 +08:00
|
|
|
meeting_id = opts[:meeting_id]
|
|
|
|
|
|
|
|
# This script lives in scripts/archive/steps while bigbluebutton.yml lives in scripts/
|
|
|
|
props = YAML::load(File.open('bigbluebutton.yml'))
|
|
|
|
|
|
|
|
audio_dir = props['raw_audio_src']
|
|
|
|
recording_dir = props['recording_dir']
|
|
|
|
raw_archive_dir = "#{recording_dir}/raw"
|
2012-08-21 07:12:58 +08:00
|
|
|
redis_host = props['redis_host']
|
|
|
|
redis_port = props['redis_port']
|
2012-08-16 08:10:29 +08:00
|
|
|
|
|
|
|
begin
|
2012-08-21 07:12:58 +08:00
|
|
|
BigBlueButton.logger.info("checking events.xml")
|
2012-08-16 08:10:29 +08:00
|
|
|
check_events_xml(raw_archive_dir,meeting_id)
|
2012-08-21 07:12:58 +08:00
|
|
|
BigBlueButton.logger.info("checking audio")
|
2012-08-16 08:10:29 +08:00
|
|
|
check_audio_files(raw_archive_dir,meeting_id)
|
|
|
|
#delete keys
|
2012-08-21 07:12:58 +08:00
|
|
|
BigBlueButton.logger.info("deleting keys")
|
2012-08-16 08:10:29 +08:00
|
|
|
redis = BigBlueButton::RedisWrapper.new(redis_host, redis_port)
|
|
|
|
events_archiver = BigBlueButton::RedisEventsArchiver.new redis
|
|
|
|
events_archiver.delete_events(meeting_id)
|
|
|
|
|
|
|
|
#delete audio
|
|
|
|
#Dir.glob("#{audio_dir}/#{meeting_id}*.wav").each{ |audio_meeting|
|
|
|
|
# FileUtils.rm(
|
|
|
|
#}
|
|
|
|
|
|
|
|
#create done files for sanity
|
2012-08-21 07:12:58 +08:00
|
|
|
BigBlueButton.logger.info("creating sanity done files")
|
2012-08-16 08:10:29 +08:00
|
|
|
sanity_done = File.new("#{recording_dir}/status/sanity/#{meeting_id}.done", "w")
|
|
|
|
sanity_done.write("sanity check #{meeting_id}")
|
|
|
|
sanity_done.close
|
|
|
|
rescue Exception => e
|
|
|
|
BigBlueButton.logger.error("error in sanity check: " + e.message)
|
2012-08-22 05:55:41 +08:00
|
|
|
sanity_done = File.new("#{recording_dir}/status/sanity/#{meeting_id}.fail", "w")
|
|
|
|
sanity_done.write("error: " + e.message)
|
|
|
|
sanity_done.close
|
2012-08-16 08:10:29 +08:00
|
|
|
end
|
2012-08-14 04:22:53 +08:00
|
|
|
|
|
|
|
|