|
@@ -0,0 +1,67 @@
|
|
1
|
+#!/usr/bin/ruby
|
|
2
|
+# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+# Scalelite recording transfer script
|
|
5
|
+# Copyright © 2020 Blindside Networks
|
|
6
|
+#
|
|
7
|
+# This program is free software: you can redistribute it and/or modify
|
|
8
|
+# it under the terms of the GNU Affero General Public License as
|
|
9
|
+# published by the Free Software Foundation, either version 3 of the
|
|
10
|
+# License, or (at your option) any later version.
|
|
11
|
+#
|
|
12
|
+# This program is distributed in the hope that it will be useful,
|
|
13
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+# GNU Affero General Public License for more details.
|
|
16
|
+#
|
|
17
|
+# You should have received a copy of the GNU Affero General Public License
|
|
18
|
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
|
|
20
|
+require 'optparse'
|
|
21
|
+require 'psych'
|
|
22
|
+require 'fileutils'
|
|
23
|
+
|
|
24
|
+meeting_id = nil
|
|
25
|
+OptionParser.new do |opts|
|
|
26
|
+ opts.on('-m', '--meeting-id MEETING_ID', 'Internal Meeting ID') do |v|
|
|
27
|
+ meeting_id = v
|
|
28
|
+ end
|
|
29
|
+end.parse!
|
|
30
|
+raise 'Meeting ID was not provided' unless meeting_id
|
|
31
|
+
|
|
32
|
+props = Psych.load_file(File.join(__dir__, '../bigbluebutton.yml'))
|
|
33
|
+published_dir = props['published_dir'] || raise('Unable to determine published_dir from bigbluebutton.yml')
|
|
34
|
+scalelite_props = Psych.load_file(File.join(__dir__, '../scalelite.yml'))
|
|
35
|
+work_dir = scalelite_props['work_dir'] || raise('Unable to determine work_dir from scalelite.yml')
|
|
36
|
+spool_dir = scalelite_props['spool_dir'] || raise('Unable to determine spool_dir from scalelite.yml')
|
|
37
|
+extra_rsync_opts = scalelite_props['extra_rsync_opts'] || []
|
|
38
|
+
|
|
39
|
+puts("Transferring recording for #{meeting_id} to Scalelite")
|
|
40
|
+format_dirs = []
|
|
41
|
+FileUtils.cd(published_dir) do
|
|
42
|
+ format_dirs = Dir.glob("*/#{meeting_id}")
|
|
43
|
+end
|
|
44
|
+if format_dirs.empty?
|
|
45
|
+ puts('No published recording formats found')
|
|
46
|
+ exit
|
|
47
|
+end
|
|
48
|
+
|
|
49
|
+format_dirs.each do |format_dir|
|
|
50
|
+ puts("Found recording format: #{format_dir}")
|
|
51
|
+end
|
|
52
|
+
|
|
53
|
+archive_file = "#{work_dir}/#{meeting_id}.tar"
|
|
54
|
+begin
|
|
55
|
+ puts('Creating recording archive')
|
|
56
|
+ FileUtils.mkdir_p(work_dir)
|
|
57
|
+ FileUtils.cd(published_dir) do
|
|
58
|
+ system('tar', '--create', '--file', archive_file, *format_dirs) \
|
|
59
|
+ || raise('Failed to create recording archive')
|
|
60
|
+ end
|
|
61
|
+
|
|
62
|
+ puts("Transferring recording archive to #{spool_dir}")
|
|
63
|
+ system('cp', archive_file, spool_dir) \
|
|
64
|
+ || raise('Failed to transfer recording archive')
|
|
65
|
+ensure
|
|
66
|
+ FileUtils.rm_f(archive_file)
|
|
67
|
+end
|