Files
teslausb/windows_archive/archive-teslacam-clips
2018-10-23 20:32:28 -07:00

48 lines
878 B
Bash

#!/bin/bash -eu
export LOG_FILE=/tmp/archive-teslacam-clips.log
export ARCHIVE_MOUNT=/mnt/archive
function log () {
echo "$( date )" >> "$LOG_FILE"
echo "$1" >> "$LOG_FILE"
}
function disconnect_usb_drives_from_host () {
log "Disconnecting usb from host..."
modprobe -r g_mass_storage
log "Disconnected usb from host."
}
function ensure_archive_is_mounted () {
log "Ensuring cam archive is mounted..."
ensure_mountpoint_is_mounted_with_retry "$ARCHIVE_MOUNT"
log "Ensured cam archive is mounted."
}
export -f log
log "Starting..."
if [ ! -r "/root/.teslaCamRsyncConfig" ]
then
ensure_archive_is_mounted
fi
disconnect_usb_drives_from_host
ensure_cam_file_is_mounted
fix_errors_in_cam_file
if [ -r "/root/.teslaCamRsyncConfig" ]
then
/root/bin/archive-rsync.sh
else
/root/bin/archive-cifs.sh
fi
unmount_cam_file
connect_usb_drives_to_host