mirror of
https://github.com/cimryan/teslausb.git
synced 2026-02-28 20:20:32 +00:00
Fix errors.
This commit is contained in:
@@ -3,14 +3,14 @@
|
||||
# Change the value on the right side of the equal sign to the name of the server hosting the archive.
|
||||
ARCHIVE_HOST_NAME=archiveserver
|
||||
|
||||
LOGFILE=/tmp/archiveloop.log
|
||||
LOG_FILE=/tmp/archiveloop.log
|
||||
|
||||
export CAM_MOUNT=/mnt/cam
|
||||
export MUSIC_MOUNT=/mnt/music
|
||||
|
||||
function log () {
|
||||
echo "$( date )" >> "$LOGFILE"
|
||||
echo "$1" >> "$LOGFILE"
|
||||
echo "$( date )" >> "$LOG_FILE"
|
||||
echo "$1" >> "$LOG_FILE"
|
||||
}
|
||||
|
||||
function fix_errors_in_mount_point () {
|
||||
@@ -51,6 +51,12 @@ function wait_for_archive_to_be_reachable () {
|
||||
log "Archive is reachable."
|
||||
break
|
||||
fi
|
||||
if [ -e /tmp/archive_is_reachable ]
|
||||
then
|
||||
log "Simulating archive is reachable"
|
||||
rm /tmp/archive_is_reachable
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
@@ -116,9 +122,7 @@ function ensure_mountpoint_is_mounted_with_retry () {
|
||||
}
|
||||
|
||||
function fix_errors_in_cam_file () {
|
||||
ensure_cam_file_is_mounted
|
||||
fix_errors_in_mount_point "$CAM_MOUNT"
|
||||
unmount_cam_file
|
||||
}
|
||||
|
||||
function ensure_cam_file_is_mounted () {
|
||||
@@ -136,7 +140,7 @@ function ensure_music_file_is_mounted () {
|
||||
function unmount_mount_point () {
|
||||
local mount_point="$1"
|
||||
log "Unmounting $mount_point..."
|
||||
umount "$mount_point"
|
||||
umount "$mount_point" >> "$LOG_FILE" 2>&1
|
||||
log "Unmounted $mount_point."
|
||||
}
|
||||
|
||||
@@ -149,9 +153,7 @@ function unmount_music_file () {
|
||||
}
|
||||
|
||||
function fix_errors_in_music_file () {
|
||||
ensure_music_file_is_mounted
|
||||
fix_errors_in_mount_point "$MUSIC_MOUNT"
|
||||
unmount_music_file
|
||||
}
|
||||
|
||||
function archive_clips () {
|
||||
@@ -169,15 +171,34 @@ function wait_for_archive_to_be_unreachable () {
|
||||
log "Archive is unreachable."
|
||||
break
|
||||
fi
|
||||
if [ -e /tmp/archive_is_unreachable ]
|
||||
then
|
||||
log "Simulating archive being unreachable."
|
||||
rm /tmp/archive_is_unreachable
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
function fix_errors_in_files () {
|
||||
function mount_and_fix_errors_in_cam_file () {
|
||||
ensure_cam_file_is_mounted
|
||||
fix_errors_in_cam_file
|
||||
fix_errors_in_music_file
|
||||
unmount_cam_file
|
||||
}
|
||||
|
||||
function mount_and_fix_errors_in_music_file () {
|
||||
ensure_music_file_is_mounted
|
||||
fix_errors_in_music_file
|
||||
unmount_music_file
|
||||
}
|
||||
|
||||
function mount_and_fix_errors_in_files () {
|
||||
mount_and_fix_errors_in_cam_file
|
||||
mount_and_fix_errors_in_music_file
|
||||
}
|
||||
|
||||
export -f fix_errors_in_mount_point
|
||||
export -f fix_errors_in_cam_file
|
||||
export -f retry
|
||||
export -f mount_mountpoint
|
||||
@@ -185,6 +206,7 @@ export -f ensure_mountpoint_is_mounted
|
||||
export -f ensure_mountpoint_is_mounted_with_retry
|
||||
export -f ensure_cam_file_is_mounted
|
||||
export -f fix_errors_in_cam_file
|
||||
export -f unmount_mount_point
|
||||
export -f unmount_cam_file
|
||||
export -f connect_usb_drives_to_host
|
||||
|
||||
@@ -193,13 +215,13 @@ log "Starting..."
|
||||
if archive_is_reachable
|
||||
then
|
||||
# archive_clips will fix errors in the cam file
|
||||
fix_errors_in_music_file
|
||||
mount_and_fix_errors_in_music_file
|
||||
|
||||
archive_clips
|
||||
|
||||
wait_for_archive_to_be_unreachable
|
||||
else
|
||||
fix_errors_in_files
|
||||
mount_and_fix_errors_in_files
|
||||
|
||||
connect_usb_drives_to_host
|
||||
fi
|
||||
@@ -211,4 +233,4 @@ do
|
||||
archive_clips
|
||||
|
||||
wait_for_archive_to_be_unreachable
|
||||
done
|
||||
done
|
||||
Reference in New Issue
Block a user