cdist-contrib-pedro-fork/type/__jitsi_jibri/files/finalize_recording.sh

33 lines
914 B
Bash
Executable File

# Managed remotely, changes will be lost
#!/bin/sh
set -e
set -u
guess_room_name() {
recording_meeting_path="${1}"
# the approach is to delete the 25 fixed character postfix string on each
# file (example: room_name_2022-06-08-15-28-25.mp4) another approach would be
# to take the url
# from the metadata.json file, but that would imply json parsing or jq dependency
basename "$(ls "${recording_meeting_path}"/*.mp4)" | rev | cut -c25- | rev
}
move_meeting() {
mkdir -p "${recording_general_path}/${room}/"
mv "${recording_meeting_path}"/*.mp4 "${recording_general_path}/${room}/"
rm "${recording_meeting_path}/metadata.json"
rmdir "${recording_meeting_path}"
}
main() {
recording_meeting_path="${1}"
recording_general_path="$(dirname "${1}")"
room="$(guess_room_name "${recording_meeting_path}")"
move_meeting
echo "$0 ${@} ${room}" >> /tmp/thisisatest.log
}
main "${@}"
exit 0